main.c 1.0 KB

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