simplexml.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /** **************************************************************************
  2. * simplexml.h
  3. *
  4. * Copyright 2008 Bryan Ischo <[email protected]>
  5. *
  6. * This file is part of libs3.
  7. *
  8. * libs3 is free software: you can redistribute it and/or modify it under the
  9. * terms of the GNU Lesser General Public License as published by the Free
  10. * Software Foundation, version 3 of the License.
  11. *
  12. * In addition, as a special exception, the copyright holders give
  13. * permission to link the code of this library and its programs with the
  14. * OpenSSL library, and distribute linked combinations including the two.
  15. *
  16. * libs3 is distributed in the hope that it will be useful, but WITHOUT ANY
  17. * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  18. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  19. * details.
  20. *
  21. * You should have received a copy of the GNU Lesser General Public License
  22. * version 3 along with libs3, in a file named COPYING. If not, see
  23. * <https://www.gnu.org/licenses/>.
  24. *
  25. ************************************************************************** **/
  26. #ifndef SIMPLEXML_H
  27. #define SIMPLEXML_H
  28. #include "libs3.h"
  29. // Simple XML callback.
  30. //
  31. // elementPath: is the full "path" of the element; i.e.
  32. // <foo><bar><baz>data</baz></bar></foo> would have 'data' in the element
  33. // foo/bar/baz.
  34. //
  35. // Return of anything other than S3StatusOK causes the calling
  36. // simplexml_add() function to immediately stop and return the status.
  37. //
  38. // data is passed in as 0 on end of element
  39. typedef S3Status (SimpleXmlCallback)(const char *elementPath, const char *data,
  40. int dataLen, void *callbackData);
  41. typedef struct SimpleXml
  42. {
  43. void *xmlParser;
  44. SimpleXmlCallback *callback;
  45. void *callbackData;
  46. char elementPath[512];
  47. int elementPathLen;
  48. S3Status status;
  49. } SimpleXml;
  50. // Simple XML parsing
  51. // ----------------------------------------------------------------------------
  52. // Always call this, even if the simplexml doesn't end up being used
  53. void simplexml_initialize(SimpleXml *simpleXml, SimpleXmlCallback *callback,
  54. void *callbackData);
  55. S3Status simplexml_add(SimpleXml *simpleXml, const char *data, int dataLen);
  56. // Always call this
  57. void simplexml_deinitialize(SimpleXml *simpleXml);
  58. #endif /* SIMPLEXML_H */