dummy.c 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. /* Dummy handler functions for the Expat test suite
  2. __ __ _
  3. ___\ \/ /_ __ __ _| |_
  4. / _ \\ /| '_ \ / _` | __|
  5. | __// \| |_) | (_| | |_
  6. \___/_/\_\ .__/ \__,_|\__|
  7. |_| XML parser
  8. Copyright (c) 2001-2006 Fred L. Drake, Jr. <[email protected]>
  9. Copyright (c) 2003 Greg Stein <[email protected]>
  10. Copyright (c) 2005-2007 Steven Solie <[email protected]>
  11. Copyright (c) 2005-2012 Karl Waclawek <[email protected]>
  12. Copyright (c) 2016-2022 Sebastian Pipping <[email protected]>
  13. Copyright (c) 2017-2022 Rhodri James <[email protected]>
  14. Copyright (c) 2017 Joe Orton <[email protected]>
  15. Copyright (c) 2017 José Gutiérrez de la Concha <[email protected]>
  16. Copyright (c) 2018 Marco Maggi <[email protected]>
  17. Copyright (c) 2019 David Loffredo <[email protected]>
  18. Copyright (c) 2020 Tim Gates <[email protected]>
  19. Copyright (c) 2021 Donghee Na <[email protected]>
  20. Licensed under the MIT license:
  21. Permission is hereby granted, free of charge, to any person obtaining
  22. a copy of this software and associated documentation files (the
  23. "Software"), to deal in the Software without restriction, including
  24. without limitation the rights to use, copy, modify, merge, publish,
  25. distribute, sublicense, and/or sell copies of the Software, and to permit
  26. persons to whom the Software is furnished to do so, subject to the
  27. following conditions:
  28. The above copyright notice and this permission notice shall be included
  29. in all copies or substantial portions of the Software.
  30. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  31. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  32. MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  33. NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  34. DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  35. OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  36. USE OR OTHER DEALINGS IN THE SOFTWARE.
  37. */
  38. #include "expat.h"
  39. #include "internal.h"
  40. #include "common.h"
  41. #include "dummy.h"
  42. /* Dummy handlers for when we need to set a handler to tickle a bug,
  43. but it doesn't need to do anything.
  44. */
  45. static unsigned long dummy_handler_flags = 0;
  46. void
  47. init_dummy_handlers(void) {
  48. dummy_handler_flags = 0;
  49. }
  50. unsigned long
  51. get_dummy_handler_flags(void) {
  52. return dummy_handler_flags;
  53. }
  54. void XMLCALL
  55. dummy_xdecl_handler(void *userData, const XML_Char *version,
  56. const XML_Char *encoding, int standalone) {
  57. UNUSED_P(userData);
  58. UNUSED_P(version);
  59. UNUSED_P(encoding);
  60. UNUSED_P(standalone);
  61. }
  62. void XMLCALL
  63. dummy_start_doctype_handler(void *userData, const XML_Char *doctypeName,
  64. const XML_Char *sysid, const XML_Char *pubid,
  65. int has_internal_subset) {
  66. UNUSED_P(userData);
  67. UNUSED_P(doctypeName);
  68. UNUSED_P(sysid);
  69. UNUSED_P(pubid);
  70. UNUSED_P(has_internal_subset);
  71. dummy_handler_flags |= DUMMY_START_DOCTYPE_HANDLER_FLAG;
  72. }
  73. void XMLCALL
  74. dummy_end_doctype_handler(void *userData) {
  75. UNUSED_P(userData);
  76. dummy_handler_flags |= DUMMY_END_DOCTYPE_HANDLER_FLAG;
  77. }
  78. void XMLCALL
  79. dummy_entity_decl_handler(void *userData, const XML_Char *entityName,
  80. int is_parameter_entity, const XML_Char *value,
  81. int value_length, const XML_Char *base,
  82. const XML_Char *systemId, const XML_Char *publicId,
  83. const XML_Char *notationName) {
  84. UNUSED_P(userData);
  85. UNUSED_P(entityName);
  86. UNUSED_P(is_parameter_entity);
  87. UNUSED_P(value);
  88. UNUSED_P(value_length);
  89. UNUSED_P(base);
  90. UNUSED_P(systemId);
  91. UNUSED_P(publicId);
  92. UNUSED_P(notationName);
  93. dummy_handler_flags |= DUMMY_ENTITY_DECL_HANDLER_FLAG;
  94. }
  95. void XMLCALL
  96. dummy_notation_decl_handler(void *userData, const XML_Char *notationName,
  97. const XML_Char *base, const XML_Char *systemId,
  98. const XML_Char *publicId) {
  99. UNUSED_P(userData);
  100. UNUSED_P(notationName);
  101. UNUSED_P(base);
  102. UNUSED_P(systemId);
  103. UNUSED_P(publicId);
  104. dummy_handler_flags |= DUMMY_NOTATION_DECL_HANDLER_FLAG;
  105. }
  106. void XMLCALL
  107. dummy_element_decl_handler(void *userData, const XML_Char *name,
  108. XML_Content *model) {
  109. UNUSED_P(userData);
  110. UNUSED_P(name);
  111. /* The content model must be freed by the handler. Unfortunately
  112. * we cannot pass the parser as the userData because this is used
  113. * with other handlers that require other userData.
  114. */
  115. XML_FreeContentModel(g_parser, model);
  116. dummy_handler_flags |= DUMMY_ELEMENT_DECL_HANDLER_FLAG;
  117. }
  118. void XMLCALL
  119. dummy_attlist_decl_handler(void *userData, const XML_Char *elname,
  120. const XML_Char *attname, const XML_Char *att_type,
  121. const XML_Char *dflt, int isrequired) {
  122. UNUSED_P(userData);
  123. UNUSED_P(elname);
  124. UNUSED_P(attname);
  125. UNUSED_P(att_type);
  126. UNUSED_P(dflt);
  127. UNUSED_P(isrequired);
  128. dummy_handler_flags |= DUMMY_ATTLIST_DECL_HANDLER_FLAG;
  129. }
  130. void XMLCALL
  131. dummy_comment_handler(void *userData, const XML_Char *data) {
  132. UNUSED_P(userData);
  133. UNUSED_P(data);
  134. dummy_handler_flags |= DUMMY_COMMENT_HANDLER_FLAG;
  135. }
  136. void XMLCALL
  137. dummy_pi_handler(void *userData, const XML_Char *target, const XML_Char *data) {
  138. UNUSED_P(userData);
  139. UNUSED_P(target);
  140. UNUSED_P(data);
  141. dummy_handler_flags |= DUMMY_PI_HANDLER_FLAG;
  142. }
  143. void XMLCALL
  144. dummy_start_element(void *userData, const XML_Char *name,
  145. const XML_Char **atts) {
  146. UNUSED_P(userData);
  147. UNUSED_P(name);
  148. UNUSED_P(atts);
  149. dummy_handler_flags |= DUMMY_START_ELEMENT_HANDLER_FLAG;
  150. }
  151. void XMLCALL
  152. dummy_end_element(void *userData, const XML_Char *name) {
  153. UNUSED_P(userData);
  154. UNUSED_P(name);
  155. }
  156. void XMLCALL
  157. dummy_start_cdata_handler(void *userData) {
  158. UNUSED_P(userData);
  159. dummy_handler_flags |= DUMMY_START_CDATA_HANDLER_FLAG;
  160. }
  161. void XMLCALL
  162. dummy_end_cdata_handler(void *userData) {
  163. UNUSED_P(userData);
  164. dummy_handler_flags |= DUMMY_END_CDATA_HANDLER_FLAG;
  165. }
  166. void XMLCALL
  167. dummy_cdata_handler(void *userData, const XML_Char *s, int len) {
  168. UNUSED_P(userData);
  169. UNUSED_P(s);
  170. UNUSED_P(len);
  171. }
  172. void XMLCALL
  173. dummy_start_namespace_decl_handler(void *userData, const XML_Char *prefix,
  174. const XML_Char *uri) {
  175. UNUSED_P(userData);
  176. UNUSED_P(prefix);
  177. UNUSED_P(uri);
  178. dummy_handler_flags |= DUMMY_START_NS_DECL_HANDLER_FLAG;
  179. }
  180. void XMLCALL
  181. dummy_end_namespace_decl_handler(void *userData, const XML_Char *prefix) {
  182. UNUSED_P(userData);
  183. UNUSED_P(prefix);
  184. dummy_handler_flags |= DUMMY_END_NS_DECL_HANDLER_FLAG;
  185. }
  186. /* This handler is obsolete, but while the code exists we should
  187. * ensure that dealing with the handler is covered by tests.
  188. */
  189. void XMLCALL
  190. dummy_unparsed_entity_decl_handler(void *userData, const XML_Char *entityName,
  191. const XML_Char *base,
  192. const XML_Char *systemId,
  193. const XML_Char *publicId,
  194. const XML_Char *notationName) {
  195. UNUSED_P(userData);
  196. UNUSED_P(entityName);
  197. UNUSED_P(base);
  198. UNUSED_P(systemId);
  199. UNUSED_P(publicId);
  200. UNUSED_P(notationName);
  201. dummy_handler_flags |= DUMMY_UNPARSED_ENTITY_DECL_HANDLER_FLAG;
  202. }
  203. void XMLCALL
  204. dummy_default_handler(void *userData, const XML_Char *s, int len) {
  205. UNUSED_P(userData);
  206. UNUSED_P(s);
  207. UNUSED_P(len);
  208. }
  209. void XMLCALL
  210. dummy_start_doctype_decl_handler(void *userData, const XML_Char *doctypeName,
  211. const XML_Char *sysid, const XML_Char *pubid,
  212. int has_internal_subset) {
  213. UNUSED_P(userData);
  214. UNUSED_P(doctypeName);
  215. UNUSED_P(sysid);
  216. UNUSED_P(pubid);
  217. UNUSED_P(has_internal_subset);
  218. dummy_handler_flags |= DUMMY_START_DOCTYPE_DECL_HANDLER_FLAG;
  219. }
  220. void XMLCALL
  221. dummy_end_doctype_decl_handler(void *userData) {
  222. UNUSED_P(userData);
  223. dummy_handler_flags |= DUMMY_END_DOCTYPE_DECL_HANDLER_FLAG;
  224. }
  225. void XMLCALL
  226. dummy_skip_handler(void *userData, const XML_Char *entityName,
  227. int is_parameter_entity) {
  228. UNUSED_P(userData);
  229. UNUSED_P(entityName);
  230. UNUSED_P(is_parameter_entity);
  231. dummy_handler_flags |= DUMMY_SKIP_HANDLER_FLAG;
  232. }