diff options
Diffstat (limited to 'dom.c')
| -rw-r--r-- | dom.c | 37 |
1 files changed, 37 insertions, 0 deletions
@@ -0,0 +1,37 @@ +#include <stdio.h> + +#include "dom.h" +#include "parse.h" + +void init_dom(const char *html) +{ + parse(html); +} + +/* Parser event handlers */ +extern void on_open(const char *tag, size_t n) +{ + printf("Tag opened: %.*s\n", (int)n, tag); +} + +extern void on_close(const char *tag, size_t n) +{ + printf("Tag closed: %.*s\n", (int)n, tag); +} + +extern void on_text(const char *text, size_t n) +{ + printf("Text: %.*s\n", (int)n, text); +} + +extern void on_attr(const char *name, size_t nname, const char *val, + size_t nval) +{ + printf("Attribute: name=%.*s", (int)nname, name); + + if (val && nval > 0) + printf(", value=%.*s", (int)nval, val); + + printf("\n"); +} + |
