Barracuda Application Server C/C++ Reference
NO
xparser.h
1/*
2 * ____ _________ __ _
3 * / __ \___ ____ _/ /_ __(_)___ ___ ___ / / ____ ____ _(_)____
4 * / /_/ / _ \/ __ `/ / / / / / __ `__ \/ _ \/ / / __ \/ __ `/ / ___/
5 * / _, _/ __/ /_/ / / / / / / / / / / / __/ /___/ /_/ / /_/ / / /__
6 * /_/ |_|\___/\__,_/_/ /_/ /_/_/ /_/ /_/\___/_____/\____/\__, /_/\___/
7 * /____/
8 *
9 * SharkSSL Embedded SSL/TLS Stack
10 ****************************************************************************
11 * PROGRAM MODULE
12 *
13 * $Id: xparser.h 5076 2022-02-10 16:59:48Z wini $
14 *
15 * COPYRIGHT: Real Time Logic LLC, 2010
16 *
17 * This software is copyrighted by and is the sole property of Real
18 * Time Logic LLC. All rights, title, ownership, or other interests in
19 * the software remain the property of Real Time Logic LLC. This
20 * software may only be used in accordance with the terms and
21 * conditions stipulated in the corresponding license agreement under
22 * which the software has been supplied. Any unauthorized use,
23 * duplication, transmission, distribution, or disclosure of this
24 * software is expressly forbidden.
25 *
26 * This Copyright notice may not be removed or modified without prior
27 * written consent of Real Time Logic LLC.
28 *
29 * Real Time Logic LLC. reserves the right to modify this software
30 * without notice.
31 *
32 * http://www.realtimelogic.com
33 * http://www.sharkssl.com
34 ****************************************************************************
35 * xparser.h : streaming xml parser
36 */
37
38#ifndef __xparser_h
39#define __xparser_h
44#ifndef XPARSER_ALLOC
45#define XPARSER_ALLOC 2
46#endif
47
48#ifdef __cplusplus
49extern "C" {
50#endif
51
53 struct xparser_context;
54 typedef struct xparser_context xparser;
55
60 /*
61 these event flags are for pseudo-events, which have no
62 data attached to them.
63 */
68 /*
69 the following are all called from first xparser_parse()
70 name, attrs,data indicate which parameters will be returned.
71 */
81 };
82 typedef enum xparser_event xparser_event;
83
90 extern const char* const xparser_eventname[xparserLAST];
91
92
98 typedef int (*xparser_callback)(
99 xparser* parser,
100 void* userdata,
101 xparser_event event,
102 const char* name, /* start element/end element/empty element/PI : tag name. */
103 const char** attr, /* xml/start element/empty element : name,value pairs, as zero-terminated list. */
104 const char* data); /* comment/pi/text/cdata : content*/
105
106 typedef xparser_callback xparser_handlers[xparserLAST];
107
108
110 enum xparser_textmode {xparserPRESERVE=0,xparserSKIPBLANK=1,xparserTRIM=2};
111
115 xparser* xparser_create(void);
116
117
131 int xparser_init(xparser* parser, xparser_handlers* handlers, void* userdata,unsigned int options);
132
133
134
143 int xparser_term(xparser* parser);
144
145
150 void xparser_destroy(xparser* parser);
151
152
159 int xparser_reset(xparser* parser, int full);
160
161
172 int xparser_parse(xparser* parser,const char* pData, size_t datalen);
173
174/*
175 information functions
176*/
177 const char* xparser_errormsg(xparser* parser);
178 unsigned int xparser_line(xparser* parser);
179 unsigned int xparser_col(xparser* parser);
180 size_t xparser_count(xparser* parser);
181 unsigned int xparser_depth(xparser* parser);
182 unsigned int xparser_flags(xparser* parser);
183 int xparser_has_doc(xparser* parser);
184 void* xparser_userdata(xparser* parser);
187#ifdef __DOXYGEN__
201#else
202
203/* #define XPARSER_ALLOC 2 */ /* no allocation functions in library */
204
205#endif /* doxygen */
206
207#if XPARSER_ALLOC
210 typedef void * (*xparser_alloc) (
211 void *ud, /*< user token, supplied with allocator */
212 void *ptr, /*< pointer to realloc/free. NULL for alloc */
213 size_t osize, /*< current size : 0 to allocate */
214 size_t nsize); /*< new size. 0 to de-allocate */
215
224
225#endif
226
227#ifdef __cplusplus
228}
229#endif
230
231
233#endif
int xparser_reset(xparser *parser, int full)
reset a parser to post-create state.
void xparser_setalloc(xparser_alloc pa, void *ud)
install user memory allocator.
xparser_textmode
flags for text handling
Definition: xparser.h:110
const char *const xparser_eventname[xparserLAST]
array lookup for event names
xparser_event
events for user callbacks
Definition: xparser.h:57
unsigned int xparser_flags(xparser *parser)
whitespace flags
size_t xparser_count(xparser *parser)
source bytes parsed
int(* xparser_callback)(xparser *parser, void *userdata, xparser_event event, const char *name, const char **attr, const char *data)
xparser user callback.
Definition: xparser.h:98
int xparser_parse(xparser *parser, const char *pData, size_t datalen)
parse a chunk of xml data.
int xparser_has_doc(xparser *parser)
have we parsed the document node ?
xparser * xparser_create(void)
create a parser.
void *(* xparser_alloc)(void *ud, void *ptr, size_t osize, size_t nsize)
define XPARSER_ALLOC non-zero to enable a user memory allocator.
Definition: xparser.h:210
unsigned int xparser_line(xparser *parser)
current source line (1-based)
const char * xparser_errormsg(xparser *parser)
last error message
void * xparser_userdata(xparser *parser)
user data supplied to create/init
int xparser_term(xparser *parser)
destroy a parser, WITHOUT deallocating pointer.
unsigned int xparser_depth(xparser *parser)
current tag nesting depth
unsigned int xparser_col(xparser *parser)
current source column (1-based)
void xparser_destroy(xparser *parser)
destroy a parser
int xparser_init(xparser *parser, xparser_handlers *handlers, void *userdata, unsigned int options)
initialise a parser.
@ xparserPI
processing instruction : <?name data?>
Definition: xparser.h:76
@ xparserEND_ELEMENT
end element : </name>
Definition: xparser.h:74
@ xparserCOMMENT
comment : <!–data-->
Definition: xparser.h:77
@ xparserCDATA
cdata : data
Definition: xparser.h:78
@ xparserINIT
called from xparser_init()
Definition: xparser.h:64
@ xparserSTART_ELEMENT
start element : <name attrs >
Definition: xparser.h:73
@ xparserSTART
called from xparser_parse(), on first call since init() or reset()
Definition: xparser.h:67
@ xparserXML
xml declaration : <?xml attrs ?>
Definition: xparser.h:72
@ xparserLAST
dummy for array sizing
Definition: xparser.h:80
@ xparserTERM
called from xparser_destroy()
Definition: xparser.h:66
@ xparserRESET
called from xparser_reset()
Definition: xparser.h:65
@ xparserNOEVENT
internal flag for no event set.
Definition: xparser.h:59
@ xparserEMPTY_ELEMENT
empty element : <name attrs />
Definition: xparser.h:75
@ xparserTEXT
text : data
Definition: xparser.h:79