]> git.lizzy.rs Git - plan9front.git/blob - sys/src/libhtml/impl.h
kernel: implement portable userinit() and simplify process creation
[plan9front.git] / sys / src / libhtml / impl.h
1
2 // UTILS
3 typedef struct List List;
4 typedef struct Strlist Strlist;
5
6 // List of integers (and also generic list with next pointer at beginning)
7 struct List
8 {
9         List*   next;
10         int     val;
11 };
12
13 struct Strlist
14 {
15         Strlist*        next;
16         Rune*   val;
17 };
18
19 extern int              _inclass(Rune c, Rune* cl);
20 extern int              _listlen(List* l);
21 extern List*    _newlist(int val, List* rest);
22 extern Rune*    _newstr(int n);
23 extern int              _prefix(Rune* pre, Rune* s);
24 extern List*    _revlist(List* l);
25 extern void     _splitl(Rune* s, int n, Rune* cl, Rune** p1, int* n1, Rune** p2, int* n2);
26 extern void     _splitr(Rune* s, int n, Rune* cl, Rune** p1, int* n1, Rune** p2, int* n2);
27 extern int              _splitall(Rune* s, int n, Rune* cl, Rune** strarr, int* lenarr, int alen);
28 extern Rune*    _Stradd(Rune*s1, Rune* s2, int n);
29 extern Rune*    _Strclass(Rune* s, Rune* cl);
30 extern int              _Strcmp(Rune* s1, Rune* s2);
31 extern Rune*    _Strdup(Rune* s);
32 extern Rune*    _Strdup2(Rune* s, Rune* t);
33 extern int              _Streqn(Rune* s1, int n1, Rune* s2);
34 extern int              _Strlen(Rune* s);
35 extern Rune*    _Strnclass(Rune* s, Rune* cl, int n);
36 extern int              _Strncmpci(Rune* s1, int n1, Rune* s2);
37 extern Rune*    _Strndup(Rune* s, int n);
38 extern Rune*    _Strnrclass(Rune* s, Rune* cl, int n);
39 extern Rune*    _Strrclass(Rune* s, Rune* cl);
40 extern Rune*    _Strsubstr(Rune* s, int start, int stop);
41 extern long     _Strtol(Rune* s, Rune** eptr, int base);
42 extern void     _trimwhite(Rune* s, int n, Rune** pans, int* panslen);
43
44 extern Rune*    notwhitespace;
45 extern Rune*    whitespace;
46
47 // STRINTTAB
48 typedef struct StringInt StringInt;
49
50 // Element of String-Int table (used for keyword lookup)
51 struct StringInt
52 {
53         Rune*   key;
54         int             val;
55 };
56
57 extern int                      _lookup(StringInt* t, int n, Rune* key, int keylen, int* pans);
58 extern StringInt*       _makestrinttab(Rune** a, int n);
59 extern Rune*            _revlookup(StringInt* t, int n, int val);
60
61 // Colors, in html format, not Plan 9 format.  (RGB values in bottom 3 bytes)
62 enum {
63         White = 0xFFFFFF,
64         Black = 0x000000,
65         Blue = 0x0000CC,
66 };
67
68 // LEX
69
70 // HTML 4.0 tags (plus blink, nobr)
71 // sorted in lexical order; used as array indices
72 enum {
73         Notfound,
74         Comment,
75         Ta, Tabbr, Tacronym, Taddress, Tapplet, Tarea,
76         Tb, Tbase, Tbasefont, Tbdo, Tbig, Tblink,
77         Tblockquote, Tbody, Tbq, Tbr, Tbutton,
78         Tcaption, Tcenter, Tcite, Tcode, Tcol, Tcolgroup,
79         Tdd, Tdel, Tdfn, Tdir, Tdiv, Tdl, Tdt,
80         Tem,
81         Tfieldset, Tfont, Tform, Tframe, Tframeset,
82         Th1, Th2, Th3, Th4, Th5, Th6,
83         Thead, Thr, Thtml,
84         Ti, Tiframe, Timg, Tinput, Tins, Tisindex,
85         Tkbd,
86         Tlabel, Tlegend, Tli, Tlink,
87         Tmap, Tmenu, Tmeta,
88         Tnobr, Tnoframes, Tnoscript,
89         Tobject, Tol, Toptgroup, Toption,
90         Tp, Tparam, Tpre,
91         Tq,
92         Ts, Tsamp, Tscript, Tselect, Tsmall,
93         Tspan, Tstrike, Tstrong, Tstyle, Tsub, Tsup,
94         Ttable, Ttbody, Ttd, Ttextarea, Ttfoot,
95         Tth, Tthead, Ttitle, Ttr, Ttt,
96         Tu, Tul,
97         Tvar,
98         Numtags,
99         RBRA = Numtags,
100         Data = Numtags+RBRA
101 };
102
103 // HTML 4.0 tag attributes
104 // Keep sorted in lexical order
105 enum {
106         Aabbr, Aaccept_charset, Aaccess_key, Aaction,
107         Aalign, Aalink, Aalt, Aarchive, Aaxis,
108         Abackground, Abgcolor, Aborder,
109         Acellpadding, Acellspacing, Achar, Acharoff,
110         Acharset, Achecked, Acite, Aclass, Aclassid,
111         Aclear, Acode, Acodebase, Acodetype, Acolor,
112         Acols, Acolspan, Acompact, Acontent, Acoords,
113         Adata, Adatetime, Adeclare, Adefer, Adir, Adisabled,
114         Aenctype,
115         Aface, Afor, Aframe, Aframeborder,
116         Aheaders, Aheight, Ahref, Ahreflang, Ahspace, Ahttp_equiv,
117         Aid, Aismap,
118         Alabel, Alang, Alink, Alongdesc,
119         Amarginheight, Amarginwidth, Amaxlength,
120         Amedia, Amethod, Amultiple,
121         Aname, Anohref, Anoresize, Anoshade, Anowrap,
122         Aobject, Aonblur, Aonchange, Aonclick, Aondblclick,
123         Aonfocus, Aonkeypress, Aonkeyup, Aonload,
124         Aonmousedown, Aonmousemove, Aonmouseout,
125         Aonmouseover, Aonmouseup, Aonreset, Aonselect,
126         Aonsubmit, Aonunload,
127         Aprofile, Aprompt,
128         Areadonly, Arel, Arev, Arows, Arowspan, Arules,
129         Ascheme, Ascope, Ascrolling, Aselected, Ashape,
130         Asize, Aspan, Asrc, Astandby, Astart, Astyle, Asummary,
131         Atabindex, Atarget, Atext, Atitle, Atype,
132         Ausemap,
133         Avalign, Avalue, Avaluetype, Aversion, Avlink, Avspace,
134         Awidth,
135         Numattrs
136 };
137
138 struct Attr
139 {
140         Attr*           next;           // in list of attrs for a token
141         int             attid;          // Aabbr, etc.
142         Rune*   value;
143 };
144
145 struct Token
146 {
147         int             tag;            // Ta, etc
148         Rune*   text;           // text in Data, attribute text in tag
149         Attr*           attr;           // list of Attrs
150         int             starti; // index into source buffer of token start
151 };
152
153 extern Rune*    tagnames[];
154 extern Rune*    attrnames[];
155
156 extern void     _freetokens(Token* tarray, int n);
157 extern Token*   _gettoks(uchar* data, int datalen, int chset, int mtype, int* plen);
158 extern int              _tokaval(Token* t, int attid, Rune** pans, int xfer);
159
160 #pragma varargck        type "T"        Token*