parser.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef _KLONE_PARSER_H_
00012 #define _KLONE_PARSER_H_
00013
00014 #include <sys/types.h>
00015 #include <stdlib.h>
00016 #include <stdio.h>
00017 #include <klone/io.h>
00018
00019 #ifdef __cplusplus
00020 extern "C" {
00021 #endif
00022
00023 struct parser_s;
00024 typedef struct parser_s parser_t;
00025
00026 struct parser_s
00027 {
00028 io_t *in, *out;
00029 int state, prev_state, cmd_code, line, code_line;
00030 void *cb_arg;
00031
00032 int (*cb_code) (parser_t *, int, void *, const char *, size_t);
00033 int (*cb_html) (parser_t *, void *, const char *, size_t);
00034 };
00035
00036 typedef int (*parser_cb_html_t)(parser_t *, void *, const char *, size_t);
00037 typedef int (*parser_cb_code_t)(parser_t *, int, void *, const char *, size_t);
00038
00039 int parser_create(parser_t **);
00040 int parser_free(parser_t *);
00041 int parser_run(parser_t *);
00042 int parser_reset(parser_t *);
00043
00044 void parser_set_io(parser_t *, io_t *, io_t *);
00045 void parser_set_cb_code(parser_t *, parser_cb_code_t);
00046 void parser_set_cb_html(parser_t *, parser_cb_html_t);
00047 void parser_set_cb_arg(parser_t *, void *);
00048
00049 void* parser_get_cb_arg(parser_t *p);
00050
00051 #ifdef __cplusplus
00052 }
00053 #endif
00054
00055 #endif