27 static inline int good_tag(char *tn
, char *pn
)
32 for (i
=0; t
= &grab_tags
[i
], t
->name
; i
++) {
33 if (!strcmp(t
->name
, tn
) && !strcmp(t
->param
, pn
))
40 #define otag(tn,pn,pv,cb,ctx) { if (good_tag(grow_cstr(tn), grow_cstr(pn))) cb(ctx, grow_cstr(pv), 0, 0); grow_reset(pv); grow_reset(pn); }
41 void generic_parse(char *input
, parser_cb_t cb
, void *ctx
)
43 struct grow tn
, pn
, pv
;
50 while ((c
=*input
++)) {
57 if (c
== '/' || isalpha(c
)) {
59 grow_put(&tn
,tolower(c
));
70 grow_put(&tn
,tolower(c
));
76 } else if (isalpha(c
)) {
79 grow_put(&pn
, tolower(c
));
85 } else if (isalpha(c
)) {
86 grow_put(&pn
, tolower(c
));
95 } else if (c
== '\'') {
97 } else if (c
== ' ' || c
== '\t' || c
== '\n' || c
== '\r') {
106 otag(&tn
, &pn
, &pv
, cb
, ctx
);
114 otag(&tn
, &pn
, &pv
, cb
, ctx
);
121 if (c
== ' ' || c
== '\t' || c
== '\n' || c
== '\r' || c
== '>') {
122 otag(&tn
, &pn
, &pv
, cb
, ctx
);
139 void parse(char *input
, parser_cb_t cb
, void *ctx
)
141 generic_parse(input
, cb
, ctx
);