1
0

simplexml.h 2.6 KB

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