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