MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
my_xml.h
1 /* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
2 
3  This program is free software; you can redistribute it and/or modify
4  it under the terms of the GNU General Public License as published by
5  the Free Software Foundation; version 2 of the License.
6 
7  This program is distributed in the hope that it will be useful,
8  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  GNU General Public License for more details.
11 
12  You should have received a copy of the GNU General Public License
13  along with this program; if not, write to the Free Software
14  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
15 
16 
17 #ifndef _my_xml_h
18 #define _my_xml_h
19 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 
24 
25 #define MY_XML_OK 0
26 #define MY_XML_ERROR 1
27 
28 /*
29  A flag whether to use absolute tag names in call-back functions,
30  like "a", "a.b" and "a.b.c" (used in character set file parser),
31  or relative names like "a", "b" and "c".
32 */
33 #define MY_XML_FLAG_RELATIVE_NAMES 1
34 
35 /*
36  A flag whether to skip normilization of text values before calling
37  call-back functions: i.e. skip leading/trailing spaces,
38  \r, \n, \t characters.
39 */
40 #define MY_XML_FLAG_SKIP_TEXT_NORMALIZATION 2
41 
42 enum my_xml_node_type
43 {
44  MY_XML_NODE_TAG, /* can have TAG, ATTR and TEXT children */
45  MY_XML_NODE_ATTR, /* can have TEXT children */
46  MY_XML_NODE_TEXT /* cannot have children */
47 };
48 
49 typedef struct xml_stack_st
50 {
51  int flags;
52  enum my_xml_node_type current_node_type;
53  char errstr[128];
54 
55  struct {
56  char static_buffer[128];
57  char *buffer;
58  size_t buffer_size;
59  char *start;
60  char *end;
61  } attr;
62 
63  const char *beg;
64  const char *cur;
65  const char *end;
66  void *user_data;
67  int (*enter)(struct xml_stack_st *st,const char *val, size_t len);
68  int (*value)(struct xml_stack_st *st,const char *val, size_t len);
69  int (*leave_xml)(struct xml_stack_st *st,const char *val, size_t len);
71 
72 void my_xml_parser_create(MY_XML_PARSER *st);
73 void my_xml_parser_free(MY_XML_PARSER *st);
74 int my_xml_parse(MY_XML_PARSER *st,const char *str, size_t len);
75 
76 void my_xml_set_value_handler(MY_XML_PARSER *st, int (*)(MY_XML_PARSER *,
77  const char *,
78  size_t len));
79 void my_xml_set_enter_handler(MY_XML_PARSER *st, int (*)(MY_XML_PARSER *,
80  const char *,
81  size_t len));
82 void my_xml_set_leave_handler(MY_XML_PARSER *st, int (*)(MY_XML_PARSER *,
83  const char *,
84  size_t len));
85 void my_xml_set_user_data(MY_XML_PARSER *st, void *);
86 
87 size_t my_xml_error_pos(MY_XML_PARSER *st);
88 uint my_xml_error_lineno(MY_XML_PARSER *st);
89 
90 const char *my_xml_error_string(MY_XML_PARSER *st);
91 
92 #ifdef __cplusplus
93 }
94 #endif
95 
96 #endif /* _my_xml_h */