blob: 2fa1ae96f127f2a8a17a9fa19925f7e9938a2097 [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 Walkindc06f6b2004-10-20 15:50:55 +000011/*
12 * Types of data transferred to the application.
13 */
14typedef enum {
15 PXML_TEXT, /* Plain text between XML tags. */
16 PXML_TAG, /* A tag, starting with '<'. */
17 PXML_COMMENT, /* An XML comment, including "<!--" and "-->". */
18 /*
19 * The following chunk types are reported if the chunk
20 * terminates the specified XML element.
21 */
22 PXML_TAG_END, /* Tag ended */
23 PXML_COMMENT_END /* Comment ended */
24} pxml_chunk_type_e;
25
26/*
27 * Callback function that is called by the parser when parsed data is
28 * available. The _opaque is the pointer to a field containing opaque user
29 * data specified in pxml_create() call. The chunk type is _type and the text
30 * data is the piece of buffer identified by _bufid (as supplied to
31 * pxml_feed() call) starting at offset _offset and of _size bytes size.
32 * The chunk is NOT '\0'-terminated.
33 */
34typedef int (pxml_callback_f)(pxml_chunk_type_e _type,
35 void *_chunk_data, size_t _chunk_size, void *_key);
36
37/*
38 * Parse the given buffer as it were a chunk of XML data.
39 * Invoke the specified callback each time the meaninful data is found.
40 * This function returns number of bytes consumed from the bufer.
41 * It will always be lesser than or equal to the specified _size.
42 * The next invocation of this function must account the difference.
43 */
44ssize_t pxml_parse(int *_stateContext, void *_buf, size_t _size,
45 pxml_callback_f *cb, void *_key);
46
47#endif /* _XER_SUPPORT_H_ */