xer_support.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * Copyright (c) 2003, 2004 X/IO Labs, xiolabs.com.
  3. * Copyright (c) 2003-2017 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. #include <asn_system.h> /* Platform-specific types */
  9. #ifdef __cplusplus
  10. extern "C" {
  11. #endif
  12. /*
  13. * Types of data transferred to the application.
  14. */
  15. typedef enum {
  16. PXML_TEXT, /* Plain text between XML tags. */
  17. PXML_TAG, /* A tag, starting with '<'. */
  18. PXML_COMMENT, /* An XML comment, including "<!--" and "-->". */
  19. /*
  20. * The following chunk types are reported if the chunk
  21. * terminates the specified XML element.
  22. */
  23. PXML_TAG_END, /* Tag ended */
  24. PXML_COMMENT_END /* Comment ended */
  25. } pxml_chunk_type_e;
  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. */
  34. typedef int (pxml_callback_f)(pxml_chunk_type_e _type,
  35. const void *_chunk_data, size_t _chunk_size, void *_key);
  36. /*
  37. * Parse the given buffer as it were a chunk of XML data.
  38. * Invoke the specified callback each time the meaninful data is found.
  39. * This function returns number of bytes consumed from the bufer.
  40. * It will always be lesser than or equal to the specified _size.
  41. * The next invocation of this function must account the difference.
  42. */
  43. ssize_t pxml_parse(int *_stateContext, const void *_buf, size_t _size,
  44. pxml_callback_f *cb, void *_key);
  45. #ifdef __cplusplus
  46. }
  47. #endif
  48. #endif /* _XER_SUPPORT_H_ */