parser.h

00001 /*
00002  * Copyright (c) 2005-2012 by KoanLogic s.r.l. <http://www.koanlogic.com>
00003  * All rights reserved.
00004  *
00005  * This file is part of KLone, and as such it is subject to the license stated
00006  * in the LICENSE file which you have received as part of this distribution.
00007  *
00008  * $Id: parser.h,v 1.8 2008/10/18 00:03:00 tat Exp $
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; /* opaque callback funcs argument */
00031     /* <%[.]   %>  where . is a non-blank char */
00032     int (*cb_code) (parser_t *, int, void *, const char *, size_t); 
00033     int (*cb_html) (parser_t *, void *, const char *, size_t); /* HTML */
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

←Products
Copyright © 2005-2012 - KoanLogic S.r.l. - All rights reserved