summaryrefslogtreecommitdiffstats
path: root/src/cmd/htmlroff/main.c
diff options
context:
space:
mode:
authorrsc <devnull@localhost>2006-02-21 18:37:05 +0000
committerrsc <devnull@localhost>2006-02-21 18:37:05 +0000
commitc42a1d3d6168df56f966ea1f3ba3ef39ebbff4e4 (patch)
tree400f263e56681842ba1e6e1fdd8be453856474ef /src/cmd/htmlroff/main.c
parent49a1496cbbb871bc623cfd0925566628e246c9ba (diff)
downloadplan9port-c42a1d3d6168df56f966ea1f3ba3ef39ebbff4e4.tar.gz
plan9port-c42a1d3d6168df56f966ea1f3ba3ef39ebbff4e4.zip
add
Diffstat (limited to 'src/cmd/htmlroff/main.c')
-rw-r--r--src/cmd/htmlroff/main.c72
1 files changed, 72 insertions, 0 deletions
diff --git a/src/cmd/htmlroff/main.c b/src/cmd/htmlroff/main.c
new file mode 100644
index 00000000..b6af1e7b
--- /dev/null
+++ b/src/cmd/htmlroff/main.c
@@ -0,0 +1,72 @@
+/*
+ * Convert troff -ms input to HTML.
+ */
+
+#include "a.h"
+
+Biobuf bout;
+char* tmacdir;
+int verbose;
+int utf8 = 0;
+
+void
+usage(void)
+{
+ fprint(2, "usage: htmlroff [-iuv] [-m mac] [-r an] [file...]\n");
+ exits("usage");
+}
+
+void
+main(int argc, char **argv)
+{
+ int i, dostdin;
+ char *p;
+ Rune *r;
+ Rune buf[2];
+
+ Binit(&bout, 1, OWRITE);
+ fmtinstall('L', linefmt);
+ quotefmtinstall();
+
+ tmacdir = unsharp("#9/tmac");
+ dostdin = 0;
+ ARGBEGIN{
+ case 'i':
+ dostdin = 1;
+ break;
+ case 'm':
+ r = erunesmprint("%s/tmac.%s", tmacdir, EARGF(usage()));
+ if(queueinputfile(r) < 0)
+ fprint(2, "%S: %r\n", r);
+ break;
+ case 'r':
+ p = EARGF(usage());
+ p += chartorune(buf, p);
+ buf[1] = 0;
+ _nr(buf, erunesmprint("%s", p+1));
+ break;
+ case 'u':
+ utf8 = 1;
+ break;
+ case 'v':
+ verbose = 1;
+ break;
+ default:
+ usage();
+ }ARGEND
+
+ for(i=0; i<argc; i++){
+ if(strcmp(argv[i], "-") == 0)
+ queuestdin();
+ else
+ queueinputfile(erunesmprint("%s", argv[i]));
+ }
+ if(argc == 0 || dostdin)
+ queuestdin();
+
+ run();
+ Bprint(&bout, "\n");
+ Bterm(&bout);
+ exits(nil);
+}
+