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