summaryrefslogtreecommitdiff
path: root/support/RTF-1_06a1/rtfdiag.c
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /support/RTF-1_06a1/rtfdiag.c
Initial commit
Diffstat (limited to 'support/RTF-1_06a1/rtfdiag.c')
-rw-r--r--support/RTF-1_06a1/rtfdiag.c121
1 files changed, 121 insertions, 0 deletions
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 <stdio.h>
+# 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);
+}