xmlrole.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. /*
  2. __ __ _
  3. ___\ \/ /_ __ __ _| |_
  4. / _ \\ /| '_ \ / _` | __|
  5. | __// \| |_) | (_| | |_
  6. \___/_/\_\ .__/ \__,_|\__|
  7. |_| XML parser
  8. Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
  9. Copyright (c) 2000 Clark Cooper <coopercc@users.sourceforge.net>
  10. Copyright (c) 2002 Karl Waclawek <karl@waclawek.net>
  11. Copyright (c) 2002 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
  12. Copyright (c) 2017-2024 Sebastian Pipping <sebastian@pipping.org>
  13. Licensed under the MIT license:
  14. Permission is hereby granted, free of charge, to any person obtaining
  15. a copy of this software and associated documentation files (the
  16. "Software"), to deal in the Software without restriction, including
  17. without limitation the rights to use, copy, modify, merge, publish,
  18. distribute, sublicense, and/or sell copies of the Software, and to permit
  19. persons to whom the Software is furnished to do so, subject to the
  20. following conditions:
  21. The above copyright notice and this permission notice shall be included
  22. in all copies or substantial portions of the Software.
  23. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  24. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  25. MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  26. NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  27. DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  28. OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  29. USE OR OTHER DEALINGS IN THE SOFTWARE.
  30. */
  31. #ifndef XmlRole_INCLUDED
  32. #define XmlRole_INCLUDED 1
  33. #ifdef __VMS
  34. /* 0 1 2 3 0 1 2 3
  35. 1234567890123456789012345678901 1234567890123456789012345678901 */
  36. # define XmlPrologStateInitExternalEntity XmlPrologStateInitExternalEnt
  37. #endif
  38. #include "xmltok.h"
  39. #ifdef __cplusplus
  40. extern "C" {
  41. #endif
  42. enum {
  43. XML_ROLE_ERROR = -1,
  44. XML_ROLE_NONE = 0,
  45. XML_ROLE_XML_DECL,
  46. XML_ROLE_INSTANCE_START,
  47. XML_ROLE_DOCTYPE_NONE,
  48. XML_ROLE_DOCTYPE_NAME,
  49. XML_ROLE_DOCTYPE_SYSTEM_ID,
  50. XML_ROLE_DOCTYPE_PUBLIC_ID,
  51. XML_ROLE_DOCTYPE_INTERNAL_SUBSET,
  52. XML_ROLE_DOCTYPE_CLOSE,
  53. XML_ROLE_GENERAL_ENTITY_NAME,
  54. XML_ROLE_PARAM_ENTITY_NAME,
  55. XML_ROLE_ENTITY_NONE,
  56. XML_ROLE_ENTITY_VALUE,
  57. XML_ROLE_ENTITY_SYSTEM_ID,
  58. XML_ROLE_ENTITY_PUBLIC_ID,
  59. XML_ROLE_ENTITY_COMPLETE,
  60. XML_ROLE_ENTITY_NOTATION_NAME,
  61. XML_ROLE_NOTATION_NONE,
  62. XML_ROLE_NOTATION_NAME,
  63. XML_ROLE_NOTATION_SYSTEM_ID,
  64. XML_ROLE_NOTATION_NO_SYSTEM_ID,
  65. XML_ROLE_NOTATION_PUBLIC_ID,
  66. XML_ROLE_ATTRIBUTE_NAME,
  67. XML_ROLE_ATTRIBUTE_TYPE_CDATA,
  68. XML_ROLE_ATTRIBUTE_TYPE_ID,
  69. XML_ROLE_ATTRIBUTE_TYPE_IDREF,
  70. XML_ROLE_ATTRIBUTE_TYPE_IDREFS,
  71. XML_ROLE_ATTRIBUTE_TYPE_ENTITY,
  72. XML_ROLE_ATTRIBUTE_TYPE_ENTITIES,
  73. XML_ROLE_ATTRIBUTE_TYPE_NMTOKEN,
  74. XML_ROLE_ATTRIBUTE_TYPE_NMTOKENS,
  75. XML_ROLE_ATTRIBUTE_ENUM_VALUE,
  76. XML_ROLE_ATTRIBUTE_NOTATION_VALUE,
  77. XML_ROLE_ATTLIST_NONE,
  78. XML_ROLE_ATTLIST_ELEMENT_NAME,
  79. XML_ROLE_IMPLIED_ATTRIBUTE_VALUE,
  80. XML_ROLE_REQUIRED_ATTRIBUTE_VALUE,
  81. XML_ROLE_DEFAULT_ATTRIBUTE_VALUE,
  82. XML_ROLE_FIXED_ATTRIBUTE_VALUE,
  83. XML_ROLE_ELEMENT_NONE,
  84. XML_ROLE_ELEMENT_NAME,
  85. XML_ROLE_CONTENT_ANY,
  86. XML_ROLE_CONTENT_EMPTY,
  87. XML_ROLE_CONTENT_PCDATA,
  88. XML_ROLE_GROUP_OPEN,
  89. XML_ROLE_GROUP_CLOSE,
  90. XML_ROLE_GROUP_CLOSE_REP,
  91. XML_ROLE_GROUP_CLOSE_OPT,
  92. XML_ROLE_GROUP_CLOSE_PLUS,
  93. XML_ROLE_GROUP_CHOICE,
  94. XML_ROLE_GROUP_SEQUENCE,
  95. XML_ROLE_CONTENT_ELEMENT,
  96. XML_ROLE_CONTENT_ELEMENT_REP,
  97. XML_ROLE_CONTENT_ELEMENT_OPT,
  98. XML_ROLE_CONTENT_ELEMENT_PLUS,
  99. XML_ROLE_PI,
  100. XML_ROLE_COMMENT,
  101. #ifdef XML_DTD
  102. XML_ROLE_TEXT_DECL,
  103. XML_ROLE_IGNORE_SECT,
  104. XML_ROLE_INNER_PARAM_ENTITY_REF,
  105. #endif /* XML_DTD */
  106. XML_ROLE_PARAM_ENTITY_REF
  107. };
  108. typedef struct prolog_state {
  109. int(PTRCALL *handler)(struct prolog_state *state, int tok, const char *ptr,
  110. const char *end, const ENCODING *enc);
  111. unsigned level;
  112. int role_none;
  113. #ifdef XML_DTD
  114. unsigned includeLevel;
  115. int documentEntity;
  116. int inEntityValue;
  117. #endif /* XML_DTD */
  118. } PROLOG_STATE;
  119. void XmlPrologStateInit(PROLOG_STATE *state);
  120. #ifdef XML_DTD
  121. void XmlPrologStateInitExternalEntity(PROLOG_STATE *state);
  122. #endif /* XML_DTD */
  123. #define XmlTokenRole(state, tok, ptr, end, enc) \
  124. (((state)->handler)(state, tok, ptr, end, enc))
  125. #ifdef __cplusplus
  126. }
  127. #endif
  128. #endif /* not XmlRole_INCLUDED */