blob: 8b01944ab584c4bca90139c4b322fa5103030f49 [file] [log] [blame]
Lev Walkindc06f6b2004-10-20 15:50:55 +00001/*
2 * Copyright (c) 2003, 2004 X/IO Labs, xiolabs.com.
3 * Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
4 * Redistribution and modifications are permitted subject to BSD license.
5 */
6#ifndef _XER_SUPPORT_H_
7#define _XER_SUPPORT_H_
8
Lev Walkin7bd457f2005-02-18 22:21:31 +00009#include <asn_system.h> /* Platform-specific types */
10
Lev Walkin21b41ac2005-07-24 09:03:44 +000011#ifdef __cplusplus
12extern "C" {
13#endif
14
Lev Walkindc06f6b2004-10-20 15:50:55 +000015/*
16 * Types of data transferred to the application.
17 */
18typedef enum {
19 PXML_TEXT, /* Plain text between XML tags. */
20 PXML_TAG, /* A tag, starting with '<'. */
21 PXML_COMMENT, /* An XML comment, including "<!--" and "-->". */
22 /*
23 * The following chunk types are reported if the chunk
24 * terminates the specified XML element.
25 */
26 PXML_TAG_END, /* Tag ended */
27 PXML_COMMENT_END /* Comment ended */
28} pxml_chunk_type_e;
29
30/*
31 * Callback function that is called by the parser when parsed data is
32 * available. The _opaque is the pointer to a field containing opaque user
33 * data specified in pxml_create() call. The chunk type is _type and the text
34 * data is the piece of buffer identified by _bufid (as supplied to
35 * pxml_feed() call) starting at offset _offset and of _size bytes size.
36 * The chunk is NOT '\0'-terminated.
37 */
38typedef int (pxml_callback_f)(pxml_chunk_type_e _type,
Lev Walkin0fab1a62005-03-09 22:19:25 +000039 const void *_chunk_data, size_t _chunk_size, void *_key);
Lev Walkindc06f6b2004-10-20 15:50:55 +000040
41/*
42 * Parse the given buffer as it were a chunk of XML data.
43 * Invoke the specified callback each time the meaninful data is found.
44 * This function returns number of bytes consumed from the bufer.
45 * It will always be lesser than or equal to the specified _size.
46 * The next invocation of this function must account the difference.
47 */
Lev Walkin0fab1a62005-03-09 22:19:25 +000048ssize_t pxml_parse(int *_stateContext, const void *_buf, size_t _size,
Lev Walkindc06f6b2004-10-20 15:50:55 +000049 pxml_callback_f *cb, void *_key);
50
Lev Walkin21b41ac2005-07-24 09:03:44 +000051#ifdef __cplusplus
52}
53#endif
54
Lev Walkindc06f6b2004-10-20 15:50:55 +000055#endif /* _XER_SUPPORT_H_ */