structdata.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /* Interface to some helper routines used to accumulate and check
  2. structured content.
  3. __ __ _
  4. ___\ \/ /_ __ __ _| |_
  5. / _ \\ /| '_ \ / _` | __|
  6. | __// \| |_) | (_| | |_
  7. \___/_/\_\ .__/ \__,_|\__|
  8. |_| XML parser
  9. Copyright (c) 2017 Rhodri James <[email protected]>
  10. Licensed under the MIT license:
  11. Permission is hereby granted, free of charge, to any person obtaining
  12. a copy of this software and associated documentation files (the
  13. "Software"), to deal in the Software without restriction, including
  14. without limitation the rights to use, copy, modify, merge, publish,
  15. distribute, sublicense, and/or sell copies of the Software, and to permit
  16. persons to whom the Software is furnished to do so, subject to the
  17. following conditions:
  18. The above copyright notice and this permission notice shall be included
  19. in all copies or substantial portions of the Software.
  20. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  21. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  22. MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  23. NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  24. DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  25. OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  26. USE OR OTHER DEALINGS IN THE SOFTWARE.
  27. */
  28. #ifdef __cplusplus
  29. extern "C" {
  30. #endif
  31. #ifndef XML_STRUCTDATA_H
  32. # define XML_STRUCTDATA_H 1
  33. # include "expat.h"
  34. typedef struct {
  35. const XML_Char *str;
  36. int data0;
  37. int data1;
  38. int data2;
  39. } StructDataEntry;
  40. typedef struct {
  41. int count; /* Number of entries used */
  42. int max_count; /* Number of StructDataEntry items in `entries` */
  43. StructDataEntry *entries;
  44. } StructData;
  45. void StructData_Init(StructData *storage);
  46. void StructData_AddItem(StructData *storage, const XML_Char *s, int data0,
  47. int data1, int data2);
  48. void StructData_CheckItems(StructData *storage, const StructDataEntry *expected,
  49. int count);
  50. void StructData_Dispose(StructData *storage);
  51. #endif /* XML_STRUCTDATA_H */
  52. #ifdef __cplusplus
  53. }
  54. #endif