2 * - Need to document error code meanings.
3 * - Need to do something with \* on destinations.
4 * - Make the parameter a long?
6 * reader.c - RTF file reader. Release 1.10.
8 * ASCII 10 (\n) and 13 (\r) are ignored and silently discarded.
9 * Nulls are also discarded.
10 * (although the read hook will still get a look at them.)
12 * "\:" is not a ":", it's a control symbol. But some versions of
13 * Word seem to write "\:" for ":". This reader treats "\:" as a
17 * - Add hack to skip "{\*\keycode ... }" group in stylesheet.
18 * This is probably the wrong thing to do, but it's simple.
20 * - Add THINK C awareness to malloc() declaration. Necessary so
21 * compiler knows the malloc argument is 4 bytes. Ugh.
23 * - Text characters are mapped onto standard codes, which are placed
25 * - Eliminated use of index() function.
27 * - Added zillions of new symbols (those defined in RTF spec 1.2).
29 * - Public functions RTFMsg() and RTFPanic() now take variable arguments.
30 * This means RTFPanic() now is used in place of what was formerly the
31 * internal function Error().
32 * - 8-bit characters are now legal, so they're not converted to \'xx
33 * hex char representation now.
35 * - Added public variables rtfLineNum and rtfLinePos.
36 * - #include string.h or strings.h, avoiding strncmp() problem where
37 * last argument is treated as zero when prototype isn't available.
39 * - Treat style numbers 222 and 0 properly as "no style" and "normal".
41 * Author: Paul DuBois dubois@primate.wisc.edu
43 * This software may be redistributed without restriction and used for
44 * any purpose whatsoever.
48 # define STRING_H <string.h>
67 * include hard coded charsets
79 #include "wine/debug.h"
81 WINE_DEFAULT_DEBUG_CHANNEL(richedit);
83 extern HANDLE RICHED32_hHeap;
86 * Return pointer to new element of type t, or NULL
87 * if no memory available.
90 # define New(t) ((t *) RTFAlloc ((int) sizeof (t)))
92 /* maximum number of character values representable in a byte */
94 # define charSetSize 256
96 /* charset stack size */
98 # define maxCSStack 10
100 static int _RTFGetChar();
101 static void _RTFGetToken ();
102 static void _RTFGetToken2 ();
103 static int GetChar ();
104 static void ReadFontTbl ();
105 static void ReadColorTbl ();
106 static void ReadStyleSheet ();
107 static void ReadInfoGroup ();
108 static void ReadPictGroup ();
109 static void ReadObjGroup ();
110 static void LookupInit ();
111 static void Lookup ();
114 static void CharSetInit ();
115 static void ReadCharSetMaps ();
119 * Public variables (listed in rtf.h)
127 char *rtfTextBuf = (char *) NULL;
138 static int pushedChar; /* pushback char if read too far */
140 static int pushedClass; /* pushed token info for RTFUngetToken() */
141 static int pushedMajor;
142 static int pushedMinor;
143 static int pushedParam;
144 static char *pushedTextBuf = (char *) NULL;
149 static RTFFont *fontList = (RTFFont *) NULL; /* these lists MUST be */
150 static RTFColor *colorList = (RTFColor *) NULL; /* initialized to NULL */
151 static RTFStyle *styleList = (RTFStyle *) NULL;
153 static char *inputName = (char *) NULL;
154 static char *outputName = (char *) NULL;
156 static EDITSTREAM editstream;
157 static CHARLIST inputCharList = {0, NULL, NULL};
160 * This array is used to map standard character names onto their numeric codes.
161 * The position of the name within the array is the code.
162 * stdcharnames.h is generated in the ../h directory.
165 #include "stdcharnames.h"
168 * These arrays are used to map RTF input character values onto the standard
169 * character names represented by the values. Input character values are
170 * used as indices into the arrays to produce standard character codes.
174 static char *genCharSetFile = (char *) NULL;
175 static int genCharCode[charSetSize]; /* general */
176 static int haveGenCharSet = 0;
178 static char *symCharSetFile = (char *) NULL;
179 static int symCharCode[charSetSize]; /* symbol */
180 static int haveSymCharSet = 0;
182 static int curCharSet = rtfCSGeneral;
183 static int *curCharCode = genCharCode;
186 * By default, the reader is configured to handle charset mapping invisibly,
187 * including reading the charset files and switching charset maps as necessary
191 static int autoCharSetFlags;
194 * Stack for keeping track of charset map on group begin/end. This is
195 * necessary because group termination reverts the font to the previous
196 * value, which may implicitly change it.
199 static int csStack[maxCSStack];
200 static int csTop = 0;
203 * Get a char from the charlist. The charlist is used to store characters
204 * from the editstream.
208 int _RTFGetChar(void)
214 if(CHARLIST_GetNbItems(&inputCharList) == 0)
218 editstream.pfnCallback(editstream.dwCookie, buff, 1, &pcb);
222 CHARLIST_Enqueue(&inputCharList, buff[0]);
224 myChar = CHARLIST_Dequeue(&inputCharList);
228 void RTFSetEditStream(EDITSTREAM *es)
232 editstream.dwCookie = es->dwCookie;
233 editstream.dwError = es->dwError;
234 editstream.pfnCallback = es->pfnCallback;
238 * Initialize the reader. This may be called multiple times,
239 * to read multiple files. The only thing not reset is the input
240 * stream; that must be done with RTFSetStream().
249 RTFStyleElt *eltList, *ep;
253 if (rtfTextBuf == (char *) NULL) /* initialize the text buffers */
255 rtfTextBuf = RTFAlloc (rtfBufSiz);
256 pushedTextBuf = RTFAlloc (rtfBufSiz);
257 if (rtfTextBuf == (char *) NULL
258 || pushedTextBuf == (char *) NULL)
259 RTFPanic ("Cannot allocate text buffers.");
260 rtfTextBuf[0] = pushedTextBuf[0] = '\0';
264 RTFFree (outputName);
265 inputName = outputName = (char *) NULL;
267 /* initialize lookup table */
270 for (i = 0; i < rtfMaxClass; i++)
271 RTFSetClassCallback (i, (RTFFuncPtr) NULL);
272 for (i = 0; i < rtfMaxDestination; i++)
273 RTFSetDestinationCallback (i, (RTFFuncPtr) NULL);
275 /* install built-in destination readers */
276 RTFSetDestinationCallback (rtfFontTbl, ReadFontTbl);
277 RTFSetDestinationCallback (rtfColorTbl, ReadColorTbl);
278 RTFSetDestinationCallback (rtfStyleSheet, ReadStyleSheet);
279 RTFSetDestinationCallback (rtfInfo, ReadInfoGroup);
280 RTFSetDestinationCallback (rtfPict, ReadPictGroup);
281 RTFSetDestinationCallback (rtfObject, ReadObjGroup);
284 RTFSetReadHook ((RTFFuncPtr) NULL);
286 /* dump old lists if necessary */
288 while (fontList != (RTFFont *) NULL)
290 fp = fontList->rtfNextFont;
291 RTFFree (fontList->rtfFName);
292 RTFFree ((char *) fontList);
295 while (colorList != (RTFColor *) NULL)
297 cp = colorList->rtfNextColor;
298 RTFFree ((char *) colorList);
301 while (styleList != (RTFStyle *) NULL)
303 sp = styleList->rtfNextStyle;
304 eltList = styleList->rtfSSEList;
305 while (eltList != (RTFStyleElt *) NULL)
307 ep = eltList->rtfNextSE;
308 RTFFree (eltList->rtfSEText);
309 RTFFree ((char *) eltList);
312 RTFFree (styleList->rtfSName);
313 RTFFree ((char *) styleList);
331 * Set or get the input or output file name. These are never guaranteed
332 * to be accurate, only insofar as the calling program makes them so.
335 void RTFSetInputName(char *name)
339 if ((inputName = RTFStrSave (name)) == (char *) NULL)
340 RTFPanic ("RTFSetInputName: out of memory");
344 char *RTFGetInputName(void)
350 void RTFSetOutputName(char *name)
354 if ((outputName = RTFStrSave (name)) == (char *) NULL)
355 RTFPanic ("RTFSetOutputName: out of memory");
359 char *RTFGetOutputName(void)
366 /* ---------------------------------------------------------------------- */
369 * Callback table manipulation routines
374 * Install or return a writer callback for a token class
378 static RTFFuncPtr ccb[rtfMaxClass]; /* class callbacks */
381 void RTFSetClassCallback(int class, RTFFuncPtr callback)
383 if (class >= 0 && class < rtfMaxClass)
384 ccb[class] = callback;
388 RTFFuncPtr RTFGetClassCallback(int class)
390 if (class >= 0 && class < rtfMaxClass)
392 return ((RTFFuncPtr) NULL);
397 * Install or return a writer callback for a destination type
400 static RTFFuncPtr dcb[rtfMaxDestination]; /* destination callbacks */
403 void RTFSetDestinationCallback(int dest, RTFFuncPtr callback)
405 if (dest >= 0 && dest < rtfMaxDestination)
406 dcb[dest] = callback;
410 RTFFuncPtr RTFGetDestinationCallback(int dest)
412 if (dest >= 0 && dest < rtfMaxDestination)
414 return ((RTFFuncPtr) NULL);
418 /* ---------------------------------------------------------------------- */
421 * Token reading routines
426 * Read the input stream, invoking the writer's callbacks
432 while (RTFGetToken () != rtfEOF)
438 * Route a token. If it's a destination for which a reader is
439 * installed, process the destination internally, otherwise
440 * pass the token to the writer's class callback.
443 void RTFRouteToken(void)
449 if (rtfClass < 0 || rtfClass >= rtfMaxClass) /* watchdog */
451 RTFPanic ("Unknown class %d: %s (reader malfunction)",
452 rtfClass, rtfTextBuf);
454 if (RTFCheckCM (rtfControl, rtfDestination))
456 /* invoke destination-specific callback if there is one */
457 if ((p = RTFGetDestinationCallback (rtfMinor))
458 != (RTFFuncPtr) NULL)
464 /* invoke class callback if there is one */
465 if ((p = RTFGetClassCallback (rtfClass)) != (RTFFuncPtr) NULL)
471 * Skip to the end of the current group. When this returns,
472 * writers that maintain a state stack may want to call their
473 * state unstacker; global vars will still be set to the group's
477 void RTFSkipGroup(void)
482 while (RTFGetToken () != rtfEOF)
484 if (rtfClass == rtfGroup)
486 if (rtfMajor == rtfBeginGroup)
488 else if (rtfMajor == rtfEndGroup)
491 break; /* end of initial group */
499 * Read one token. Call the read hook if there is one. The
500 * token class is the return value. Returns rtfEOF when there
501 * are no more tokens.
504 int RTFGetToken(void)
512 if ((p = RTFGetReadHook ()) != (RTFFuncPtr) NULL)
513 (*p) (); /* give read hook a look at token */
515 /* Silently discard newlines, carriage returns, nulls. */
516 if (!(rtfClass == rtfText && rtfFormat != SF_TEXT
517 && (rtfMajor == '\r' || rtfMajor == '\n' || rtfMajor == '\0')))
525 * Install or return a token reader hook.
528 static RTFFuncPtr readHook;
531 void RTFSetReadHook(RTFFuncPtr f)
537 RTFFuncPtr RTFGetReadHook(void)
543 void RTFUngetToken(void)
547 if (pushedClass >= 0) /* there's already an ungotten token */
548 RTFPanic ("cannot unget two tokens");
550 RTFPanic ("no token to unget");
551 pushedClass = rtfClass;
552 pushedMajor = rtfMajor;
553 pushedMinor = rtfMinor;
554 pushedParam = rtfParam;
555 (void) strcpy (pushedTextBuf, rtfTextBuf);
559 int RTFPeekToken(void)
567 static void _RTFGetToken(void)
573 if (rtfFormat == SF_TEXT) {
574 rtfMajor = GetChar ();
575 rtfMinor = rtfSC_nothing;
576 rtfParam = rtfNoParam;
577 rtfTextBuf[rtfTextLen = 0] = '\0';
585 /* first check for pushed token from RTFUngetToken() */
587 if (pushedClass >= 0)
589 rtfClass = pushedClass;
590 rtfMajor = pushedMajor;
591 rtfMinor = pushedMinor;
592 rtfParam = pushedParam;
593 (void) strcpy (rtfTextBuf, pushedTextBuf);
594 rtfTextLen = strlen (rtfTextBuf);
600 * Beyond this point, no token is ever seen twice, which is
601 * important, e.g., for making sure no "}" pops the font stack twice.
605 if (rtfClass == rtfText) /* map RTF char to standard code */
606 rtfMinor = RTFMapChar (rtfMajor);
609 * If auto-charset stuff is activated, see if anything needs doing,
610 * like reading the charset maps or switching between them.
613 if (autoCharSetFlags == 0)
616 if ((autoCharSetFlags & rtfReadCharSet)
617 && RTFCheckCM (rtfControl, rtfCharSet))
621 else if ((autoCharSetFlags & rtfSwitchCharSet)
622 && RTFCheckCMM (rtfControl, rtfCharAttr, rtfFontNum))
624 if ((fp = RTFGetFont (rtfParam)) != (RTFFont *) NULL)
626 if (strncmp (fp->rtfFName, "Symbol", 6) == 0)
627 curCharSet = rtfCSSymbol;
629 curCharSet = rtfCSGeneral;
630 RTFSetCharSet (curCharSet);
633 else if ((autoCharSetFlags & rtfSwitchCharSet) && rtfClass == rtfGroup)
638 if (csTop >= maxCSStack)
639 RTFPanic ("_RTFGetToken: stack overflow");
640 csStack[csTop++] = curCharSet;
644 RTFPanic ("_RTFGetToken: stack underflow");
645 curCharSet = csStack[--csTop];
646 RTFSetCharSet (curCharSet);
653 /* this shouldn't be called anywhere but from _RTFGetToken() */
655 static void _RTFGetToken2(void)
662 /* initialize token vars */
664 rtfClass = rtfUnknown;
665 rtfParam = rtfNoParam;
666 rtfTextBuf[rtfTextLen = 0] = '\0';
668 /* get first character, which may be a pushback from previous token */
670 if (pushedChar != EOF)
673 rtfTextBuf[rtfTextLen++] = c;
674 rtfTextBuf[rtfTextLen] = '\0';
677 else if ((c = GetChar ()) == EOF)
686 rtfMajor = rtfBeginGroup;
692 rtfMajor = rtfEndGroup;
698 * Two possibilities here:
699 * 1) ASCII 9, effectively like \tab control symbol
700 * 2) literal text char
702 if (c == '\t') /* ASCII 9 */
704 rtfClass = rtfControl;
705 rtfMajor = rtfSpecialChar;
715 if ((c = GetChar ()) == EOF)
717 /* early eof, whoops (class is rtfUnknown) */
723 * Three possibilities here:
724 * 1) hex encoded text char, e.g., \'d5, \'d3
725 * 2) special escaped text char, e.g., \{, \}
726 * 3) control symbol, e.g., \_, \-, \|, \<10>
728 if (c == '\'') /* hex char */
732 if ((c = GetChar ()) != EOF && (c2 = GetChar ()) != EOF)
734 /* should do isxdigit check! */
736 rtfMajor = RTFCharToHex (c) * 16
740 /* early eof, whoops (class is rtfUnknown) */
745 /*if (index (":{}\\", c) != (char *) NULL)*/ /* escaped char */
746 if (c == ':' || c == '{' || c == '}' || c == '\\')
754 Lookup (rtfTextBuf); /* sets class, major, minor */
760 if ((c = GetChar ()) == EOF)
765 * At this point, the control word is all collected, so the
766 * major/minor numbers are determined before the parameter
767 * (if any) is scanned. There will be one too many characters
768 * in the buffer, though, so fix up before and restore after
773 rtfTextBuf[rtfTextLen-1] = '\0';
774 Lookup (rtfTextBuf); /* sets class, major, minor */
776 rtfTextBuf[rtfTextLen-1] = c;
779 * Should be looking at first digit of parameter if there
780 * is one, unless it's negative. In that case, next char
781 * is '-', so need to gobble next char, and remember sign.
790 if (c != EOF && isdigit (c))
793 while (isdigit (c)) /* gobble parameter */
795 rtfParam = rtfParam * 10 + c - '0';
796 if ((c = GetChar ()) == EOF)
802 * If control symbol delimiter was a blank, gobble it.
803 * Otherwise the character is first char of next token, so
804 * push it back for next call. In either case, delete the
805 * delimiter from the token buffer.
811 rtfTextBuf[--rtfTextLen] = '\0';
817 * Read the next character from the input. This handles setting the
818 * current line and position-within-line variables. Those variable are
819 * set correctly whether lines end with CR, LF, or CRLF (the last being
822 * bumpLine indicates whether the line number should be incremented on
823 * the *next* input character.
827 static int GetChar(void)
834 if ((c = _RTFGetChar()) != EOF)
836 rtfTextBuf[rtfTextLen++] = c;
837 rtfTextBuf[rtfTextLen] = '\0';
841 oldBumpLine = bumpLine; /* non-zero if prev char was line ending */
848 if (prevChar == '\r') /* oops, previous \r wasn't */
849 oldBumpLine = 0; /* really a line ending */
852 if (oldBumpLine) /* were we supposed to increment the */
853 { /* line count on this char? */
863 * Synthesize a token by setting the global variables to the
864 * values supplied. Typically this is followed with a call
865 * to RTFRouteToken().
867 * If a param value other than rtfNoParam is passed, it becomes
868 * part of the token text.
871 void RTFSetToken(int class, int major, int minor, int param, char *text)
879 if (param == rtfNoParam)
880 (void) strcpy (rtfTextBuf, text);
882 sprintf (rtfTextBuf, "%s%d", text, param);
883 rtfTextLen = strlen (rtfTextBuf);
887 /* ---------------------------------------------------------------------- */
890 * Routines to handle mapping of RTF character sets
891 * onto standard characters.
893 * RTFStdCharCode(name) given char name, produce numeric code
894 * RTFStdCharName(code) given char code, return name
895 * RTFMapChar(c) map input (RTF) char code to std code
896 * RTFSetCharSet(id) select given charset map
897 * RTFGetCharSet() get current charset map
899 * See ../h/README for more information about charset names and codes.
904 * Initialize charset stuff.
907 static void CharSetInit(void)
911 autoCharSetFlags = (rtfReadCharSet | rtfSwitchCharSet);
912 RTFFree (genCharSetFile);
913 genCharSetFile = (char *) NULL;
915 RTFFree (symCharSetFile);
916 symCharSetFile = (char *) NULL;
918 curCharSet = rtfCSGeneral;
919 curCharCode = genCharCode;
924 * Specify the name of a file to be read when auto-charset-file reading is
928 void RTFSetCharSetMap (char *name, int csId)
932 if ((name = RTFStrSave (name)) == (char *) NULL) /* make copy */
933 RTFPanic ("RTFSetCharSetMap: out of memory");
937 RTFFree (genCharSetFile); /* free any previous value */
938 genCharSetFile = name;
941 RTFFree (symCharSetFile); /* free any previous value */
942 symCharSetFile = name;
949 * Do auto-charset-file reading.
950 * will always use the ansi charset no mater what the value
951 * of the rtfTextBuf is.
953 * TODO: add support for other charset in the future.
957 static void ReadCharSetMaps(void)
963 if (genCharSetFile != (char *) NULL)
964 (void) strcpy (buf, genCharSetFile);
966 sprintf (buf, "%s-gen", &rtfTextBuf[1]);
967 if (RTFReadCharSetMap (rtfCSGeneral) == 0)
968 RTFPanic ("ReadCharSetMaps: Cannot read charset map %s", buf);
969 if (symCharSetFile != (char *) NULL)
970 (void) strcpy (buf, symCharSetFile);
972 sprintf (buf, "%s-sym", &rtfTextBuf[1]);
973 if (RTFReadCharSetMap (rtfCSSymbol) == 0)
974 RTFPanic ("ReadCharSetMaps: Cannot read charset map %s", buf);
980 * Convert a CaracterSetMap (caracter_name, caracter) into
981 * this form : array[caracter_ident] = caracter;
984 int RTFReadCharSetMap(int csId)
994 return (0); /* illegal charset id */
998 stdCodeArray = genCharCode;
999 for (i = 0; i < charSetSize; i++)
1001 stdCodeArray[i] = rtfSC_nothing;
1004 for ( i = 0 ; i< sizeof(ansi_gen)/(sizeof(int));i+=2)
1006 stdCodeArray[ ansi_gen[i+1] ] = ansi_gen[i];
1013 stdCodeArray = symCharCode;
1014 for (i = 0; i < charSetSize; i++)
1016 stdCodeArray[i] = rtfSC_nothing;
1019 for ( i = 0 ; i< sizeof(ansi_sym)/(sizeof(int));i+=2)
1021 stdCodeArray[ ansi_sym[i+1] ] = ansi_sym[i];
1031 * Given a standard character name (a string), find its code (a number).
1032 * Return -1 if name is unknown.
1035 int RTFStdCharCode(char *name)
1041 for (i = 0; i < rtfSC_MaxChar; i++)
1043 if (strcmp (name, stdCharName[i]) == 0)
1051 * Given a standard character code (a number), find its name (a string).
1052 * Return NULL if code is unknown.
1055 char *RTFStdCharName(int code)
1057 if (code < 0 || code >= rtfSC_MaxChar)
1058 return ((char *) NULL);
1059 return (stdCharName[code]);
1064 * Given an RTF input character code, find standard character code.
1065 * The translator should read the appropriate charset maps when it finds a
1066 * charset control. However, the file might not contain one. In this
1067 * case, no map will be available. When the first attempt is made to
1068 * map a character under these circumstances, RTFMapChar() assumes ANSI
1069 * and reads the map as necessary.
1072 int RTFMapChar(int c)
1079 if (!haveGenCharSet)
1081 if (RTFReadCharSetMap (rtfCSGeneral) == 0)
1082 RTFPanic ("RTFMapChar: cannot read ansi-gen");
1086 if (!haveSymCharSet)
1088 if (RTFReadCharSetMap (rtfCSSymbol) == 0)
1089 RTFPanic ("RTFMapChar: cannot read ansi-sym");
1093 if (c < 0 || c >= charSetSize)
1094 return (rtfSC_nothing);
1095 return (curCharCode[c]);
1100 * Set the current character set. If csId is illegal, uses general charset.
1103 void RTFSetCharSet(int csId)
1109 default: /* use general if csId unknown */
1111 curCharCode = genCharCode;
1115 curCharCode = symCharCode;
1122 int RTFGetCharSet(void)
1124 return (curCharSet);
1128 /* ---------------------------------------------------------------------- */
1131 * Special destination readers. They gobble the destination so the
1132 * writer doesn't have to deal with them. That's wrong for any
1133 * translator that wants to process any of these itself. In that
1134 * case, these readers should be overridden by installing a different
1135 * destination callback.
1137 * NOTE: The last token read by each of these reader will be the
1138 * destination's terminating '}', which will then be the current token.
1139 * That '}' token is passed to RTFRouteToken() - the writer has already
1140 * seen the '{' that began the destination group, and may have pushed a
1141 * state; it also needs to know at the end of the group that a state
1144 * It's important that rtf.h and the control token lookup table list
1145 * as many symbols as possible, because these destination readers
1146 * unfortunately make strict assumptions about the input they expect,
1147 * and a token of class rtfUnknown will throw them off easily.
1152 * Read { \fonttbl ... } destination. Old font tables don't have
1153 * braces around each table entry; try to adjust for that.
1156 static void ReadFontTbl(void)
1159 char buf[rtfBufSiz], *bp;
1161 char *fn = "ReadFontTbl";
1167 (void) RTFGetToken ();
1168 if (RTFCheckCM (rtfGroup, rtfEndGroup))
1170 if (old < 0) /* first entry - determine tbl type */
1172 if (RTFCheckCMM (rtfControl, rtfCharAttr, rtfFontNum))
1173 old = 1; /* no brace */
1174 else if (RTFCheckCM (rtfGroup, rtfBeginGroup))
1175 old = 0; /* brace */
1176 else /* can't tell! */
1177 RTFPanic ("%s: Cannot determine format", fn);
1179 if (old == 0) /* need to find "{" here */
1181 if (!RTFCheckCM (rtfGroup, rtfBeginGroup))
1182 RTFPanic ("%s: missing \"{\"", fn);
1183 (void) RTFGetToken (); /* yes, skip to next token */
1185 if ((fp = New (RTFFont)) == (RTFFont *) NULL)
1186 RTFPanic ("%s: cannot allocate font entry", fn);
1188 fp->rtfNextFont = fontList;
1191 fp->rtfFName = (char *) NULL;
1192 fp->rtfFAltName = (char *) NULL;
1195 fp->rtfFCharSet = 0;
1198 fp->rtfFCodePage = 0;
1200 while (rtfClass != rtfEOF
1201 && !RTFCheckCM (rtfText, ';')
1202 && !RTFCheckCM (rtfGroup, rtfEndGroup))
1204 if (rtfClass == rtfControl)
1209 /* ignore token but announce it */
1210 RTFMsg ("%s: unknown token \"%s\"\n",
1213 fp->rtfFFamily = rtfMinor;
1219 break; /* ignore unknown? */
1221 fp->rtfFNum = rtfParam;
1229 break; /* ignore unknown? */
1230 case rtfFontCharSet:
1231 fp->rtfFCharSet = rtfParam;
1234 fp->rtfFPitch = rtfParam;
1236 case rtfFontCodePage:
1237 fp->rtfFCodePage = rtfParam;
1240 case rtfFTypeTrueType:
1241 fp->rtfFType = rtfParam;
1247 else if (RTFCheckCM (rtfGroup, rtfBeginGroup)) /* dest */
1249 RTFSkipGroup (); /* ignore for now */
1251 else if (rtfClass == rtfText) /* font name */
1254 while (rtfClass != rtfEOF
1255 && !RTFCheckCM (rtfText, ';')
1256 && !RTFCheckCM (rtfGroup, rtfEndGroup))
1259 (void) RTFGetToken ();
1262 /* FIX: in some cases the <fontinfo> isn't finished with a semi-column */
1263 if(RTFCheckCM (rtfGroup, rtfEndGroup))
1268 fp->rtfFName = RTFStrSave (buf);
1269 if (fp->rtfFName == (char *) NULL)
1270 RTFPanic ("%s: cannot allocate font name", fn);
1271 /* already have next token; don't read one */
1272 /* at bottom of loop */
1277 /* ignore token but announce it */
1278 RTFMsg ("%s: unknown token \"%s\"\n",
1281 (void) RTFGetToken ();
1283 if (old == 0) /* need to see "}" here */
1285 (void) RTFGetToken ();
1286 if (!RTFCheckCM (rtfGroup, rtfEndGroup))
1287 RTFPanic ("%s: missing \"}\"", fn);
1290 if (fp->rtfFNum == -1)
1291 RTFPanic ("%s: missing font number", fn);
1293 * Could check other pieces of structure here, too, I suppose.
1295 RTFRouteToken (); /* feed "}" back to router */
1300 * The color table entries have color values of -1 if
1301 * the default color should be used for the entry (only
1302 * a semi-colon is given in the definition, no color values).
1303 * There will be a problem if a partial entry (1 or 2 but
1304 * not 3 color values) is given. The possibility is ignored
1308 static void ReadColorTbl(void)
1312 char *fn = "ReadColorTbl";
1318 (void) RTFGetToken ();
1319 if (RTFCheckCM (rtfGroup, rtfEndGroup))
1321 if ((cp = New (RTFColor)) == (RTFColor *) NULL)
1322 RTFPanic ("%s: cannot allocate color entry", fn);
1323 cp->rtfCNum = cnum++;
1324 cp->rtfCRed = cp->rtfCGreen = cp->rtfCBlue = -1;
1325 cp->rtfNextColor = colorList;
1327 while (RTFCheckCM (rtfControl, rtfColorName))
1331 case rtfRed: cp->rtfCRed = rtfParam; break;
1332 case rtfGreen: cp->rtfCGreen = rtfParam; break;
1333 case rtfBlue: cp->rtfCBlue = rtfParam; break;
1337 if (!RTFCheckCM (rtfText, (int) ';'))
1338 RTFPanic ("%s: malformed entry", fn);
1340 RTFRouteToken (); /* feed "}" back to router */
1345 * The "Normal" style definition doesn't contain any style number,
1346 * all others do. Normal style is given style rtfNormalStyleNum.
1349 static void ReadStyleSheet(void)
1352 RTFStyleElt *sep, *sepLast;
1353 char buf[rtfBufSiz], *bp;
1354 char *fn = "ReadStyleSheet";
1360 (void) RTFGetToken ();
1361 if (RTFCheckCM (rtfGroup, rtfEndGroup))
1363 if ((sp = New (RTFStyle)) == (RTFStyle *) NULL)
1364 RTFPanic ("%s: cannot allocate stylesheet entry", fn);
1365 sp->rtfSName = (char *) NULL;
1367 sp->rtfSType = rtfParStyle;
1368 sp->rtfSAdditive = 0;
1369 sp->rtfSBasedOn = rtfNoStyleNum;
1370 sp->rtfSNextPar = -1;
1371 sp->rtfSSEList = sepLast = (RTFStyleElt *) NULL;
1372 sp->rtfNextStyle = styleList;
1373 sp->rtfExpanding = 0;
1375 if (!RTFCheckCM (rtfGroup, rtfBeginGroup))
1376 RTFPanic ("%s: missing \"{\"", fn);
1379 (void) RTFGetToken ();
1380 if (rtfClass == rtfEOF
1381 || RTFCheckCM (rtfText, ';'))
1383 if (rtfClass == rtfControl)
1385 if (RTFCheckMM (rtfSpecialChar, rtfOptDest))
1386 continue; /* ignore "\*" */
1387 if (RTFCheckMM (rtfParAttr, rtfStyleNum))
1389 sp->rtfSNum = rtfParam;
1390 sp->rtfSType = rtfParStyle;
1393 if (RTFCheckMM (rtfCharAttr, rtfCharStyleNum))
1395 sp->rtfSNum = rtfParam;
1396 sp->rtfSType = rtfCharStyle;
1399 if (RTFCheckMM (rtfSectAttr, rtfSectStyleNum))
1401 sp->rtfSNum = rtfParam;
1402 sp->rtfSType = rtfSectStyle;
1405 if (RTFCheckMM (rtfStyleAttr, rtfBasedOn))
1407 sp->rtfSBasedOn = rtfParam;
1410 if (RTFCheckMM (rtfStyleAttr, rtfAdditive))
1412 sp->rtfSAdditive = 1;
1415 if (RTFCheckMM (rtfStyleAttr, rtfNext))
1417 sp->rtfSNextPar = rtfParam;
1420 if ((sep = New (RTFStyleElt)) == (RTFStyleElt *) NULL)
1421 RTFPanic ("%s: cannot allocate style element", fn);
1422 sep->rtfSEClass = rtfClass;
1423 sep->rtfSEMajor = rtfMajor;
1424 sep->rtfSEMinor = rtfMinor;
1425 sep->rtfSEParam = rtfParam;
1426 if ((sep->rtfSEText = RTFStrSave (rtfTextBuf))
1428 RTFPanic ("%s: cannot allocate style element text", fn);
1429 if (sepLast == (RTFStyleElt *) NULL)
1430 sp->rtfSSEList = sep; /* first element */
1431 else /* add to end */
1432 sepLast->rtfNextSE = sep;
1433 sep->rtfNextSE = (RTFStyleElt *) NULL;
1436 else if (RTFCheckCM (rtfGroup, rtfBeginGroup))
1439 * This passes over "{\*\keycode ... }, among
1440 * other things. A temporary (perhaps) hack.
1445 else if (rtfClass == rtfText) /* style name */
1448 while (rtfClass == rtfText)
1450 if (rtfMajor == ';')
1452 /* put back for "for" loop */
1453 (void) RTFUngetToken ();
1457 (void) RTFGetToken ();
1460 if ((sp->rtfSName = RTFStrSave (buf)) == (char *) NULL)
1461 RTFPanic ("%s: cannot allocate style name", fn);
1463 else /* unrecognized */
1465 /* ignore token but announce it */
1466 RTFMsg ("%s: unknown token \"%s\"\n",
1470 (void) RTFGetToken ();
1471 if (!RTFCheckCM (rtfGroup, rtfEndGroup))
1472 RTFPanic ("%s: missing \"}\"", fn);
1475 * Check over the style structure. A name is a must.
1476 * If no style number was specified, check whether it's the
1477 * Normal style (in which case it's given style number
1478 * rtfNormalStyleNum). Note that some "normal" style names
1479 * just begin with "Normal" and can have other stuff following,
1480 * e.g., "Normal,Times 10 point". Ugh.
1482 * Some German RTF writers use "Standard" instead of "Normal".
1484 if (sp->rtfSName == (char *) NULL)
1485 RTFPanic ("%s: missing style name", fn);
1486 if (sp->rtfSNum < 0)
1488 if (strncmp (buf, "Normal", 6) != 0
1489 && strncmp (buf, "Standard", 8) != 0)
1490 RTFPanic ("%s: missing style number", fn);
1491 sp->rtfSNum = rtfNormalStyleNum;
1493 if (sp->rtfSNextPar == -1) /* if \snext not given, */
1494 sp->rtfSNextPar = sp->rtfSNum; /* next is itself */
1496 RTFRouteToken (); /* feed "}" back to router */
1500 static void ReadInfoGroup(void)
1503 RTFRouteToken (); /* feed "}" back to router */
1507 static void ReadPictGroup(void)
1510 RTFRouteToken (); /* feed "}" back to router */
1514 static void ReadObjGroup(void)
1517 RTFRouteToken (); /* feed "}" back to router */
1521 /* ---------------------------------------------------------------------- */
1524 * Routines to return pieces of stylesheet, or font or color tables.
1525 * References to style 0 are mapped onto the Normal style.
1529 RTFStyle *RTFGetStyle(int num)
1535 for (s = styleList; s != (RTFStyle *) NULL; s = s->rtfNextStyle)
1537 if (s->rtfSNum == num)
1540 return (s); /* NULL if not found */
1544 RTFFont *RTFGetFont(int num)
1550 for (f = fontList; f != (RTFFont *) NULL; f = f->rtfNextFont)
1552 if (f->rtfFNum == num)
1555 return (f); /* NULL if not found */
1559 RTFColor *RTFGetColor(int num)
1565 for (c = colorList; c != (RTFColor *) NULL; c = c->rtfNextColor)
1567 if (c->rtfCNum == num)
1570 return (c); /* NULL if not found */
1574 /* ---------------------------------------------------------------------- */
1578 * Expand style n, if there is such a style.
1581 void RTFExpandStyle(int n)
1588 if (n == -1 || (s = RTFGetStyle (n)) == (RTFStyle *) NULL)
1590 if (s->rtfExpanding != 0)
1591 RTFPanic ("Style expansion loop, style %d", n);
1592 s->rtfExpanding = 1; /* set expansion flag for loop detection */
1594 * Expand "based-on" style (unless it's the same as the current
1595 * style -- Normal style usually gives itself as its own based-on
1596 * style). Based-on style expansion is done by synthesizing
1597 * the token that the writer needs to see in order to trigger
1598 * another style expansion, and feeding to token back through
1599 * the router so the writer sees it.
1601 if (n != s->rtfSBasedOn)
1603 RTFSetToken (rtfControl, rtfParAttr, rtfStyleNum,
1604 s->rtfSBasedOn, "\\s");
1608 * Now route the tokens unique to this style. RTFSetToken()
1609 * isn't used because it would add the param value to the end
1610 * of the token text, which already has it in.
1612 for (se = s->rtfSSEList; se != (RTFStyleElt *) NULL; se = se->rtfNextSE)
1614 rtfClass = se->rtfSEClass;
1615 rtfMajor = se->rtfSEMajor;
1616 rtfMinor = se->rtfSEMinor;
1617 rtfParam = se->rtfSEParam;
1618 (void) strcpy (rtfTextBuf, se->rtfSEText);
1619 rtfTextLen = strlen (rtfTextBuf);
1622 s->rtfExpanding = 0; /* done - clear expansion flag */
1626 /* ---------------------------------------------------------------------- */
1629 * Control symbol lookup routines
1633 typedef struct RTFKey RTFKey;
1637 int rtfKMajor; /* major number */
1638 int rtfKMinor; /* minor number */
1639 char *rtfKStr; /* symbol name */
1640 int rtfKHash; /* symbol name hash value */
1644 * A minor number of -1 means the token has no minor number
1645 * (all valid minor numbers are >= 0).
1648 static RTFKey rtfKey[] =
1651 * Special characters
1654 { rtfSpecialChar, rtfIIntVersion, "vern", 0 },
1655 { rtfSpecialChar, rtfICreateTime, "creatim", 0 },
1656 { rtfSpecialChar, rtfIRevisionTime, "revtim", 0 },
1657 { rtfSpecialChar, rtfIPrintTime, "printim", 0 },
1658 { rtfSpecialChar, rtfIBackupTime, "buptim", 0 },
1659 { rtfSpecialChar, rtfIEditTime, "edmins", 0 },
1660 { rtfSpecialChar, rtfIYear, "yr", 0 },
1661 { rtfSpecialChar, rtfIMonth, "mo", 0 },
1662 { rtfSpecialChar, rtfIDay, "dy", 0 },
1663 { rtfSpecialChar, rtfIHour, "hr", 0 },
1664 { rtfSpecialChar, rtfIMinute, "min", 0 },
1665 { rtfSpecialChar, rtfISecond, "sec", 0 },
1666 { rtfSpecialChar, rtfINPages, "nofpages", 0 },
1667 { rtfSpecialChar, rtfINWords, "nofwords", 0 },
1668 { rtfSpecialChar, rtfINChars, "nofchars", 0 },
1669 { rtfSpecialChar, rtfIIntID, "id", 0 },
1671 { rtfSpecialChar, rtfCurHeadDate, "chdate", 0 },
1672 { rtfSpecialChar, rtfCurHeadDateLong, "chdpl", 0 },
1673 { rtfSpecialChar, rtfCurHeadDateAbbrev, "chdpa", 0 },
1674 { rtfSpecialChar, rtfCurHeadTime, "chtime", 0 },
1675 { rtfSpecialChar, rtfCurHeadPage, "chpgn", 0 },
1676 { rtfSpecialChar, rtfSectNum, "sectnum", 0 },
1677 { rtfSpecialChar, rtfCurFNote, "chftn", 0 },
1678 { rtfSpecialChar, rtfCurAnnotRef, "chatn", 0 },
1679 { rtfSpecialChar, rtfFNoteSep, "chftnsep", 0 },
1680 { rtfSpecialChar, rtfFNoteCont, "chftnsepc", 0 },
1681 { rtfSpecialChar, rtfCell, "cell", 0 },
1682 { rtfSpecialChar, rtfRow, "row", 0 },
1683 { rtfSpecialChar, rtfPar, "par", 0 },
1684 /* newline and carriage return are synonyms for */
1685 /* \par when they are preceded by a \ character */
1686 { rtfSpecialChar, rtfPar, "\n", 0 },
1687 { rtfSpecialChar, rtfPar, "\r", 0 },
1688 { rtfSpecialChar, rtfSect, "sect", 0 },
1689 { rtfSpecialChar, rtfPage, "page", 0 },
1690 { rtfSpecialChar, rtfColumn, "column", 0 },
1691 { rtfSpecialChar, rtfLine, "line", 0 },
1692 { rtfSpecialChar, rtfSoftPage, "softpage", 0 },
1693 { rtfSpecialChar, rtfSoftColumn, "softcol", 0 },
1694 { rtfSpecialChar, rtfSoftLine, "softline", 0 },
1695 { rtfSpecialChar, rtfSoftLineHt, "softlheight", 0 },
1696 { rtfSpecialChar, rtfTab, "tab", 0 },
1697 { rtfSpecialChar, rtfEmDash, "emdash", 0 },
1698 { rtfSpecialChar, rtfEnDash, "endash", 0 },
1699 { rtfSpecialChar, rtfEmSpace, "emspace", 0 },
1700 { rtfSpecialChar, rtfEnSpace, "enspace", 0 },
1701 { rtfSpecialChar, rtfBullet, "bullet", 0 },
1702 { rtfSpecialChar, rtfLQuote, "lquote", 0 },
1703 { rtfSpecialChar, rtfRQuote, "rquote", 0 },
1704 { rtfSpecialChar, rtfLDblQuote, "ldblquote", 0 },
1705 { rtfSpecialChar, rtfRDblQuote, "rdblquote", 0 },
1706 { rtfSpecialChar, rtfFormula, "|", 0 },
1707 { rtfSpecialChar, rtfNoBrkSpace, "~", 0 },
1708 { rtfSpecialChar, rtfNoReqHyphen, "-", 0 },
1709 { rtfSpecialChar, rtfNoBrkHyphen, "_", 0 },
1710 { rtfSpecialChar, rtfOptDest, "*", 0 },
1711 { rtfSpecialChar, rtfLTRMark, "ltrmark", 0 },
1712 { rtfSpecialChar, rtfRTLMark, "rtlmark", 0 },
1713 { rtfSpecialChar, rtfNoWidthJoiner, "zwj", 0 },
1714 { rtfSpecialChar, rtfNoWidthNonJoiner, "zwnj", 0 },
1715 /* is this valid? */
1716 { rtfSpecialChar, rtfCurHeadPict, "chpict", 0 },
1719 * Character formatting attributes
1722 { rtfCharAttr, rtfPlain, "plain", 0 },
1723 { rtfCharAttr, rtfBold, "b", 0 },
1724 { rtfCharAttr, rtfAllCaps, "caps", 0 },
1725 { rtfCharAttr, rtfDeleted, "deleted", 0 },
1726 { rtfCharAttr, rtfSubScript, "dn", 0 },
1727 { rtfCharAttr, rtfSubScrShrink, "sub", 0 },
1728 { rtfCharAttr, rtfNoSuperSub, "nosupersub", 0 },
1729 { rtfCharAttr, rtfExpand, "expnd", 0 },
1730 { rtfCharAttr, rtfExpandTwips, "expndtw", 0 },
1731 { rtfCharAttr, rtfKerning, "kerning", 0 },
1732 { rtfCharAttr, rtfFontNum, "f", 0 },
1733 { rtfCharAttr, rtfFontSize, "fs", 0 },
1734 { rtfCharAttr, rtfItalic, "i", 0 },
1735 { rtfCharAttr, rtfOutline, "outl", 0 },
1736 { rtfCharAttr, rtfRevised, "revised", 0 },
1737 { rtfCharAttr, rtfRevAuthor, "revauth", 0 },
1738 { rtfCharAttr, rtfRevDTTM, "revdttm", 0 },
1739 { rtfCharAttr, rtfSmallCaps, "scaps", 0 },
1740 { rtfCharAttr, rtfShadow, "shad", 0 },
1741 { rtfCharAttr, rtfStrikeThru, "strike", 0 },
1742 { rtfCharAttr, rtfUnderline, "ul", 0 },
1743 { rtfCharAttr, rtfDotUnderline, "uld", 0 },
1744 { rtfCharAttr, rtfDbUnderline, "uldb", 0 },
1745 { rtfCharAttr, rtfNoUnderline, "ulnone", 0 },
1746 { rtfCharAttr, rtfWordUnderline, "ulw", 0 },
1747 { rtfCharAttr, rtfSuperScript, "up", 0 },
1748 { rtfCharAttr, rtfSuperScrShrink, "super", 0 },
1749 { rtfCharAttr, rtfInvisible, "v", 0 },
1750 { rtfCharAttr, rtfForeColor, "cf", 0 },
1751 { rtfCharAttr, rtfBackColor, "cb", 0 },
1752 { rtfCharAttr, rtfRTLChar, "rtlch", 0 },
1753 { rtfCharAttr, rtfLTRChar, "ltrch", 0 },
1754 { rtfCharAttr, rtfCharStyleNum, "cs", 0 },
1755 { rtfCharAttr, rtfCharCharSet, "cchs", 0 },
1756 { rtfCharAttr, rtfLanguage, "lang", 0 },
1757 /* this has disappeared from spec 1.2 */
1758 { rtfCharAttr, rtfGray, "gray", 0 },
1761 * Paragraph formatting attributes
1764 { rtfParAttr, rtfParDef, "pard", 0 },
1765 { rtfParAttr, rtfStyleNum, "s", 0 },
1766 { rtfParAttr, rtfHyphenate, "hyphpar", 0 },
1767 { rtfParAttr, rtfInTable, "intbl", 0 },
1768 { rtfParAttr, rtfKeep, "keep", 0 },
1769 { rtfParAttr, rtfNoWidowControl, "nowidctlpar", 0 },
1770 { rtfParAttr, rtfKeepNext, "keepn", 0 },
1771 { rtfParAttr, rtfOutlineLevel, "level", 0 },
1772 { rtfParAttr, rtfNoLineNum, "noline", 0 },
1773 { rtfParAttr, rtfPBBefore, "pagebb", 0 },
1774 { rtfParAttr, rtfSideBySide, "sbys", 0 },
1775 { rtfParAttr, rtfQuadLeft, "ql", 0 },
1776 { rtfParAttr, rtfQuadRight, "qr", 0 },
1777 { rtfParAttr, rtfQuadJust, "qj", 0 },
1778 { rtfParAttr, rtfQuadCenter, "qc", 0 },
1779 { rtfParAttr, rtfFirstIndent, "fi", 0 },
1780 { rtfParAttr, rtfLeftIndent, "li", 0 },
1781 { rtfParAttr, rtfRightIndent, "ri", 0 },
1782 { rtfParAttr, rtfSpaceBefore, "sb", 0 },
1783 { rtfParAttr, rtfSpaceAfter, "sa", 0 },
1784 { rtfParAttr, rtfSpaceBetween, "sl", 0 },
1785 { rtfParAttr, rtfSpaceMultiply, "slmult", 0 },
1787 { rtfParAttr, rtfSubDocument, "subdocument", 0 },
1789 { rtfParAttr, rtfRTLPar, "rtlpar", 0 },
1790 { rtfParAttr, rtfLTRPar, "ltrpar", 0 },
1792 { rtfParAttr, rtfTabPos, "tx", 0 },
1794 * FrameMaker writes \tql (to mean left-justified tab, apparently)
1795 * although it's not in the spec. It's also redundant, since lj
1796 * tabs are the default.
1798 { rtfParAttr, rtfTabLeft, "tql", 0 },
1799 { rtfParAttr, rtfTabRight, "tqr", 0 },
1800 { rtfParAttr, rtfTabCenter, "tqc", 0 },
1801 { rtfParAttr, rtfTabDecimal, "tqdec", 0 },
1802 { rtfParAttr, rtfTabBar, "tb", 0 },
1803 { rtfParAttr, rtfLeaderDot, "tldot", 0 },
1804 { rtfParAttr, rtfLeaderHyphen, "tlhyph", 0 },
1805 { rtfParAttr, rtfLeaderUnder, "tlul", 0 },
1806 { rtfParAttr, rtfLeaderThick, "tlth", 0 },
1807 { rtfParAttr, rtfLeaderEqual, "tleq", 0 },
1809 { rtfParAttr, rtfParLevel, "pnlvl", 0 },
1810 { rtfParAttr, rtfParBullet, "pnlvlblt", 0 },
1811 { rtfParAttr, rtfParSimple, "pnlvlbody", 0 },
1812 { rtfParAttr, rtfParNumCont, "pnlvlcont", 0 },
1813 { rtfParAttr, rtfParNumOnce, "pnnumonce", 0 },
1814 { rtfParAttr, rtfParNumAcross, "pnacross", 0 },
1815 { rtfParAttr, rtfParHangIndent, "pnhang", 0 },
1816 { rtfParAttr, rtfParNumRestart, "pnrestart", 0 },
1817 { rtfParAttr, rtfParNumCardinal, "pncard", 0 },
1818 { rtfParAttr, rtfParNumDecimal, "pndec", 0 },
1819 { rtfParAttr, rtfParNumULetter, "pnucltr", 0 },
1820 { rtfParAttr, rtfParNumURoman, "pnucrm", 0 },
1821 { rtfParAttr, rtfParNumLLetter, "pnlcltr", 0 },
1822 { rtfParAttr, rtfParNumLRoman, "pnlcrm", 0 },
1823 { rtfParAttr, rtfParNumOrdinal, "pnord", 0 },
1824 { rtfParAttr, rtfParNumOrdinalText, "pnordt", 0 },
1825 { rtfParAttr, rtfParNumBold, "pnb", 0 },
1826 { rtfParAttr, rtfParNumItalic, "pni", 0 },
1827 { rtfParAttr, rtfParNumAllCaps, "pncaps", 0 },
1828 { rtfParAttr, rtfParNumSmallCaps, "pnscaps", 0 },
1829 { rtfParAttr, rtfParNumUnder, "pnul", 0 },
1830 { rtfParAttr, rtfParNumDotUnder, "pnuld", 0 },
1831 { rtfParAttr, rtfParNumDbUnder, "pnuldb", 0 },
1832 { rtfParAttr, rtfParNumNoUnder, "pnulnone", 0 },
1833 { rtfParAttr, rtfParNumWordUnder, "pnulw", 0 },
1834 { rtfParAttr, rtfParNumStrikethru, "pnstrike", 0 },
1835 { rtfParAttr, rtfParNumForeColor, "pncf", 0 },
1836 { rtfParAttr, rtfParNumFont, "pnf", 0 },
1837 { rtfParAttr, rtfParNumFontSize, "pnfs", 0 },
1838 { rtfParAttr, rtfParNumIndent, "pnindent", 0 },
1839 { rtfParAttr, rtfParNumSpacing, "pnsp", 0 },
1840 { rtfParAttr, rtfParNumInclPrev, "pnprev", 0 },
1841 { rtfParAttr, rtfParNumCenter, "pnqc", 0 },
1842 { rtfParAttr, rtfParNumLeft, "pnql", 0 },
1843 { rtfParAttr, rtfParNumRight, "pnqr", 0 },
1844 { rtfParAttr, rtfParNumStartAt, "pnstart", 0 },
1846 { rtfParAttr, rtfBorderTop, "brdrt", 0 },
1847 { rtfParAttr, rtfBorderBottom, "brdrb", 0 },
1848 { rtfParAttr, rtfBorderLeft, "brdrl", 0 },
1849 { rtfParAttr, rtfBorderRight, "brdrr", 0 },
1850 { rtfParAttr, rtfBorderBetween, "brdrbtw", 0 },
1851 { rtfParAttr, rtfBorderBar, "brdrbar", 0 },
1852 { rtfParAttr, rtfBorderBox, "box", 0 },
1853 { rtfParAttr, rtfBorderSingle, "brdrs", 0 },
1854 { rtfParAttr, rtfBorderThick, "brdrth", 0 },
1855 { rtfParAttr, rtfBorderShadow, "brdrsh", 0 },
1856 { rtfParAttr, rtfBorderDouble, "brdrdb", 0 },
1857 { rtfParAttr, rtfBorderDot, "brdrdot", 0 },
1858 { rtfParAttr, rtfBorderDot, "brdrdash", 0 },
1859 { rtfParAttr, rtfBorderHair, "brdrhair", 0 },
1860 { rtfParAttr, rtfBorderWidth, "brdrw", 0 },
1861 { rtfParAttr, rtfBorderColor, "brdrcf", 0 },
1862 { rtfParAttr, rtfBorderSpace, "brsp", 0 },
1864 { rtfParAttr, rtfShading, "shading", 0 },
1865 { rtfParAttr, rtfBgPatH, "bghoriz", 0 },
1866 { rtfParAttr, rtfBgPatV, "bgvert", 0 },
1867 { rtfParAttr, rtfFwdDiagBgPat, "bgfdiag", 0 },
1868 { rtfParAttr, rtfBwdDiagBgPat, "bgbdiag", 0 },
1869 { rtfParAttr, rtfHatchBgPat, "bgcross", 0 },
1870 { rtfParAttr, rtfDiagHatchBgPat, "bgdcross", 0 },
1871 { rtfParAttr, rtfDarkBgPatH, "bgdkhoriz", 0 },
1872 { rtfParAttr, rtfDarkBgPatV, "bgdkvert", 0 },
1873 { rtfParAttr, rtfFwdDarkBgPat, "bgdkfdiag", 0 },
1874 { rtfParAttr, rtfBwdDarkBgPat, "bgdkbdiag", 0 },
1875 { rtfParAttr, rtfDarkHatchBgPat, "bgdkcross", 0 },
1876 { rtfParAttr, rtfDarkDiagHatchBgPat, "bgdkdcross", 0 },
1877 { rtfParAttr, rtfBgPatLineColor, "cfpat", 0 },
1878 { rtfParAttr, rtfBgPatColor, "cbpat", 0 },
1881 * Section formatting attributes
1884 { rtfSectAttr, rtfSectDef, "sectd", 0 },
1885 { rtfSectAttr, rtfENoteHere, "endnhere", 0 },
1886 { rtfSectAttr, rtfPrtBinFirst, "binfsxn", 0 },
1887 { rtfSectAttr, rtfPrtBin, "binsxn", 0 },
1888 { rtfSectAttr, rtfSectStyleNum, "ds", 0 },
1890 { rtfSectAttr, rtfNoBreak, "sbknone", 0 },
1891 { rtfSectAttr, rtfColBreak, "sbkcol", 0 },
1892 { rtfSectAttr, rtfPageBreak, "sbkpage", 0 },
1893 { rtfSectAttr, rtfEvenBreak, "sbkeven", 0 },
1894 { rtfSectAttr, rtfOddBreak, "sbkodd", 0 },
1896 { rtfSectAttr, rtfColumns, "cols", 0 },
1897 { rtfSectAttr, rtfColumnSpace, "colsx", 0 },
1898 { rtfSectAttr, rtfColumnNumber, "colno", 0 },
1899 { rtfSectAttr, rtfColumnSpRight, "colsr", 0 },
1900 { rtfSectAttr, rtfColumnWidth, "colw", 0 },
1901 { rtfSectAttr, rtfColumnLine, "linebetcol", 0 },
1903 { rtfSectAttr, rtfLineModulus, "linemod", 0 },
1904 { rtfSectAttr, rtfLineDist, "linex", 0 },
1905 { rtfSectAttr, rtfLineStarts, "linestarts", 0 },
1906 { rtfSectAttr, rtfLineRestart, "linerestart", 0 },
1907 { rtfSectAttr, rtfLineRestartPg, "lineppage", 0 },
1908 { rtfSectAttr, rtfLineCont, "linecont", 0 },
1910 { rtfSectAttr, rtfSectPageWid, "pgwsxn", 0 },
1911 { rtfSectAttr, rtfSectPageHt, "pghsxn", 0 },
1912 { rtfSectAttr, rtfSectMarginLeft, "marglsxn", 0 },
1913 { rtfSectAttr, rtfSectMarginRight, "margrsxn", 0 },
1914 { rtfSectAttr, rtfSectMarginTop, "margtsxn", 0 },
1915 { rtfSectAttr, rtfSectMarginBottom, "margbsxn", 0 },
1916 { rtfSectAttr, rtfSectMarginGutter, "guttersxn", 0 },
1917 { rtfSectAttr, rtfSectLandscape, "lndscpsxn", 0 },
1918 { rtfSectAttr, rtfTitleSpecial, "titlepg", 0 },
1919 { rtfSectAttr, rtfHeaderY, "headery", 0 },
1920 { rtfSectAttr, rtfFooterY, "footery", 0 },
1922 { rtfSectAttr, rtfPageStarts, "pgnstarts", 0 },
1923 { rtfSectAttr, rtfPageCont, "pgncont", 0 },
1924 { rtfSectAttr, rtfPageRestart, "pgnrestart", 0 },
1925 { rtfSectAttr, rtfPageNumRight, "pgnx", 0 },
1926 { rtfSectAttr, rtfPageNumTop, "pgny", 0 },
1927 { rtfSectAttr, rtfPageDecimal, "pgndec", 0 },
1928 { rtfSectAttr, rtfPageURoman, "pgnucrm", 0 },
1929 { rtfSectAttr, rtfPageLRoman, "pgnlcrm", 0 },
1930 { rtfSectAttr, rtfPageULetter, "pgnucltr", 0 },
1931 { rtfSectAttr, rtfPageLLetter, "pgnlcltr", 0 },
1932 { rtfSectAttr, rtfPageNumHyphSep, "pgnhnsh", 0 },
1933 { rtfSectAttr, rtfPageNumSpaceSep, "pgnhnsp", 0 },
1934 { rtfSectAttr, rtfPageNumColonSep, "pgnhnsc", 0 },
1935 { rtfSectAttr, rtfPageNumEmdashSep, "pgnhnsm", 0 },
1936 { rtfSectAttr, rtfPageNumEndashSep, "pgnhnsn", 0 },
1938 { rtfSectAttr, rtfTopVAlign, "vertalt", 0 },
1939 /* misspelled as "vertal" in specification 1.0 */
1940 { rtfSectAttr, rtfBottomVAlign, "vertalb", 0 },
1941 { rtfSectAttr, rtfCenterVAlign, "vertalc", 0 },
1942 { rtfSectAttr, rtfJustVAlign, "vertalj", 0 },
1944 { rtfSectAttr, rtfRTLSect, "rtlsect", 0 },
1945 { rtfSectAttr, rtfLTRSect, "ltrsect", 0 },
1947 /* I've seen these in an old spec, but not in real files... */
1948 /*rtfSectAttr, rtfNoBreak, "nobreak", 0,*/
1949 /*rtfSectAttr, rtfColBreak, "colbreak", 0,*/
1950 /*rtfSectAttr, rtfPageBreak, "pagebreak", 0,*/
1951 /*rtfSectAttr, rtfEvenBreak, "evenbreak", 0,*/
1952 /*rtfSectAttr, rtfOddBreak, "oddbreak", 0,*/
1955 * Document formatting attributes
1958 { rtfDocAttr, rtfDefTab, "deftab", 0 },
1959 { rtfDocAttr, rtfHyphHotZone, "hyphhotz", 0 },
1960 { rtfDocAttr, rtfHyphConsecLines, "hyphconsec", 0 },
1961 { rtfDocAttr, rtfHyphCaps, "hyphcaps", 0 },
1962 { rtfDocAttr, rtfHyphAuto, "hyphauto", 0 },
1963 { rtfDocAttr, rtfLineStart, "linestart", 0 },
1964 { rtfDocAttr, rtfFracWidth, "fracwidth", 0 },
1965 /* \makeback was given in old version of spec, it's now */
1966 /* listed as \makebackup */
1967 { rtfDocAttr, rtfMakeBackup, "makeback", 0 },
1968 { rtfDocAttr, rtfMakeBackup, "makebackup", 0 },
1969 { rtfDocAttr, rtfRTFDefault, "defformat", 0 },
1970 { rtfDocAttr, rtfPSOverlay, "psover", 0 },
1971 { rtfDocAttr, rtfDocTemplate, "doctemp", 0 },
1972 { rtfDocAttr, rtfDefLanguage, "deflang", 0 },
1974 { rtfDocAttr, rtfFENoteType, "fet", 0 },
1975 { rtfDocAttr, rtfFNoteEndSect, "endnotes", 0 },
1976 { rtfDocAttr, rtfFNoteEndDoc, "enddoc", 0 },
1977 { rtfDocAttr, rtfFNoteText, "ftntj", 0 },
1978 { rtfDocAttr, rtfFNoteBottom, "ftnbj", 0 },
1979 { rtfDocAttr, rtfENoteEndSect, "aendnotes", 0 },
1980 { rtfDocAttr, rtfENoteEndDoc, "aenddoc", 0 },
1981 { rtfDocAttr, rtfENoteText, "aftntj", 0 },
1982 { rtfDocAttr, rtfENoteBottom, "aftnbj", 0 },
1983 { rtfDocAttr, rtfFNoteStart, "ftnstart", 0 },
1984 { rtfDocAttr, rtfENoteStart, "aftnstart", 0 },
1985 { rtfDocAttr, rtfFNoteRestartPage, "ftnrstpg", 0 },
1986 { rtfDocAttr, rtfFNoteRestart, "ftnrestart", 0 },
1987 { rtfDocAttr, rtfFNoteRestartCont, "ftnrstcont", 0 },
1988 { rtfDocAttr, rtfENoteRestart, "aftnrestart", 0 },
1989 { rtfDocAttr, rtfENoteRestartCont, "aftnrstcont", 0 },
1990 { rtfDocAttr, rtfFNoteNumArabic, "ftnnar", 0 },
1991 { rtfDocAttr, rtfFNoteNumLLetter, "ftnnalc", 0 },
1992 { rtfDocAttr, rtfFNoteNumULetter, "ftnnauc", 0 },
1993 { rtfDocAttr, rtfFNoteNumLRoman, "ftnnrlc", 0 },
1994 { rtfDocAttr, rtfFNoteNumURoman, "ftnnruc", 0 },
1995 { rtfDocAttr, rtfFNoteNumChicago, "ftnnchi", 0 },
1996 { rtfDocAttr, rtfENoteNumArabic, "aftnnar", 0 },
1997 { rtfDocAttr, rtfENoteNumLLetter, "aftnnalc", 0 },
1998 { rtfDocAttr, rtfENoteNumULetter, "aftnnauc", 0 },
1999 { rtfDocAttr, rtfENoteNumLRoman, "aftnnrlc", 0 },
2000 { rtfDocAttr, rtfENoteNumURoman, "aftnnruc", 0 },
2001 { rtfDocAttr, rtfENoteNumChicago, "aftnnchi", 0 },
2003 { rtfDocAttr, rtfPaperWidth, "paperw", 0 },
2004 { rtfDocAttr, rtfPaperHeight, "paperh", 0 },
2005 { rtfDocAttr, rtfPaperSize, "psz", 0 },
2006 { rtfDocAttr, rtfLeftMargin, "margl", 0 },
2007 { rtfDocAttr, rtfRightMargin, "margr", 0 },
2008 { rtfDocAttr, rtfTopMargin, "margt", 0 },
2009 { rtfDocAttr, rtfBottomMargin, "margb", 0 },
2010 { rtfDocAttr, rtfFacingPage, "facingp", 0 },
2011 { rtfDocAttr, rtfGutterWid, "gutter", 0 },
2012 { rtfDocAttr, rtfMirrorMargin, "margmirror", 0 },
2013 { rtfDocAttr, rtfLandscape, "landscape", 0 },
2014 { rtfDocAttr, rtfPageStart, "pgnstart", 0 },
2015 { rtfDocAttr, rtfWidowCtrl, "widowctrl", 0 },
2017 { rtfDocAttr, rtfLinkStyles, "linkstyles", 0 },
2019 { rtfDocAttr, rtfNoAutoTabIndent, "notabind", 0 },
2020 { rtfDocAttr, rtfWrapSpaces, "wraptrsp", 0 },
2021 { rtfDocAttr, rtfPrintColorsBlack, "prcolbl", 0 },
2022 { rtfDocAttr, rtfNoExtraSpaceRL, "noextrasprl", 0 },
2023 { rtfDocAttr, rtfNoColumnBalance, "nocolbal", 0 },
2024 { rtfDocAttr, rtfCvtMailMergeQuote, "cvmme", 0 },
2025 { rtfDocAttr, rtfSuppressTopSpace, "sprstsp", 0 },
2026 { rtfDocAttr, rtfSuppressPreParSpace, "sprsspbf", 0 },
2027 { rtfDocAttr, rtfCombineTblBorders, "otblrul", 0 },
2028 { rtfDocAttr, rtfTranspMetafiles, "transmf", 0 },
2029 { rtfDocAttr, rtfSwapBorders, "swpbdr", 0 },
2030 { rtfDocAttr, rtfShowHardBreaks, "brkfrm", 0 },
2032 { rtfDocAttr, rtfFormProtected, "formprot", 0 },
2033 { rtfDocAttr, rtfAllProtected, "allprot", 0 },
2034 { rtfDocAttr, rtfFormShading, "formshade", 0 },
2035 { rtfDocAttr, rtfFormDisplay, "formdisp", 0 },
2036 { rtfDocAttr, rtfPrintData, "printdata", 0 },
2038 { rtfDocAttr, rtfRevProtected, "revprot", 0 },
2039 { rtfDocAttr, rtfRevisions, "revisions", 0 },
2040 { rtfDocAttr, rtfRevDisplay, "revprop", 0 },
2041 { rtfDocAttr, rtfRevBar, "revbar", 0 },
2043 { rtfDocAttr, rtfAnnotProtected, "annotprot", 0 },
2045 { rtfDocAttr, rtfRTLDoc, "rtldoc", 0 },
2046 { rtfDocAttr, rtfLTRDoc, "ltrdoc", 0 },
2052 { rtfStyleAttr, rtfAdditive, "additive", 0 },
2053 { rtfStyleAttr, rtfBasedOn, "sbasedon", 0 },
2054 { rtfStyleAttr, rtfNext, "snext", 0 },
2057 * Picture attributes
2060 { rtfPictAttr, rtfMacQD, "macpict", 0 },
2061 { rtfPictAttr, rtfPMMetafile, "pmmetafile", 0 },
2062 { rtfPictAttr, rtfWinMetafile, "wmetafile", 0 },
2063 { rtfPictAttr, rtfDevIndBitmap, "dibitmap", 0 },
2064 { rtfPictAttr, rtfWinBitmap, "wbitmap", 0 },
2065 { rtfPictAttr, rtfPixelBits, "wbmbitspixel", 0 },
2066 { rtfPictAttr, rtfBitmapPlanes, "wbmplanes", 0 },
2067 { rtfPictAttr, rtfBitmapWid, "wbmwidthbytes", 0 },
2069 { rtfPictAttr, rtfPicWid, "picw", 0 },
2070 { rtfPictAttr, rtfPicHt, "pich", 0 },
2071 { rtfPictAttr, rtfPicGoalWid, "picwgoal", 0 },
2072 { rtfPictAttr, rtfPicGoalHt, "pichgoal", 0 },
2073 /* these two aren't in the spec, but some writers emit them */
2074 { rtfPictAttr, rtfPicGoalWid, "picwGoal", 0 },
2075 { rtfPictAttr, rtfPicGoalHt, "pichGoal", 0 },
2076 { rtfPictAttr, rtfPicScaleX, "picscalex", 0 },
2077 { rtfPictAttr, rtfPicScaleY, "picscaley", 0 },
2078 { rtfPictAttr, rtfPicScaled, "picscaled", 0 },
2079 { rtfPictAttr, rtfPicCropTop, "piccropt", 0 },
2080 { rtfPictAttr, rtfPicCropBottom, "piccropb", 0 },
2081 { rtfPictAttr, rtfPicCropLeft, "piccropl", 0 },
2082 { rtfPictAttr, rtfPicCropRight, "piccropr", 0 },
2084 { rtfPictAttr, rtfPicMFHasBitmap, "picbmp", 0 },
2085 { rtfPictAttr, rtfPicMFBitsPerPixel, "picbpp", 0 },
2087 { rtfPictAttr, rtfPicBinary, "bin", 0 },
2090 * NeXT graphic attributes
2093 { rtfNeXTGrAttr, rtfNeXTGWidth, "width", 0 },
2094 { rtfNeXTGrAttr, rtfNeXTGHeight, "height", 0 },
2100 { rtfDestination, rtfFontTbl, "fonttbl", 0 },
2101 { rtfDestination, rtfFontAltName, "falt", 0 },
2102 { rtfDestination, rtfEmbeddedFont, "fonteb", 0 },
2103 { rtfDestination, rtfFontFile, "fontfile", 0 },
2104 { rtfDestination, rtfFileTbl, "filetbl", 0 },
2105 { rtfDestination, rtfFileInfo, "file", 0 },
2106 { rtfDestination, rtfColorTbl, "colortbl", 0 },
2107 { rtfDestination, rtfStyleSheet, "stylesheet", 0 },
2108 { rtfDestination, rtfKeyCode, "keycode", 0 },
2109 { rtfDestination, rtfRevisionTbl, "revtbl", 0 },
2110 { rtfDestination, rtfInfo, "info", 0 },
2111 { rtfDestination, rtfITitle, "title", 0 },
2112 { rtfDestination, rtfISubject, "subject", 0 },
2113 { rtfDestination, rtfIAuthor, "author", 0 },
2114 { rtfDestination, rtfIOperator, "operator", 0 },
2115 { rtfDestination, rtfIKeywords, "keywords", 0 },
2116 { rtfDestination, rtfIComment, "comment", 0 },
2117 { rtfDestination, rtfIVersion, "version", 0 },
2118 { rtfDestination, rtfIDoccomm, "doccomm", 0 },
2119 /* \verscomm may not exist -- was seen in earlier spec version */
2120 { rtfDestination, rtfIVerscomm, "verscomm", 0 },
2121 { rtfDestination, rtfNextFile, "nextfile", 0 },
2122 { rtfDestination, rtfTemplate, "template", 0 },
2123 { rtfDestination, rtfFNSep, "ftnsep", 0 },
2124 { rtfDestination, rtfFNContSep, "ftnsepc", 0 },
2125 { rtfDestination, rtfFNContNotice, "ftncn", 0 },
2126 { rtfDestination, rtfENSep, "aftnsep", 0 },
2127 { rtfDestination, rtfENContSep, "aftnsepc", 0 },
2128 { rtfDestination, rtfENContNotice, "aftncn", 0 },
2129 { rtfDestination, rtfPageNumLevel, "pgnhn", 0 },
2130 { rtfDestination, rtfParNumLevelStyle, "pnseclvl", 0 },
2131 { rtfDestination, rtfHeader, "header", 0 },
2132 { rtfDestination, rtfFooter, "footer", 0 },
2133 { rtfDestination, rtfHeaderLeft, "headerl", 0 },
2134 { rtfDestination, rtfHeaderRight, "headerr", 0 },
2135 { rtfDestination, rtfHeaderFirst, "headerf", 0 },
2136 { rtfDestination, rtfFooterLeft, "footerl", 0 },
2137 { rtfDestination, rtfFooterRight, "footerr", 0 },
2138 { rtfDestination, rtfFooterFirst, "footerf", 0 },
2139 { rtfDestination, rtfParNumText, "pntext", 0 },
2140 { rtfDestination, rtfParNumbering, "pn", 0 },
2141 { rtfDestination, rtfParNumTextAfter, "pntexta", 0 },
2142 { rtfDestination, rtfParNumTextBefore, "pntextb", 0 },
2143 { rtfDestination, rtfBookmarkStart, "bkmkstart", 0 },
2144 { rtfDestination, rtfBookmarkEnd, "bkmkend", 0 },
2145 { rtfDestination, rtfPict, "pict", 0 },
2146 { rtfDestination, rtfObject, "object", 0 },
2147 { rtfDestination, rtfObjClass, "objclass", 0 },
2148 { rtfDestination, rtfObjName, "objname", 0 },
2149 { rtfObjAttr, rtfObjTime, "objtime", 0 },
2150 { rtfDestination, rtfObjData, "objdata", 0 },
2151 { rtfDestination, rtfObjAlias, "objalias", 0 },
2152 { rtfDestination, rtfObjSection, "objsect", 0 },
2153 /* objitem and objtopic aren't documented in the spec! */
2154 { rtfDestination, rtfObjItem, "objitem", 0 },
2155 { rtfDestination, rtfObjTopic, "objtopic", 0 },
2156 { rtfDestination, rtfObjResult, "result", 0 },
2157 { rtfDestination, rtfDrawObject, "do", 0 },
2158 { rtfDestination, rtfFootnote, "footnote", 0 },
2159 { rtfDestination, rtfAnnotRefStart, "atrfstart", 0 },
2160 { rtfDestination, rtfAnnotRefEnd, "atrfend", 0 },
2161 { rtfDestination, rtfAnnotID, "atnid", 0 },
2162 { rtfDestination, rtfAnnotAuthor, "atnauthor", 0 },
2163 { rtfDestination, rtfAnnotation, "annotation", 0 },
2164 { rtfDestination, rtfAnnotRef, "atnref", 0 },
2165 { rtfDestination, rtfAnnotTime, "atntime", 0 },
2166 { rtfDestination, rtfAnnotIcon, "atnicn", 0 },
2167 { rtfDestination, rtfField, "field", 0 },
2168 { rtfDestination, rtfFieldInst, "fldinst", 0 },
2169 { rtfDestination, rtfFieldResult, "fldrslt", 0 },
2170 { rtfDestination, rtfDataField, "datafield", 0 },
2171 { rtfDestination, rtfIndex, "xe", 0 },
2172 { rtfDestination, rtfIndexText, "txe", 0 },
2173 { rtfDestination, rtfIndexRange, "rxe", 0 },
2174 { rtfDestination, rtfTOC, "tc", 0 },
2175 { rtfDestination, rtfNeXTGraphic, "NeXTGraphic", 0 },
2181 { rtfFontFamily, rtfFFNil, "fnil", 0 },
2182 { rtfFontFamily, rtfFFRoman, "froman", 0 },
2183 { rtfFontFamily, rtfFFSwiss, "fswiss", 0 },
2184 { rtfFontFamily, rtfFFModern, "fmodern", 0 },
2185 { rtfFontFamily, rtfFFScript, "fscript", 0 },
2186 { rtfFontFamily, rtfFFDecor, "fdecor", 0 },
2187 { rtfFontFamily, rtfFFTech, "ftech", 0 },
2188 { rtfFontFamily, rtfFFBidirectional, "fbidi", 0 },
2194 { rtfFontAttr, rtfFontCharSet, "fcharset", 0 },
2195 { rtfFontAttr, rtfFontPitch, "fprq", 0 },
2196 { rtfFontAttr, rtfFontCodePage, "cpg", 0 },
2197 { rtfFontAttr, rtfFTypeNil, "ftnil", 0 },
2198 { rtfFontAttr, rtfFTypeTrueType, "fttruetype", 0 },
2201 * File table attributes
2204 { rtfFileAttr, rtfFileNum, "fid", 0 },
2205 { rtfFileAttr, rtfFileRelPath, "frelative", 0 },
2206 { rtfFileAttr, rtfFileOSNum, "fosnum", 0 },
2212 { rtfFileSource, rtfSrcMacintosh, "fvalidmac", 0 },
2213 { rtfFileSource, rtfSrcDOS, "fvaliddos", 0 },
2214 { rtfFileSource, rtfSrcNTFS, "fvalidntfs", 0 },
2215 { rtfFileSource, rtfSrcHPFS, "fvalidhpfs", 0 },
2216 { rtfFileSource, rtfSrcNetwork, "fnetwork", 0 },
2222 { rtfColorName, rtfRed, "red", 0 },
2223 { rtfColorName, rtfGreen, "green", 0 },
2224 { rtfColorName, rtfBlue, "blue", 0 },
2230 { rtfCharSet, rtfMacCharSet, "mac", 0 },
2231 { rtfCharSet, rtfAnsiCharSet, "ansi", 0 },
2232 { rtfCharSet, rtfPcCharSet, "pc", 0 },
2233 { rtfCharSet, rtfPcaCharSet, "pca", 0 },
2239 { rtfTblAttr, rtfRowDef, "trowd", 0 },
2240 { rtfTblAttr, rtfRowGapH, "trgaph", 0 },
2241 { rtfTblAttr, rtfCellPos, "cellx", 0 },
2242 { rtfTblAttr, rtfMergeRngFirst, "clmgf", 0 },
2243 { rtfTblAttr, rtfMergePrevious, "clmrg", 0 },
2245 { rtfTblAttr, rtfRowLeft, "trql", 0 },
2246 { rtfTblAttr, rtfRowRight, "trqr", 0 },
2247 { rtfTblAttr, rtfRowCenter, "trqc", 0 },
2248 { rtfTblAttr, rtfRowLeftEdge, "trleft", 0 },
2249 { rtfTblAttr, rtfRowHt, "trrh", 0 },
2250 { rtfTblAttr, rtfRowHeader, "trhdr", 0 },
2251 { rtfTblAttr, rtfRowKeep, "trkeep", 0 },
2253 { rtfTblAttr, rtfRTLRow, "rtlrow", 0 },
2254 { rtfTblAttr, rtfLTRRow, "ltrrow", 0 },
2256 { rtfTblAttr, rtfRowBordTop, "trbrdrt", 0 },
2257 { rtfTblAttr, rtfRowBordLeft, "trbrdrl", 0 },
2258 { rtfTblAttr, rtfRowBordBottom, "trbrdrb", 0 },
2259 { rtfTblAttr, rtfRowBordRight, "trbrdrr", 0 },
2260 { rtfTblAttr, rtfRowBordHoriz, "trbrdrh", 0 },
2261 { rtfTblAttr, rtfRowBordVert, "trbrdrv", 0 },
2263 { rtfTblAttr, rtfCellBordBottom, "clbrdrb", 0 },
2264 { rtfTblAttr, rtfCellBordTop, "clbrdrt", 0 },
2265 { rtfTblAttr, rtfCellBordLeft, "clbrdrl", 0 },
2266 { rtfTblAttr, rtfCellBordRight, "clbrdrr", 0 },
2268 { rtfTblAttr, rtfCellShading, "clshdng", 0 },
2269 { rtfTblAttr, rtfCellBgPatH, "clbghoriz", 0 },
2270 { rtfTblAttr, rtfCellBgPatV, "clbgvert", 0 },
2271 { rtfTblAttr, rtfCellFwdDiagBgPat, "clbgfdiag", 0 },
2272 { rtfTblAttr, rtfCellBwdDiagBgPat, "clbgbdiag", 0 },
2273 { rtfTblAttr, rtfCellHatchBgPat, "clbgcross", 0 },
2274 { rtfTblAttr, rtfCellDiagHatchBgPat, "clbgdcross", 0 },
2276 * The spec lists "clbgdkhor", but the corresponding non-cell
2277 * control is "bgdkhoriz". At any rate Macintosh Word seems
2278 * to accept both "clbgdkhor" and "clbgdkhoriz".
2280 { rtfTblAttr, rtfCellDarkBgPatH, "clbgdkhoriz", 0 },
2281 { rtfTblAttr, rtfCellDarkBgPatH, "clbgdkhor", 0 },
2282 { rtfTblAttr, rtfCellDarkBgPatV, "clbgdkvert", 0 },
2283 { rtfTblAttr, rtfCellFwdDarkBgPat, "clbgdkfdiag", 0 },
2284 { rtfTblAttr, rtfCellBwdDarkBgPat, "clbgdkbdiag", 0 },
2285 { rtfTblAttr, rtfCellDarkHatchBgPat, "clbgdkcross", 0 },
2286 { rtfTblAttr, rtfCellDarkDiagHatchBgPat, "clbgdkdcross", 0 },
2287 { rtfTblAttr, rtfCellBgPatLineColor, "clcfpat", 0 },
2288 { rtfTblAttr, rtfCellBgPatColor, "clcbpat", 0 },
2294 { rtfFieldAttr, rtfFieldDirty, "flddirty", 0 },
2295 { rtfFieldAttr, rtfFieldEdited, "fldedit", 0 },
2296 { rtfFieldAttr, rtfFieldLocked, "fldlock", 0 },
2297 { rtfFieldAttr, rtfFieldPrivate, "fldpriv", 0 },
2298 { rtfFieldAttr, rtfFieldAlt, "fldalt", 0 },
2301 * Positioning attributes
2304 { rtfPosAttr, rtfAbsWid, "absw", 0 },
2305 { rtfPosAttr, rtfAbsHt, "absh", 0 },
2307 { rtfPosAttr, rtfRPosMargH, "phmrg", 0 },
2308 { rtfPosAttr, rtfRPosPageH, "phpg", 0 },
2309 { rtfPosAttr, rtfRPosColH, "phcol", 0 },
2310 { rtfPosAttr, rtfPosX, "posx", 0 },
2311 { rtfPosAttr, rtfPosNegX, "posnegx", 0 },
2312 { rtfPosAttr, rtfPosXCenter, "posxc", 0 },
2313 { rtfPosAttr, rtfPosXInside, "posxi", 0 },
2314 { rtfPosAttr, rtfPosXOutSide, "posxo", 0 },
2315 { rtfPosAttr, rtfPosXRight, "posxr", 0 },
2316 { rtfPosAttr, rtfPosXLeft, "posxl", 0 },
2318 { rtfPosAttr, rtfRPosMargV, "pvmrg", 0 },
2319 { rtfPosAttr, rtfRPosPageV, "pvpg", 0 },
2320 { rtfPosAttr, rtfRPosParaV, "pvpara", 0 },
2321 { rtfPosAttr, rtfPosY, "posy", 0 },
2322 { rtfPosAttr, rtfPosNegY, "posnegy", 0 },
2323 { rtfPosAttr, rtfPosYInline, "posyil", 0 },
2324 { rtfPosAttr, rtfPosYTop, "posyt", 0 },
2325 { rtfPosAttr, rtfPosYCenter, "posyc", 0 },
2326 { rtfPosAttr, rtfPosYBottom, "posyb", 0 },
2328 { rtfPosAttr, rtfNoWrap, "nowrap", 0 },
2329 { rtfPosAttr, rtfDistFromTextAll, "dxfrtext", 0 },
2330 { rtfPosAttr, rtfDistFromTextX, "dfrmtxtx", 0 },
2331 { rtfPosAttr, rtfDistFromTextY, "dfrmtxty", 0 },
2332 /* \dyfrtext no longer exists in spec 1.2, apparently */
2333 /* replaced by \dfrmtextx and \dfrmtexty. */
2334 { rtfPosAttr, rtfTextDistY, "dyfrtext", 0 },
2336 { rtfPosAttr, rtfDropCapLines, "dropcapli", 0 },
2337 { rtfPosAttr, rtfDropCapType, "dropcapt", 0 },
2343 { rtfObjAttr, rtfObjEmb, "objemb", 0 },
2344 { rtfObjAttr, rtfObjLink, "objlink", 0 },
2345 { rtfObjAttr, rtfObjAutoLink, "objautlink", 0 },
2346 { rtfObjAttr, rtfObjSubscriber, "objsub", 0 },
2347 { rtfObjAttr, rtfObjPublisher, "objpub", 0 },
2348 { rtfObjAttr, rtfObjICEmb, "objicemb", 0 },
2350 { rtfObjAttr, rtfObjLinkSelf, "linkself", 0 },
2351 { rtfObjAttr, rtfObjLock, "objupdate", 0 },
2352 { rtfObjAttr, rtfObjUpdate, "objlock", 0 },
2354 { rtfObjAttr, rtfObjHt, "objh", 0 },
2355 { rtfObjAttr, rtfObjWid, "objw", 0 },
2356 { rtfObjAttr, rtfObjSetSize, "objsetsize", 0 },
2357 { rtfObjAttr, rtfObjAlign, "objalign", 0 },
2358 { rtfObjAttr, rtfObjTransposeY, "objtransy", 0 },
2359 { rtfObjAttr, rtfObjCropTop, "objcropt", 0 },
2360 { rtfObjAttr, rtfObjCropBottom, "objcropb", 0 },
2361 { rtfObjAttr, rtfObjCropLeft, "objcropl", 0 },
2362 { rtfObjAttr, rtfObjCropRight, "objcropr", 0 },
2363 { rtfObjAttr, rtfObjScaleX, "objscalex", 0 },
2364 { rtfObjAttr, rtfObjScaleY, "objscaley", 0 },
2366 { rtfObjAttr, rtfObjResRTF, "rsltrtf", 0 },
2367 { rtfObjAttr, rtfObjResPict, "rsltpict", 0 },
2368 { rtfObjAttr, rtfObjResBitmap, "rsltbmp", 0 },
2369 { rtfObjAttr, rtfObjResText, "rslttxt", 0 },
2370 { rtfObjAttr, rtfObjResMerge, "rsltmerge", 0 },
2372 { rtfObjAttr, rtfObjBookmarkPubObj, "bkmkpub", 0 },
2373 { rtfObjAttr, rtfObjPubAutoUpdate, "pubauto", 0 },
2376 * Associated character formatting attributes
2379 { rtfACharAttr, rtfACBold, "ab", 0 },
2380 { rtfACharAttr, rtfACAllCaps, "caps", 0 },
2381 { rtfACharAttr, rtfACForeColor, "acf", 0 },
2382 { rtfACharAttr, rtfACSubScript, "adn", 0 },
2383 { rtfACharAttr, rtfACExpand, "aexpnd", 0 },
2384 { rtfACharAttr, rtfACFontNum, "af", 0 },
2385 { rtfACharAttr, rtfACFontSize, "afs", 0 },
2386 { rtfACharAttr, rtfACItalic, "ai", 0 },
2387 { rtfACharAttr, rtfACLanguage, "alang", 0 },
2388 { rtfACharAttr, rtfACOutline, "aoutl", 0 },
2389 { rtfACharAttr, rtfACSmallCaps, "ascaps", 0 },
2390 { rtfACharAttr, rtfACShadow, "ashad", 0 },
2391 { rtfACharAttr, rtfACStrikeThru, "astrike", 0 },
2392 { rtfACharAttr, rtfACUnderline, "aul", 0 },
2393 { rtfACharAttr, rtfACDotUnderline, "auld", 0 },
2394 { rtfACharAttr, rtfACDbUnderline, "auldb", 0 },
2395 { rtfACharAttr, rtfACNoUnderline, "aulnone", 0 },
2396 { rtfACharAttr, rtfACWordUnderline, "aulw", 0 },
2397 { rtfACharAttr, rtfACSuperScript, "aup", 0 },
2400 * Footnote attributes
2403 { rtfFNoteAttr, rtfFNAlt, "ftnalt", 0 },
2406 * Key code attributes
2409 { rtfKeyCodeAttr, rtfAltKey, "alt", 0 },
2410 { rtfKeyCodeAttr, rtfShiftKey, "shift", 0 },
2411 { rtfKeyCodeAttr, rtfControlKey, "ctrl", 0 },
2412 { rtfKeyCodeAttr, rtfFunctionKey, "fn", 0 },
2415 * Bookmark attributes
2418 { rtfBookmarkAttr, rtfBookmarkFirstCol, "bkmkcolf", 0 },
2419 { rtfBookmarkAttr, rtfBookmarkLastCol, "bkmkcoll", 0 },
2422 * Index entry attributes
2425 { rtfIndexAttr, rtfIndexNumber, "xef", 0 },
2426 { rtfIndexAttr, rtfIndexBold, "bxe", 0 },
2427 { rtfIndexAttr, rtfIndexItalic, "ixe", 0 },
2430 * Table of contents attributes
2433 { rtfTOCAttr, rtfTOCType, "tcf", 0 },
2434 { rtfTOCAttr, rtfTOCLevel, "tcl", 0 },
2437 * Drawing object attributes
2440 { rtfDrawAttr, rtfDrawLock, "dolock", 0 },
2441 { rtfDrawAttr, rtfDrawPageRelX, "doxpage", 0 },
2442 { rtfDrawAttr, rtfDrawColumnRelX, "dobxcolumn", 0 },
2443 { rtfDrawAttr, rtfDrawMarginRelX, "dobxmargin", 0 },
2444 { rtfDrawAttr, rtfDrawPageRelY, "dobypage", 0 },
2445 { rtfDrawAttr, rtfDrawColumnRelY, "dobycolumn", 0 },
2446 { rtfDrawAttr, rtfDrawMarginRelY, "dobymargin", 0 },
2447 { rtfDrawAttr, rtfDrawHeight, "dobhgt", 0 },
2449 { rtfDrawAttr, rtfDrawBeginGroup, "dpgroup", 0 },
2450 { rtfDrawAttr, rtfDrawGroupCount, "dpcount", 0 },
2451 { rtfDrawAttr, rtfDrawEndGroup, "dpendgroup", 0 },
2452 { rtfDrawAttr, rtfDrawArc, "dparc", 0 },
2453 { rtfDrawAttr, rtfDrawCallout, "dpcallout", 0 },
2454 { rtfDrawAttr, rtfDrawEllipse, "dpellipse", 0 },
2455 { rtfDrawAttr, rtfDrawLine, "dpline", 0 },
2456 { rtfDrawAttr, rtfDrawPolygon, "dppolygon", 0 },
2457 { rtfDrawAttr, rtfDrawPolyLine, "dppolyline", 0 },
2458 { rtfDrawAttr, rtfDrawRect, "dprect", 0 },
2459 { rtfDrawAttr, rtfDrawTextBox, "dptxbx", 0 },
2461 { rtfDrawAttr, rtfDrawOffsetX, "dpx", 0 },
2462 { rtfDrawAttr, rtfDrawSizeX, "dpxsize", 0 },
2463 { rtfDrawAttr, rtfDrawOffsetY, "dpy", 0 },
2464 { rtfDrawAttr, rtfDrawSizeY, "dpysize", 0 },
2466 { rtfDrawAttr, rtfCOAngle, "dpcoa", 0 },
2467 { rtfDrawAttr, rtfCOAccentBar, "dpcoaccent", 0 },
2468 { rtfDrawAttr, rtfCOBestFit, "dpcobestfit", 0 },
2469 { rtfDrawAttr, rtfCOBorder, "dpcoborder", 0 },
2470 { rtfDrawAttr, rtfCOAttachAbsDist, "dpcodabs", 0 },
2471 { rtfDrawAttr, rtfCOAttachBottom, "dpcodbottom", 0 },
2472 { rtfDrawAttr, rtfCOAttachCenter, "dpcodcenter", 0 },
2473 { rtfDrawAttr, rtfCOAttachTop, "dpcodtop", 0 },
2474 { rtfDrawAttr, rtfCOLength, "dpcolength", 0 },
2475 { rtfDrawAttr, rtfCONegXQuadrant, "dpcominusx", 0 },
2476 { rtfDrawAttr, rtfCONegYQuadrant, "dpcominusy", 0 },
2477 { rtfDrawAttr, rtfCOOffset, "dpcooffset", 0 },
2478 { rtfDrawAttr, rtfCOAttachSmart, "dpcosmarta", 0 },
2479 { rtfDrawAttr, rtfCODoubleLine, "dpcotdouble", 0 },
2480 { rtfDrawAttr, rtfCORightAngle, "dpcotright", 0 },
2481 { rtfDrawAttr, rtfCOSingleLine, "dpcotsingle", 0 },
2482 { rtfDrawAttr, rtfCOTripleLine, "dpcottriple", 0 },
2484 { rtfDrawAttr, rtfDrawTextBoxMargin, "dptxbxmar", 0 },
2485 { rtfDrawAttr, rtfDrawTextBoxText, "dptxbxtext", 0 },
2486 { rtfDrawAttr, rtfDrawRoundRect, "dproundr", 0 },
2488 { rtfDrawAttr, rtfDrawPointX, "dpptx", 0 },
2489 { rtfDrawAttr, rtfDrawPointY, "dppty", 0 },
2490 { rtfDrawAttr, rtfDrawPolyCount, "dppolycount", 0 },
2492 { rtfDrawAttr, rtfDrawArcFlipX, "dparcflipx", 0 },
2493 { rtfDrawAttr, rtfDrawArcFlipY, "dparcflipy", 0 },
2495 { rtfDrawAttr, rtfDrawLineBlue, "dplinecob", 0 },
2496 { rtfDrawAttr, rtfDrawLineGreen, "dplinecog", 0 },
2497 { rtfDrawAttr, rtfDrawLineRed, "dplinecor", 0 },
2498 { rtfDrawAttr, rtfDrawLinePalette, "dplinepal", 0 },
2499 { rtfDrawAttr, rtfDrawLineDashDot, "dplinedado", 0 },
2500 { rtfDrawAttr, rtfDrawLineDashDotDot, "dplinedadodo", 0 },
2501 { rtfDrawAttr, rtfDrawLineDash, "dplinedash", 0 },
2502 { rtfDrawAttr, rtfDrawLineDot, "dplinedot", 0 },
2503 { rtfDrawAttr, rtfDrawLineGray, "dplinegray", 0 },
2504 { rtfDrawAttr, rtfDrawLineHollow, "dplinehollow", 0 },
2505 { rtfDrawAttr, rtfDrawLineSolid, "dplinesolid", 0 },
2506 { rtfDrawAttr, rtfDrawLineWidth, "dplinew", 0 },
2508 { rtfDrawAttr, rtfDrawHollowEndArrow, "dpaendhol", 0 },
2509 { rtfDrawAttr, rtfDrawEndArrowLength, "dpaendl", 0 },
2510 { rtfDrawAttr, rtfDrawSolidEndArrow, "dpaendsol", 0 },
2511 { rtfDrawAttr, rtfDrawEndArrowWidth, "dpaendw", 0 },
2512 { rtfDrawAttr, rtfDrawHollowStartArrow,"dpastarthol", 0 },
2513 { rtfDrawAttr, rtfDrawStartArrowLength,"dpastartl", 0 },
2514 { rtfDrawAttr, rtfDrawSolidStartArrow, "dpastartsol", 0 },
2515 { rtfDrawAttr, rtfDrawStartArrowWidth, "dpastartw", 0 },
2517 { rtfDrawAttr, rtfDrawBgFillBlue, "dpfillbgcb", 0 },
2518 { rtfDrawAttr, rtfDrawBgFillGreen, "dpfillbgcg", 0 },
2519 { rtfDrawAttr, rtfDrawBgFillRed, "dpfillbgcr", 0 },
2520 { rtfDrawAttr, rtfDrawBgFillPalette, "dpfillbgpal", 0 },
2521 { rtfDrawAttr, rtfDrawBgFillGray, "dpfillbggray", 0 },
2522 { rtfDrawAttr, rtfDrawFgFillBlue, "dpfillfgcb", 0 },
2523 { rtfDrawAttr, rtfDrawFgFillGreen, "dpfillfgcg", 0 },
2524 { rtfDrawAttr, rtfDrawFgFillRed, "dpfillfgcr", 0 },
2525 { rtfDrawAttr, rtfDrawFgFillPalette, "dpfillfgpal", 0 },
2526 { rtfDrawAttr, rtfDrawFgFillGray, "dpfillfggray", 0 },
2527 { rtfDrawAttr, rtfDrawFillPatIndex, "dpfillpat", 0 },
2529 { rtfDrawAttr, rtfDrawShadow, "dpshadow", 0 },
2530 { rtfDrawAttr, rtfDrawShadowXOffset, "dpshadx", 0 },
2531 { rtfDrawAttr, rtfDrawShadowYOffset, "dpshady", 0 },
2533 { rtfVersion, -1, "rtf", 0 },
2534 { rtfDefFont, -1, "deff", 0 },
2536 { 0, -1, (char *) NULL, 0 }
2541 * Initialize lookup table hash values. Only need to do this once.
2544 static void LookupInit(void)
2546 static int inited = 0;
2551 for (rp = rtfKey; rp->rtfKStr != (char *) NULL; rp++)
2552 rp->rtfKHash = Hash (rp->rtfKStr);
2559 * Determine major and minor number of control token. If it's
2560 * not found, the class turns into rtfUnknown.
2563 static void Lookup(char *s)
2569 ++s; /* skip over the leading \ character */
2571 for (rp = rtfKey; rp->rtfKStr != (char *) NULL; rp++)
2573 if (hash == rp->rtfKHash && strcmp (s, rp->rtfKStr) == 0)
2575 rtfClass = rtfControl;
2576 rtfMajor = rp->rtfKMajor;
2577 rtfMinor = rp->rtfKMinor;
2581 rtfClass = rtfUnknown;
2586 * Compute hash value of symbol
2589 static int Hash(char *s)
2594 while ((c = *s++) != '\0')
2600 /* ---------------------------------------------------------------------- */
2603 * Memory allocation routines
2608 * Return pointer to block of size bytes, or NULL if there's
2609 * not enough memory available.
2611 * This is called through RTFAlloc(), a define which coerces the
2612 * argument to int. This avoids the persistent problem of allocation
2613 * failing under THINK C when a long is passed.
2616 char *_RTFAlloc(int size)
2618 return HeapAlloc(RICHED32_hHeap, 0, size);
2623 * Saves a string on the heap and returns a pointer to it.
2627 char *RTFStrSave(char *s)
2631 if ((p = RTFAlloc ((int) (strlen (s) + 1))) == (char *) NULL)
2632 return ((char *) NULL);
2633 return (strcpy (p, s));
2637 void RTFFree(char *p)
2639 if (p != (char *) NULL)
2640 HeapFree(RICHED32_hHeap, 0, p);
2644 /* ---------------------------------------------------------------------- */
2648 * Token comparison routines
2651 int RTFCheckCM(int class, int major)
2653 return (rtfClass == class && rtfMajor == major);
2657 int RTFCheckCMM(int class, int major, int minor)
2659 return (rtfClass == class && rtfMajor == major && rtfMinor == minor);
2663 int RTFCheckMM(int major, int minor)
2665 return (rtfMajor == major && rtfMinor == minor);
2669 /* ---------------------------------------------------------------------- */
2672 int RTFCharToHex(char c)
2677 return (c - '0'); /* '0'..'9' */
2678 return (c - 'a' + 10); /* 'a'..'f' */
2682 int RTFHexToChar(int i)
2686 return (i - 10 + 'a');
2690 /* ---------------------------------------------------------------------- */
2693 * RTFReadOutputMap() -- Read output translation map
2697 * Read in an array describing the relation between the standard character set
2698 * and an RTF translator's corresponding output sequences. Each line consists
2699 * of a standard character name and the output sequence for that character.
2701 * outMap is an array of strings into which the sequences should be placed.
2702 * It should be declared like this in the calling program:
2704 * char *outMap[rtfSC_MaxChar];
2706 * reinit should be non-zero if outMap should be initialized
2711 int RTFReadOutputMap(char *outMap[], int reinit)
2719 for (i = 0; i < rtfSC_MaxChar; i++)
2721 outMap[i] = (char *) NULL;
2725 for (i=0 ;i< sizeof(text_map)/sizeof(char*); i+=2)
2728 seq = text_map[i+1];
2729 stdCode = RTFStdCharCode( name );
2730 outMap[stdCode] = seq;
2736 /* ---------------------------------------------------------------------- */
2739 * Open a library file.
2743 static FILE *(*libFileOpen) () = NULL;
2747 void RTFSetOpenLibFileProc(FILE *(*proc)())
2753 FILE *RTFOpenLibFile (char *file, char *mode)
2755 if (libFileOpen == NULL)
2756 return ((FILE *) NULL);
2757 return ((*libFileOpen) (file, mode));
2761 /* ---------------------------------------------------------------------- */
2764 * Print message. Default is to send message to stderr
2765 * but this may be overridden with RTFSetMsgProc().
2767 * Message should include linefeeds as necessary. If the default
2768 * function is overridden, the overriding function may want to
2769 * map linefeeds to another line ending character or sequence if
2770 * the host system doesn't use linefeeds.
2774 static void DefaultMsgProc(char *s)
2780 static RTFFuncPtr msgProc = DefaultMsgProc;
2783 void RTFSetMsgProc(RTFFuncPtr proc)
2792 * This version is for systems with stdarg
2795 void RTFMsg (char *fmt, ...)
2797 char buf[rtfBufSiz];
2800 va_start (args,fmt);
2801 vsprintf (buf, fmt, args);
2806 # else /* !STDARG */
2812 * This version is for systems that have varargs.
2815 void RTFMsg (va_dcl va_alist)
2819 char buf[rtfBufSiz];
2822 fmt = va_arg (args, char *);
2823 vsprintf (buf, fmt, args);
2828 # else /* !VARARGS */
2831 * This version is for systems that don't have varargs.
2834 void RTFMsg (char *fmt, char *a1, char *a2, char *a3, char *a4, char *a5, char *a6, char *a7, char *a8, char *a9)
2836 char buf[rtfBufSiz];
2838 sprintf (buf, fmt, a1, a2, a3, a4, a5, a6, a7, a8, a9);
2842 # endif /* !VARARGS */
2843 # endif /* !STDARG */
2846 /* ---------------------------------------------------------------------- */
2850 * Process termination. Print error message and exit. Also prints
2851 * current token, and current input line number and position within
2852 * line if any input has been read from the current file. (No input
2853 * has been read if prevChar is EOF).
2856 static void DefaultPanicProc(char *s)
2863 static RTFFuncPtr panicProc = DefaultPanicProc;
2866 void RTFSetPanicProc(RTFFuncPtr proc)
2875 * This version is for systems with stdarg
2878 void RTFPanic(char *fmt, ...)
2880 char buf[rtfBufSiz];
2883 va_start (args,fmt);
2884 vsprintf (buf, fmt, args);
2886 (void) strcat (buf, "\n");
2887 if (prevChar != EOF && rtfTextBuf != (char *) NULL)
2889 sprintf (buf + strlen (buf),
2890 "Last token read was \"%s\" near line %ld, position %d.\n",
2891 rtfTextBuf, rtfLineNum, rtfLinePos);
2896 # else /* !STDARG */
2902 * This version is for systems that have varargs.
2905 void RTFPanic(va_dcl va_alist)
2909 char buf[rtfBufSiz];
2912 fmt = va_arg (args, char *);
2913 vsprintf (buf, fmt, args);
2915 (void) strcat (buf, "\n");
2916 if (prevChar != EOF && rtfTextBuf != (char *) NULL)
2918 sprintf (buf + strlen (buf),
2919 "Last token read was \"%s\" near line %ld, position %d.\n",
2920 rtfTextBuf, rtfLineNum, rtfLinePos);
2925 # else /* !VARARGS */
2928 * This version is for systems that don't have varargs.
2931 void RTFPanic (char *fmt, char *a1, char *a2, char *a3, char *a4, char *a5, char *a6, char *a7, char *a8, char *a9)
2933 char buf[rtfBufSiz];
2935 sprintf (buf, fmt, a1, a2, a3, a4, a5, a6, a7, a8, a9);
2936 (void) strcat (buf, "\n");
2937 if (prevChar != EOF && rtfTextBuf != (char *) NULL)
2939 sprintf (buf + strlen (buf),
2940 "Last token read was \"%s\" near line %ld, position %d.\n",
2941 rtfTextBuf, rtfLineNum, rtfLinePos);
2946 # endif /* !VARARGS */
2947 # endif /* !STDARG */