home *** CD-ROM | disk | FTP | other *** search
/ Borland Programmer's Resource / Borland_Programmers_Resource_CD_1995.iso / utils / rtfprsr / rtf2null.c < prev    next >
Text File  |  1995-05-18  |  981b  |  56 lines

  1. /*
  2.     rtf2null - RTF-to-nothing translator
  3.  
  4.     Example only: demonstrates a minimal translator.  Does nothing,
  5.     with the single exception that unknown tokens are echoed.  This
  6.     allows rtf2null to be used as a "find unknown tokens" filter.
  7.  
  8.     07 Feb 91    Paul DuBois    dubois@primate.wisc.edu
  9.  
  10.     07 Feb 91 V1.0. Created.
  11.     24 Feb 91 V1.01. Added unknown token class callback.
  12. */
  13.  
  14. # include    <stdio.h>
  15. # include    "rtf.h"
  16.  
  17. static void Unknown ();
  18.  
  19.  
  20. int main (argc, argv)
  21. int    argc;
  22. char    **argv;
  23. {
  24.     RTFInit ();
  25.  
  26.     --argc;
  27.     ++argv;
  28.  
  29.     /* not clever; only allows stdin or one named file to be read */
  30.  
  31.     if (argc > 0)
  32.     {
  33.         if (freopen (argv[0], "r", stdin) == (FILE *) NULL)
  34.         {
  35.             fprintf (stderr, "Can't open \"%s\"\n", argv[0]);
  36.             exit (1);
  37.         }
  38.     }
  39.  
  40.     RTFSetClassCallback (rtfUnknown, Unknown);
  41.     RTFRead ();
  42.  
  43.     exit (0);
  44. }
  45.  
  46.  
  47. /*
  48.     Echo any unknown tokens.  This helps to find out where
  49.     reader needs to be made smarter.
  50. */
  51.  
  52. static void Unknown ()
  53. {
  54.     fprintf (stderr, "Unknown symbol %s\n", rtfTextBuf);
  55. }
  56.