diff options
-rw-r--r-- | src/xine-utils/Makefile.am | 4 | ||||
-rw-r--r-- | src/xine-utils/xineutils.h | 4 | ||||
-rw-r--r-- | src/xine-utils/xmllexer.c | 405 | ||||
-rw-r--r-- | src/xine-utils/xmllexer.h | 54 | ||||
-rw-r--r-- | src/xine-utils/xmlparser.c | 457 | ||||
-rw-r--r-- | src/xine-utils/xmlparser.h | 58 |
6 files changed, 978 insertions, 4 deletions
diff --git a/src/xine-utils/Makefile.am b/src/xine-utils/Makefile.am index a3f2e5fac..72ef80ad4 100644 --- a/src/xine-utils/Makefile.am +++ b/src/xine-utils/Makefile.am @@ -4,13 +4,13 @@ lib_LTLIBRARIES = libxineutils.la -libxineutils_la_SOURCES = utils.c memcpy.c monitor.c cpu_accel.c xine_mutex.c +libxineutils_la_SOURCES = utils.c memcpy.c monitor.c cpu_accel.c xine_mutex.c xmllexer.c xmlparser.c libxineutils_la_LDFLAGS = \ -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \ -release $(LT_RELEASE) -include_HEADERS = xineutils.h attributes.h compat.h +include_HEADERS = xineutils.h attributes.h compat.h xmllexer.h xmlparser.h debug: diff --git a/src/xine-utils/xineutils.h b/src/xine-utils/xineutils.h index 9a751ec5a..5db895a64 100644 --- a/src/xine-utils/xineutils.h +++ b/src/xine-utils/xineutils.h @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: xineutils.h,v 1.13 2002/04/27 14:35:39 richwareham Exp $ + * $Id: xineutils.h,v 1.14 2002/05/01 19:41:55 guenter Exp $ * */ #ifndef XINEUTILS_H @@ -34,7 +34,7 @@ extern "C" { #include <pthread.h> #include "attributes.h" #include "compat.h" - +#include "xmlparser.h" /* * debugable mutexes */ diff --git a/src/xine-utils/xmllexer.c b/src/xine-utils/xmllexer.c new file mode 100644 index 000000000..4a150a0b0 --- /dev/null +++ b/src/xine-utils/xmllexer.c @@ -0,0 +1,405 @@ +/* + * Copyright (C) 2002 the xine project + * + * This file is part of xine, a free video player. + * + * xine is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * xine is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + * + * $Id: xmllexer.c,v 1.1 2002/05/01 19:41:55 guenter Exp $ + * + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "xmllexer.h" +#include <stdio.h> +#include <ctype.h> +#include <string.h> + +/* private constants*/ +#define NORMAL 0 /* normal lex mode */ +#define DATA 1 /* data lex mode */ + +/* +#define LOG +*/ + +/* private global variables */ +char * lexbuf; +int lexbuf_size = 0; +int lexbuf_pos = 0; +int lex_mode = NORMAL; + +void lexer_init(char * buf, int size) { + lexbuf = buf; + lexbuf_size = size; + lexbuf_pos = 0; + lex_mode = NORMAL; +#ifdef LOG + printf("xmllexer: buffer length %d\n", size); +#endif +} + +int lexer_get_token(char * tok, int tok_size) { + int tok_pos = 0; + int state = 0; + char c; + + if (tok) { + while ((tok_pos < tok_size) && (lexbuf_pos < lexbuf_size)) { + c = lexbuf[lexbuf_pos]; +#ifdef LOG + printf("xmllexer: c=%c, state=%d\n", c, state); +#endif + if (lex_mode == NORMAL) { + /* normal mode */ + switch (state) { + /* init state */ + case 0: + switch (c) { + case '\n': + case '\r': + state = 1; + tok[tok_pos] = c; + tok_pos++; + break; + + case ' ': + case '\t': + state = 2; + tok[tok_pos] = c; + tok_pos++; + break; + + case '<': + state = 3; + tok[tok_pos] = c; + tok_pos++; + break; + + case '>': + state = 4; + tok[tok_pos] = c; + tok_pos++; + break; + + case '/': + state = 5; + tok[tok_pos] = c; + tok_pos++; + break; + + case '=': + state = 6; + tok[tok_pos] = c; + tok_pos++; + break; + + case '\"': + state = 7; + break; + + case '-': + state = 10; + tok[tok_pos] = c; + tok_pos++; + break; + + case '?': + state = 9; + tok[tok_pos] = c; + tok_pos++; + break; + + default: + state = 100; + tok[tok_pos] = c; + tok_pos++; + break; + } + lexbuf_pos++; + break; + + /* end of line */ + case 1: + if (c == '\n' || (c == '\r')) { + tok[tok_pos] = c; + lexbuf_pos++; + tok_pos++; + } else { + tok[tok_pos] = '\0'; + return T_EOL; + } + break; + + /* T_SEPAR */ + case 2: + if (c == ' ' || (c == '\t')) { + tok[tok_pos] = c; + lexbuf_pos++; + tok_pos++; + } else { + tok[tok_pos] = '\0'; + return T_SEPAR; + } + break; + + /* T_M_START < or </ or <! or <? */ + case 3: + switch (c) { + case '/': + tok[tok_pos] = c; + lexbuf_pos++; + tok_pos++; /* FIXME */ + tok[tok_pos] = '\0'; + return T_M_START_2; + break; + case '!': + tok[tok_pos] = c; + lexbuf_pos++; + tok_pos++; + state = 8; + break; + case '?': + tok[tok_pos] = c; + lexbuf_pos++; + tok_pos++; /* FIXME */ + tok[tok_pos] = '\0'; + return T_TI_START; + break; + default: + tok[tok_pos] = '\0'; + return T_M_START_1; + } + break; + + /* T_M_STOP_1 */ + case 4: + tok[tok_pos] = '\0'; + lex_mode = DATA; + return T_M_STOP_1; + break; + + /* T_M_STOP_2 */ + case 5: + if (c == '>') { + tok[tok_pos] = c; + lexbuf_pos++; + tok_pos++; /* FIXME */ + tok[tok_pos] = '\0'; + lex_mode = DATA; + return T_M_STOP_2; + } else { + tok[tok_pos] = '\0'; + return T_ERROR; + } + break; + + /* T_EQUAL */ + case 6: + tok[tok_pos] = '\0'; + return T_EQUAL; + break; + + /* T_STRING */ + case 7: + tok[tok_pos] = c; + lexbuf_pos++; + if (c == '\"') { + tok[tok_pos] = '\0'; /* FIXME */ + return T_STRING; + } + tok_pos++; + break; + + /* T_C_START or T_DOCTYPE_START */ + case 8: + switch (c) { + case '-': + lexbuf_pos++; + if (lexbuf[lexbuf_pos] == '-') + { + lexbuf_pos++; + tok[tok_pos++] = '-'; /* FIXME */ + tok[tok_pos++] = '-'; + tok[tok_pos] = '\0'; + return T_C_START; + } + break; + case 'D': + lexbuf_pos++; + if (strncmp(lexbuf + lexbuf_pos, "OCTYPE", 6) == 0) { + strncpy(tok + tok_pos, "DOCTYPE", 7); /* FIXME */ + lexbuf_pos += 6; + return T_DOCTYPE_START; + } else { + return T_ERROR; + } + break; + default: + /* error */ + return T_ERROR; + } + break; + + /* T_TI_STOP */ + case 9: + if (c == '>') { + tok[tok_pos] = c; + lexbuf_pos++; + tok_pos++; /* FIXME */ + tok[tok_pos] = '\0'; + return T_TI_STOP; + } else { + tok[tok_pos] = '\0'; + return T_ERROR; + } + break; + + /* -- */ + case 10: + switch (c) { + case '-': + tok[tok_pos] = c; + tok_pos++; + lexbuf_pos++; + state = 11; + break; + default: + tok[tok_pos] = c; + tok_pos++; + lexbuf_pos++; + state = 100; + } + break; + + /* --> */ + case 11: + switch (c) { + case '>': + tok[tok_pos] = c; + tok_pos++; + lexbuf_pos++; + tok[tok_pos] = '\0'; /* FIX ME */ + if (strlen(tok) != 3) { + tok[tok_pos - 3] = '\0'; + lexbuf_pos -= 3; + return T_IDENT; + } else { + return T_C_STOP; + } + break; + default: + tok[tok_pos] = c; + tok_pos++; + lexbuf_pos++; + state = 100; + } + break; + + /* IDENT */ + case 100: + switch (c) { + case '<': + case '>': + case '\\': + case '\"': + case ' ': + case '\t': + case '=': + tok[tok_pos] = '\0'; + return T_IDENT; + break; + case '?': + tok[tok_pos] = c; + tok_pos++; + lexbuf_pos++; + state = 9; + break; + case '-': + tok[tok_pos] = c; + tok_pos++; + lexbuf_pos++; + state = 10; + break; + default: + tok[tok_pos] = c; + tok_pos++; + lexbuf_pos++; + } + break; + default: + printf("xmllexer: expected char \'%c\'\n", tok[tok_pos - 1]); /* FIX ME */ + return T_ERROR; + } + } else { + /* data mode, stop if char equal '<' */ + if (c == '<') { + tok[tok_pos] = '\0'; + lex_mode = NORMAL; + return T_DATA; + } else { + tok[tok_pos] = c; + tok_pos++; + lexbuf_pos++; + } + } + } + /* pb */ + if (tok_pos >= tok_size) { + printf("xmllexer: token buffer is too little\n"); + } else { + if (lexbuf_pos >= lexbuf_size) { + /* Terminate the current token */ + tok[tok_pos] = '\0'; + switch (state) { + case 0: + case 1: + case 2: + return T_EOF; + break; + case 3: + return T_M_START_1; + break; + case 4: + return T_M_STOP_1; + break; + case 5: + return T_ERROR; + break; + case 6: + return T_EQUAL; + break; + case 7: + return T_STRING; + break; + case 100: + return T_DATA; + break; + default: + printf("xmllexer: unknown state, state=%d\n", state); + } + } else { + printf("xmllexer: abnormal end of buffer, state=%d\n", state); + } + } + return T_ERROR; + } + /* tok == null */ + printf("xmllexer: token buffer is null\n"); + return T_ERROR; +} diff --git a/src/xine-utils/xmllexer.h b/src/xine-utils/xmllexer.h new file mode 100644 index 000000000..e9a382d46 --- /dev/null +++ b/src/xine-utils/xmllexer.h @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2002 the xine project + * + * This file is part of xine, a free video player. + * + * xine is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * xine is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + * + * $Id: xmllexer.h,v 1.1 2002/05/01 19:41:55 guenter Exp $ + * + */ + +/* xml lexer */ +#ifndef XML_LEXER_H +#define XML_LEXER_H + +/* public constants */ +#define T_ERROR -1 /* lexer error */ +#define T_EOF 0 /* end of file */ +#define T_EOL 1 /* end of line */ +#define T_SEPAR 2 /* separator ' ' '/t' '\n' '\r' */ +#define T_M_START_1 3 /* markup start < */ +#define T_M_START_2 4 /* markup start </ */ +#define T_M_STOP_1 5 /* markup stop > */ +#define T_M_STOP_2 6 /* markup stop /> */ +#define T_EQUAL 7 /* = */ +#define T_QUOTE 8 /* \" or \' */ +#define T_STRING 9 /* "string" */ +#define T_IDENT 10 /* identifier */ +#define T_DATA 11 /* data */ +#define T_C_START 12 /* <!-- */ +#define T_C_STOP 13 /* --> */ +#define T_TI_START 14 /* <? */ +#define T_TI_STOP 15 /* ?> */ +#define T_DOCTYPE_START 16 /* <!DOCTYPE */ +#define T_DOCTYPE_STOP 17 /* > */ + + +/* public functions */ +void lexer_init(char * buf, int size); +int lexer_get_token(char * tok, int tok_size); + +#endif diff --git a/src/xine-utils/xmlparser.c b/src/xine-utils/xmlparser.c new file mode 100644 index 000000000..8324cac2a --- /dev/null +++ b/src/xine-utils/xmlparser.c @@ -0,0 +1,457 @@ +/* + * Copyright (C) 2002 the xine project + * + * This file is part of xine, a free video player. + * + * xine is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * xine is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + * + * $Id: xmlparser.c,v 1.1 2002/05/01 19:41:55 guenter Exp $ + * + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <ctype.h> +#include "xmllexer.h" +#include "xmlparser.h" + + +#define TOKEN_SIZE 4 * 1024 +#define DATA_SIZE 4 * 1024 +#define MAX_RECURSION 10 + +#define LOG + +/* private global variables */ +int xml_parser_mode; + +/* private functions */ + +char * strtoupper(char * str) { + int i = 0; + + while (str[i] != '\0') { + str[i] = (char)toupper((int)str[i]); + i++; + } + return str; +} + +xml_node_t * new_xml_node() { + xml_node_t * new_node; + + new_node = (xml_node_t*) malloc(sizeof(xml_node_t)); + new_node->name = NULL; + new_node->data = NULL; + new_node->props = NULL; + new_node->child = NULL; + new_node->next = NULL; + return new_node; +} + +void free_xml_node(xml_node_t * node) { + free(node); +} + +xml_property_t * new_xml_property() { + xml_property_t * new_property; + + new_property = (xml_property_t*) malloc(sizeof(xml_property_t)); + new_property->name = NULL; + new_property->value = NULL; + new_property->next = NULL; + return new_property; +} + +void free_xml_property(xml_property_t * property) { + free(property); +} + +void xml_parser_init(char * buf, int size, int mode) { + lexer_init(buf, size); + xml_parser_mode = mode; +} + +void xml_parser_free_props(xml_property_t *current_property) { + if (current_property) { + if (!current_property->next) { + free_xml_property(current_property); + } else { + xml_parser_free_props(current_property->next); + free_xml_property(current_property); + } + } +} + +void xml_parser_free_tree(xml_node_t *current_node) { + if (current_node) { + /* propertys */ + if (current_node->props) { + xml_parser_free_props(current_node->props); + } + + /* child nodes */ + if (current_node->child) { + xml_parser_free_tree(current_node->child); + } + + if (current_node->next) { + xml_parser_free_tree(current_node->next); + } + + free_xml_node(current_node); + } +} + +int xml_parser_get_node(xml_node_t *current_node, char *root_name, int rec) { + char tok[TOKEN_SIZE]; + char property_name[TOKEN_SIZE]; + char node_name[TOKEN_SIZE]; + int state = 0; + int res; + int parse_res; + int bypass_get_token = 0; + xml_node_t *subtree = NULL; + xml_node_t *current_subtree = NULL; + xml_property_t *current_property = NULL; + xml_property_t *propertys = NULL; + + if (rec < MAX_RECURSION) { + + while ((bypass_get_token) || (res = lexer_get_token(tok, TOKEN_SIZE)) != T_ERROR) { + bypass_get_token = 0; +#ifdef LOG + printf("xmlparser: info: %d - %d : %s\n", state, res, tok); +#endif + switch (state) { + case 0: + switch (res) { + case (T_EOL): + case (T_SEPAR): + /* do nothing */ + break; + case (T_EOF): + return 0; /* normal end */ + break; + case (T_M_START_1): + state = 1; + break; + case (T_M_START_2): + state = 3; + break; + case (T_C_START): + state = 7; + break; + case (T_TI_START): + state = 8; + break; + case (T_DOCTYPE_START): + state = 9; + break; + case (T_DATA): + /* current data */ + current_node->data = (char *)malloc(strlen(tok) + 1); + strcpy(current_node->data, tok); +#ifdef LOG + printf("xmlparser: info: node data : %s\n", current_node->data); +#endif + break; + default: + printf("xmlparser: error: unexpected token \"%s\", state %d\n", tok, state); + return -1; + break; + } + break; + + case 1: + switch (res) { + case (T_IDENT): + propertys = NULL; + current_property = NULL; + + /* save node name */ + if (xml_parser_mode == XML_PARSER_CASE_INSENSITIVE) { + strtoupper(tok); + } + strcpy(node_name, tok); + state = 2; +#ifdef LOG + printf("xmlparser: info: current node name \"%s\"\n", node_name); +#endif + break; + default: + printf("xmlparser: error: unexpected token \"%s\", state %d\n", tok, state); + return -1; + break; + } + break; + case 2: + switch (res) { + case (T_EOL): + case (T_SEPAR): + /* nothing */ + break; + case (T_M_STOP_1): + /* new subtree */ + subtree = new_xml_node(); + + /* set node name */ + subtree->name = malloc(strlen(node_name + 1)); + strcpy(subtree->name, node_name); + + /* set node propertys */ + subtree->props = propertys; +#ifdef LOG + printf("xmlparser: info: recursive level: %d\n", rec); + printf("xmlparser: info: new subtree %s\n", node_name); +#endif + parse_res = xml_parser_get_node(subtree, node_name, rec + 1); +#ifdef LOG + printf("xmlparser: info: new subtree result: %d\n", parse_res); + printf("xmlparser: info: recursive level: %d\n", rec); +#endif + if (parse_res != 0) { + return parse_res; + } + if (current_subtree == NULL) { + current_node->child = subtree; + current_subtree = subtree; + } else { + current_subtree->next = subtree; + current_subtree = subtree; + } + state = 0; + break; + case (T_M_STOP_2): + /* new leaf */ + /* new subtree */ + subtree = new_xml_node(); + + /* set node name */ + subtree->name = malloc(strlen(node_name + 1)); + strcpy(subtree->name, node_name); + + /* set node propertys */ + subtree->props = propertys; + + if (current_subtree == NULL) { + current_node->child = subtree; + current_subtree = subtree; + } else { + current_subtree->next = subtree; + current_subtree = subtree; + } + state = 0; + break; + case (T_IDENT): + /* save property name */ + if (xml_parser_mode == XML_PARSER_CASE_INSENSITIVE) { + strtoupper(tok); + } + strcpy(property_name, tok); + state = 5; +#ifdef LOG + printf("xmlparser: info: current property name \"%s\"\n", property_name); +#endif + break; + default: + printf("xmlparser: error: unexpected token \"%s\", state %d\n", tok, state); + return -1; + break; + } + break; + + case 3: + switch (res) { + case (T_IDENT): + /* must be equal to root_name */ + if (xml_parser_mode == XML_PARSER_CASE_INSENSITIVE) { + strtoupper(tok); + } + if (strcmp(tok, root_name) == 0) { + state = 4; + } else { + printf("xmlparser: error: xml struct, tok=%s, waited_tok=%s\n", tok, root_name); + return -1; + } + break; + default: + printf("xmlparser: error: unexpected token \"%s\", state %d\n", tok, state); + return -1; + break; + } + break; + + /* > expected */ + case 4: + switch (res) { + case (T_M_STOP_1): + return 0; + break; + default: + printf("xmlparser: error: unexpected token \"%s\", state %d\n", tok, state); + return -1; + break; + } + break; + + /* = or > or ident or separator expected */ + case 5: + switch (res) { + case (T_EOL): + case (T_SEPAR): + /* do nothing */ + break; + case (T_EQUAL): + state = 6; + break; + case (T_IDENT): + bypass_get_token = 1; /* jump to state 2 without get a new token */ + state = 2; + break; + case (T_M_STOP_1): + /* add a new property without value */ + if (current_property == NULL) { + propertys = new_xml_property(); + current_property = propertys; + } else { + current_property->next = new_xml_property(); + current_property = current_property->next; + } + current_property->name = (char *)malloc(strlen(property_name) + 1); + strcpy(current_property->name, property_name); +#ifdef LOG + printf("xmlparser: info: new property %s\n", current_property->name); +#endif + bypass_get_token = 1; /* jump to state 2 without get a new token */ + state = 2; + break; + default: + printf("xmlparser: error: unexpected token \"%s\", state %d\n", tok, state); + return -1; + break; + } + break; + + /* string or ident or separator expected */ + case 6: + switch (res) { + case (T_EOL): + case (T_SEPAR): + /* do nothing */ + break; + case (T_STRING): + case (T_IDENT): + /* add a new property */ + if (current_property == NULL) { + propertys = new_xml_property(); + current_property = propertys; + } else { + current_property->next = new_xml_property(); + current_property = current_property->next; + } + current_property->name = (char *)malloc(strlen(property_name) + 1); + strcpy(current_property->name, property_name); + current_property->value = (char *)malloc(strlen(tok) + 1); + strcpy(current_property->value, tok); +#ifdef LOG + printf("xmlparser: info: new property %s=%s\n", current_property->name, current_property->value); +#endif + state = 2; + break; + default: + printf("xmlparser: error: unexpected token \"%s\", state %d\n", tok, state); + return -1; + break; + } + break; + + /* --> expected */ + case 7: + switch (res) { + case (T_C_STOP): + state = 0; + break; + default: + state = 7; + break; + } + break; + + /* > expected */ + case 8: + switch (res) { + case (T_TI_STOP): + state = 0; + break; + default: + state = 8; + break; + } + break; + + /* ?> expected */ + case 9: + switch (res) { + case (T_M_STOP_1): + state = 0; + break; + default: + state = 9; + break; + } + break; + + + default: + printf("xmlparser: error: unknown parser state, state=%d\n", state); + return -1; + } + } + /* lex error */ + printf("xmlparser: error: lexer error\n"); + return -1; + } else { + /* max recursion */ + printf("xmlparser: error: max recursion\n"); + return -1; + } +} + +int xml_parser_build_tree(xml_node_t **root_node) { + xml_node_t *tmp_node; + int res; + + *root_node = new_xml_node(); + tmp_node = new_xml_node(); + res = xml_parser_get_node(tmp_node, "", 0); + if ((tmp_node->child) && (!tmp_node->child->next)) { + (*root_node)->name = tmp_node->child->name; + (*root_node)->data = tmp_node->child->data; + (*root_node)->props = tmp_node->child->props; + (*root_node)->child = tmp_node->child->child; + (*root_node)->next = tmp_node->child->next; + } else { + printf("xmlparser: error: xml struct\n"); + res = -1; + } + free(tmp_node); + return res; +} diff --git a/src/xine-utils/xmlparser.h b/src/xine-utils/xmlparser.h new file mode 100644 index 000000000..18c5a95df --- /dev/null +++ b/src/xine-utils/xmlparser.h @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2002 the xine project + * + * This file is part of xine, a free video player. + * + * xine is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * xine is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + * + * $Id: xmlparser.h,v 1.1 2002/05/01 19:41:55 guenter Exp $ + * + */ +#ifndef XML_PARSER_H +#define XML_PARSER_H + +/* parser modes */ +#define XML_PARSER_CASE_INSENSITIVE 0 +#define XML_PARSER_CASE_SENSITIVE 1 + +/* return codes */ +#define XML_PARSER_OK 0 +#define XML_PARSER_ERROR 1 + + +/* xml property */ +typedef struct xml_property_s { + char *name; + char *value; + struct xml_property_s *next; +} xml_property_t; + +/* xml node */ +typedef struct xml_node_s { + char *name; + char *data; + struct xml_property_s *props; + struct xml_node_s *child; + struct xml_node_s *next; +} xml_node_t; + +void xml_parser_init(char * buf, int size, int mode); + +int xml_parser_build_tree(xml_node_t **root_node); + +void xml_parser_free_tree(xml_node_t *root_node); + + +#endif |