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