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 librararies 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"
87 #include "FormatUtilI.h"
88 #include "FormatCCDFI.h"
89 #include "FormatSDLI.h"
95 /******** Private Function Declarations ********/
97 /******** End Public Function Declarations ********/
99 /******************************************************************************
101 * Private variables and defines.
103 *****************************************************************************/
104 #define BUFF_SIZE 1024
106 static char *ScanString = "\n\t";
107 static const _FrmtUiInfo defUiInfo = { NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, 1, False };
109 /******************************************************************************
113 *****************************************************************************/
114 /******************************************************************************
115 * Function: int FormatChunksToXmString ()
118 * *ret_list may be NULL when called
120 * Returns: 0 if successful, -1 if errors
124 * Purpose: Take some rich text chunks and turn it into an XmString.
126 ******************************************************************************/
128 FormatChunksToXmString(
129 DtHelpDispAreaStruct *pDAS,
133 XmFontList *ret_list,
142 _DtCvPointer fontPtr;
144 const char *strChunk;
146 _DtHelpFontHints fontSpecs;
147 XmFontContext fontContext;
150 XrmQuark charSetQuark;
151 XrmName myCharSetQuarks[20];
152 XrmName xrmName[_CEFontAttrNumber];
156 * Initialize the pointers.
161 if (title_chunks == NULL)
165 * initialize the font context
167 _DtHelpCeCopyDefFontAttrList(&fontSpecs);
168 if ( NULL != *ret_list )
170 if (XmFontListInitFontContext (&fontContext, *ret_list) == False)
174 XFontStruct *myFontStruct;
176 * quarkize all the character sets found.
181 myMore = XmFontListGetNextFont (fontContext, &charSet,
185 myCharSetQuarks[quarkCount++] =
186 XrmStringToQuark (charSet);
191 XmFontListFreeFontContext (fontContext);
193 } /* if NULL != *ret_list */
195 { /* if NULL == *ret_list */
197 myCharSetQuarks[0] = 0;
201 * Build the XrmString based on the segments.
202 * The format of the returned information is
203 * 'DT_HELP_CE_CHARSET locale string'
204 * 'DT_HELP_CE_FONT_PTR fontptr string'
205 * 'DT_HELP_CE_SPC spc'
206 * 'DT_HELP_CE_STRING string' - uses last specified
209 * The order and manner in which the title_chunks are processed
210 * is known and depended upon in several locations.
211 * Do not change this without changing the other locations.
212 * See the _DtHelpFormatxxx() routines and the ones that
213 * create the title_chunk arrays in FormatSDL.c and FormatCCDF.c
215 myIdx = __DtHelpDefaultFontIndexGet(pDAS);
216 _DtHelpCopyDefaultList(xrmName);
217 for (i = 0; result == 0 && title_chunks[i] != DT_HELP_CE_END; i++)
220 * create a string for the char set and a quark for it.
222 chunkType = (int) title_chunks[i++];
225 * i now points to the first value after the type
227 if (chunkType & DT_HELP_CE_CHARSET)
230 char *lang = (char *) title_chunks[i];
233 * test to see if the locale is in a lang.codeset form
235 if (_DtHelpCeStrchr(lang, ".", 1, &charSet) == 0)
247 * resolve/load the font for the default fonts
249 _DtHelpDAResolveFont(pDAS, lang, charSet, fontSpecs, &fontPtr);
250 myIdx = (int) fontPtr;
258 free(title_chunks[i]);
261 * move the i to point to the string.
265 else if (chunkType & DT_HELP_CE_FONT_PTR)
268 * get the default font for the language and code set.
270 (void) __DtHelpFontCharSetQuarkGet(pDAS, (int)title_chunks[i],
271 &xrmName[_DT_HELP_FONT_CHAR_SET]);
272 (void) __DtHelpFontLangQuarkGet(pDAS, (int)title_chunks[i],
273 &xrmName[_DT_HELP_FONT_LANG_TER]);
274 (void) __DtHelpFontIndexGet(pDAS, xrmName, &myIdx);
277 * move the i to point to the string.
283 * the i point spc or string.
285 if (chunkType & DT_HELP_CE_SPC)
287 j = (int) title_chunks[i];
288 strChunk = _DtHelpDAGetSpcString(pDAS->spc_chars[j].spc_idx);
289 fontPtr = pDAS->spc_chars[j].font_ptr;
292 * get the default font for the language and code set.
294 (void) __DtHelpFontCharSetQuarkGet(pDAS, (int)fontPtr,
295 &xrmName[_DT_HELP_FONT_CHAR_SET]);
296 (void) __DtHelpFontLangQuarkGet(pDAS, (int)fontPtr,
297 &xrmName[_DT_HELP_FONT_LANG_TER]);
298 (void) __DtHelpFontIndexGet(pDAS, xrmName, &myIdx);
300 else /* if (chunkType & _DT_HELP_CE_STRING) */
301 strChunk = (char *) title_chunks[i];
303 sprintf(buffer, "%d", myIdx);
304 charSetQuark = XrmStringToQuark(buffer);
307 while (j < quarkCount && myCharSetQuarks[j] != charSetQuark)
311 * If we didn't find a matching character set,
312 * add it to the list.
316 /* Copy the input list so XmFontListAppendEntry can mangle it. */
317 /* But only do it once! */
318 if (False == *ret_mod)
319 *ret_list = XmFontListCopy(*ret_list);
323 XFontSet fontSet = __DtHelpFontSetGet(pDAS->font_info, myIdx);
324 XmFontListEntry fontEntry;
326 fontEntry = XmFontListEntryCreate (buffer,
328 (XtPointer) fontSet);
329 *ret_list = XmFontListAppendEntry (*ret_list, fontEntry);
330 XmFontListEntryFree (&fontEntry);
334 XFontStruct *fontStruct =
335 __DtHelpFontStructGet(pDAS->font_info, myIdx);
336 XmFontListEntry fontEntry;
338 fontEntry = XmFontListEntryCreate (buffer,
340 (XtPointer) fontStruct);
341 *ret_list = XmFontListAppendEntry (*ret_list, fontEntry);
342 XmFontListEntryFree (&fontEntry);
346 if (*ret_list == NULL)
349 myCharSetQuarks[quarkCount++] = charSetQuark;
353 * add this segment to the XmString.
357 if (*ret_title == NULL)
358 *ret_title = XmStringGenerate ((char *) strChunk, buffer,
359 XmCHARSET_TEXT, NULL);
362 partTitle = XmStringGenerate ((char *) strChunk, buffer,
363 XmCHARSET_TEXT, NULL);
365 newTitle = XmStringConcat (*ret_title, partTitle);
367 XmStringFree (*ret_title);
368 XmStringFree (partTitle);
369 *ret_title = newTitle;
373 * if a newline was specified,
374 * replace it with a blank.
376 if (*ret_title != NULL && (chunkType & DT_HELP_CE_NEWLINE))
378 partTitle = XmStringGenerate (" ", buffer, XmCHARSET_TEXT, NULL);
379 newTitle = XmStringConcat (*ret_title, partTitle);
380 XmStringFree (*ret_title);
381 XmStringFree (partTitle);
382 *ret_title = newTitle;
385 if (*ret_title == NULL)
389 if (free_flag && (chunkType & DT_HELP_CE_STRING))
390 free(title_chunks[i]);
393 * deallocate the memory.
395 if (free_flag) free(title_chunks);
399 /******************************************************************************
401 * Semi-Public Functions
403 *****************************************************************************/
404 /*****************************************************************************
405 * Function: int _DtHelpFormatAsciiFile (char *filename,
406 * CEParagraph **ret_para, int *ret_num)
409 * filename Specifies the ascii file to read.
410 * ret_para Returns a pointer to a list of CEParagraph
412 * ret_num Returns the number of structures in 'ret_para'.
414 * Returns: 0 if successful, -1 if errors
419 * Purpose: _DtHelpFormatAsciiFile formats Ascii Files into a list of
420 * CEParagraph structures.
422 *****************************************************************************/
424 _DtHelpFormatAsciiFile(
425 XtPointer client_data,
427 XtPointer *ret_handle)
431 _DtHelpFontHints fontAttrs;
432 char buffer [BUFF_SIZE];
435 _DtCvTopicPtr topic = NULL;
436 DtHelpDispAreaStruct *pDAS = (DtHelpDispAreaStruct *) client_data;
437 _FrmtUiInfo myUiInfo = defUiInfo;
440 * check the parameters
442 if (filename == NULL || ret_handle == NULL)
449 * Initialize the pointers, buffers and counters
456 myFile = open (filename, O_RDONLY);
460 * set the information
462 rawInput = _DtHelpCeBufFileRdWithFd(myFile);
469 result = _DtHelpCeReadBuf (rawInput, buffer, BUFF_SIZE);
473 _DtHelpCeCopyDefFontAttrList (&fontAttrs);
474 fontAttrs.spacing = _DtHelpFontSpacingMono;
475 _DtHelpCeXlateOpToStdLocale(DtLCX_OPER_SETLOCALE,
476 setlocale(LC_CTYPE,NULL), NULL,
477 &(fontAttrs.language), &(fontAttrs.char_set));
480 * fill out the ui information
482 myUiInfo.load_font = _DtHelpDAResolveFont;
483 myUiInfo.client_data = (_DtCvPointer) pDAS;
484 myUiInfo.line_width = pDAS->lineThickness;
485 myUiInfo.line_height = pDAS->lineHeight;
486 myUiInfo.leading = pDAS->leading;
487 myUiInfo.avg_char = (int)(pDAS->charWidth / 10 +
488 ((pDAS->charWidth % 10) ? 1 : 0));
489 myUiInfo.nl_to_space = pDAS->nl_to_space;
492 * get the formatting structure.
494 varHandle = __DtHelpCeSetUpVars(fontAttrs.language,
495 fontAttrs.char_set, &myUiInfo);
496 if (varHandle == NULL)
498 free(fontAttrs.language);
499 free(fontAttrs.char_set);
503 result = __DtHelpCeProcessString (varHandle, rawInput,
505 ScanString, buffer, BUFF_SIZE,
506 0, False, &fontAttrs);
509 result = __DtHelpCeGetParagraphList (varHandle, True,
513 free(fontAttrs.language);
514 free(fontAttrs.char_set);
518 _DtHelpCeBufFileClose(rawInput, True);
521 *ret_handle = (XtPointer) topic;
524 } /* End _DtHelpFormatAsciiFile */
526 /*****************************************************************************
527 * Function: int _DtHelpFormatAsciiString (char *input_string,
528 * CEParagraph **ret_para, int *ret_num)
531 * input_string Specifies the ascii string to format.
532 * ret_para Returns a pointer to a list of CEParagraph
534 * ret_num Returns the number of structures in 'ret_para'.
536 * Returns: 0 if successful, -1 if errors
540 * Purpose: _DtHelpFormatAsciiString formats a string as if it were a
541 * static string - watching for newlines and using them
542 * to force a break in the line.
544 *****************************************************************************/
546 _DtHelpFormatAsciiString(
547 XtPointer client_data,
549 XtPointer *ret_handle)
552 _DtHelpFontHints fontAttrs;
554 _DtCvTopicPtr topic = NULL;
555 DtHelpDispAreaStruct *pDAS = (DtHelpDispAreaStruct *) client_data;
556 _FrmtUiInfo myUiInfo = defUiInfo;
559 * check the parameters.
561 if (input_string == NULL || ret_handle == NULL)
568 * fill out the ui information
570 myUiInfo.load_font = _DtHelpDAResolveFont;
571 myUiInfo.client_data = (_DtCvPointer) pDAS;
572 myUiInfo.line_width = pDAS->lineThickness;
573 myUiInfo.line_height = pDAS->lineHeight;
574 myUiInfo.leading = pDAS->leading;
575 myUiInfo.avg_char = (int)(pDAS->charWidth / 10 +
576 ((pDAS->charWidth % 10) ? 1 : 0));
577 myUiInfo.nl_to_space = pDAS->nl_to_space;
580 * Get the initialized variables
584 _DtHelpCeCopyDefFontAttrList (&fontAttrs);
585 _DtHelpCeXlateOpToStdLocale(DtLCX_OPER_SETLOCALE,setlocale(LC_CTYPE,NULL),
586 NULL, &(fontAttrs.language),
587 &(fontAttrs.char_set));
589 varHandle = __DtHelpCeSetUpVars(fontAttrs.language, fontAttrs.char_set,
591 if (varHandle == NULL)
593 free(fontAttrs.language);
594 free(fontAttrs.char_set);
598 result = __DtHelpCeProcessString (varHandle, NULL,
600 ScanString, input_string,
601 strlen(input_string),
606 result = __DtHelpCeGetParagraphList (varHandle, True, _DtCvLITERAL,
609 *ret_handle = (XtPointer) topic;
611 free(fontAttrs.language);
612 free(fontAttrs.char_set);
617 } /* End _DtHelpFormatAsciiString */
619 /*****************************************************************************
620 * Function: int _DtHelpFormatAsciiStringDynamic (char *input_string,
621 * CEParagraph **ret_para, int *ret_num)
624 * input_string Specifies the ascii string to format.
625 * ret_para Returns a pointer to a list of CEParagraph
627 * ret_num Returns the number of structures in 'ret_para'.
629 * Returns: 0 if successful, -1 if errors
633 * Purpose: _DtHelpFormatAsciiStringDynamic formats a string as if it were
634 * a dynamic string - it uses newline characters to terminate
635 * the current paragraph, not a line.
637 *****************************************************************************/
639 _DtHelpFormatAsciiStringDynamic(
640 XtPointer client_data,
642 XtPointer *ret_handle)
645 _DtHelpFontHints fontAttrs;
647 _DtCvTopicPtr topic = NULL;
648 DtHelpDispAreaStruct *pDAS = (DtHelpDispAreaStruct *) client_data;
649 _FrmtUiInfo myUiInfo = defUiInfo;
652 * check the parameters.
654 if (input_string == NULL || ret_handle == NULL)
661 * fill out the ui information
663 myUiInfo.load_font = _DtHelpDAResolveFont;
664 myUiInfo.client_data = (_DtCvPointer) pDAS;
665 myUiInfo.line_width = pDAS->lineThickness;
666 myUiInfo.line_height = pDAS->lineHeight;
667 myUiInfo.leading = pDAS->leading;
668 myUiInfo.avg_char = (int)(pDAS->charWidth / 10 +
669 ((pDAS->charWidth % 10) ? 1 : 0));
670 myUiInfo.nl_to_space = pDAS->nl_to_space;
673 * Fake the flag and give the string as the input buffer.
677 _DtHelpCeCopyDefFontAttrList (&fontAttrs);
678 _DtHelpCeXlateOpToStdLocale(DtLCX_OPER_SETLOCALE,setlocale(LC_CTYPE,NULL),
679 NULL, &(fontAttrs.language),
680 &(fontAttrs.char_set));
682 varHandle = __DtHelpCeSetUpVars(fontAttrs.language, fontAttrs.char_set,
684 if (varHandle == NULL)
686 free(fontAttrs.language);
687 free(fontAttrs.char_set);
691 result = __DtHelpCeProcessString (varHandle, NULL,
693 ScanString, input_string,
694 strlen(input_string),
699 result = __DtHelpCeGetParagraphList (varHandle, False, _DtCvDYNAMIC,
701 *ret_handle = (XtPointer) topic;
703 free(fontAttrs.language);
704 free(fontAttrs.char_set);
709 } /* End _DtHelpFormatAsciiStringDynamic */
711 /******************************************************************************
712 * Function: int _DtHelpFormatTopicTitle (Display *dpy, _XvhVolume volume,
713 * char *filename, int offset,
714 * XmString *ret_title, XmFontList *ret_list,
718 * dpy Specifies the connection to the server.
719 * volume Specifies the Help Volume the information
720 * is associated with.
721 * filename Specifies the file containing the Help Topic
723 * offset Specifies the offset into 'filename' to
724 * the Help Topic desired.
725 * ret_title Returns XmString containing the title.
726 * ret_list Specifies the current font list being used.
727 * Returns a new font list if new character
728 * sets are added to it.
729 * ret_mod Returns True if fonts were added to the
732 * Returns: 0 if successful, -1 if errors
736 * Purpose: _DtHelpFormatTopicTitle formats a topic title and associates
737 * the correct font with it.
739 ******************************************************************************/
741 _DtHelpFormatTopicTitle(
742 XtPointer client_data,
743 _DtHelpVolumeHdl volume_handle,
746 XmFontList *ret_list,
750 void **titleChunks = NULL;
751 _FrmtUiInfo myUiInfo = defUiInfo;
752 _DtHelpCeLockInfo lockInfo;
753 DtHelpDispAreaStruct *pDAS = (DtHelpDispAreaStruct *) client_data;
756 * Check the parameters
758 if (ret_title == NULL || ret_list == NULL || ret_mod == NULL)
767 if (_DtHelpCeLockVolume(volume_handle, &lockInfo) != 0)
771 * set up my UI information
773 myUiInfo.load_graphic = _DtHelpDALoadGraphic;
774 myUiInfo.resolve_spc = _DtHelpDAResolveSpc;
775 myUiInfo.load_font = _DtHelpDAResolveFont;
776 myUiInfo.exec_filter = pDAS->exec_filter;
777 myUiInfo.destroy_region = _DtHelpDADestroyRegion;
778 myUiInfo.client_data = (_DtCvPointer) pDAS;
779 /* since we're going for chunks, set avg_char width to 1 */
780 myUiInfo.line_width = 0;
781 myUiInfo.line_height = 0;
782 myUiInfo.leading = 0;
783 myUiInfo.avg_char = 1;
784 myUiInfo.nl_to_space = pDAS->nl_to_space;
787 * Get the title and charsets associated with the title segments.
788 * The format of the returned information is
789 * [type,charset/fontptr,]type,string/spc
791 result = _DtHelpCeGetVolumeFlag(volume_handle);
792 _DtHelpProcessLock();
794 result = _DtHelpCeGetSdlTitleChunks(volume_handle, location_id,
795 &myUiInfo, &titleChunks);
796 else if (result == 0)
797 result = _DtHelpCeGetCcdfTitleChunks( volume_handle, location_id,
798 &myUiInfo, &titleChunks);
799 _DtHelpProcessUnlock();
801 result = FormatChunksToXmString(pDAS, True, titleChunks,
802 ret_title, ret_list, ret_mod);
803 _DtHelpCeUnlockVolume(lockInfo);
806 } /* End _DtHelpFormatTopicTitle */
808 /******************************************************************************
809 * Function: int _DtHelpFormatVolumeTitle (DtHelpDispAreaStruct *pDAS,
811 * XmString *ret_title, XmFontList *ret_list,
815 * volume Specifies the Help Volume the information
816 * is associated with.
817 * ret_title Returns XmString containing the title.
818 * ret_list Specifies the current font list being used.
819 * Returns a new font list if new character
820 * sets are added to it.
821 * ret_mod Returns True if fonts were added to the
824 * Returns: 0 if successful, -1 if errors
828 * Purpose: _DtHelpFormatVolumeTitle formats a volume title and associates
829 * the correct font with it.
831 ******************************************************************************/
833 _DtHelpFormatVolumeTitle(
834 XtPointer client_data,
835 _DtHelpVolumeHdl volume_handle,
837 XmFontList *ret_list,
841 void **titleChunks = NULL;
842 _FrmtUiInfo myUiInfo = defUiInfo;
843 _DtHelpCeLockInfo lockInfo;
844 DtHelpDispAreaStruct *pDAS = (DtHelpDispAreaStruct *) client_data;
847 * Check the parameters
849 if (ret_title == NULL || ret_list == NULL || ret_mod == NULL)
859 if (_DtHelpCeLockVolume(volume_handle, &lockInfo) != 0)
863 * set up my UI information
865 myUiInfo.load_graphic = _DtHelpDALoadGraphic;
866 myUiInfo.resolve_spc = _DtHelpDAResolveSpc;
867 myUiInfo.load_font = _DtHelpDAResolveFont;
868 myUiInfo.exec_filter = pDAS->exec_filter;
869 myUiInfo.destroy_region = _DtHelpDADestroyRegion;
870 myUiInfo.client_data = (_DtCvPointer) pDAS;
871 /* since we're going for chunks, set avg_char width to 1 */
872 myUiInfo.line_width = 0;
873 myUiInfo.line_height = 0;
874 myUiInfo.leading = 0;
875 myUiInfo.avg_char = 1;
876 myUiInfo.nl_to_space = pDAS->nl_to_space;
879 * Get the title and charsets associated with the volume title.
880 * The format of the returned information is
881 * [type,charset/fontptr,]type,string/spc
883 result = _DtHelpCeGetVolumeFlag(volume_handle);
884 _DtHelpProcessLock();
886 result = _DtHelpCeGetSdlVolTitleChunks(volume_handle, &myUiInfo,
888 else if (result == 0)
889 result = _DtHelpCeGetCcdfVolTitleChunks(
890 (_DtHelpVolume) volume_handle,
893 _DtHelpProcessUnlock();
895 result = FormatChunksToXmString(pDAS, True, titleChunks,
896 ret_title, ret_list, ret_mod);
897 _DtHelpCeUnlockVolume(lockInfo);
900 } /* End _DtHelpFormatVolumeTitle */
902 /******************************************************************************
903 * Function: int _DtHelpFormatIndexEntries (DtHelpDispAreaStruct *pDAS,
905 * XmString *ret_title, XmFontList *ret_list,
909 * volume Specifies the Help Volume the information
910 * is associated with.
911 * ret_cnt number of valid entries in the array
912 * ret_words Returns NULL-termintaed array of
913 * XmStrings containing the words.
914 * ret_list Specifies the current font list being used.
915 * Returns a new font list if new character
916 * sets are added to it.
917 * ret_mod Returns True if fonts were added to the
920 * Returns: 0 if successful, -1 if errors
924 * Purpose: _DtHelpFormatIndexEntries formats index entries and associates
925 * the correct font with it.
927 ******************************************************************************/
929 _DtHelpFormatIndexEntries(
930 XtPointer client_data,
931 _DtHelpVolumeHdl volume_handle,
933 XmString **ret_words,
934 XmFontList *ret_list,
939 void *titleChunks[4];
942 Boolean myMod = False;
944 DtHelpDispAreaStruct *pDAS = (DtHelpDispAreaStruct *) client_data;
947 * Check the parameters
949 if (ret_words == NULL || ret_list == NULL || ret_mod == NULL)
957 charSet = _DtHelpGetVolumeLocale(volume_handle);
960 *ret_cnt = _DtHelpCeGetKeywordList(volume_handle, &keyWords);
964 *ret_words = (XmString *) malloc (sizeof(XmString) * (*ret_cnt+1));
965 if (*ret_words == NULL)
968 /* the order of the string ptr and charset ptr in the titleChunks
969 is determined by the order of the if(..) tests on the
970 flags and subsequent processing in FormatChunksToXmString() */
971 titleChunks[0] = (void *) (DT_HELP_CE_STRING | DT_HELP_CE_CHARSET);
972 titleChunks[1] = (void *) charSet;
973 titleChunks[3] = (void *) DT_HELP_CE_END;
974 for (i = 0, result = 0; result == 0 && i < *ret_cnt; i++)
977 titleChunks[2] = (void *) keyWords[i];
978 result = FormatChunksToXmString(pDAS, False, titleChunks,
979 &(*ret_words)[i], ret_list, &myMod);
983 * if the list has been modified before,
984 * free the previously modified list.
986 if (True == *ret_mod)
987 XmFontListFree(oldList);
992 (*ret_words)[i] = NULL;
999 } /* End _DtHelpFormatIndexEntries */
1001 /******************************************************************************
1002 * Function: int _DtHelpFormatTopic (
1003 * DtHelpDispAreaStruct *pDAS,
1004 * _DtHelpVolumeHdl volume,
1006 * Boolean look_at_id,
1007 * XtPointer *ret_handle)
1010 * pDAS Specifies the display area to use.
1011 * volume Specifies the Help Volume the information
1012 * is associated with.
1013 * id_string Specifies the location id for the topic.
1014 * This location id can be contained in a
1016 * look_at_id Specifies whether or not to start the
1017 * display of the topic at the location id.
1018 * ret_handle Returns a handle to the topic information
1019 * including the number of paragraphs and the
1022 * Returns: 0 if successful.
1024 * -2 if the id was not found.
1025 * -3 if unable to format the topic.
1029 * Purpose: _DtHelpParseTopic accesses and parses Help topics.
1031 ******************************************************************************/
1034 XtPointer client_data,
1035 _DtHelpVolumeHdl volume,
1038 XtPointer *ret_handle )
1040 char *filename = NULL;
1043 _DtHelpCeLockInfo lockInfo;
1044 _FrmtUiInfo myUiInfo = defUiInfo;
1045 DtHelpDispAreaStruct *pDAS = (DtHelpDispAreaStruct *) client_data;
1046 _DtCvTopicInfo *topic;
1048 if (_DtHelpCeLockVolume(volume, &lockInfo) != 0)
1051 if (_DtHelpCeFindId(volume,id_string,lockInfo.fd,&filename,&offset)==True)
1053 if (look_at_id == False)
1056 myUiInfo.load_graphic = _DtHelpDALoadGraphic;
1057 myUiInfo.resolve_spc = _DtHelpDAResolveSpc;
1058 myUiInfo.load_font = _DtHelpDAResolveFont;
1059 myUiInfo.exec_filter = pDAS->exec_filter;
1060 myUiInfo.destroy_region = _DtHelpDADestroyRegion;
1061 myUiInfo.client_data = (_DtCvPointer) pDAS;
1062 myUiInfo.line_width = pDAS->lineThickness;
1063 myUiInfo.line_height = pDAS->lineHeight;
1064 myUiInfo.leading = pDAS->leading;
1065 myUiInfo.avg_char = (int)(pDAS->charWidth / 10 +
1066 ((pDAS->charWidth % 10) ? 1 : 0));
1067 myUiInfo.nl_to_space = pDAS->nl_to_space;
1069 result = _DtHelpCeGetVolumeFlag(volume);
1070 _DtHelpProcessLock();
1072 result = _DtHelpCeParseSdlTopic(volume,
1074 lockInfo.fd, offset,
1075 id_string, True, &topic);
1076 else if (result == 0)
1077 result = _DtHelpCeFrmtCcdfTopic((_DtHelpVolume) volume,
1081 _DtHelpProcessUnlock();
1082 *ret_handle = (XtPointer) topic;
1086 if (filename != NULL)
1090 _DtHelpCeUnlockVolume(lockInfo);
1094 } /* End _DtHelpFormatTopic */
1097 /******************************************************************************
1098 * Function: int _DtHelpGetAsciiVolumeTitle (
1100 * Parameters: vol Specifies the loaded volume.
1101 * retTitle Returns the title of the volume. This string is
1102 * owned by the caller and must be freed.
1104 * Return Value: 0 if successful, -1 if a failure occurs
1106 * errno Values: CEErrorMalloc
1107 * EINVAL 'vol' or 'retTitle' is NULL.
1108 * CEErrorMissingTitleRes
1109 * 'vol' does not contain the resource
1110 * 'Title' or 'title' or the resource
1113 * Purpose: Get the title of a volume.
1115 ******************************************************************************/
1117 _DtHelpGetAsciiVolumeTitle (
1118 XtPointer client_data,
1119 _DtHelpVolumeHdl volume,
1123 _FrmtUiInfo myUiInfo = defUiInfo;
1124 DtHelpDispAreaStruct *pDAS = (DtHelpDispAreaStruct *) client_data;
1127 * What type of volume is it?
1129 result = _DtHelpCeGetVolumeFlag(volume);
1133 * set up my UI information
1135 myUiInfo.load_graphic = _DtHelpDALoadGraphic;
1136 myUiInfo.resolve_spc = _DtHelpDAResolveSpc;
1137 myUiInfo.load_font = _DtHelpDAResolveFont;
1138 myUiInfo.exec_filter = pDAS->exec_filter;
1139 myUiInfo.destroy_region = _DtHelpDADestroyRegion;
1140 myUiInfo.client_data = (_DtCvPointer) pDAS;
1141 /* since we're going for a string, set avg_char width to 1 */
1142 myUiInfo.line_width = 0;
1143 myUiInfo.line_height = 0;
1144 myUiInfo.leading = 0;
1145 myUiInfo.avg_char = 1;
1146 myUiInfo.nl_to_space = pDAS->nl_to_space;
1148 _DtHelpProcessLock();
1149 result = _DtHelpCeFrmtSDLVolTitleToAscii(volume, &myUiInfo, ret_title);
1151 else if (0 == result)
1153 _DtHelpProcessLock();
1154 result = _DtHelpCeGetCcdfVolumeTitle(volume, ret_title);
1156 _DtHelpProcessUnlock();
1160 /*****************************************************************************
1161 * Function: int _DtHelpFormatToc (
1162 * _DtHelpVolumeHdl volume, id);
1165 * canvas Specifies the handle for the canvas.
1167 * Returns: -1 if errors.
1173 *****************************************************************************/
1176 DtHelpDispAreaStruct *pDAS,
1177 _DtHelpVolumeHdl volume,
1180 XtPointer *ret_handle)
1183 _DtCvTopicPtr topic;
1184 _DtHelpCeLockInfo lockInfo;
1186 if (volume == NULL || id == NULL)
1190 * This becomes my volume; want to ensure that it doesn't
1191 * get closed out from under me, so tell the system that
1194 if (_DtHelpCeLockVolume(volume, &lockInfo) != 0)
1197 result = _DtHelpCeMapTargetToId(volume, id, ret_id);
1201 _FrmtUiInfo myUiInfo = defUiInfo;
1203 myUiInfo.client_data = (XtPointer) pDAS;
1204 myUiInfo.load_graphic = _DtHelpDALoadGraphic;
1205 myUiInfo.resolve_spc = _DtHelpDAResolveSpc;
1206 myUiInfo.load_font = _DtHelpDAResolveFont;
1207 myUiInfo.exec_filter = pDAS->exec_filter;
1208 myUiInfo.destroy_region = _DtHelpDADestroyRegion;
1209 myUiInfo.client_data = (_DtCvPointer) pDAS;
1210 myUiInfo.line_width = pDAS->lineThickness;
1211 myUiInfo.line_height = pDAS->lineHeight;
1212 myUiInfo.leading = pDAS->leading;
1213 myUiInfo.avg_char = (int)(pDAS->charWidth / 10 +
1214 ((pDAS->charWidth % 10) ? 1 : 0));
1215 myUiInfo.nl_to_space = pDAS->nl_to_space;
1217 result = _DtHelpCeGetVolumeFlag(volume);
1218 _DtHelpProcessLock();
1220 result = _DtHelpCeFrmtSdlPathAndChildren(volume,
1224 else if (result == 0)
1225 result = _DtHelpCeFrmtCcdfPathAndChildren(volume,
1228 _DtHelpProcessUnlock();
1229 *ret_handle = (XtPointer) topic;
1232 * didn't successfully format a path, so close my copy
1236 _DtHelpCloseVolume (volume);
1238 _DtHelpCeUnlockVolume(lockInfo);
1241 } /* End _DtHelpFormatToc */