]> git.lizzy.rs Git - plan9front.git/blob - sys/src/cmd/wikifs/wiki.h
merge
[plan9front.git] / sys / src / cmd / wikifs / wiki.h
1 typedef struct Map Map;
2 typedef struct Mapel Mapel;
3 typedef struct Sub Sub;
4 typedef struct Wdoc Wdoc;
5 typedef struct Whist Whist;
6 typedef struct Wpage Wpage;
7
8 enum {
9         Tcache = 5,     /* seconds */
10         Maxmap = 10*1024*1024,
11         Maxfile = 100*1024,
12 };
13 enum {
14         Wpara,
15         Wheading,
16         Wbullet,
17         Wlink,
18         Wman,
19         Wplain,
20         Wpre,
21         Whr,
22         Nwtxt,
23 };
24
25 struct Wpage {
26         int type;
27         char *text;
28         int section;    /* Wman */
29         char *url;              /* Wlink */
30         Wpage *next;
31 };
32
33 struct Whist {
34         Ref;
35         int n;
36         char *title;
37         Wdoc *doc;
38         int ndoc;
39         int current;
40 };
41
42 struct Wdoc {
43         char *author;
44         char *comment;
45         int conflict;
46         ulong time;
47         Wpage *wtxt;
48 };
49
50 enum {
51         Tpage,
52         Tedit,
53         Tdiff,
54         Thistory,
55         Tnew,
56         Toldpage,
57         Twerror,
58         Ntemplate,
59 };
60
61 struct Sub {
62         char *match;
63         char *sub;
64 };
65
66 struct Mapel {
67         char *s;
68         int n;
69 };
70
71 struct Map {
72         Ref;
73         Mapel *el;
74         int nel;
75         ulong t;
76         char *buf;
77         Qid qid;
78 };
79
80 void *erealloc(void*, ulong);
81 void *emalloc(ulong);
82 char *estrdup(char*);
83 char *estrdupn(char*, int);
84 char *strcondense(char*, int);
85 char *strlower(char*);
86
87 String *s_appendsub(String*, char*, int, Sub*, int);
88 String *s_appendlist(String*, ...);
89 Whist *Brdwhist(Biobuf*);
90 Wpage *Brdpage(char*(*)(void*,int), void*);
91
92 void printpage(Wpage*);
93 String *pagehtml(String*, Wpage*, int);
94 String *pagetext(String*, Wpage*, int);
95 String *tohtml(Whist*, Wdoc*, int);
96 String *totext(Whist*, Wdoc*, int);
97 String *doctext(String*, Wdoc*);
98
99 Whist *getcurrent(int);
100 Whist *getcurrentbyname(char*);
101 Whist *gethistory(int);
102 void closewhist(Whist*);
103 int allocnum(char*, int);
104 void freepage(Wpage*);
105 int nametonum(char*);
106 char *numtoname(int);
107 int writepage(int, ulong, String*, char*);
108 void voidcache(int);
109
110 void closemap(Map*);
111 void currentmap(int);
112
113 extern Map *map;
114 extern RWLock maplock;
115 extern char *wikidir;
116 Biobuf *wBopen(char*, int);
117 int wopen(char*, int);
118 int wcreate(char*, int, long);
119 int waccess(char*, int);
120 Dir *wdirstat(char*);
121 int opentemp(char*);