123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286 |
- /*
- * CDE - Common Desktop Environment
- *
- * Copyright (c) 1993-2012, The Open Group. All rights reserved.
- *
- * These libraries and programs are free software; you can
- * redistribute them and/or modify them under the terms of the GNU
- * Lesser General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option)
- * any later version.
- *
- * These libraries and programs are distributed in the hope that
- * they will be useful, but WITHOUT ANY WARRANTY; without even the
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- * PURPOSE. See the GNU Lesser General Public License for more
- * details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with these libraries and programs; if not, write
- * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
- * Floor, Boston, MA 02110-1301 USA
- */
- /* $XConsortium: GenUtils.c /main/10 1996/05/09 03:42:28 drk $ */
- /************************************<+>*************************************
- ****************************************************************************
- **
- ** File: GenUtils.c
- **
- ** Project: CDEnext Info Access.
- **
- ** Description: This module contains non public routines used only by
- ** CDE 1.0 dthelpgen. If any of these routines are
- ** renamed or modified to remove or add parameters, the
- ** original routine should be moved to Obsolete.c, a new
- ** routine created (and named differently), and the old
- ** routine should call the new routine.
- **
- ** (c) Copyright 1987, 1988, 1989, 1990, 1991, 1992 Hewlett-Packard Company
- **
- ** (c) Copyright 1993, 1994 Hewlett-Packard Company
- ** (c) Copyright 1993, 1994 International Business Machines Corp.
- ** (c) Copyright 1993, 1994 Sun Microsystems, Inc.
- ** (c) Copyright 1993, 1994 Novell, Inc.
- **
- **
- ****************************************************************************
- ************************************<+>*************************************/
- /*
- * system includes
- */
- #include <stdio.h>
- #include <X11/Xlib.h>
- #include <X11/Xresource.h>
- /*
- * Canvas Engine includes
- */
- #include "CanvasP.h"
- #include "CanvasSegP.h"
- /*
- * private includes
- */
- #include "bufioI.h" /* for FormatUtilI.h */
- #include "GenUtilsP.h"
- #include "FontAttrI.h"
- #include "Access.h"
- #include "AccessI.h"
- #include "AccessP.h"
- #include "AccessSDLP.h"
- #include "AccessSDLI.h"
- #include "AccessCCDFP.h"
- #include "AccessCCDFI.h"
- #include "SDLI.h"
- #include "FormatUtilI.h"
- #include "FormatSDLI.h"
- #include "Lock.h"
- #ifdef NLS16
- #endif
- /******** Private Defines ********/
- /******** Private Function Declarations ********/
- static void DefCvsMetrics(
- _DtCvPointer client_data,
- _DtCvElemType elem_type,
- _DtCvPointer ret_metrics);
- /******** Private Macro Declarations ********/
- /******************************************************************************
- *
- * Private variables used within this file.
- *
- *******************************************************************************/
- static _DtCvVirtualInfo MyVirtInfo =
- {
- DefCvsMetrics, /* void (*_CEGet_DtCvMetrics)(); */
- NULL, /* void (*_DtCvRenderElem)(); */
- NULL, /* DefCvsStrWidth, _DtCvUnit (*_DtCvGetElemWidth)(); */
- NULL, /* DefCvsFontMetrics, void (*_DtCvGetFontMetrics)(); */
- NULL, /* VStatus (*_DtCvBuildSelection)(); */
- };
- static const _DtCvSpaceMetrics defLinkMetrics = { 0, 0, 0, 0 };
- /******************************************************************************
- *
- * Private functions
- *
- ******************************************************************************/
- /*****************************************************************************
- * Function: void DefCvsMetrics ();
- *
- * Parameters:
- *
- * Returns:
- *
- * Purpose:
- *
- *****************************************************************************/
- static void
- DefCvsMetrics (
- _DtCvPointer client_data,
- _DtCvElemType elem_type,
- _DtCvPointer ret_metrics)
- {
- _DtCvSpaceMetrics *retLink = (_DtCvSpaceMetrics *) ret_metrics;
- if (_DtCvCANVAS_TYPE == elem_type)
- {
- _DtCvMetrics *retCanvas = (_DtCvMetrics *) ret_metrics;
- retCanvas->width = 1;
- retCanvas->height = 1;
- retCanvas->top_margin = 0;
- retCanvas->side_margin = 0;
- retCanvas->line_height = 1;
- retCanvas->horiz_pad_hint = 1;
- }
- else if (_DtCvLINK_TYPE == elem_type || _DtCvTRAVERSAL_TYPE == elem_type)
- *retLink = defLinkMetrics;
- }
- /******************************************************************************
- * Semi-Public Functions
- ******************************************************************************/
- /******************************************************************************
- * Function: int _DtHelpCeGetVolumeTitle(_DtHelpVolume vol, char **retTitle);
- *
- * Parameters: vol Specifies the loaded volume.
- * retTitle Returns the title of the volume. This string is
- * owned by the caller and must be freed.
- *
- * Return Value: 0 if successful, -1 if a failure occurs
- *
- * Purpose: Get the title of a volume.
- *
- * Used by: dthelpgen 1.0
- *
- ******************************************************************************/
- int
- _DtHelpCeGetVolumeTitle (
- CanvasHandle canvas,
- VolumeHandle volume,
- char **ret_title)
- {
- _FrmtUiInfo myUiInfo;
- _DtHelpVolume vol = (_DtHelpVolume)volume;
- int result;
- /*
- * set up my UI information
- */
- myUiInfo.load_graphic = NULL;
- myUiInfo.resolve_spc = NULL;
- myUiInfo.load_font = NULL;
- myUiInfo.destroy_region = NULL;
- myUiInfo.exec_filter = NULL;
- myUiInfo.client_data = NULL;
- /* since we're going for a string, set avg_char width to 1 */
- myUiInfo.line_width = 0;
- myUiInfo.line_height = 0;
- myUiInfo.leading = 0;
- myUiInfo.avg_char = 1;
- myUiInfo.nl_to_space = 0;
- /*
- * What type of volume is it?
- */
- _DtHelpProcessLock();
- if (0 == _DtHelpCeGetVolumeFlag(volume))
- {
- result = _DtHelpCeGetCcdfVolumeTitle(vol, ret_title);
- }
- else
- {
- result = _DtHelpCeFrmtSDLVolTitleToAscii(volume, &myUiInfo, ret_title);
- }
- _DtHelpProcessUnlock();
- return result;
- }
- /******************************************************************************
- * Function: int _DtHelpCeGetAsciiVolumeAbstract (_DtHelpVolume vol, char **a
- bstract);
- *
- * Parameters: vol Specifies the loaded volume.
- * abstract Returns the abstract of the volume. This string
- * is owned by the caller and should be freed.
- *
- * Return Value: 0 if successful, -1 if a failure occurs
- *
- * Purpose: Get the abstract of a volume.
- *
- * Used by: dthelpgen 1.0
- *
- ******************************************************************************/
- int
- _DtHelpCeGetAsciiVolumeAbstract (
- CanvasHandle canvas,
- VolumeHandle volume,
- char **retAbs)
- {
- _DtHelpVolume vol = (_DtHelpVolume)volume;
- int result;
- /*
- * What type of volume is it?
- */
- _DtHelpProcessLock();
- if (0 == _DtHelpCeGetVolumeFlag(volume))
- {
- result = _DtHelpCeGetCcdfVolumeAbstract(vol, retAbs);
- _DtHelpProcessUnlock();
- return result;
- }
- *retAbs = _DtHelpCeGetSdlVolumeAsciiAbstract(volume);
- if (*retAbs == NULL)
- {
- _DtHelpProcessUnlock();
- return (-1);
- }
- _DtHelpProcessUnlock();
- return (0);
- }
- /*****************************************************************************
- * Function: CanvasHandle _DtHelpCeCreateDefCanvas (void);
- *
- * Parameters:
- *
- * Returns: A handle to the canvas or NULL if an error occurs.
- *
- * Purpose: Create a canvas and attach the appropriate virtual functions
- * to the canvas.
- *****************************************************************************/
- CanvasHandle
- _DtHelpCeCreateDefCanvas (void)
- {
- return (_DtCanvasCreate(MyVirtInfo, NULL));
- } /* End _DtHelpCeCreateDefCanvas */
- /******************************************************************************
- * Function: char *_DtHelpCeGetNxtToken (char *str, char **retToken)
- *
- * Parameters:
- * Return Value: Returns the pointer to the next unparsed character in
- * the input string. A NULL value indicates an error.
- *
- * errno Values:
- * EINVAL
- * CEErrorMalloc
- *
- * Purpose: Parse tokens in resource string values.
- *
- *****************************************************************************/
- char *
- _DtHelpCeGetNxtToken (
- char *str,
- char **retToken)
- {
- return (_DtHelpGetNxtToken(str, retToken));
- }
|