main.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. * This file is part of the UCB release of Plan 9. It is subject to the license
  3. * terms in the LICENSE file found in the top-level directory of this
  4. * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
  5. * part of the UCB release of Plan 9, including this file, may be copied,
  6. * modified, propagated, or distributed except according to the terms contained
  7. * in the LICENSE file.
  8. */
  9. /*
  10. * Convert troff -ms input to HTML.
  11. */
  12. #include "a.h"
  13. Biobuf bout;
  14. char* tmacdir;
  15. int verbose;
  16. int utf8 = 0;
  17. void
  18. usage(void)
  19. {
  20. fprint(2, "usage: htmlroff [-iuv] [-m mac] [-r an] [file...]\n");
  21. exits("usage");
  22. }
  23. void
  24. main(int argc, char **argv)
  25. {
  26. int i, dostdin;
  27. char *p;
  28. Rune *r;
  29. Rune buf[2];
  30. Binit(&bout, 1, OWRITE);
  31. fmtinstall('L', linefmt);
  32. quotefmtinstall();
  33. tmacdir = "/sys/lib/tmac";
  34. dostdin = 0;
  35. ARGBEGIN{
  36. case 'i':
  37. dostdin = 1;
  38. break;
  39. case 'm':
  40. r = erunesmprint("%s/tmac.%s", tmacdir, EARGF(usage()));
  41. if(queueinputfile(r) < 0)
  42. fprint(2, "%S: %r\n", r);
  43. break;
  44. case 'r':
  45. p = EARGF(usage());
  46. p += chartorune(buf, p);
  47. buf[1] = 0;
  48. _nr(buf, erunesmprint("%s", p+1));
  49. break;
  50. case 'u':
  51. utf8 = 1;
  52. break;
  53. case 'v':
  54. verbose = 1;
  55. break;
  56. default:
  57. usage();
  58. }ARGEND
  59. for(i=0; i<argc; i++){
  60. if(strcmp(argv[i], "-") == 0)
  61. queuestdin();
  62. else
  63. queueinputfile(erunesmprint("%s", argv[i]));
  64. }
  65. if(argc == 0 || dostdin)
  66. queuestdin();
  67. run();
  68. Bprint(&bout, "\n");
  69. Bterm(&bout);
  70. exits(nil);
  71. }