From e0c6872cf40896c7be36b11dcc744620f10adf1d Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Mon, 2 Sep 2019 13:46:59 +0900 Subject: Initial commit --- support/RTF-1_06a1/rtfdiag.c | 121 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 support/RTF-1_06a1/rtfdiag.c (limited to 'support/RTF-1_06a1/rtfdiag.c') diff --git a/support/RTF-1_06a1/rtfdiag.c b/support/RTF-1_06a1/rtfdiag.c new file mode 100644 index 0000000000..ccc6df9d35 --- /dev/null +++ b/support/RTF-1_06a1/rtfdiag.c @@ -0,0 +1,121 @@ +/* + rtfdiag - read rtf input, write diagnostic stuff. Useful for + testing reader to see if it's finding and classifying + tokens properly, reading destinations, reprocessing + styles, etc. + + Options: + + -e echo tokens as they are read + + 03 Feb 91 Paul DuBois dubois@primate.wisc.edu + + 03 Feb 91 V1.0. Created. + 27 Feb 91 V1.01. Updated for distribution 1.05. +*/ + +# include +# include "rtf.h" + + +static char *usage = "rtfdiag [-e] [file]"; + +static void TokenEcho (); +static void PrintTables (); + +int main (argc, argv) +int argc; +char **argv; +{ + RTFInit (); + + --argc; + ++argv; + + while (argc > 1 && **argv == '-') + { + while (*++*argv != '\0') + { + switch (**argv) + { + case 'e': + RTFSetReadHook (TokenEcho); + break; + default: + fprintf (stderr, "Unknown option: -%c\n", + **argv); + fprintf (stderr, "%s\n", usage); + exit (1); + } + } + --argc; + ++argv; + } + + /* not clever; only allows stdin or one named file to be read */ + + if (argc > 0) + { + if (freopen (argv[0], "r", stdin) == NULL) + { + fprintf (stderr, "Can't open \"%s\"\n", argv[0]); + exit (1); + } + } + + /* process the input stream */ + + RTFRead (); + + PrintTables (); + + exit (0); +} + +static void TokenEcho () +{ + printf ("%d\t%d\t%d\t%d\t\"%s\"\n", + rtfClass, rtfMajor, rtfMinor, rtfParam, rtfTextBuf); +} + + +static void PrintTables () +{ +RTFColor *cp; +RTFFont *fp; +RTFStyle *sp; +RTFStyleElt *sep; +int count; + + printf ("Font table:\n"); + count = 0; + for (fp = RTFGetFont (-1); fp != NULL; fp = fp->rtfNextFont) + { + ++count; + printf ("%2d:\t%s\t%d\n", fp->rtfFNum, fp->rtfFName, + fp->rtfFFamily); + } + printf ("Font table entries:\t%d\n\n", count); + + printf ("Color table:\n\tred\tgreen\tblue\n"); + count = 0; + for (cp = RTFGetColor (-1); cp != NULL; cp = cp->rtfNextColor) + { + ++count; + printf ("%2d:\t%d\t%d\t%d\n", cp->rtfCNum, cp->rtfCRed, + cp->rtfCGreen, cp->rtfCBlue); + } + printf ("Color table entries:\t%d\n\n", count); + + printf ("Stylesheet:\n"); + count = 0; + for (sp = RTFGetStyle (-1); sp != NULL; sp = sp->rtfNextStyle) + { + ++count; + printf ("%2d:\t%s\t%d\t%d\n", sp->rtfSNum, sp->rtfSName, + sp->rtfSBasedOn, sp->rtfSNextPar); + for (sep = sp->rtfSSEList; sep != NULL; sep = sep->rtfNextSE) + printf ("\t%s\n", sep->rtfSEText); + } + printf ("Style table entries:\t%d\n\n", count); +} -- cgit v1.2.3