1 /* $XConsortium: CCDFUtil.c /main/7 1996/11/01 10:10:08 drk $ */
2 /************************************<+>*************************************
3 ****************************************************************************
7 ** Project: Un*x Desktop Help
10 ** Description: Semi private format utility functions for
14 ** (c) Copyright 1987, 1988, 1989, 1990, 1991, 1992 Hewlett-Packard Company
16 ** (c) Copyright 1993, 1994 Hewlett-Packard Company
17 ** (c) Copyright 1993, 1994 International Business Machines Corp.
18 ** (c) Copyright 1993, 1994 Sun Microsystems, Inc.
19 ** (c) Copyright 1993, 1994 Novell, Inc.
22 ****************************************************************************
23 ************************************<+>*************************************/
41 * Canvas Engine includes
49 #include "CanvasError.h"
50 #include "CCDFUtilI.h"
51 #include "FontAttrI.h"
52 #include "CvStringI.h"
57 /******** Private Function Declarations ********/
58 static int GetCmdData(
69 /******** End Private Function Declarations ********/
71 /******************************************************************************
73 * Private variables and defines.
75 *****************************************************************************/
77 #define REALLOC_INCR 10
78 #define CMD_NOT_ALLOWED -1000
86 static const FormatCmds CcdfFormatCmds[] =
88 { "abbrev" , CCDF_ABBREV_CMD , 2 },
89 { "angle" , CCDF_FONT_CMD , 2 },
90 { "characterset", CCDF_FONT_CMD , 1 },
91 { "figure" , CCDF_FIGURE_CMD , 1 },
92 { "graphic" , CCDF_GRAPHIC_CMD , 1 },
93 { "id" , CCDF_ID_CMD , 1 },
94 { "label" , CCDF_LABEL_CMD , 2 },
95 { "link" , CCDF_LINK_CMD , 2 },
96 { "newline" , CCDF_NEWLINE_CMD , 1 },
97 { "paragraph" , CCDF_PARAGRAPH_CMD, 1 },
98 { "size" , CCDF_FONT_CMD , 2 },
99 { "spacing" , CCDF_FONT_CMD , 2 },
100 { "title" , CCDF_TITLE_CMD , 2 },
101 { "topic" , CCDF_TOPIC_CMD , 2 },
102 { "type" , CCDF_FONT_CMD , 2 },
103 { "weight" , CCDF_FONT_CMD , 1 },
104 { "0x" , CCDF_OCTAL_CMD , 2 },
105 /* always leave this one as the last entry */
106 { "/" , CCDF_FORMAT_END , 1 }
109 /******************************************************************************
111 * Semi Public variables.
113 *****************************************************************************/
114 /******************************************************************************
118 *****************************************************************************/
119 /******************************************************************************
120 * Function: static int GetCmdData (FILE *in_file, char *in_buf, int in_size,
121 * char **in_ptr, int allowed, int strip,
122 * int *ret_size, int *ret_max, char **ret_string)
125 * in_file Specifies a stream to read from.
126 * in_buf Specifies the buffer where new information
128 * in_size Specifies the maximum size of 'in_buf'.
129 * in_ptr Specifies the pointer into 'in_buf' to
131 * Returns the new location in 'in_buf' to
132 * continue processing.
133 * allowed Specifies the formatting commands allowed
135 * strip Specifies the formatting commands to strip.
137 * ret_size Specifies the current size of
139 * Returns the new size of 'ret_string'.
140 * ret_max Specifies the current maximum size of
142 * Returns the new size of 'ret_string'.
143 * ret_string Returns the data found.
146 * Returns: 0 if successful, -1 if errors.
149 * read (2) Errors set via a read call.
156 * Purpose: Gets a string containing font change tags
158 * "data with font change tags </>"
160 *****************************************************************************/
178 char *myBufPtr = *in_ptr;
180 int skipString = False;
190 charSize = mblen(myBufPtr, cur_mb_len);
195 * Do we need to read more information?
197 if (((int) strlen (myBufPtr)) < 3 &&
198 _DtHelpCeGetNxtBuf(in_file,in_buf,&myBufPtr,in_size) == -1)
205 * Go to the next character.
214 if (*myBufPtr == '/')
217 return _DtHelpCeGetCcdfEndMark (in_file, in_buf,
218 in_ptr, in_size,cur_mb_len);
221 fontType = _DtHelpCeGetCcdfFontType (myBufPtr);
224 switch (_DtCvToLower (*myBufPtr))
231 _DtHelpCeAddOctalToBuf (
233 ret_string, ret_size,
236 _DtHelpCeGetCcdfEndMark (in_file, in_buf,
237 &myBufPtr,in_size,cur_mb_len) == -1)
248 if (_DtCvToLower (*myBufPtr) == 'b')
250 if (CCDF_NOT_ALLOW_CMD (allowed,
253 errno = CMD_NOT_ALLOWED;
256 else if (CCDF_NOT_ALLOW_CMD (strip,
262 errno = CEErrorFormattingCmd;
273 if (CCDF_NOT_ALLOW_CMD (allowed,
276 errno = CMD_NOT_ALLOWED;
279 else if (CCDF_NOT_ALLOW_CMD (strip,
289 if (CCDF_NOT_ALLOW_CMD (allowed,
292 errno = CMD_NOT_ALLOWED;
296 if (_DtHelpCeGetCcdfEndMark (in_file, in_buf,
297 &myBufPtr,in_size,cur_mb_len) == -1)
307 if (CCDF_NOT_ALLOW_CMD (allowed,
310 errno = CMD_NOT_ALLOWED;
313 else if (CCDF_NOT_ALLOW_CMD (strip,
324 if (_DtCvToLower (*myBufPtr) == 'a')
326 if (CCDF_NOT_ALLOW_CMD (allowed,
329 errno = CMD_NOT_ALLOWED;
332 else if (CCDF_NOT_ALLOW_CMD (strip,
336 else if (_DtCvToLower (*myBufPtr) == 'i')
338 if (CCDF_NOT_ALLOW_CMD (allowed,
341 errno = CMD_NOT_ALLOWED;
344 else if (CCDF_NOT_ALLOW_CMD (strip,
350 errno = CEErrorFormattingCmd;
360 if (CCDF_NOT_ALLOW_CMD (allowed,
363 errno = CMD_NOT_ALLOWED;
367 if (_DtHelpCeGetCcdfEndMark (in_file, in_buf,
368 &myBufPtr,in_size,cur_mb_len) == -1)
378 if (CCDF_NOT_ALLOW_CMD (allowed,
381 errno = CMD_NOT_ALLOWED;
384 else if (CCDF_NOT_ALLOW_CMD (strip,
395 if (_DtCvToLower (*myBufPtr) == 'o')
397 if (CCDF_NOT_ALLOW_CMD (allowed,
400 errno = CMD_NOT_ALLOWED;
403 else if (CCDF_NOT_ALLOW_CMD (strip,
407 else if (_DtCvToLower (*myBufPtr) == 'i')
409 if (CCDF_NOT_ALLOW_CMD (allowed,
412 errno = CMD_NOT_ALLOWED;
415 else if (CCDF_NOT_ALLOW_CMD (strip,
421 errno = CEErrorFormattingCmd;
428 errno = CEErrorFormattingCmd;
432 else if (CCDF_NOT_ALLOW_CMD (allowed, CCDF_FONT_CMD))
434 errno = CMD_NOT_ALLOWED;
437 else if (CCDF_NOT_ALLOW_CMD (strip, CCDF_FONT_CMD))
443 * This is a <token>....</token> construct.
444 * pass over the <token> part.
446 if (_DtHelpCeGetCcdfEndMark (in_file, in_buf,
447 &myBufPtr, in_size,cur_mb_len) == -1 ||
448 GetCmdData (in_file, in_buf, in_size,
449 &myBufPtr, cur_mb_len, allowed, strip,
450 ret_size, ret_max, ret_string) == -1)
458 * Put a space in the segment
463 result = _DtHelpCeAddCharToBuf (&tmpPtr,
464 ret_string, ret_size, ret_max, MIN_GROW);
473 * Save the escaped character
476 result = _DtHelpCeAddCharToBuf (&myBufPtr,
477 ret_string, ret_size, ret_max, MIN_GROW);
484 * Put the information in the buffer
486 result = _DtHelpCeStrcspn (myBufPtr, "<\\\n ",
489 * If _DtHelpCeStrcspn found an invalid character
490 * we don't want to quit yet. Allow another pass
491 * to try to read another buffer of information.
495 if (!skipString && size)
496 result = _DtHelpCeAddStrToBuf (&myBufPtr,
497 ret_string, ret_size, ret_max, size, 0);
502 else if (charSize > 1)
504 result = _DtHelpCeStrcspn (myBufPtr, "<\\\n ", cur_mb_len, &size);
507 * If _DtHelpCeStrcspn found an invalid character
508 * we don't want to quit yet. Allow another pass
509 * to try to read another buffer of information.
513 if (!skipString && size)
514 result = _DtHelpCeAddStrToBuf (&myBufPtr,
515 ret_string, ret_size, ret_max, size, 0);
519 else /* if (charSize < 1) */
521 if (*myBufPtr == '\0' || ((int) strlen (in_buf)) < cur_mb_len)
522 result = _DtHelpCeGetNxtBuf(in_file,in_buf,&myBufPtr,in_size);
525 errno = CEErrorIllegalInfo;
533 /******************************************************************************
534 * Function: int GetTitleCmd (FILE *in_file, char in_buf, int in_size,
535 * char **in_ptr, char **ret_string)
538 * in_file Specifies a stream to read from.
539 * in_buf Specifies the buffer where new information
541 * in_size Specifies the maximum size of 'in_buf'.
542 * in_ptr Specifies the pointer into 'in_buf' to
544 * Returns the new location in 'in_buf' to
545 * continue processing.
546 * ret_string Returns the data found.
548 * Returns: 0 if successful, -1 if errors
551 * read (2) Errors set via a read call.
556 * Purpose: Determine if the next formatting command is
558 * Returns the data found between <ABBREV> and its ending </>.
560 * Note: The only formatting command allowed between <ABBREV> and
561 * its </> is the <NEWLINE> command. And it is stripped.
563 *****************************************************************************/
578 * null the return string
584 * check for the token
586 result = _DtHelpCeCheckNextCcdfCmd ("ti", in_file, in_buf, in_size, cur_mb_len, in_ptr);
590 errno = CEErrorMissingTitleCmd;
594 if (_DtHelpCeGetCcdfEndMark(in_file,in_buf,in_ptr,in_size,cur_mb_len) != 0)
597 result = GetCmdData (in_file, in_buf, in_size, in_ptr, cur_mb_len,
598 (CCDF_NEWLINE_CMD | CCDF_GRAPHIC_CMD |
599 CCDF_LINK_CMD | CCDF_FONT_CMD | CCDF_ID_CMD),
600 (CCDF_NEWLINE_CMD | CCDF_GRAPHIC_CMD |
601 CCDF_LINK_CMD | CCDF_FONT_CMD | CCDF_ID_CMD),
602 &junkSize, &junkMax, ret_string);
604 if (result == -1 && errno == CMD_NOT_ALLOWED)
605 errno = CEErrorTitleSyntax;
610 /******************************************************************************
612 * Semi Public Functions
614 *****************************************************************************/
615 /******************************************************************************
616 * Function: int _DtHelpCeGetCcdfEndMark (FILE *file, char *buffer,
617 * char **buf_ptr, int buf_size, int flag)
620 * file Specifies a stream to read from.
621 * buffer Specifies the buffer where new information
623 * buf_ptr Specifies the pointer into 'buffer' to
625 * Returns the new location in 'buffer' to
626 * continue processing.
627 * buf_size Specifies the maximum size of 'buffer'.
630 * Return Value: 0 if successful, -1 if a failure occurs
633 * read (2) Errors set via a read call.
638 * Purpose: Find the end of tag marker '>'.
640 ******************************************************************************/
642 _DtHelpCeGetCcdfEndMark (
658 * Find the end of marker or end of topic
660 result = _DtHelpCeStrcspn (ptr, "\\>", cur_mb_len, &len);
666 * found either a backslash or the end marker,
667 * update the pointer and if it was the '>'
676 else /* result == -1 || result == 1 */
679 * nothing here - get the next buffer and keep looking
680 * unless getting the next buffer has problems/eof
682 if (((int) strlen(ptr)) >= cur_mb_len)
684 errno = CEErrorIllegalInfo;
688 if (_DtHelpCeGetNxtBuf (file, buffer, &ptr, buf_size) == -1)
697 /******************************************************************************
698 * Function: int _DtHelpCeGetCcdfStrParam (FILE *in_file, char *in_buf,
699 * int in_size, char **in_ptr, int flag,
700 * int eat_escape, Boolean ignore_quotes,
701 * int less_test, char **ret_string)
704 * in_file Specifies a stream to read from.
705 * in_buf Specifies the buffer where new information
707 * in_size Specifies the maximum size of 'in_buf'.
708 * in_ptr Specifies the pointer into 'in_buf' to
710 * Returns the new location in 'in_buf' to
711 * continue processing.
712 * flag Specifies whether the routine returns
713 * a -1 if '>' is the next token.
714 * eat_secape Specifies whether the backslash is not
715 * placed in the returned string.
716 * True - it is skipped.
717 * False - it is saved in 'ret_string'.
718 * ignore_quotes Specifies whether quotes are to be included
719 * in the returned string.
720 * less_test Specifies whether the routine should
721 * stop when it finds a '<' character.
722 * ret_string If NULL, throws the information away.
723 * Otherwise, returns the string found.
725 * Returns: 0 if successful, -1 if errors, 1 if 'flag' is false and
726 * the next token is '>'.
729 * read (2) Errors set via a read call.
735 * Purpose: Skip the rest of the current token.
736 * Get the next token. A token is defined as being one or
737 * more strings between single or double quotes,
738 * or a string bounded by spaces or ended by the
741 *****************************************************************************/
743 _DtHelpCeGetCcdfStrParam(
750 _DtCvValue eat_escape,
751 _DtCvValue ignore_quotes,
752 _DtCvValue less_test,
760 char *stringPtr = NULL;
764 int singleQuotes = False;
765 int doubleQuotes = False;
766 int skipString = False;
773 * do we want to skip the string or read it.
779 * skip to the next parameter or > character. If flag is true,
780 * we want another parameter, so error if the > character is found.
782 if (_DtHelpCeSkipToNextCcdfToken (in_file, in_buf, in_size, cur_mb_len, in_ptr, flag) != 0)
788 * see if there is another parameter
790 if (_DtCvFALSE == flag && *myBufPtr == '>')
794 * Initialize the global buffer.
796 if (_DtCvFALSE == ignore_quotes &&
797 (!testMB || mblen (myBufPtr, cur_mb_len) == 1))
799 if (*myBufPtr == '\"')
804 else if (*myBufPtr == '\'')
813 spnResult = _DtHelpCeStrcspn (myBufPtr, " <>\'\"\\\n",
814 cur_mb_len, ©Size);
816 * Either skip the string or place it in storage
819 myBufPtr += copySize;
820 else if (_DtHelpCeAddStrToBuf (&myBufPtr, &stringPtr, &stringSize,
821 &stringMax, copySize, 0) == -1)
825 * If spnResult is non-zero, read the next buffer of information
829 if (spnResult == -1 && ((int)strlen(myBufPtr)) >= cur_mb_len)
831 errno = CEErrorIllegalInfo;
835 if (_DtHelpCeGetNxtBuf(in_file,in_buf,&myBufPtr,in_size) == -1)
840 * Otherwise _DtHelpCeStrcspn stopped at a character we want
847 if (_DtCvTRUE == eat_escape || skipString)
849 else if (_DtHelpCeAddCharToBuf (&myBufPtr, &stringPtr,
850 &stringSize, &stringMax, MIN_GROW) == -1)
853 if (*myBufPtr == '\0' && _DtHelpCeGetNxtBuf(in_file,
854 in_buf,&myBufPtr,in_size) == -1)
859 else if (_DtHelpCeAddCharToBuf (&myBufPtr, &stringPtr,
860 &stringSize, &stringMax, MIN_GROW) == -1)
865 if (!doubleQuotes && !singleQuotes)
872 if (_DtHelpCeAddCharToBuf (&mySpace, &stringPtr,
873 &stringSize, &stringMax, MIN_GROW) == -1)
879 if (_DtCvTRUE == less_test)
883 else if (_DtHelpCeAddCharToBuf (&myBufPtr, &stringPtr,
884 &stringSize, &stringMax, MIN_GROW) == -1)
890 if (!doubleQuotes && !singleQuotes)
894 else if (_DtHelpCeAddCharToBuf (&myBufPtr, &stringPtr,
895 &stringSize, &stringMax, MIN_GROW) == -1)
900 if (_DtCvFALSE == ignore_quotes && singleQuotes)
904 else if (_DtHelpCeAddCharToBuf (&myBufPtr, &stringPtr,
905 &stringSize, &stringMax, MIN_GROW) == -1)
910 if (_DtCvFALSE == ignore_quotes && doubleQuotes)
914 else if (_DtHelpCeAddCharToBuf (&myBufPtr, &stringPtr,
915 &stringSize, &stringMax, MIN_GROW) == -1)
929 *ret_string = stringPtr;
934 } /* End _DtHelpCeGetCcdfStrParam */
936 /******************************************************************************
937 * Function: int _DtHelpCeGetCcdfValueParam (FILE *in_file, char *in_buf,
938 * int in_size, char **in_ptr,
939 * int flag, int *ret_value)
942 * in_file Specifies a stream to read from.
943 * in_buf Specifies the buffer where new information
945 * in_size Specifies the maximum size of 'in_buf'.
946 * in_ptr Specifies the pointer into 'in_buf' to
948 * Returns the new location in 'in_buf' to
949 * continue processing.
950 * flag Specifies whether the routine returns
951 * a -2 if '>' is the next token.
952 * ret_value Returns the atoi conversion
953 * of the string found.
955 * Returns: 0 if successful, -1 if errors, -2 if 'flag' is True and
956 * the next token is '>'.
959 * read (2) Errors set via a read call.
963 * CEErrorFormattingValue
966 * Purpose: Get then next numeric parameter.
968 *****************************************************************************/
970 _DtHelpCeGetCcdfValueParam(
981 char *stringPtr = NULL;
988 if (_DtHelpCeSkipToNextCcdfToken (in_file, in_buf, in_size,
989 cur_mb_len, in_ptr, _DtCvTRUE) != 0)
996 spnResult = _DtHelpCeStrcspn (myBufPtr, " >\n", cur_mb_len, ©Size);
997 if (_DtHelpCeAddStrToBuf (&myBufPtr, &stringPtr, &stringSize,
998 &stringMax, copySize, 0) == -1)
1002 * _DtHelpCeStrcspn stopped at a character we want
1006 else if (((int)strlen(myBufPtr)) >= cur_mb_len)
1008 errno = CEErrorIllegalInfo;
1011 else if (_DtHelpCeGetNxtBuf(in_file,in_buf,&myBufPtr,in_size) == -1)
1015 if (stringPtr != NULL && *stringPtr != '\0')
1017 *ret_value = atoi(stringPtr);
1022 errno = CEErrorFormattingValue;
1028 if (result != -1 && _DtCvTRUE == flag && *myBufPtr == '>')
1034 /******************************************************************************
1035 * Function: int _DtHelpCeSkipToNextCcdfToken (FILE *read_file, char *read_buf,
1036 * int read_size, char **src_ptr, int flag)
1039 * read_file Specifies a stream to read from.
1040 * read_buf Specifies the buffer where new information
1042 * read_size Specifies the maximum size of 'read_buf'.
1043 * src_ptr Specifies the pointer into 'read_buf' to
1045 * Returns the new location in 'read_buf' to
1046 * continue processing.
1047 * flag Specifies whether the routine returns
1048 * a 1 if '>' is the next token.
1050 * -1 If problems encountered finding the next token.
1051 * 0 If no problems encountered finding the next token.
1052 * 1 If flag is true and the next token is a > character.
1055 * read (2) Errors set via a read call.
1058 * CEErrorIllegalInfo
1060 * Purpose: Move 'src_ptr' to the next occurrance of a > character
1061 * or the first character after the next space.
1063 *****************************************************************************/
1065 _DtHelpCeSkipToNextCcdfToken (
1066 BufFilePtr read_file,
1075 char *srcPtr = *src_ptr;
1078 * Skip the rest of the alphanumeric string.
1083 * _DtHelpCeStrcspn returns 0 for 'found a character'
1085 result = _DtHelpCeStrcspn (srcPtr, " >\n", cur_mb_len, &len);
1086 srcPtr = srcPtr + len;
1090 if (result == -1 && ((int)strlen(srcPtr)) >= cur_mb_len)
1092 errno = CEErrorIllegalInfo;
1095 if (_DtHelpCeGetNxtBuf(read_file, read_buf,&srcPtr,read_size) == -1)
1101 * Now skip the blanks and end of lines
1106 * _DtHelpCeStrspn returns 0 for 'found a character'
1108 result = _DtHelpCeStrspn (srcPtr, " \n", cur_mb_len, &len);
1109 srcPtr = srcPtr + len;
1112 if (result == -1 && ((int)strlen(srcPtr)) >= cur_mb_len)
1114 errno = CEErrorIllegalInfo;
1117 if (_DtHelpCeGetNxtBuf(read_file,read_buf,&srcPtr,read_size) == -1)
1124 if (_DtCvTRUE == flag && *srcPtr == '>')
1126 errno = CEErrorFormattingOption;
1132 /******************************************************************************
1133 * Function: int _DtHelpCeGetCcdfTopicCmd (void *dpy, FILE *in_file, char *in_buf,
1134 * char **in_ptr, int in_size,
1135 * char **ret_charSet)
1138 * in_file Specifies a stream to read from.
1139 * in_buf Specifies the buffer where new information
1141 * in_ptr Specifies the pointer into 'in_buf' to
1143 * Returns the new location in 'in_buf' to
1144 * continue processing.
1145 * in_size Specifies the maximum size of 'in_buf'.
1146 * ret_charSet Returns the characters set if specified.
1148 * Returns: 0 if successful, -1 if errors.
1151 * read (2) Errors set via a read call.
1154 * CEErrorIllegalInfo
1158 * Purpose: Checks for the <TOPIC> command and returns the charset
1161 *****************************************************************************/
1163 _DtHelpCeGetCcdfTopicCmd (
1170 char **ret_charSet )
1172 char *mycharSet = NULL;
1175 * null the return values
1178 *ret_charSet = NULL;
1181 * check for <TOPIC charset string>
1183 if (_DtHelpCeCheckNextCcdfCmd ("to",in_file,in_buf,in_size,cur_mb_len,in_ptr) == 0)
1186 * The <TOPIC> command and it's attributes must be in 1-byte charset.
1188 if (_DtHelpCeSkipToNextCcdfToken(in_file, in_buf, in_size, 1,
1189 in_ptr, _DtCvFALSE) == -1)
1195 if (_DtCvToLower (**in_ptr) == 'c')
1197 if (_DtHelpCeGetCcdfStrParam (in_file, in_buf, in_size,
1198 1, in_ptr, True, False, False, False, &mycharSet) == -1)
1201 if (_DtHelpCeGetCcdfEndMark(in_file,in_buf,in_ptr,in_size,1) == -1)
1209 else if (**in_ptr != '>')
1211 errno = CEErrorTopicSyntax;
1217 * skip the end token
1219 *in_ptr = *in_ptr + 1;
1224 errno = CEErrorMissingTopicCmd;
1229 *ret_charSet = mycharSet;
1236 /******************************************************************************
1237 * Function: int _DtHelpCeCheckNextCcdfCmd (char *token, FILE *in_file, char in_buf,
1238 * int in_size, char **in_ptr)
1241 * token Specifies the syntax to look for.
1242 * <token ....> data </>
1243 * in_file Specifies a stream to read from.
1244 * in_buf Specifies the buffer where new information
1246 * in_size Specifies the maximum size of 'in_buf'.
1247 * in_ptr Specifies the pointer into 'in_buf' to
1249 * Returns the new location in 'in_buf' to
1250 * continue processing.
1252 * Returns: 0 if successful, -1 if errors, -2 if token not found.
1255 * read (2) Errors set via a read call.
1257 * CEErrorIllegalInfo
1260 * Purpose: Determine if the next formatting command is
1263 * Note: 'token' must be a lower case string.
1265 *****************************************************************************/
1267 _DtHelpCeCheckNextCcdfCmd(
1276 int len = strlen (token);
1280 * check for the token
1282 while (len > 0 && result > -1)
1284 if (**in_ptr == '\0' &&
1285 _DtHelpCeGetNxtBuf(in_file, in_buf, in_ptr, in_size) == -1)
1288 if (cur_mb_len == 1 || mblen (*in_ptr, cur_mb_len) == 1)
1290 if ((isspace (**in_ptr) || **in_ptr == '\n'))
1291 *in_ptr = *in_ptr + 1;
1292 else if (**in_ptr == '<')
1294 if (((int)strlen(*in_ptr)) < (len + 1) &&
1295 _DtHelpCeGetNxtBuf (in_file, in_buf,
1296 in_ptr, in_size) == -1)
1299 for (str = *in_ptr + 1; len > 0; len--, str++, token++)
1301 if (_DtCvToLower (*str) != *token)
1316 /*****************************************************************************
1317 * Function: int _DtHelpCeGetCcdfTopicAbbrev (void *dpy, FILE *file, char *buffer,
1318 * char **buf_ptr, int buf_size, int strip,
1319 * char **ret_title, char **ret_charSet,
1320 * char **ret_abbrev)
1323 * dpy Specifies the display connection as a void.
1324 * Do it this way to prevent the terminal
1325 * functions from having to know about Xlib.
1326 * Terminal/Access Functions should pass NULL
1328 * file Specifies the stream of the open file.
1329 * buffer The buffer holding the current information.
1330 * buf_ptr Specifies the pointer into 'buffer' to
1332 * Returns the new location in 'buffer' to
1333 * continue processing.
1334 * buf_size The size of buffer.
1335 * ret_title Returns a null terminated string
1336 * containing the title if found.
1337 * ret_charSet Returns a null terminated string
1338 * containing the character set if found.
1339 * ret_abbrev Returns a null terminated string
1340 * containing the abbreviated title if found.
1342 * Memory own by caller:
1347 * Returns: 0 if successful, -2 if <TOPIC> not found, otherwise -1.
1350 * read (2) Errors set via a read call.
1353 * CEErrorIllegalInfo
1356 * Purpose: Find the title and abbreviated title of a topic.
1358 *****************************************************************************/
1360 _DtHelpCeGetCcdfTopicAbbrev (
1380 * check for <TOPIC charset string>
1382 if (_DtHelpCeGetCcdfTopicCmd (dpy,
1390 /* Must have a <TITLE> token*/
1391 GetTitleCmd(file, buffer, buf_size, cur_mb_len,buf_ptr,ret_title) == -1
1393 /* check for the <ABBREV> token */
1394 _DtHelpCeGetCcdfAbbrevCmd (file, buffer, buf_size, cur_mb_len,buf_ptr, ret_abbrev) == -1)
1401 /*****************************************************************************
1402 * Function: int _DtHelpCeSkipCcdfAbbrev (FILE *file, char *buffer, int buf_size,
1406 * file Specifies the stream of the open file.
1407 * buffer The buffer holding the current information.
1408 * buf_size The size of buffer.
1409 * buf_ptr Specifies the pointer into 'buffer' to
1411 * Returns the new location in 'buffer' to
1412 * continue processing.
1414 * Returns: 0 if successful, otherwise -1.
1417 * read (2) Errors set via a read call.
1420 * CEErrorIllegalInfo
1423 * Purpose: Skip the <ABBREV> command
1425 *****************************************************************************/
1427 _DtHelpCeSkipCcdfAbbrev (
1435 * check for the <ABBREV> token and skip its data.
1437 return _DtHelpCeGetCcdfAbbrevCmd(file, buffer, buf_size, cur_mb_len,buf_ptr, NULL);
1440 /******************************************************************************
1441 * Function: int _DtHelpCeGetCcdfAbbrevCmd (FILE *in_file, char *in_buf, int in_size,
1442 * char **in_ptr, char **ret_string)
1445 * in_file Specifies a stream to read from.
1446 * in_buf Specifies the buffer where new information
1448 * in_size Specifies the maximum size of 'in_buf'.
1449 * in_ptr Specifies the pointer into 'in_buf' to
1451 * Returns the new location in 'in_buf' to
1452 * continue processing.
1453 * ret_string Returns the data found.
1455 * Returns: 0 if successful, -1 if errors
1458 * read (2) Errors set via a read call.
1460 * CEErrorIllegalInfo
1463 * Purpose: Determine if the next formatting command is
1465 * Returns the data found between <ABBREV> and its ending </>.
1467 * Note: The only formatting command allowed between <ABBREV> and
1468 * its </> is the <NEWLINE> command. And it is stripped.
1470 *****************************************************************************/
1472 _DtHelpCeGetCcdfAbbrevCmd(
1485 * null the return string
1491 * check for the token
1493 result = _DtHelpCeCheckNextCcdfCmd ("ab", in_file, in_buf, in_size, cur_mb_len, in_ptr);
1496 else if (result == 0 &&
1497 _DtHelpCeGetCcdfEndMark(in_file,in_buf,in_ptr,in_size,cur_mb_len) != -1)
1499 result = GetCmdData (in_file, in_buf, in_size, in_ptr, cur_mb_len,
1500 CCDF_NEWLINE_CMD, CCDF_NEWLINE_CMD,
1501 &junkSize, &junkMax, ret_string);
1502 if (result == -1 && errno == CMD_NOT_ALLOWED)
1503 errno = CEErrorAbbrevSyntax;
1511 /******************************************************************************
1512 * Function: int _DtHelpCeGetCcdfCmd (int current, char *buffer,
1513 * char **buf_ptr, FILE *my_file,
1514 * int size, int allowed, int flag )
1516 * Parameters: current Specifies the current formatting command.
1517 * buffer Specifies the buffer to use for input.
1518 * buf_ptr Specifies the current position into 'buffer'.
1519 * my_file Specifies the file stream to read from.
1520 * size Specifies the maximum size of the input buffer.
1521 * allowed Specifies the commands allowed at this time.
1522 * flag Specifies the flag to use for
1523 * _DtHelpCeGetNxtBuf. No longer used.
1526 * -1 If errors reading the file or the command is not
1528 * > 0 The formmatting command.
1532 * Purpose: Determine if the string pointed to by 'ptr' is a formatting
1535 *****************************************************************************/
1537 _DtHelpCeGetCcdfCmd (
1553 * always allow the end of formatting command
1555 allowed = allowed | CCDF_FORMAT_END;
1558 * set the pointer to the current position in the input buffer
1561 if (*myPtr == '\0' &&
1562 _DtHelpCeGetNxtBuf(my_file, buffer, &myPtr, size) == -1)
1565 firstChar = _DtCvToLower (*myPtr);
1568 different = firstChar - CcdfFormatCmds[i].cmd[0];
1570 if (!different && CcdfFormatCmds[i].significant > 1)
1572 if (((int)strlen(myPtr)) < CcdfFormatCmds[i].significant &&
1573 _DtHelpCeGetNxtBuf (my_file, buffer, &myPtr, size) == -1)
1578 different = _DtCvToLower(myPtr[j]) - CcdfFormatCmds[i].cmd[j];
1580 } while (!different && j < CcdfFormatCmds[i].significant);
1583 } while (different && CcdfFormatCmds[i].type != CCDF_FORMAT_END);
1586 * update the passed in pointer
1591 * check to see if the formatting command is valid
1594 errno = CEErrorFormattingCmd;
1596 else if (!different && CCDF_NOT_ALLOW_CMD (allowed, CcdfFormatCmds[i].type))
1601 case CCDF_ABBREV_CMD:
1602 errno = CEErrorAbbrevSyntax;
1604 case CCDF_FIGURE_CMD:
1605 errno = CEErrorFigureSyntax;
1608 errno = CEErrorFontSyntax;
1610 case CCDF_GRAPHIC_CMD:
1611 errno = CEErrorGraphicSyntax;
1614 errno = CEErrorIdSyntax;
1616 case CCDF_LABEL_CMD:
1617 errno = CEErrorLabelSyntax;
1620 errno = CEErrorLinkSyntax;
1622 case CCDF_NEWLINE_CMD:
1623 errno = CEErrorNewLineSyntax;
1625 case CCDF_OCTAL_CMD:
1626 errno = CEErrorOctalSyntax;
1628 case CCDF_PARAGRAPH_CMD:
1629 errno = CEErrorParagraphSyntax;
1631 case CCDF_TITLE_CMD:
1632 errno = CEErrorTitleSyntax;
1634 case CCDF_TOPIC_CMD:
1635 errno = CEErrorTopicSyntax;
1639 if (different || my_error)
1642 return CcdfFormatCmds[i].type;
1645 /******************************************************************************
1646 * Function: int _DtHelpCeGetCcdfFontType (char *code)
1648 * Parameters: code Specifies the character set to initialize
1649 * data and flags. The caller must ensure that
1650 * there is enough of the code string available
1651 * to make the determination.
1653 * Return Value: int Returns the font resource to change.
1654 * -1 if unknown font change type.
1656 * Purpose: Determines if the code is a font change specification.
1658 *****************************************************************************/
1660 _DtHelpCeGetCcdfFontType (char *code)
1663 char myChar = _DtCvToLower (*code);
1666 my2Char = _DtCvToLower (*code);
1674 return _CEFONT_ANGLE;
1679 case 'c': return _CEFONT_CHAR_SET;
1686 return _CEFONT_TYPE;
1692 case 'w': return _CEFONT_WEIGHT;
1700 return _CEFONT_SIZE;
1703 return _CEFONT_SPACING;