URI:
       tmain.c - plan9port - [fork] Plan 9 from user space
  HTML git clone git://src.adamsgaard.dk/plan9port
   DIR Log
   DIR Files
   DIR Refs
   DIR README
   DIR LICENSE
       ---
       tmain.c (1064B)
       ---
            1 /*
            2  * Convert troff -ms input to HTML.
            3  */
            4 
            5 #include "a.h"
            6 
            7 Biobuf        bout;
            8 char*        tmacdir;
            9 int                verbose;
           10 int                utf8 = 0;
           11 
           12 void
           13 usage(void)
           14 {
           15         fprint(2, "usage: htmlroff [-iuv] [-m mac] [-r an] [file...]\n");
           16         exits("usage");
           17 }
           18 
           19 void
           20 main(int argc, char **argv)
           21 {
           22         int i, dostdin;
           23         char *p;
           24         Rune *r;
           25         Rune buf[2];
           26 
           27         Binit(&bout, 1, OWRITE);
           28         fmtinstall('L', linefmt);
           29         quotefmtinstall();
           30 
           31         tmacdir = unsharp("#9/tmac");
           32         dostdin = 0;
           33         ARGBEGIN{
           34         case 'i':
           35                 dostdin = 1;
           36                 break;
           37         case 'm':
           38                 r = erunesmprint("%s/tmac.%s", tmacdir, EARGF(usage()));
           39                 if(queueinputfile(r) < 0)
           40                         fprint(2, "%S: %r\n", r);
           41                 break;
           42         case 'r':
           43                 p = EARGF(usage());
           44                 p += chartorune(buf, p);
           45                 buf[1] = 0;
           46                 _nr(buf, erunesmprint("%s", p+1));
           47                 break;
           48         case 'u':
           49                 utf8 = 1;
           50                 break;
           51         case 'v':
           52                 verbose = 1;
           53                 break;
           54         default:
           55                 usage();
           56         }ARGEND
           57 
           58         for(i=0; i<argc; i++){
           59                 if(strcmp(argv[i], "-") == 0)
           60                         queuestdin();
           61                 else
           62                         queueinputfile(erunesmprint("%s", argv[i]));
           63         }
           64         if(argc == 0 || dostdin)
           65                 queuestdin();
           66 
           67         run();
           68         Bprint(&bout, "\n");
           69         Bterm(&bout);
           70         exits(nil);
           71 }