2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these libraries and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $XConsortium: GenUtils.c /main/10 1996/05/09 03:42:28 drk $ */
24 /************************************<+>*************************************
25 ****************************************************************************
29 ** Project: CDEnext Info Access.
31 ** Description: This module contains non public routines used only by
32 ** CDE 1.0 dthelpgen. If any of these routines are
33 ** renamed or modified to remove or add parameters, the
34 ** original routine should be moved to Obsolete.c, a new
35 ** routine created (and named differently), and the old
36 ** routine should call the new routine.
38 ** (c) Copyright 1987, 1988, 1989, 1990, 1991, 1992 Hewlett-Packard Company
40 ** (c) Copyright 1993, 1994 Hewlett-Packard Company
41 ** (c) Copyright 1993, 1994 International Business Machines Corp.
42 ** (c) Copyright 1993, 1994 Sun Microsystems, Inc.
43 ** (c) Copyright 1993, 1994 Novell, Inc.
46 ****************************************************************************
47 ************************************<+>*************************************/
54 #include <X11/Xresource.h>
57 * Canvas Engine includes
60 #include "CanvasSegP.h"
65 #include "bufioI.h" /* for FormatUtilI.h */
66 #include "GenUtilsP.h"
67 #include "FontAttrI.h"
71 #include "AccessSDLP.h"
72 #include "AccessSDLI.h"
73 #include "AccessCCDFP.h"
74 #include "AccessCCDFI.h"
76 #include "FormatUtilI.h"
77 #include "FormatSDLI.h"
83 /******** Private Defines ********/
84 /******** Private Function Declarations ********/
85 static void DefCvsMetrics(
86 _DtCvPointer client_data,
87 _DtCvElemType elem_type,
88 _DtCvPointer ret_metrics);
89 /******** Private Macro Declarations ********/
91 /******************************************************************************
93 * Private variables used within this file.
95 *******************************************************************************/
96 static _DtCvVirtualInfo MyVirtInfo =
98 DefCvsMetrics, /* void (*_CEGet_DtCvMetrics)(); */
99 NULL, /* void (*_DtCvRenderElem)(); */
100 NULL, /* DefCvsStrWidth, _DtCvUnit (*_DtCvGetElemWidth)(); */
101 NULL, /* DefCvsFontMetrics, void (*_DtCvGetFontMetrics)(); */
102 NULL, /* VStatus (*_DtCvBuildSelection)(); */
105 static const _DtCvSpaceMetrics defLinkMetrics = { 0, 0, 0, 0 };
107 /******************************************************************************
111 ******************************************************************************/
112 /*****************************************************************************
113 * Function: void DefCvsMetrics ();
121 *****************************************************************************/
124 _DtCvPointer client_data,
125 _DtCvElemType elem_type,
126 _DtCvPointer ret_metrics)
128 _DtCvSpaceMetrics *retLink = (_DtCvSpaceMetrics *) ret_metrics;
130 if (_DtCvCANVAS_TYPE == elem_type)
132 _DtCvMetrics *retCanvas = (_DtCvMetrics *) ret_metrics;
134 retCanvas->width = 1;
135 retCanvas->height = 1;
136 retCanvas->top_margin = 0;
137 retCanvas->side_margin = 0;
138 retCanvas->line_height = 1;
139 retCanvas->horiz_pad_hint = 1;
141 else if (_DtCvLINK_TYPE == elem_type || _DtCvTRAVERSAL_TYPE == elem_type)
142 *retLink = defLinkMetrics;
145 /******************************************************************************
146 * Semi-Public Functions
147 ******************************************************************************/
148 /******************************************************************************
149 * Function: int _DtHelpCeGetVolumeTitle(_DtHelpVolume vol, char **retTitle);
151 * Parameters: vol Specifies the loaded volume.
152 * retTitle Returns the title of the volume. This string is
153 * owned by the caller and must be freed.
155 * Return Value: 0 if successful, -1 if a failure occurs
157 * Purpose: Get the title of a volume.
159 * Used by: dthelpgen 1.0
161 ******************************************************************************/
163 _DtHelpCeGetVolumeTitle (
168 _FrmtUiInfo myUiInfo;
169 _DtHelpVolume vol = (_DtHelpVolume)volume;
173 * set up my UI information
175 myUiInfo.load_graphic = NULL;
176 myUiInfo.resolve_spc = NULL;
177 myUiInfo.load_font = NULL;
178 myUiInfo.destroy_region = NULL;
179 myUiInfo.exec_filter = NULL;
180 myUiInfo.client_data = NULL;
181 /* since we're going for a string, set avg_char width to 1 */
182 myUiInfo.line_width = 0;
183 myUiInfo.line_height = 0;
184 myUiInfo.leading = 0;
185 myUiInfo.avg_char = 1;
186 myUiInfo.nl_to_space = 0;
189 * What type of volume is it?
191 _DtHelpProcessLock();
192 if (0 == _DtHelpCeGetVolumeFlag(volume))
194 result = _DtHelpCeGetCcdfVolumeTitle(vol, ret_title);
198 result = _DtHelpCeFrmtSDLVolTitleToAscii(volume, &myUiInfo, ret_title);
200 _DtHelpProcessUnlock();
203 /******************************************************************************
204 * Function: int _DtHelpCeGetAsciiVolumeAbstract (_DtHelpVolume vol, char **a
207 * Parameters: vol Specifies the loaded volume.
208 * abstract Returns the abstract of the volume. This string
209 * is owned by the caller and should be freed.
211 * Return Value: 0 if successful, -1 if a failure occurs
213 * Purpose: Get the abstract of a volume.
215 * Used by: dthelpgen 1.0
217 ******************************************************************************/
219 _DtHelpCeGetAsciiVolumeAbstract (
224 _DtHelpVolume vol = (_DtHelpVolume)volume;
228 * What type of volume is it?
230 _DtHelpProcessLock();
231 if (0 == _DtHelpCeGetVolumeFlag(volume))
233 result = _DtHelpCeGetCcdfVolumeAbstract(vol, retAbs);
234 _DtHelpProcessUnlock();
238 *retAbs = _DtHelpCeGetSdlVolumeAsciiAbstract(volume);
241 _DtHelpProcessUnlock();
245 _DtHelpProcessUnlock();
249 /*****************************************************************************
250 * Function: CanvasHandle _DtHelpCeCreateDefCanvas (void);
254 * Returns: A handle to the canvas or NULL if an error occurs.
256 * Purpose: Create a canvas and attach the appropriate virtual functions
258 *****************************************************************************/
260 _DtHelpCeCreateDefCanvas (void)
262 return (_DtCanvasCreate(MyVirtInfo, NULL));
264 } /* End _DtHelpCeCreateDefCanvas */
266 /******************************************************************************
267 * Function: char *_DtHelpCeGetNxtToken (char *str, char **retToken)
270 * Return Value: Returns the pointer to the next unparsed character in
271 * the input string. A NULL value indicates an error.
277 * Purpose: Parse tokens in resource string values.
279 *****************************************************************************/
281 _DtHelpCeGetNxtToken (
285 return (_DtHelpGetNxtToken(str, retToken));