Daniel Veillard | b847864 | 2001-10-12 17:29:10 +0000 | [diff] [blame] | 1 | /* |
| 2 | * globals.c: definition and handling of the set of global variables |
| 3 | * of the library |
| 4 | * |
| 5 | * The bottom of this file is automatically generated by build_glob.py |
| 6 | * based on the description file global.data |
| 7 | * |
| 8 | * See Copyright for the status of this software. |
| 9 | * |
| 10 | * Gary Pennington <Gary.Pennington@uk.sun.com> |
| 11 | * daniel@veillard.com |
| 12 | */ |
| 13 | |
Daniel Veillard | 34ce8be | 2002-03-18 19:37:11 +0000 | [diff] [blame] | 14 | #define IN_LIBXML |
Daniel Veillard | b847864 | 2001-10-12 17:29:10 +0000 | [diff] [blame] | 15 | #include "libxml.h" |
| 16 | |
Daniel Veillard | e709061 | 2001-10-13 12:18:28 +0000 | [diff] [blame] | 17 | #ifdef HAVE_STDLIB_H |
Jaka Mocnik | 77d19ae | 2001-10-13 12:06:09 +0000 | [diff] [blame] | 18 | #include <stdlib.h> |
Daniel Veillard | e709061 | 2001-10-13 12:18:28 +0000 | [diff] [blame] | 19 | #endif |
Jaka Mocnik | 77d19ae | 2001-10-13 12:06:09 +0000 | [diff] [blame] | 20 | #include <string.h> |
| 21 | |
Daniel Veillard | 3c01b1d | 2001-10-17 15:58:35 +0000 | [diff] [blame] | 22 | #include <libxml/globals.h> |
Daniel Veillard | e709061 | 2001-10-13 12:18:28 +0000 | [diff] [blame] | 23 | #include <libxml/xmlmemory.h> |
| 24 | |
Daniel Veillard | 3c01b1d | 2001-10-17 15:58:35 +0000 | [diff] [blame] | 25 | /* #define DEBUG_GLOBALS */ |
| 26 | |
Daniel Veillard | b847864 | 2001-10-12 17:29:10 +0000 | [diff] [blame] | 27 | /* |
| 28 | * Helpful Macro |
| 29 | */ |
Daniel Veillard | 3c01b1d | 2001-10-17 15:58:35 +0000 | [diff] [blame] | 30 | #ifdef LIBXML_THREAD_ENABLED |
| 31 | #define IS_MAIN_THREAD (xmlIsMainThread()) |
Daniel Veillard | b847864 | 2001-10-12 17:29:10 +0000 | [diff] [blame] | 32 | #else |
| 33 | #define IS_MAIN_THREAD 1 |
| 34 | #endif |
| 35 | |
| 36 | /************************************************************************ |
| 37 | * * |
| 38 | * All the user accessible global variables of the library * |
| 39 | * * |
| 40 | ************************************************************************/ |
| 41 | |
Daniel Veillard | b847864 | 2001-10-12 17:29:10 +0000 | [diff] [blame] | 42 | /* |
| 43 | * Memory allocation routines |
| 44 | */ |
Daniel Veillard | 7216cfd | 2002-11-08 15:10:00 +0000 | [diff] [blame] | 45 | #if defined(DEBUG_MEMORY_LOCATION) || defined(DEBUG_MEMORY) |
Daniel Veillard | d046356 | 2001-10-13 09:15:48 +0000 | [diff] [blame] | 46 | extern void xmlMemFree(void *ptr); |
| 47 | extern void * xmlMemMalloc(size_t size); |
| 48 | extern void * xmlMemRealloc(void *ptr,size_t size); |
| 49 | extern char * xmlMemoryStrdup(const char *str); |
| 50 | |
Daniel Veillard | b847864 | 2001-10-12 17:29:10 +0000 | [diff] [blame] | 51 | xmlFreeFunc xmlFree = (xmlFreeFunc) xmlMemFree; |
| 52 | xmlMallocFunc xmlMalloc = (xmlMallocFunc) xmlMemMalloc; |
| 53 | xmlReallocFunc xmlRealloc = (xmlReallocFunc) xmlMemRealloc; |
| 54 | xmlStrdupFunc xmlMemStrdup = (xmlStrdupFunc) xmlMemoryStrdup; |
| 55 | #else |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 56 | /** |
| 57 | * xmlFree: |
| 58 | * @mem: an already allocated block of memory |
| 59 | * |
| 60 | * The variable holding the libxml free() implementation |
| 61 | */ |
Daniel Veillard | b847864 | 2001-10-12 17:29:10 +0000 | [diff] [blame] | 62 | xmlFreeFunc xmlFree = (xmlFreeFunc) free; |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 63 | /** |
| 64 | * xmlMalloc: |
| 65 | * @size: the size requested in bytes |
| 66 | * |
| 67 | * The variable holding the libxml malloc() implementation |
| 68 | * |
| 69 | * Returns a pointer to the newly allocated block or NULL in case of error |
| 70 | */ |
Daniel Veillard | b847864 | 2001-10-12 17:29:10 +0000 | [diff] [blame] | 71 | xmlMallocFunc xmlMalloc = (xmlMallocFunc) malloc; |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 72 | /** |
| 73 | * xmlRealloc: |
| 74 | * @mem: an already allocated block of memory |
| 75 | * @size: the new size requested in bytes |
| 76 | * |
| 77 | * The variable holding the libxml realloc() implementation |
| 78 | * |
| 79 | * Returns a pointer to the newly reallocated block or NULL in case of error |
| 80 | */ |
Daniel Veillard | b847864 | 2001-10-12 17:29:10 +0000 | [diff] [blame] | 81 | xmlReallocFunc xmlRealloc = (xmlReallocFunc) realloc; |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 82 | /** |
| 83 | * xmlMemStrdup: |
| 84 | * @str: a zero terminated string |
| 85 | * |
| 86 | * The variable holding the libxml strdup() implementation |
| 87 | * |
| 88 | * Returns the copy of the string or NULL in case of error |
| 89 | */ |
Daniel Veillard | b82c166 | 2001-12-09 14:00:54 +0000 | [diff] [blame] | 90 | xmlStrdupFunc xmlMemStrdup = (xmlStrdupFunc) xmlStrdup; |
Daniel Veillard | b847864 | 2001-10-12 17:29:10 +0000 | [diff] [blame] | 91 | #endif |
| 92 | |
Daniel Veillard | d046356 | 2001-10-13 09:15:48 +0000 | [diff] [blame] | 93 | #include <libxml/threads.h> |
| 94 | #include <libxml/globals.h> |
| 95 | #include <libxml/SAX.h> |
| 96 | |
| 97 | #undef docbDefaultSAXHandler |
| 98 | #undef htmlDefaultSAXHandler |
| 99 | #undef oldXMLWDcompatibility |
| 100 | #undef xmlBufferAllocScheme |
| 101 | #undef xmlDefaultBufferSize |
| 102 | #undef xmlDefaultSAXHandler |
| 103 | #undef xmlDefaultSAXLocator |
| 104 | #undef xmlDoValidityCheckingDefaultValue |
| 105 | #undef xmlGenericError |
| 106 | #undef xmlGenericErrorContext |
| 107 | #undef xmlGetWarningsDefaultValue |
| 108 | #undef xmlIndentTreeOutput |
Aleksey Sanin | 2300256 | 2002-05-24 07:18:40 +0000 | [diff] [blame] | 109 | #undef xmlTreeIndentString |
Daniel Veillard | d046356 | 2001-10-13 09:15:48 +0000 | [diff] [blame] | 110 | #undef xmlKeepBlanksDefaultValue |
| 111 | #undef xmlLineNumbersDefaultValue |
| 112 | #undef xmlLoadExtDtdDefaultValue |
| 113 | #undef xmlParserDebugEntities |
| 114 | #undef xmlParserVersion |
| 115 | #undef xmlPedanticParserDefaultValue |
| 116 | #undef xmlSaveNoEmptyTags |
| 117 | #undef xmlSubstituteEntitiesDefaultValue |
| 118 | |
| 119 | #undef xmlFree |
| 120 | #undef xmlMalloc |
| 121 | #undef xmlMemStrdup |
| 122 | #undef xmlRealloc |
| 123 | |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 124 | /** |
| 125 | * xmlParserVersion: |
| 126 | * |
| 127 | * Constant string describing the internal version of the library |
| 128 | */ |
Daniel Veillard | 3c01b1d | 2001-10-17 15:58:35 +0000 | [diff] [blame] | 129 | const char *xmlParserVersion = LIBXML_VERSION_STRING; |
| 130 | |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 131 | /** |
| 132 | * xmlBufferAllocScheme: |
| 133 | * |
| 134 | * Global setting, default allocation policy for buffers, default is |
| 135 | * XML_BUFFER_ALLOC_EXACT |
Daniel Veillard | b847864 | 2001-10-12 17:29:10 +0000 | [diff] [blame] | 136 | */ |
| 137 | xmlBufferAllocationScheme xmlBufferAllocScheme = XML_BUFFER_ALLOC_EXACT; |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 138 | /** |
| 139 | * xmlDefaultBufferSize: |
| 140 | * |
| 141 | * Global setting, default buffer size. Default value is BASE_BUFFER_SIZE |
| 142 | */ |
Daniel Veillard | b847864 | 2001-10-12 17:29:10 +0000 | [diff] [blame] | 143 | int xmlDefaultBufferSize = BASE_BUFFER_SIZE; |
| 144 | |
| 145 | /* |
| 146 | * Parser defaults |
| 147 | */ |
Daniel Veillard | d046356 | 2001-10-13 09:15:48 +0000 | [diff] [blame] | 148 | |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 149 | /** |
| 150 | * oldXMLWDcompatibility: |
| 151 | * |
| 152 | * Global setting, DEPRECATED. |
| 153 | */ |
Daniel Veillard | b847864 | 2001-10-12 17:29:10 +0000 | [diff] [blame] | 154 | int oldXMLWDcompatibility = 0; /* DEPRECATED */ |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 155 | /** |
| 156 | * xmlParserDebugEntities: |
| 157 | * |
| 158 | * Global setting, asking the parser to print out debugging informations. |
| 159 | * while handling entities. |
| 160 | * Disabled by default |
| 161 | */ |
Daniel Veillard | b847864 | 2001-10-12 17:29:10 +0000 | [diff] [blame] | 162 | int xmlParserDebugEntities = 0; |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 163 | /** |
| 164 | * xmlDoValidityCheckingDefaultValue: |
| 165 | * |
| 166 | * Global setting, indicate that the parser should work in validating mode. |
| 167 | * Disabled by default. |
| 168 | */ |
Daniel Veillard | b847864 | 2001-10-12 17:29:10 +0000 | [diff] [blame] | 169 | int xmlDoValidityCheckingDefaultValue = 0; |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 170 | /** |
| 171 | * xmlGetWarningsDefaultValue: |
| 172 | * |
| 173 | * Global setting, indicate that the parser should provide warnings. |
| 174 | * Activated by default. |
| 175 | */ |
Daniel Veillard | b847864 | 2001-10-12 17:29:10 +0000 | [diff] [blame] | 176 | int xmlGetWarningsDefaultValue = 1; |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 177 | /** |
| 178 | * xmlLoadExtDtdDefaultValue: |
| 179 | * |
| 180 | * Global setting, indicate that the parser should load DTD while not |
| 181 | * validating. |
| 182 | * Disabled by default. |
| 183 | */ |
Daniel Veillard | b847864 | 2001-10-12 17:29:10 +0000 | [diff] [blame] | 184 | int xmlLoadExtDtdDefaultValue = 0; |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 185 | /** |
| 186 | * xmlPedanticParserDefaultValue: |
| 187 | * |
| 188 | * Global setting, indicate that the parser be pedantic |
| 189 | * Disabled by default. |
| 190 | */ |
Daniel Veillard | b847864 | 2001-10-12 17:29:10 +0000 | [diff] [blame] | 191 | int xmlPedanticParserDefaultValue = 0; |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 192 | /** |
| 193 | * xmlLineNumbersDefaultValue: |
| 194 | * |
| 195 | * Global setting, indicate that the parser should store the line number |
| 196 | * in the content field of elements in the DOM tree. |
| 197 | * Disabled by default since this may not be safe for old classes of |
| 198 | * applicaton. |
| 199 | */ |
Daniel Veillard | b847864 | 2001-10-12 17:29:10 +0000 | [diff] [blame] | 200 | int xmlLineNumbersDefaultValue = 0; |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 201 | /** |
| 202 | * xmlKeepBlanksDefaultValue: |
| 203 | * |
| 204 | * Global setting, indicate that the parser should keep all blanks |
| 205 | * nodes found in the content |
| 206 | * Activated by default, this is actually needed to have the parser |
| 207 | * conformant to the XML Recommendation, however the option is kept |
| 208 | * for some applications since this was libxml1 default behaviour. |
| 209 | */ |
Daniel Veillard | b847864 | 2001-10-12 17:29:10 +0000 | [diff] [blame] | 210 | int xmlKeepBlanksDefaultValue = 1; |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 211 | /** |
| 212 | * xmlSubstituteEntitiesDefaultValue: |
| 213 | * |
| 214 | * Global setting, indicate that the parser should not generate entity |
| 215 | * references but replace them with the actual content of the entity |
| 216 | * Disabled by default, this should be activated when using XPath since |
| 217 | * the XPath data model requires entities replacement and the XPath |
| 218 | * engine does not handle entities references transparently. |
| 219 | */ |
Daniel Veillard | b847864 | 2001-10-12 17:29:10 +0000 | [diff] [blame] | 220 | int xmlSubstituteEntitiesDefaultValue = 0; |
| 221 | |
Daniel Veillard | 5335dc5 | 2003-01-01 20:59:38 +0000 | [diff] [blame] | 222 | xmlRegisterNodeFunc xmlRegisterNodeDefaultValue = NULL; |
| 223 | xmlDeregisterNodeFunc xmlDeregisterNodeDefaultValue = NULL; |
| 224 | |
Daniel Veillard | b847864 | 2001-10-12 17:29:10 +0000 | [diff] [blame] | 225 | /* |
| 226 | * Error handling |
| 227 | */ |
| 228 | |
| 229 | /* xmlGenericErrorFunc xmlGenericError = xmlGenericErrorDefaultFunc; */ |
| 230 | /* Must initialize xmlGenericError in xmlInitParser */ |
Daniel Veillard | 635ef72 | 2001-10-29 11:48:19 +0000 | [diff] [blame] | 231 | void xmlGenericErrorDefaultFunc (void *ctx ATTRIBUTE_UNUSED, |
| 232 | const char *msg, |
| 233 | ...); |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 234 | /** |
| 235 | * xmlGenericError: |
| 236 | * |
| 237 | * Global setting: function used for generic error callbacks |
| 238 | */ |
Daniel Veillard | 635ef72 | 2001-10-29 11:48:19 +0000 | [diff] [blame] | 239 | xmlGenericErrorFunc xmlGenericError = xmlGenericErrorDefaultFunc; |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 240 | /** |
| 241 | * xmlGenericErrorContext: |
| 242 | * |
| 243 | * Global setting passed to generic error callbacks |
| 244 | */ |
Daniel Veillard | b847864 | 2001-10-12 17:29:10 +0000 | [diff] [blame] | 245 | void *xmlGenericErrorContext = NULL; |
| 246 | |
| 247 | /* |
| 248 | * output defaults |
| 249 | */ |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 250 | /** |
| 251 | * xmlIndentTreeOutput: |
| 252 | * |
| 253 | * Global setting, asking the serializer to indent the output tree by default |
Aleksey Sanin | 2300256 | 2002-05-24 07:18:40 +0000 | [diff] [blame] | 254 | * Enabled by default |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 255 | */ |
Aleksey Sanin | 2300256 | 2002-05-24 07:18:40 +0000 | [diff] [blame] | 256 | int xmlIndentTreeOutput = 1; |
| 257 | |
| 258 | /** |
| 259 | * xmlTreeIndentString: |
| 260 | * |
| 261 | * The string used to do one-level indent. By default is equal to " " (two spaces) |
| 262 | */ |
| 263 | const char *xmlTreeIndentString = " "; |
| 264 | |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 265 | /** |
| 266 | * xmlSaveNoEmptyTags: |
| 267 | * |
| 268 | * Global setting, asking the serializer to not output empty tags |
| 269 | * as <empty/> but <empty></empty>. those two forms are undistinguishable |
| 270 | * once parsed. |
| 271 | * Disabled by default |
| 272 | */ |
Daniel Veillard | b847864 | 2001-10-12 17:29:10 +0000 | [diff] [blame] | 273 | int xmlSaveNoEmptyTags = 0; |
| 274 | |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 275 | /** |
| 276 | * xmlDefaultSAXHandler: |
| 277 | * |
Daniel Veillard | b847864 | 2001-10-12 17:29:10 +0000 | [diff] [blame] | 278 | * Default handler for XML, builds the DOM tree |
| 279 | */ |
| 280 | xmlSAXHandler xmlDefaultSAXHandler = { |
| 281 | internalSubset, |
| 282 | isStandalone, |
| 283 | hasInternalSubset, |
| 284 | hasExternalSubset, |
| 285 | resolveEntity, |
| 286 | getEntity, |
| 287 | entityDecl, |
| 288 | notationDecl, |
| 289 | attributeDecl, |
| 290 | elementDecl, |
| 291 | unparsedEntityDecl, |
| 292 | setDocumentLocator, |
| 293 | startDocument, |
| 294 | endDocument, |
| 295 | startElement, |
| 296 | endElement, |
| 297 | reference, |
| 298 | characters, |
| 299 | characters, |
| 300 | processingInstruction, |
| 301 | comment, |
| 302 | xmlParserWarning, |
| 303 | xmlParserError, |
| 304 | xmlParserError, |
| 305 | getParameterEntity, |
| 306 | cdataBlock, |
| 307 | externalSubset, |
| 308 | 0 |
| 309 | }; |
| 310 | |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 311 | /** |
| 312 | * xmlDefaultSAXLocator: |
| 313 | * |
| 314 | * The default SAX Locator |
| 315 | * { getPublicId, getSystemId, getLineNumber, getColumnNumber} |
Daniel Veillard | b847864 | 2001-10-12 17:29:10 +0000 | [diff] [blame] | 316 | */ |
Daniel Veillard | b847864 | 2001-10-12 17:29:10 +0000 | [diff] [blame] | 317 | xmlSAXLocator xmlDefaultSAXLocator = { |
| 318 | getPublicId, getSystemId, getLineNumber, getColumnNumber |
| 319 | }; |
| 320 | |
| 321 | #ifdef LIBXML_HTML_ENABLED |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 322 | /** |
| 323 | * htmlDefaultSAXHandler: |
| 324 | * |
Daniel Veillard | b847864 | 2001-10-12 17:29:10 +0000 | [diff] [blame] | 325 | * Default handler for HTML, builds the DOM tree |
| 326 | */ |
| 327 | xmlSAXHandler htmlDefaultSAXHandler = { |
| 328 | internalSubset, |
| 329 | NULL, |
| 330 | NULL, |
| 331 | NULL, |
| 332 | NULL, |
| 333 | getEntity, |
| 334 | NULL, |
| 335 | NULL, |
| 336 | NULL, |
| 337 | NULL, |
| 338 | NULL, |
| 339 | setDocumentLocator, |
| 340 | startDocument, |
| 341 | endDocument, |
| 342 | startElement, |
| 343 | endElement, |
| 344 | NULL, |
| 345 | characters, |
| 346 | ignorableWhitespace, |
| 347 | NULL, |
| 348 | comment, |
| 349 | xmlParserWarning, |
| 350 | xmlParserError, |
| 351 | xmlParserError, |
| 352 | getParameterEntity, |
| 353 | cdataBlock, |
| 354 | NULL, |
| 355 | 0 |
| 356 | }; |
| 357 | #endif /* LIBXML_HTML_ENABLED */ |
| 358 | |
| 359 | #ifdef LIBXML_DOCB_ENABLED |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 360 | /** |
| 361 | * docbDefaultSAXHandler: |
| 362 | * |
Daniel Veillard | b847864 | 2001-10-12 17:29:10 +0000 | [diff] [blame] | 363 | * Default handler for SGML DocBook, builds the DOM tree |
| 364 | */ |
| 365 | xmlSAXHandler docbDefaultSAXHandler = { |
| 366 | internalSubset, |
| 367 | isStandalone, |
| 368 | hasInternalSubset, |
| 369 | hasExternalSubset, |
| 370 | resolveEntity, |
| 371 | getEntity, |
| 372 | entityDecl, |
| 373 | NULL, |
| 374 | NULL, |
| 375 | NULL, |
| 376 | NULL, |
| 377 | setDocumentLocator, |
| 378 | startDocument, |
| 379 | endDocument, |
| 380 | startElement, |
| 381 | endElement, |
| 382 | reference, |
| 383 | characters, |
| 384 | ignorableWhitespace, |
| 385 | NULL, |
| 386 | comment, |
| 387 | xmlParserWarning, |
| 388 | xmlParserError, |
| 389 | xmlParserError, |
| 390 | getParameterEntity, |
| 391 | NULL, |
| 392 | NULL, |
| 393 | 0 |
| 394 | }; |
| 395 | #endif /* LIBXML_DOCB_ENABLED */ |
| 396 | |
| 397 | /** |
| 398 | * xmlInitializeGlobalState: |
| 399 | * @gs: a pointer to a newly allocated global state |
| 400 | * |
| 401 | * xmlInitializeGlobalState() initialize a global state with all the |
| 402 | * default values of the library. |
| 403 | */ |
| 404 | void |
| 405 | xmlInitializeGlobalState(xmlGlobalStatePtr gs) |
| 406 | { |
Daniel Veillard | 3c01b1d | 2001-10-17 15:58:35 +0000 | [diff] [blame] | 407 | #ifdef DEBUG_GLOBALS |
| 408 | fprintf(stderr, "Initializing globals at %lu for thread %d\n", |
| 409 | (unsigned long) gs, xmlGetThreadId()); |
| 410 | #endif |
| 411 | |
Daniel Veillard | b847864 | 2001-10-12 17:29:10 +0000 | [diff] [blame] | 412 | /* |
Daniel Veillard | cbaf399 | 2001-12-31 16:16:02 +0000 | [diff] [blame] | 413 | * Perform initialization as required by libxml |
Daniel Veillard | b847864 | 2001-10-12 17:29:10 +0000 | [diff] [blame] | 414 | */ |
William M. Brack | 8b2c7f1 | 2002-11-22 05:07:29 +0000 | [diff] [blame] | 415 | |
Daniel Veillard | a4617b8 | 2001-11-04 20:19:12 +0000 | [diff] [blame] | 416 | #ifdef LIBXML_DOCB_ENABLED |
Daniel Veillard | b847864 | 2001-10-12 17:29:10 +0000 | [diff] [blame] | 417 | initdocbDefaultSAXHandler(&gs->docbDefaultSAXHandler); |
Daniel Veillard | a4617b8 | 2001-11-04 20:19:12 +0000 | [diff] [blame] | 418 | #endif |
| 419 | #ifdef LIBXML_HTML_ENABLED |
Daniel Veillard | b847864 | 2001-10-12 17:29:10 +0000 | [diff] [blame] | 420 | inithtmlDefaultSAXHandler(&gs->htmlDefaultSAXHandler); |
Daniel Veillard | a4617b8 | 2001-11-04 20:19:12 +0000 | [diff] [blame] | 421 | #endif |
Daniel Veillard | 3c01b1d | 2001-10-17 15:58:35 +0000 | [diff] [blame] | 422 | initGenericErrorDefaultFunc(&gs->xmlGenericError); |
| 423 | |
Daniel Veillard | b847864 | 2001-10-12 17:29:10 +0000 | [diff] [blame] | 424 | gs->oldXMLWDcompatibility = 0; |
| 425 | gs->xmlBufferAllocScheme = XML_BUFFER_ALLOC_EXACT; |
| 426 | gs->xmlDefaultBufferSize = BASE_BUFFER_SIZE; |
| 427 | initxmlDefaultSAXHandler(&gs->xmlDefaultSAXHandler, 1); |
| 428 | gs->xmlDefaultSAXLocator.getPublicId = getPublicId; |
| 429 | gs->xmlDefaultSAXLocator.getSystemId = getSystemId; |
| 430 | gs->xmlDefaultSAXLocator.getLineNumber = getLineNumber; |
| 431 | gs->xmlDefaultSAXLocator.getColumnNumber = getColumnNumber; |
| 432 | gs->xmlDoValidityCheckingDefaultValue = 0; |
| 433 | #if defined(DEBUG_MEMORY_LOCATION) | defined(DEBUG_MEMORY) |
| 434 | gs->xmlFree = (xmlFreeFunc) xmlMemFree; |
| 435 | gs->xmlMalloc = (xmlMallocFunc) xmlMemMalloc; |
| 436 | gs->xmlRealloc = (xmlReallocFunc) xmlMemRealloc; |
| 437 | gs->xmlMemStrdup = (xmlStrdupFunc) xmlMemoryStrdup; |
| 438 | #else |
| 439 | gs->xmlFree = (xmlFreeFunc) free; |
| 440 | gs->xmlMalloc = (xmlMallocFunc) malloc; |
| 441 | gs->xmlRealloc = (xmlReallocFunc) realloc; |
Daniel Veillard | 572577e | 2002-01-18 16:23:55 +0000 | [diff] [blame] | 442 | gs->xmlMemStrdup = (xmlStrdupFunc) xmlStrdup; |
Daniel Veillard | b847864 | 2001-10-12 17:29:10 +0000 | [diff] [blame] | 443 | #endif |
Daniel Veillard | b847864 | 2001-10-12 17:29:10 +0000 | [diff] [blame] | 444 | gs->xmlGenericErrorContext = NULL; |
| 445 | gs->xmlGetWarningsDefaultValue = 1; |
Aleksey Sanin | 2300256 | 2002-05-24 07:18:40 +0000 | [diff] [blame] | 446 | gs->xmlIndentTreeOutput = 1; |
| 447 | gs->xmlTreeIndentString = " "; |
Daniel Veillard | b847864 | 2001-10-12 17:29:10 +0000 | [diff] [blame] | 448 | gs->xmlKeepBlanksDefaultValue = 1; |
| 449 | gs->xmlLineNumbersDefaultValue = 0; |
| 450 | gs->xmlLoadExtDtdDefaultValue = 0; |
| 451 | gs->xmlParserDebugEntities = 0; |
| 452 | gs->xmlParserVersion = LIBXML_VERSION_STRING; |
| 453 | gs->xmlPedanticParserDefaultValue = 0; |
| 454 | gs->xmlSaveNoEmptyTags = 0; |
| 455 | gs->xmlSubstituteEntitiesDefaultValue = 0; |
Daniel Veillard | 5335dc5 | 2003-01-01 20:59:38 +0000 | [diff] [blame] | 456 | |
| 457 | gs->xmlRegisterNodeDefaultValue = NULL; |
| 458 | gs->xmlDeregisterNodeDefaultValue = NULL; |
Daniel Veillard | b847864 | 2001-10-12 17:29:10 +0000 | [diff] [blame] | 459 | } |
| 460 | |
Daniel Veillard | 5335dc5 | 2003-01-01 20:59:38 +0000 | [diff] [blame] | 461 | /** |
| 462 | * xmlRegisterNodeDefault |
| 463 | * @func: function pointer to the new RegisterNodeFunc |
| 464 | * |
| 465 | */ |
| 466 | xmlRegisterNodeFunc |
| 467 | xmlRegisterNodeDefault(xmlRegisterNodeFunc func) |
| 468 | { |
| 469 | xmlRegisterNodeFunc old = xmlRegisterNodeDefaultValue; |
| 470 | |
| 471 | xmlRegisterNodeDefaultValue = func; |
| 472 | return(old); |
| 473 | } |
| 474 | |
| 475 | /** |
| 476 | * xmlDeegisterNodeDefault |
| 477 | * @func: function pointer to the new DeregisterNodeFunc |
| 478 | * |
| 479 | */ |
| 480 | xmlDeregisterNodeFunc |
| 481 | xmlDeregisterNodeDefault(xmlDeregisterNodeFunc func) |
| 482 | { |
| 483 | xmlDeregisterNodeFunc old = xmlDeregisterNodeDefaultValue; |
| 484 | |
| 485 | xmlDeregisterNodeDefaultValue = func; |
| 486 | return(old); |
| 487 | } |
| 488 | |
| 489 | |
Daniel Veillard | a4617b8 | 2001-11-04 20:19:12 +0000 | [diff] [blame] | 490 | #ifdef LIBXML_DOCB_ENABLED |
Daniel Veillard | b847864 | 2001-10-12 17:29:10 +0000 | [diff] [blame] | 491 | #undef docbDefaultSAXHandler |
| 492 | xmlSAXHandler * |
| 493 | __docbDefaultSAXHandler(void) { |
| 494 | if (IS_MAIN_THREAD) |
| 495 | return (&docbDefaultSAXHandler); |
| 496 | else |
Daniel Veillard | d046356 | 2001-10-13 09:15:48 +0000 | [diff] [blame] | 497 | return (&xmlGetGlobalState()->docbDefaultSAXHandler); |
Daniel Veillard | b847864 | 2001-10-12 17:29:10 +0000 | [diff] [blame] | 498 | } |
Daniel Veillard | a4617b8 | 2001-11-04 20:19:12 +0000 | [diff] [blame] | 499 | #endif |
Daniel Veillard | b847864 | 2001-10-12 17:29:10 +0000 | [diff] [blame] | 500 | |
Daniel Veillard | a4617b8 | 2001-11-04 20:19:12 +0000 | [diff] [blame] | 501 | #ifdef LIBXML_HTML_ENABLED |
Daniel Veillard | b847864 | 2001-10-12 17:29:10 +0000 | [diff] [blame] | 502 | #undef htmlDefaultSAXHandler |
| 503 | xmlSAXHandler * |
| 504 | __htmlDefaultSAXHandler(void) { |
| 505 | if (IS_MAIN_THREAD) |
| 506 | return (&htmlDefaultSAXHandler); |
| 507 | else |
Daniel Veillard | d046356 | 2001-10-13 09:15:48 +0000 | [diff] [blame] | 508 | return (&xmlGetGlobalState()->htmlDefaultSAXHandler); |
Daniel Veillard | b847864 | 2001-10-12 17:29:10 +0000 | [diff] [blame] | 509 | } |
Daniel Veillard | a4617b8 | 2001-11-04 20:19:12 +0000 | [diff] [blame] | 510 | #endif |
| 511 | |
| 512 | /* |
| 513 | * Everything starting from the line below is |
| 514 | * Automatically generated by build_glob.py. |
| 515 | * Do not modify the previous line. |
| 516 | */ |
| 517 | |
Daniel Veillard | b847864 | 2001-10-12 17:29:10 +0000 | [diff] [blame] | 518 | |
Daniel Veillard | b847864 | 2001-10-12 17:29:10 +0000 | [diff] [blame] | 519 | #undef oldXMLWDcompatibility |
| 520 | int * |
| 521 | __oldXMLWDcompatibility(void) { |
| 522 | if (IS_MAIN_THREAD) |
| 523 | return (&oldXMLWDcompatibility); |
| 524 | else |
Daniel Veillard | d046356 | 2001-10-13 09:15:48 +0000 | [diff] [blame] | 525 | return (&xmlGetGlobalState()->oldXMLWDcompatibility); |
Daniel Veillard | b847864 | 2001-10-12 17:29:10 +0000 | [diff] [blame] | 526 | } |
| 527 | |
Daniel Veillard | b847864 | 2001-10-12 17:29:10 +0000 | [diff] [blame] | 528 | #undef xmlBufferAllocScheme |
| 529 | xmlBufferAllocationScheme * |
| 530 | __xmlBufferAllocScheme(void) { |
| 531 | if (IS_MAIN_THREAD) |
| 532 | return (&xmlBufferAllocScheme); |
| 533 | else |
Daniel Veillard | d046356 | 2001-10-13 09:15:48 +0000 | [diff] [blame] | 534 | return (&xmlGetGlobalState()->xmlBufferAllocScheme); |
Daniel Veillard | b847864 | 2001-10-12 17:29:10 +0000 | [diff] [blame] | 535 | } |
| 536 | |
Daniel Veillard | b847864 | 2001-10-12 17:29:10 +0000 | [diff] [blame] | 537 | #undef xmlDefaultBufferSize |
| 538 | int * |
| 539 | __xmlDefaultBufferSize(void) { |
| 540 | if (IS_MAIN_THREAD) |
| 541 | return (&xmlDefaultBufferSize); |
| 542 | else |
Daniel Veillard | d046356 | 2001-10-13 09:15:48 +0000 | [diff] [blame] | 543 | return (&xmlGetGlobalState()->xmlDefaultBufferSize); |
Daniel Veillard | b847864 | 2001-10-12 17:29:10 +0000 | [diff] [blame] | 544 | } |
| 545 | |
Daniel Veillard | b847864 | 2001-10-12 17:29:10 +0000 | [diff] [blame] | 546 | #undef xmlDefaultSAXHandler |
| 547 | xmlSAXHandler * |
| 548 | __xmlDefaultSAXHandler(void) { |
| 549 | if (IS_MAIN_THREAD) |
| 550 | return (&xmlDefaultSAXHandler); |
| 551 | else |
Daniel Veillard | d046356 | 2001-10-13 09:15:48 +0000 | [diff] [blame] | 552 | return (&xmlGetGlobalState()->xmlDefaultSAXHandler); |
Daniel Veillard | b847864 | 2001-10-12 17:29:10 +0000 | [diff] [blame] | 553 | } |
| 554 | |
Daniel Veillard | b847864 | 2001-10-12 17:29:10 +0000 | [diff] [blame] | 555 | #undef xmlDefaultSAXLocator |
| 556 | xmlSAXLocator * |
| 557 | __xmlDefaultSAXLocator(void) { |
| 558 | if (IS_MAIN_THREAD) |
| 559 | return (&xmlDefaultSAXLocator); |
| 560 | else |
Daniel Veillard | d046356 | 2001-10-13 09:15:48 +0000 | [diff] [blame] | 561 | return (&xmlGetGlobalState()->xmlDefaultSAXLocator); |
Daniel Veillard | b847864 | 2001-10-12 17:29:10 +0000 | [diff] [blame] | 562 | } |
| 563 | |
Daniel Veillard | b847864 | 2001-10-12 17:29:10 +0000 | [diff] [blame] | 564 | #undef xmlDoValidityCheckingDefaultValue |
| 565 | int * |
| 566 | __xmlDoValidityCheckingDefaultValue(void) { |
| 567 | if (IS_MAIN_THREAD) |
| 568 | return (&xmlDoValidityCheckingDefaultValue); |
| 569 | else |
Daniel Veillard | d046356 | 2001-10-13 09:15:48 +0000 | [diff] [blame] | 570 | return (&xmlGetGlobalState()->xmlDoValidityCheckingDefaultValue); |
Daniel Veillard | b847864 | 2001-10-12 17:29:10 +0000 | [diff] [blame] | 571 | } |
| 572 | |
Daniel Veillard | b847864 | 2001-10-12 17:29:10 +0000 | [diff] [blame] | 573 | #undef xmlGenericError |
| 574 | xmlGenericErrorFunc * |
| 575 | __xmlGenericError(void) { |
| 576 | if (IS_MAIN_THREAD) |
| 577 | return (&xmlGenericError); |
| 578 | else |
Daniel Veillard | d046356 | 2001-10-13 09:15:48 +0000 | [diff] [blame] | 579 | return (&xmlGetGlobalState()->xmlGenericError); |
Daniel Veillard | b847864 | 2001-10-12 17:29:10 +0000 | [diff] [blame] | 580 | } |
| 581 | |
Daniel Veillard | b847864 | 2001-10-12 17:29:10 +0000 | [diff] [blame] | 582 | #undef xmlGenericErrorContext |
| 583 | void * * |
| 584 | __xmlGenericErrorContext(void) { |
| 585 | if (IS_MAIN_THREAD) |
| 586 | return (&xmlGenericErrorContext); |
| 587 | else |
Daniel Veillard | d046356 | 2001-10-13 09:15:48 +0000 | [diff] [blame] | 588 | return (&xmlGetGlobalState()->xmlGenericErrorContext); |
Daniel Veillard | b847864 | 2001-10-12 17:29:10 +0000 | [diff] [blame] | 589 | } |
| 590 | |
Daniel Veillard | b847864 | 2001-10-12 17:29:10 +0000 | [diff] [blame] | 591 | #undef xmlGetWarningsDefaultValue |
| 592 | int * |
| 593 | __xmlGetWarningsDefaultValue(void) { |
| 594 | if (IS_MAIN_THREAD) |
| 595 | return (&xmlGetWarningsDefaultValue); |
| 596 | else |
Daniel Veillard | d046356 | 2001-10-13 09:15:48 +0000 | [diff] [blame] | 597 | return (&xmlGetGlobalState()->xmlGetWarningsDefaultValue); |
Daniel Veillard | b847864 | 2001-10-12 17:29:10 +0000 | [diff] [blame] | 598 | } |
| 599 | |
Daniel Veillard | b847864 | 2001-10-12 17:29:10 +0000 | [diff] [blame] | 600 | #undef xmlIndentTreeOutput |
| 601 | int * |
| 602 | __xmlIndentTreeOutput(void) { |
| 603 | if (IS_MAIN_THREAD) |
| 604 | return (&xmlIndentTreeOutput); |
| 605 | else |
Daniel Veillard | d046356 | 2001-10-13 09:15:48 +0000 | [diff] [blame] | 606 | return (&xmlGetGlobalState()->xmlIndentTreeOutput); |
Daniel Veillard | b847864 | 2001-10-12 17:29:10 +0000 | [diff] [blame] | 607 | } |
| 608 | |
Aleksey Sanin | 2300256 | 2002-05-24 07:18:40 +0000 | [diff] [blame] | 609 | #undef xmlTreeIndentString |
| 610 | const char * * |
| 611 | __xmlTreeIndentString(void) { |
| 612 | if (IS_MAIN_THREAD) |
| 613 | return (&xmlTreeIndentString); |
| 614 | else |
| 615 | return (&xmlGetGlobalState()->xmlTreeIndentString); |
| 616 | } |
| 617 | |
Daniel Veillard | b847864 | 2001-10-12 17:29:10 +0000 | [diff] [blame] | 618 | #undef xmlKeepBlanksDefaultValue |
| 619 | int * |
| 620 | __xmlKeepBlanksDefaultValue(void) { |
| 621 | if (IS_MAIN_THREAD) |
| 622 | return (&xmlKeepBlanksDefaultValue); |
| 623 | else |
Daniel Veillard | d046356 | 2001-10-13 09:15:48 +0000 | [diff] [blame] | 624 | return (&xmlGetGlobalState()->xmlKeepBlanksDefaultValue); |
Daniel Veillard | b847864 | 2001-10-12 17:29:10 +0000 | [diff] [blame] | 625 | } |
| 626 | |
Daniel Veillard | b847864 | 2001-10-12 17:29:10 +0000 | [diff] [blame] | 627 | #undef xmlLineNumbersDefaultValue |
| 628 | int * |
| 629 | __xmlLineNumbersDefaultValue(void) { |
| 630 | if (IS_MAIN_THREAD) |
| 631 | return (&xmlLineNumbersDefaultValue); |
| 632 | else |
Daniel Veillard | d046356 | 2001-10-13 09:15:48 +0000 | [diff] [blame] | 633 | return (&xmlGetGlobalState()->xmlLineNumbersDefaultValue); |
Daniel Veillard | b847864 | 2001-10-12 17:29:10 +0000 | [diff] [blame] | 634 | } |
| 635 | |
Daniel Veillard | b847864 | 2001-10-12 17:29:10 +0000 | [diff] [blame] | 636 | #undef xmlLoadExtDtdDefaultValue |
| 637 | int * |
| 638 | __xmlLoadExtDtdDefaultValue(void) { |
| 639 | if (IS_MAIN_THREAD) |
| 640 | return (&xmlLoadExtDtdDefaultValue); |
| 641 | else |
Daniel Veillard | d046356 | 2001-10-13 09:15:48 +0000 | [diff] [blame] | 642 | return (&xmlGetGlobalState()->xmlLoadExtDtdDefaultValue); |
Daniel Veillard | b847864 | 2001-10-12 17:29:10 +0000 | [diff] [blame] | 643 | } |
| 644 | |
Daniel Veillard | b847864 | 2001-10-12 17:29:10 +0000 | [diff] [blame] | 645 | #undef xmlParserDebugEntities |
| 646 | int * |
| 647 | __xmlParserDebugEntities(void) { |
| 648 | if (IS_MAIN_THREAD) |
| 649 | return (&xmlParserDebugEntities); |
| 650 | else |
Daniel Veillard | d046356 | 2001-10-13 09:15:48 +0000 | [diff] [blame] | 651 | return (&xmlGetGlobalState()->xmlParserDebugEntities); |
Daniel Veillard | b847864 | 2001-10-12 17:29:10 +0000 | [diff] [blame] | 652 | } |
| 653 | |
Daniel Veillard | b847864 | 2001-10-12 17:29:10 +0000 | [diff] [blame] | 654 | #undef xmlParserVersion |
| 655 | const char * * |
| 656 | __xmlParserVersion(void) { |
| 657 | if (IS_MAIN_THREAD) |
| 658 | return (&xmlParserVersion); |
| 659 | else |
Daniel Veillard | d046356 | 2001-10-13 09:15:48 +0000 | [diff] [blame] | 660 | return (&xmlGetGlobalState()->xmlParserVersion); |
Daniel Veillard | b847864 | 2001-10-12 17:29:10 +0000 | [diff] [blame] | 661 | } |
| 662 | |
Daniel Veillard | b847864 | 2001-10-12 17:29:10 +0000 | [diff] [blame] | 663 | #undef xmlPedanticParserDefaultValue |
| 664 | int * |
| 665 | __xmlPedanticParserDefaultValue(void) { |
| 666 | if (IS_MAIN_THREAD) |
| 667 | return (&xmlPedanticParserDefaultValue); |
| 668 | else |
Daniel Veillard | d046356 | 2001-10-13 09:15:48 +0000 | [diff] [blame] | 669 | return (&xmlGetGlobalState()->xmlPedanticParserDefaultValue); |
Daniel Veillard | b847864 | 2001-10-12 17:29:10 +0000 | [diff] [blame] | 670 | } |
| 671 | |
Daniel Veillard | b847864 | 2001-10-12 17:29:10 +0000 | [diff] [blame] | 672 | #undef xmlSaveNoEmptyTags |
| 673 | int * |
| 674 | __xmlSaveNoEmptyTags(void) { |
| 675 | if (IS_MAIN_THREAD) |
| 676 | return (&xmlSaveNoEmptyTags); |
| 677 | else |
Daniel Veillard | d046356 | 2001-10-13 09:15:48 +0000 | [diff] [blame] | 678 | return (&xmlGetGlobalState()->xmlSaveNoEmptyTags); |
Daniel Veillard | b847864 | 2001-10-12 17:29:10 +0000 | [diff] [blame] | 679 | } |
| 680 | |
Daniel Veillard | b847864 | 2001-10-12 17:29:10 +0000 | [diff] [blame] | 681 | #undef xmlSubstituteEntitiesDefaultValue |
| 682 | int * |
| 683 | __xmlSubstituteEntitiesDefaultValue(void) { |
| 684 | if (IS_MAIN_THREAD) |
| 685 | return (&xmlSubstituteEntitiesDefaultValue); |
| 686 | else |
Daniel Veillard | d046356 | 2001-10-13 09:15:48 +0000 | [diff] [blame] | 687 | return (&xmlGetGlobalState()->xmlSubstituteEntitiesDefaultValue); |
Daniel Veillard | b847864 | 2001-10-12 17:29:10 +0000 | [diff] [blame] | 688 | } |
Daniel Veillard | 5335dc5 | 2003-01-01 20:59:38 +0000 | [diff] [blame] | 689 | |
| 690 | #undef xmlRegisterNodeDefaultValue |
| 691 | xmlRegisterNodeFunc * |
| 692 | __xmlRegisterNodeDefaultValue(void) { |
| 693 | if (IS_MAIN_THREAD) |
| 694 | return (&xmlRegisterNodeDefaultValue); |
| 695 | else |
| 696 | return (&xmlGetGlobalState()->xmlRegisterNodeDefaultValue); |
| 697 | } |
| 698 | |
| 699 | #undef xmlDeregisterNodeDefaultValue |
| 700 | xmlDeregisterNodeFunc * |
| 701 | __xmlDeregisterNodeDefaultValue(void) { |
| 702 | if (IS_MAIN_THREAD) |
| 703 | return (&xmlDeregisterNodeDefaultValue); |
| 704 | else |
| 705 | return (&xmlGetGlobalState()->xmlDeregisterNodeDefaultValue); |
| 706 | } |