xmlrpc_xmlparser.h 3.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /* Copyright (C) 2001 by First Peer, Inc. All rights reserved.
  2. **
  3. ** Redistribution and use in source and binary forms, with or without
  4. ** modification, are permitted provided that the following conditions
  5. ** are met:
  6. ** 1. Redistributions of source code must retain the above copyright
  7. ** notice, this list of conditions and the following disclaimer.
  8. ** 2. Redistributions in binary form must reproduce the above copyright
  9. ** notice, this list of conditions and the following disclaimer in the
  10. ** documentation and/or other materials provided with the distribution.
  11. ** 3. The name of the author may not be used to endorse or promote products
  12. ** derived from this software without specific prior written permission.
  13. **
  14. ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  15. ** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  16. ** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  17. ** ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  18. ** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  19. ** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  20. ** OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  21. ** HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  22. ** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  23. ** OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  24. ** SUCH DAMAGE. */
  25. /*=========================================================================
  26. ** Abstract XML Parser Interface
  27. **=========================================================================
  28. ** This file provides an abstract interface to the XML parser. For now,
  29. ** this interface is implemented by expat, but feel free to change it
  30. ** if necessary.
  31. */
  32. /*=========================================================================
  33. ** xml_element
  34. **=========================================================================
  35. ** This data structure represents an XML element. We provide no more API
  36. ** than we'll need in xmlrpc_parse.c.
  37. **
  38. ** The pointers returned by the various accessor methods belong to the
  39. ** xml_element structure. Do not free them, and do not use them after
  40. ** the xml_element has been destroyed.
  41. */
  42. /* You'll need to finish defining struct _xml_element elsewhere. */
  43. typedef struct _xml_element xml_element;
  44. /* Destroy an xml_element. */
  45. void xml_element_free (xml_element *elem);
  46. /* Return a pointer to the element's name. Do not free this pointer!
  47. ** This pointer should point to standard ASCII or UTF-8 data. */
  48. char *xml_element_name (xml_element *elem);
  49. /* Return the xml_element's CDATA. Do not free this pointer!
  50. ** This pointer should point to standard ASCII or UTF-8 data.
  51. ** The implementation is allowed to concatenate all the CDATA in the
  52. ** element regardless of child elements. Alternatively, if there are
  53. ** any child elements, the implementation is allowed to dispose
  54. ** of whitespace characters.
  55. ** The value returned by xml_element_cdata should be '\0'-terminated
  56. ** (although it may contain other '\0' characters internally).
  57. ** xml_element_cdata_size should not include the final '\0'. */
  58. size_t xml_element_cdata_size (xml_element *elem);
  59. char *xml_element_cdata (xml_element *elem);
  60. /* Return the xml_element's child elements. Do not free this pointer! */
  61. size_t xml_element_children_size (xml_element *elem);
  62. xml_element **xml_element_children (xml_element *elem);
  63. /*=========================================================================
  64. ** xml_parse
  65. **=========================================================================
  66. ** Parse a chunk of XML data and return the top-level element. If this
  67. ** routine fails, it will return NULL and set up the env appropriately.
  68. ** You are responsible for calling xml_element_free on the returned pointer.
  69. */
  70. xml_element *xml_parse (xmlrpc_env *env, const char *xml_data, int xml_len);