blob: 902a1942f357217805639c1e31fa2dfb73a6b2b4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
#include <u.h>
#include <libc.h>
#include <bio.h>
#include <String.h>
#include <thread.h>
#include "wiki.h"
char *wikidir;
void
usage(void)
{
fprint(2, "usage: wiki2html [-hoDP ] [-d dir] wikifile\n");
exits("usage");
}
void
main(int argc, char **argv)
{
int t;
int parse;
String *h;
Whist *doc;
rfork(RFNAMEG);
t = Tpage;
ARGBEGIN{
default:
usage();
case 'd':
wikidir = EARGF(usage());
break;
case 'h':
t = Thistory;
break;
case 'o':
t = Toldpage;
break;
case 'D':
t = Tdiff;
break;
case 'P':
parse = 1;
}ARGEND
if(argc != 1)
usage();
if(t == Thistory || t==Tdiff)
doc = gethistory(atoi(argv[0]));
else
doc = getcurrent(atoi(argv[0]));
if(doc == nil)
sysfatal("doc: %r");
if(parse){
printpage(doc->doc->wtxt);
exits(0);
}
if((h = tohtml(doc, doc->doc+doc->ndoc-1, t)) == nil)
sysfatal("wiki2html: %r");
write(1, s_to_c(h), s_len(h));
exits(0);
}
|