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: Format.c /main/18 1996/11/22 12:23:59 cde-hp $ */
24 /************************************<+>*************************************
25 ****************************************************************************
29 ** Project: Text Graphic Display Library
31 ** Description: This body of formats the input into a form understood by
34 ** (c) Copyright 1987, 1988, 1989, 1990, 1991, 1992 Hewlett-Packard Company
36 ** (c) Copyright 1993, 1994 Hewlett-Packard Company
37 ** (c) Copyright 1993, 1994 International Business Machines Corp.
38 ** (c) Copyright 1993, 1994 Sun Microsystems, Inc.
39 ** (c) Copyright 1993, 1994 Novell, Inc.
42 ****************************************************************************
43 ************************************<+>*************************************/
55 #include <X11/Xresource.h>
63 * Core Engine includes
66 #include "CanvasSegP.h"
72 #include "CvtToArrayP.h"
73 #include "DisplayAreaP.h"
74 #include "FontAttrI.h"
76 #include "HelpXlate.h"
77 #include "XInterfaceI.h"
86 #include "AccessCCDFI.h"
88 #include "FormatUtilI.h"
89 #include "FormatCCDFI.h"
90 #include "FormatSDLI.h"
91 #include "StringFuncsI.h"
97 /******** Private Function Declarations ********/
99 /******** End Public Function Declarations ********/
101 /******************************************************************************
103 * Private variables and defines.
105 *****************************************************************************/
106 #define BUFF_SIZE 1024
108 static char *ScanString = "\n\t";
109 static const _FrmtUiInfo defUiInfo = { NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, 1, False };
111 /******************************************************************************
115 *****************************************************************************/
116 /******************************************************************************
117 * Function: int FormatChunksToXmString ()
120 * *ret_list may be NULL when called
122 * Returns: 0 if successful, -1 if errors
126 * Purpose: Take some rich text chunks and turn it into an XmString.
128 ******************************************************************************/
130 FormatChunksToXmString(
131 DtHelpDispAreaStruct *pDAS,
135 XmFontList *ret_list,
144 _DtCvPointer fontPtr;
146 const char *strChunk;
148 _DtHelpFontHints fontSpecs;
149 XmFontContext fontContext;
152 XrmQuark charSetQuark;
153 XrmName myCharSetQuarks[20];
154 XrmName xrmName[_CEFontAttrNumber];
158 * Initialize the pointers.
163 if (title_chunks == NULL)
167 * initialize the font context
169 _DtHelpCeCopyDefFontAttrList(&fontSpecs);
170 if ( NULL != *ret_list )
172 if (XmFontListInitFontContext (&fontContext, *ret_list) == False)
176 XFontStruct *myFontStruct;
178 * quarkize all the character sets found.
183 myMore = XmFontListGetNextFont (fontContext, &charSet,
187 myCharSetQuarks[quarkCount++] =
188 XrmStringToQuark (charSet);
193 XmFontListFreeFontContext (fontContext);
195 } /* if NULL != *ret_list */
197 { /* if NULL == *ret_list */
199 myCharSetQuarks[0] = 0;
203 * Build the XrmString based on the segments.
204 * The format of the returned information is
205 * 'DT_HELP_CE_CHARSET locale string'
206 * 'DT_HELP_CE_FONT_PTR fontptr string'
207 * 'DT_HELP_CE_SPC spc'
208 * 'DT_HELP_CE_STRING string' - uses last specified
211 * The order and manner in which the title_chunks are processed
212 * is known and depended upon in several locations.
213 * Do not change this without changing the other locations.
214 * See the _DtHelpFormatxxx() routines and the ones that
215 * create the title_chunk arrays in FormatSDL.c and FormatCCDF.c
217 myIdx = __DtHelpDefaultFontIndexGet(pDAS);
218 _DtHelpCopyDefaultList(xrmName);
219 for (i = 0; result == 0 && title_chunks[i] != DT_HELP_CE_END; i++)
222 * create a string for the char set and a quark for it.
224 chunkType = (long) title_chunks[i++];
227 * i now points to the first value after the type
229 if (chunkType & DT_HELP_CE_CHARSET)
232 char *lang = (char *) title_chunks[i];
235 * test to see if the locale is in a lang.codeset form
237 if (_DtHelpCeStrchr(lang, ".", 1, &charSet) == 0)
249 * resolve/load the font for the default fonts
251 _DtHelpDAResolveFont(pDAS, lang, charSet, fontSpecs, &fontPtr);
252 myIdx = (long) fontPtr;
260 free(title_chunks[i]);
263 * move the i to point to the string.
267 else if (chunkType & DT_HELP_CE_FONT_PTR)
270 * get the default font for the language and code set.
272 (void) __DtHelpFontCharSetQuarkGet(pDAS, (long)title_chunks[i],
273 &xrmName[_DT_HELP_FONT_CHAR_SET]);
274 (void) __DtHelpFontLangQuarkGet(pDAS, (long)title_chunks[i],
275 &xrmName[_DT_HELP_FONT_LANG_TER]);
276 (void) __DtHelpFontIndexGet(pDAS, xrmName, &myIdx);
279 * move the i to point to the string.
285 * the i point spc or string.
287 if (chunkType & DT_HELP_CE_SPC)
289 j = (long) title_chunks[i];
290 strChunk = _DtHelpDAGetSpcString(pDAS->spc_chars[j].spc_idx);
291 fontPtr = pDAS->spc_chars[j].font_ptr;
294 * get the default font for the language and code set.
296 (void) __DtHelpFontCharSetQuarkGet(pDAS, (long)fontPtr,
297 &xrmName[_DT_HELP_FONT_CHAR_SET]);
298 (void) __DtHelpFontLangQuarkGet(pDAS, (long)fontPtr,
299 &xrmName[_DT_HELP_FONT_LANG_TER]);
300 (void) __DtHelpFontIndexGet(pDAS, xrmName, &myIdx);
302 else /* if (chunkType & _DT_HELP_CE_STRING) */
303 strChunk = (char *) title_chunks[i];
305 sprintf(buffer, "%ld", myIdx);
306 charSetQuark = XrmStringToQuark(buffer);
309 while (j < quarkCount && myCharSetQuarks[j] != charSetQuark)
313 * If we didn't find a matching character set,
314 * add it to the list.
318 /* Copy the input list so XmFontListAppendEntry can mangle it. */
319 /* But only do it once! */
320 if (False == *ret_mod)
321 *ret_list = XmFontListCopy(*ret_list);
325 XFontSet fontSet = __DtHelpFontSetGet(pDAS->font_info, myIdx);
326 XmFontListEntry fontEntry;
328 fontEntry = XmFontListEntryCreate (buffer,
330 (XtPointer) fontSet);
331 *ret_list = XmFontListAppendEntry (*ret_list, fontEntry);
332 XmFontListEntryFree (&fontEntry);
336 XFontStruct *fontStruct =
337 __DtHelpFontStructGet(pDAS->font_info, myIdx);
338 XmFontListEntry fontEntry;
340 fontEntry = XmFontListEntryCreate (buffer,
342 (XtPointer) fontStruct);
343 *ret_list = XmFontListAppendEntry (*ret_list, fontEntry);
344 XmFontListEntryFree (&fontEntry);
348 if (*ret_list == NULL)
351 myCharSetQuarks[quarkCount++] = charSetQuark;
355 * add this segment to the XmString.
359 if (*ret_title == NULL)
360 *ret_title = XmStringGenerate ((char *) strChunk, buffer,
361 XmCHARSET_TEXT, NULL);
364 partTitle = XmStringGenerate ((char *) strChunk, buffer,
365 XmCHARSET_TEXT, NULL);
367 newTitle = XmStringConcat (*ret_title, partTitle);
369 XmStringFree (*ret_title);
370 XmStringFree (partTitle);
371 *ret_title = newTitle;
375 * if a newline was specified,
376 * replace it with a blank.
378 if (*ret_title != NULL && (chunkType & DT_HELP_CE_NEWLINE))
380 partTitle = XmStringGenerate (" ", buffer, XmCHARSET_TEXT, NULL);
381 newTitle = XmStringConcat (*ret_title, partTitle);
382 XmStringFree (*ret_title);
383 XmStringFree (partTitle);
384 *ret_title = newTitle;
387 if (*ret_title == NULL)
391 if (free_flag && (chunkType & DT_HELP_CE_STRING))
392 free(title_chunks[i]);
395 * deallocate the memory.
397 if (free_flag) free(title_chunks);
401 /******************************************************************************
403 * Semi-Public Functions
405 *****************************************************************************/
406 /*****************************************************************************
407 * Function: int _DtHelpFormatAsciiFile (char *filename,
408 * CEParagraph **ret_para, int *ret_num)
411 * filename Specifies the ascii file to read.
412 * ret_para Returns a pointer to a list of CEParagraph
414 * ret_num Returns the number of structures in 'ret_para'.
416 * Returns: 0 if successful, -1 if errors
421 * Purpose: _DtHelpFormatAsciiFile formats Ascii Files into a list of
422 * CEParagraph structures.
424 *****************************************************************************/
426 _DtHelpFormatAsciiFile(
427 XtPointer client_data,
429 XtPointer *ret_handle)
433 _DtHelpFontHints fontAttrs;
434 char buffer [BUFF_SIZE];
437 _DtCvTopicPtr topic = NULL;
438 DtHelpDispAreaStruct *pDAS = (DtHelpDispAreaStruct *) client_data;
439 _FrmtUiInfo myUiInfo = defUiInfo;
442 * check the parameters
444 if (filename == NULL || ret_handle == NULL)
451 * Initialize the pointers, buffers and counters
458 myFile = open (filename, O_RDONLY);
462 * set the information
464 rawInput = _DtHelpCeBufFileRdWithFd(myFile);
471 result = _DtHelpCeReadBuf (rawInput, buffer, BUFF_SIZE);
475 _DtHelpCeCopyDefFontAttrList (&fontAttrs);
476 fontAttrs.spacing = _DtHelpFontSpacingMono;
477 _DtHelpCeXlateOpToStdLocale(DtLCX_OPER_SETLOCALE,
478 setlocale(LC_CTYPE,NULL), NULL,
479 &(fontAttrs.language), &(fontAttrs.char_set));
482 * fill out the ui information
484 myUiInfo.load_font = _DtHelpDAResolveFont;
485 myUiInfo.client_data = (_DtCvPointer) pDAS;
486 myUiInfo.line_width = pDAS->lineThickness;
487 myUiInfo.line_height = pDAS->lineHeight;
488 myUiInfo.leading = pDAS->leading;
489 myUiInfo.avg_char = (int)(pDAS->charWidth / 10 +
490 ((pDAS->charWidth % 10) ? 1 : 0));
491 myUiInfo.nl_to_space = pDAS->nl_to_space;
494 * get the formatting structure.
496 varHandle = __DtHelpCeSetUpVars(fontAttrs.language,
497 fontAttrs.char_set, &myUiInfo);
498 if (varHandle == NULL)
500 free(fontAttrs.language);
501 free(fontAttrs.char_set);
505 result = __DtHelpCeProcessString (varHandle, rawInput,
507 ScanString, buffer, BUFF_SIZE,
508 0, False, &fontAttrs);
511 result = __DtHelpCeGetParagraphList (varHandle, True,
515 free(fontAttrs.language);
516 free(fontAttrs.char_set);
520 _DtHelpCeBufFileClose(rawInput, True);
523 *ret_handle = (XtPointer) topic;
526 } /* End _DtHelpFormatAsciiFile */
528 /*****************************************************************************
529 * Function: int _DtHelpFormatAsciiString (char *input_string,
530 * CEParagraph **ret_para, int *ret_num)
533 * input_string Specifies the ascii string to format.
534 * ret_para Returns a pointer to a list of CEParagraph
536 * ret_num Returns the number of structures in 'ret_para'.
538 * Returns: 0 if successful, -1 if errors
542 * Purpose: _DtHelpFormatAsciiString formats a string as if it were a
543 * static string - watching for newlines and using them
544 * to force a break in the line.
546 *****************************************************************************/
548 _DtHelpFormatAsciiString(
549 XtPointer client_data,
551 XtPointer *ret_handle)
554 _DtHelpFontHints fontAttrs;
556 _DtCvTopicPtr topic = NULL;
557 DtHelpDispAreaStruct *pDAS = (DtHelpDispAreaStruct *) client_data;
558 _FrmtUiInfo myUiInfo = defUiInfo;
561 * check the parameters.
563 if (input_string == NULL || ret_handle == NULL)
570 * fill out the ui information
572 myUiInfo.load_font = _DtHelpDAResolveFont;
573 myUiInfo.client_data = (_DtCvPointer) pDAS;
574 myUiInfo.line_width = pDAS->lineThickness;
575 myUiInfo.line_height = pDAS->lineHeight;
576 myUiInfo.leading = pDAS->leading;
577 myUiInfo.avg_char = (int)(pDAS->charWidth / 10 +
578 ((pDAS->charWidth % 10) ? 1 : 0));
579 myUiInfo.nl_to_space = pDAS->nl_to_space;
582 * Get the initialized variables
586 _DtHelpCeCopyDefFontAttrList (&fontAttrs);
587 _DtHelpCeXlateOpToStdLocale(DtLCX_OPER_SETLOCALE,setlocale(LC_CTYPE,NULL),
588 NULL, &(fontAttrs.language),
589 &(fontAttrs.char_set));
591 varHandle = __DtHelpCeSetUpVars(fontAttrs.language, fontAttrs.char_set,
593 if (varHandle == NULL)
595 free(fontAttrs.language);
596 free(fontAttrs.char_set);
600 result = __DtHelpCeProcessString (varHandle, NULL,
602 ScanString, input_string,
603 strlen(input_string),
608 result = __DtHelpCeGetParagraphList (varHandle, True, _DtCvLITERAL,
611 *ret_handle = (XtPointer) topic;
613 free(fontAttrs.language);
614 free(fontAttrs.char_set);
619 } /* End _DtHelpFormatAsciiString */
621 /*****************************************************************************
622 * Function: int _DtHelpFormatAsciiStringDynamic (char *input_string,
623 * CEParagraph **ret_para, int *ret_num)
626 * input_string Specifies the ascii string to format.
627 * ret_para Returns a pointer to a list of CEParagraph
629 * ret_num Returns the number of structures in 'ret_para'.
631 * Returns: 0 if successful, -1 if errors
635 * Purpose: _DtHelpFormatAsciiStringDynamic formats a string as if it were
636 * a dynamic string - it uses newline characters to terminate
637 * the current paragraph, not a line.
639 *****************************************************************************/
641 _DtHelpFormatAsciiStringDynamic(
642 XtPointer client_data,
644 XtPointer *ret_handle)
647 _DtHelpFontHints fontAttrs;
649 _DtCvTopicPtr topic = NULL;
650 DtHelpDispAreaStruct *pDAS = (DtHelpDispAreaStruct *) client_data;
651 _FrmtUiInfo myUiInfo = defUiInfo;
654 * check the parameters.
656 if (input_string == NULL || ret_handle == NULL)
663 * fill out the ui information
665 myUiInfo.load_font = _DtHelpDAResolveFont;
666 myUiInfo.client_data = (_DtCvPointer) pDAS;
667 myUiInfo.line_width = pDAS->lineThickness;
668 myUiInfo.line_height = pDAS->lineHeight;
669 myUiInfo.leading = pDAS->leading;
670 myUiInfo.avg_char = (int)(pDAS->charWidth / 10 +
671 ((pDAS->charWidth % 10) ? 1 : 0));
672 myUiInfo.nl_to_space = pDAS->nl_to_space;
675 * Fake the flag and give the string as the input buffer.
679 _DtHelpCeCopyDefFontAttrList (&fontAttrs);
680 _DtHelpCeXlateOpToStdLocale(DtLCX_OPER_SETLOCALE,setlocale(LC_CTYPE,NULL),
681 NULL, &(fontAttrs.language),
682 &(fontAttrs.char_set));
684 varHandle = __DtHelpCeSetUpVars(fontAttrs.language, fontAttrs.char_set,
686 if (varHandle == NULL)
688 free(fontAttrs.language);
689 free(fontAttrs.char_set);
693 result = __DtHelpCeProcessString (varHandle, NULL,
695 ScanString, input_string,
696 strlen(input_string),
701 result = __DtHelpCeGetParagraphList (varHandle, False, _DtCvDYNAMIC,
703 *ret_handle = (XtPointer) topic;
705 free(fontAttrs.language);
706 free(fontAttrs.char_set);
711 } /* End _DtHelpFormatAsciiStringDynamic */
713 /******************************************************************************
714 * Function: int _DtHelpFormatTopicTitle (Display *dpy, _XvhVolume volume,
715 * char *filename, int offset,
716 * XmString *ret_title, XmFontList *ret_list,
720 * dpy Specifies the connection to the server.
721 * volume Specifies the Help Volume the information
722 * is associated with.
723 * filename Specifies the file containing the Help Topic
725 * offset Specifies the offset into 'filename' to
726 * the Help Topic desired.
727 * ret_title Returns XmString containing the title.
728 * ret_list Specifies the current font list being used.
729 * Returns a new font list if new character
730 * sets are added to it.
731 * ret_mod Returns True if fonts were added to the
734 * Returns: 0 if successful, -1 if errors
738 * Purpose: _DtHelpFormatTopicTitle formats a topic title and associates
739 * the correct font with it.
741 ******************************************************************************/
743 _DtHelpFormatTopicTitle(
744 XtPointer client_data,
745 _DtHelpVolumeHdl volume_handle,
748 XmFontList *ret_list,
752 void **titleChunks = NULL;
753 _FrmtUiInfo myUiInfo = defUiInfo;
754 _DtHelpCeLockInfo lockInfo;
755 DtHelpDispAreaStruct *pDAS = (DtHelpDispAreaStruct *) client_data;
758 * Check the parameters
760 if (ret_title == NULL || ret_list == NULL || ret_mod == NULL)
769 if (_DtHelpCeLockVolume(volume_handle, &lockInfo) != 0)
773 * set up my UI information
775 myUiInfo.load_graphic = _DtHelpDALoadGraphic;
776 myUiInfo.resolve_spc = _DtHelpDAResolveSpc;
777 myUiInfo.load_font = _DtHelpDAResolveFont;
778 myUiInfo.exec_filter = pDAS->exec_filter;
779 myUiInfo.destroy_region = _DtHelpDADestroyRegion;
780 myUiInfo.client_data = (_DtCvPointer) pDAS;
781 /* since we're going for chunks, set avg_char width to 1 */
782 myUiInfo.line_width = 0;
783 myUiInfo.line_height = 0;
784 myUiInfo.leading = 0;
785 myUiInfo.avg_char = 1;
786 myUiInfo.nl_to_space = pDAS->nl_to_space;
789 * Get the title and charsets associated with the title segments.
790 * The format of the returned information is
791 * [type,charset/fontptr,]type,string/spc
793 result = _DtHelpCeGetVolumeFlag(volume_handle);
794 _DtHelpProcessLock();
796 result = _DtHelpCeGetSdlTitleChunks(volume_handle, location_id,
797 &myUiInfo, &titleChunks);
798 else if (result == 0)
799 result = _DtHelpCeGetCcdfTitleChunks( volume_handle, location_id,
800 &myUiInfo, &titleChunks);
801 _DtHelpProcessUnlock();
803 result = FormatChunksToXmString(pDAS, True, titleChunks,
804 ret_title, ret_list, ret_mod);
805 _DtHelpCeUnlockVolume(lockInfo);
808 } /* End _DtHelpFormatTopicTitle */
810 /******************************************************************************
811 * Function: int _DtHelpFormatVolumeTitle (DtHelpDispAreaStruct *pDAS,
813 * XmString *ret_title, XmFontList *ret_list,
817 * volume Specifies the Help Volume the information
818 * is associated with.
819 * ret_title Returns XmString containing the title.
820 * ret_list Specifies the current font list being used.
821 * Returns a new font list if new character
822 * sets are added to it.
823 * ret_mod Returns True if fonts were added to the
826 * Returns: 0 if successful, -1 if errors
830 * Purpose: _DtHelpFormatVolumeTitle formats a volume title and associates
831 * the correct font with it.
833 ******************************************************************************/
835 _DtHelpFormatVolumeTitle(
836 XtPointer client_data,
837 _DtHelpVolumeHdl volume_handle,
839 XmFontList *ret_list,
843 void **titleChunks = NULL;
844 _FrmtUiInfo myUiInfo = defUiInfo;
845 _DtHelpCeLockInfo lockInfo;
846 DtHelpDispAreaStruct *pDAS = (DtHelpDispAreaStruct *) client_data;
849 * Check the parameters
851 if (ret_title == NULL || ret_list == NULL || ret_mod == NULL)
861 if (_DtHelpCeLockVolume(volume_handle, &lockInfo) != 0)
865 * set up my UI information
867 myUiInfo.load_graphic = _DtHelpDALoadGraphic;
868 myUiInfo.resolve_spc = _DtHelpDAResolveSpc;
869 myUiInfo.load_font = _DtHelpDAResolveFont;
870 myUiInfo.exec_filter = pDAS->exec_filter;
871 myUiInfo.destroy_region = _DtHelpDADestroyRegion;
872 myUiInfo.client_data = (_DtCvPointer) pDAS;
873 /* since we're going for chunks, set avg_char width to 1 */
874 myUiInfo.line_width = 0;
875 myUiInfo.line_height = 0;
876 myUiInfo.leading = 0;
877 myUiInfo.avg_char = 1;
878 myUiInfo.nl_to_space = pDAS->nl_to_space;
881 * Get the title and charsets associated with the volume title.
882 * The format of the returned information is
883 * [type,charset/fontptr,]type,string/spc
885 result = _DtHelpCeGetVolumeFlag(volume_handle);
886 _DtHelpProcessLock();
888 result = _DtHelpCeGetSdlVolTitleChunks(volume_handle, &myUiInfo,
890 else if (result == 0)
891 result = _DtHelpCeGetCcdfVolTitleChunks(
892 (_DtHelpVolume) volume_handle,
895 _DtHelpProcessUnlock();
897 result = FormatChunksToXmString(pDAS, True, titleChunks,
898 ret_title, ret_list, ret_mod);
899 _DtHelpCeUnlockVolume(lockInfo);
902 } /* End _DtHelpFormatVolumeTitle */
904 /******************************************************************************
905 * Function: int _DtHelpFormatIndexEntries (DtHelpDispAreaStruct *pDAS,
907 * XmString *ret_title, XmFontList *ret_list,
911 * volume Specifies the Help Volume the information
912 * is associated with.
913 * ret_cnt number of valid entries in the array
914 * ret_words Returns NULL-termintaed array of
915 * XmStrings containing the words.
916 * ret_list Specifies the current font list being used.
917 * Returns a new font list if new character
918 * sets are added to it.
919 * ret_mod Returns True if fonts were added to the
922 * Returns: 0 if successful, -1 if errors
926 * Purpose: _DtHelpFormatIndexEntries formats index entries and associates
927 * the correct font with it.
929 ******************************************************************************/
931 _DtHelpFormatIndexEntries(
932 XtPointer client_data,
933 _DtHelpVolumeHdl volume_handle,
935 XmString **ret_words,
936 XmFontList *ret_list,
941 void *titleChunks[4];
944 Boolean myMod = False;
946 DtHelpDispAreaStruct *pDAS = (DtHelpDispAreaStruct *) client_data;
949 * Check the parameters
951 if (ret_words == NULL || ret_list == NULL || ret_mod == NULL)
959 charSet = _DtHelpGetVolumeLocale(volume_handle);
962 *ret_cnt = _DtHelpCeGetKeywordList(volume_handle, &keyWords);
966 *ret_words = (XmString *) malloc (sizeof(XmString) * (*ret_cnt+1));
967 if (*ret_words == NULL)
970 /* the order of the string ptr and charset ptr in the titleChunks
971 is determined by the order of the if(..) tests on the
972 flags and subsequent processing in FormatChunksToXmString() */
973 titleChunks[0] = (void *) (DT_HELP_CE_STRING | DT_HELP_CE_CHARSET);
974 titleChunks[1] = (void *) charSet;
975 titleChunks[3] = (void *) DT_HELP_CE_END;
976 for (i = 0, result = 0; result == 0 && i < *ret_cnt; i++)
979 titleChunks[2] = (void *) keyWords[i];
980 result = FormatChunksToXmString(pDAS, False, titleChunks,
981 &(*ret_words)[i], ret_list, &myMod);
985 * if the list has been modified before,
986 * free the previously modified list.
988 if (True == *ret_mod)
989 XmFontListFree(oldList);
994 (*ret_words)[i] = NULL;
1001 } /* End _DtHelpFormatIndexEntries */
1003 /******************************************************************************
1004 * Function: int _DtHelpFormatTopic (
1005 * DtHelpDispAreaStruct *pDAS,
1006 * _DtHelpVolumeHdl volume,
1008 * Boolean look_at_id,
1009 * XtPointer *ret_handle)
1012 * pDAS Specifies the display area to use.
1013 * volume Specifies the Help Volume the information
1014 * is associated with.
1015 * id_string Specifies the location id for the topic.
1016 * This location id can be contained in a
1018 * look_at_id Specifies whether or not to start the
1019 * display of the topic at the location id.
1020 * ret_handle Returns a handle to the topic information
1021 * including the number of paragraphs and the
1024 * Returns: 0 if successful.
1026 * -2 if the id was not found.
1027 * -3 if unable to format the topic.
1031 * Purpose: _DtHelpParseTopic accesses and parses Help topics.
1033 ******************************************************************************/
1036 XtPointer client_data,
1037 _DtHelpVolumeHdl volume,
1040 XtPointer *ret_handle )
1042 char *filename = NULL;
1045 _DtHelpCeLockInfo lockInfo;
1046 _FrmtUiInfo myUiInfo = defUiInfo;
1047 DtHelpDispAreaStruct *pDAS = (DtHelpDispAreaStruct *) client_data;
1048 _DtCvTopicInfo *topic = NULL;
1050 if (_DtHelpCeLockVolume(volume, &lockInfo) != 0)
1053 if (_DtHelpCeFindId(volume,id_string,lockInfo.fd,&filename,&offset)==True)
1055 if (look_at_id == False)
1058 myUiInfo.load_graphic = _DtHelpDALoadGraphic;
1059 myUiInfo.resolve_spc = _DtHelpDAResolveSpc;
1060 myUiInfo.load_font = _DtHelpDAResolveFont;
1061 myUiInfo.exec_filter = pDAS->exec_filter;
1062 myUiInfo.destroy_region = _DtHelpDADestroyRegion;
1063 myUiInfo.client_data = (_DtCvPointer) pDAS;
1064 myUiInfo.line_width = pDAS->lineThickness;
1065 myUiInfo.line_height = pDAS->lineHeight;
1066 myUiInfo.leading = pDAS->leading;
1067 myUiInfo.avg_char = (int)(pDAS->charWidth / 10 +
1068 ((pDAS->charWidth % 10) ? 1 : 0));
1069 myUiInfo.nl_to_space = pDAS->nl_to_space;
1071 result = _DtHelpCeGetVolumeFlag(volume);
1072 _DtHelpProcessLock();
1074 result = _DtHelpCeParseSdlTopic(volume,
1076 lockInfo.fd, offset,
1077 id_string, True, &topic);
1078 else if (result == 0)
1079 result = _DtHelpCeFrmtCcdfTopic((_DtHelpVolume) volume,
1083 _DtHelpProcessUnlock();
1084 *ret_handle = (XtPointer) topic;
1088 if (filename != NULL)
1092 _DtHelpCeUnlockVolume(lockInfo);
1096 } /* End _DtHelpFormatTopic */
1099 /******************************************************************************
1100 * Function: int _DtHelpGetAsciiVolumeTitle (
1102 * Parameters: vol Specifies the loaded volume.
1103 * retTitle Returns the title of the volume. This string is
1104 * owned by the caller and must be freed.
1106 * Return Value: 0 if successful, -1 if a failure occurs
1108 * errno Values: CEErrorMalloc
1109 * EINVAL 'vol' or 'retTitle' is NULL.
1110 * CEErrorMissingTitleRes
1111 * 'vol' does not contain the resource
1112 * 'Title' or 'title' or the resource
1115 * Purpose: Get the title of a volume.
1117 ******************************************************************************/
1119 _DtHelpGetAsciiVolumeTitle (
1120 XtPointer client_data,
1121 _DtHelpVolumeHdl volume,
1125 _FrmtUiInfo myUiInfo = defUiInfo;
1126 DtHelpDispAreaStruct *pDAS = (DtHelpDispAreaStruct *) client_data;
1129 * What type of volume is it?
1131 result = _DtHelpCeGetVolumeFlag(volume);
1135 * set up my UI information
1137 myUiInfo.load_graphic = _DtHelpDALoadGraphic;
1138 myUiInfo.resolve_spc = _DtHelpDAResolveSpc;
1139 myUiInfo.load_font = _DtHelpDAResolveFont;
1140 myUiInfo.exec_filter = pDAS->exec_filter;
1141 myUiInfo.destroy_region = _DtHelpDADestroyRegion;
1142 myUiInfo.client_data = (_DtCvPointer) pDAS;
1143 /* since we're going for a string, set avg_char width to 1 */
1144 myUiInfo.line_width = 0;
1145 myUiInfo.line_height = 0;
1146 myUiInfo.leading = 0;
1147 myUiInfo.avg_char = 1;
1148 myUiInfo.nl_to_space = pDAS->nl_to_space;
1150 _DtHelpProcessLock();
1151 result = _DtHelpCeFrmtSDLVolTitleToAscii(volume, &myUiInfo, ret_title);
1153 else if (0 == result)
1155 _DtHelpProcessLock();
1156 result = _DtHelpCeGetCcdfVolumeTitle(volume, ret_title);
1158 _DtHelpProcessUnlock();
1162 /*****************************************************************************
1163 * Function: int _DtHelpFormatToc (
1164 * _DtHelpVolumeHdl volume, id);
1167 * canvas Specifies the handle for the canvas.
1169 * Returns: -1 if errors.
1175 *****************************************************************************/
1178 DtHelpDispAreaStruct *pDAS,
1179 _DtHelpVolumeHdl volume,
1182 XtPointer *ret_handle)
1185 _DtCvTopicPtr topic;
1186 _DtHelpCeLockInfo lockInfo;
1188 if (volume == NULL || id == NULL)
1192 * This becomes my volume; want to ensure that it doesn't
1193 * get closed out from under me, so tell the system that
1196 if (_DtHelpCeLockVolume(volume, &lockInfo) != 0)
1199 result = _DtHelpCeMapTargetToId(volume, id, ret_id);
1203 _FrmtUiInfo myUiInfo = defUiInfo;
1205 myUiInfo.client_data = (XtPointer) pDAS;
1206 myUiInfo.load_graphic = _DtHelpDALoadGraphic;
1207 myUiInfo.resolve_spc = _DtHelpDAResolveSpc;
1208 myUiInfo.load_font = _DtHelpDAResolveFont;
1209 myUiInfo.exec_filter = pDAS->exec_filter;
1210 myUiInfo.destroy_region = _DtHelpDADestroyRegion;
1211 myUiInfo.client_data = (_DtCvPointer) pDAS;
1212 myUiInfo.line_width = pDAS->lineThickness;
1213 myUiInfo.line_height = pDAS->lineHeight;
1214 myUiInfo.leading = pDAS->leading;
1215 myUiInfo.avg_char = (int)(pDAS->charWidth / 10 +
1216 ((pDAS->charWidth % 10) ? 1 : 0));
1217 myUiInfo.nl_to_space = pDAS->nl_to_space;
1219 result = _DtHelpCeGetVolumeFlag(volume);
1220 _DtHelpProcessLock();
1222 result = _DtHelpCeFrmtSdlPathAndChildren(volume,
1226 else if (result == 0)
1227 result = _DtHelpCeFrmtCcdfPathAndChildren(volume,
1230 _DtHelpProcessUnlock();
1231 *ret_handle = (XtPointer) topic;
1234 * didn't successfully format a path, so close my copy
1238 _DtHelpCloseVolume (volume);
1240 _DtHelpCeUnlockVolume(lockInfo);
1243 } /* End _DtHelpFormatToc */