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