1 /*
2  *  Copyright (C) 2002-2003,2007 the xine project
3  *
4  *  This file is part of xine, a free video player.
5  *
6  * The xine-lib XML parser is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public License as
8  * published by the Free Software Foundation; either version 2 of the
9  * License, or (at your option) any later version.
10  *
11  * The xine-lib XML parser is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License along with the Gnome Library; see the file COPYING.LIB.  If not,
18  * write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
19  * Floor, Boston, MA 02110, USA
20  */
21 
22 /* xml lexer */
23 #ifndef XML_LEXER_H
24 #define XML_LEXER_H
25 
26 #ifndef XINE_DEPRECATED
27 #define XINE_DEPRECATED
28 #endif
29 
30 #ifndef XINE_PROTECTED
31 #define XINE_PROTECTED
32 #endif
33 
34 /* public constants */
35 #define T_ERROR         -1   /* lexer error */
36 #define T_EOF            0   /* end of file */
37 #define T_EOL            1   /* end of line */
38 #define T_SEPAR          2   /* separator ' ' '/t' '\n' '\r' */
39 #define T_M_START_1      3   /* markup start < */
40 #define T_M_START_2      4   /* markup start </ */
41 #define T_M_STOP_1       5   /* markup stop > */
42 #define T_M_STOP_2       6   /* markup stop /> */
43 #define T_EQUAL          7   /* = */
44 #define T_QUOTE          8   /* \" or \' */
45 #define T_STRING         9   /* "string" */
46 #define T_IDENT         10   /* identifier */
47 #define T_DATA          11   /* data */
48 #define T_C_START       12   /* <!-- */
49 #define T_C_STOP        13   /* --> */
50 #define T_TI_START      14   /* <? */
51 #define T_TI_STOP       15   /* ?> */
52 #define T_DOCTYPE_START 16   /* <!DOCTYPE */
53 #define T_DOCTYPE_STOP  17   /* > */
54 #define T_CDATA_START   18   /* <![CDATA[ */
55 #define T_CDATA_STOP    19   /* ]]> */
56 
57 
58 typedef enum {
59   NORMAL,
60   DATA,
61   CDATA,
62 } LexMode;
63 
64 /* public structure */
65 struct lexer
66 {
67   const char * lexbuf;
68   int lexbuf_size;
69   int lexbuf_pos;
70   LexMode lex_mode;
71   int in_comment;
72   char *lex_malloc;
73 };
74 
75 
76 /* public functions */
77 void lexer_init(const char * buf, int size) XINE_DEPRECATED XINE_PROTECTED;
78 struct lexer *lexer_init_r(const char * buf, int size) XINE_PROTECTED;
79 void lexer_finalize_r(struct lexer * lexer) XINE_PROTECTED;
80 int lexer_get_token_d_r(struct lexer * lexer, char ** tok, int * tok_size, int fixed) XINE_PROTECTED;
81 int lexer_get_token_d(char ** tok, int * tok_size, int fixed) XINE_DEPRECATED XINE_PROTECTED;
82 int lexer_get_token(char * tok, int tok_size) XINE_DEPRECATED XINE_PROTECTED;
83 char *lexer_decode_entities (const char *tok) XINE_PROTECTED;
84 
85 #endif
86