home *** CD-ROM | disk | FTP | other *** search
/ Best Tools for JAVA / Best Tools for JAVA.iso / CONVERTR / RTF2HTML / SRC / RTF2HTML.TAR / rtftohtml_src / html-unix.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-05  |  1.1 KB  |  72 lines

  1. /*
  2.  * html-unix.c -- UNIX rtftohtml wrapper
  3.  *
  4.  * Driver provides OpenOutputFile() and Basename() functions for the writer.
  5.  */
  6.  
  7. # include    <stdio.h>
  8.  
  9. # include    "rtf.h"
  10. # include    "rtf-unix.h"
  11. # include    "rtftohtml.h"
  12.  
  13.  
  14. static char *usage="rtftohtml [-V] [-i] [-G] [-T] [-o filename] [-P extension] file";
  15.  
  16.  
  17. int
  18. main (argc, argv)
  19. int    argc;
  20. char    *argv[];
  21. {
  22.     /* install OS-specific callbacks into RTF library */
  23.     UnixSetProgPath (argv[0]);
  24.     RTFSetOpenLibFileProc (UnixOpenLibFile);
  25.  
  26.     WriterInit ();
  27.     RTFInit ();
  28.     switch (do_main(argc,argv))    /* set up for output file */
  29.     {
  30.     case 1:            /* successful */
  31.         RTFRead ();
  32.         HTMLCleanup();
  33.         break;
  34.     case 0:            /* unsuccessful; die */
  35.         exit (1);
  36.     case -1:        /* unsuccessful; print usage message and die*/
  37.         RTFPanic ("Usage: %s", usage);
  38.     }
  39.     exit (0);
  40. }
  41.  
  42.  
  43. FILE *
  44. OpenOutputFile (name, mode, fileType)
  45. char    *name;
  46. char    *mode;
  47. int    fileType;    /* ignored */
  48. {
  49.     return (fopen (name, mode));
  50. }
  51.  
  52.  
  53. /*
  54.  * Return pointer to basename part of pathname
  55.  */
  56.  
  57. # define    pathSep    '/'
  58.  
  59. char *
  60. Basename (name)
  61. char    *name;
  62. {
  63. int    i, lsep;
  64.  
  65.     for(i=0,lsep=0;name[i]!='\0';i++)
  66.     {
  67.         if(name[i]==pathSep)
  68.             lsep=i+1;
  69.     }
  70.     return (&name[lsep]);
  71. }
  72.