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 | |
| 14 | #include "libxml.h" |
| 15 | |
| 16 | #include <libxml/threads.h> |
| 17 | #include <libxml/globals.h> |
| 18 | |
| 19 | /* |
| 20 | * Helpful Macro |
| 21 | */ |
| 22 | #ifdef WITH_PTHREAD_H |
| 23 | #if defined(SOLARIS) |
| 24 | #define THR_MAIN(tid) (-1 == thr_main() || tid == thr_main()) |
| 25 | #else |
| 26 | #define THR_MAIN(tid) (tid == 0 || tid == 1024) |
| 27 | #endif |
| 28 | |
| 29 | #define IS_MAIN_THREAD (THR_MAIN(pthread_self())) |
| 30 | #else |
| 31 | #define IS_MAIN_THREAD 1 |
| 32 | #endif |
| 33 | |
| 34 | /************************************************************************ |
| 35 | * * |
| 36 | * All the user accessible global variables of the library * |
| 37 | * * |
| 38 | ************************************************************************/ |
| 39 | |
| 40 | const char *xmlParserVersion = LIBXML_VERSION_STRING; |
| 41 | /* |
| 42 | * Memory allocation routines |
| 43 | */ |
| 44 | #if defined(DEBUG_MEMORY_LOCATION) | defined(DEBUG_MEMORY) |
| 45 | xmlFreeFunc xmlFree = (xmlFreeFunc) xmlMemFree; |
| 46 | xmlMallocFunc xmlMalloc = (xmlMallocFunc) xmlMemMalloc; |
| 47 | xmlReallocFunc xmlRealloc = (xmlReallocFunc) xmlMemRealloc; |
| 48 | xmlStrdupFunc xmlMemStrdup = (xmlStrdupFunc) xmlMemoryStrdup; |
| 49 | #else |
| 50 | xmlFreeFunc xmlFree = (xmlFreeFunc) free; |
| 51 | xmlMallocFunc xmlMalloc = (xmlMallocFunc) malloc; |
| 52 | xmlReallocFunc xmlRealloc = (xmlReallocFunc) realloc; |
| 53 | xmlStrdupFunc xmlMemStrdup = (xmlStrdupFunc) strdup; |
| 54 | #endif |
| 55 | |
| 56 | /* |
| 57 | * Buffers stuff |
| 58 | */ |
| 59 | xmlBufferAllocationScheme xmlBufferAllocScheme = XML_BUFFER_ALLOC_EXACT; |
| 60 | int xmlDefaultBufferSize = BASE_BUFFER_SIZE; |
| 61 | |
| 62 | /* |
| 63 | * Parser defaults |
| 64 | */ |
| 65 | int oldXMLWDcompatibility = 0; /* DEPRECATED */ |
| 66 | int xmlParserDebugEntities = 0; |
| 67 | int xmlDoValidityCheckingDefaultValue = 0; |
| 68 | int xmlGetWarningsDefaultValue = 1; |
| 69 | int xmlLoadExtDtdDefaultValue = 0; |
| 70 | int xmlPedanticParserDefaultValue = 0; |
| 71 | int xmlLineNumbersDefaultValue = 0; |
| 72 | int xmlKeepBlanksDefaultValue = 1; |
| 73 | int xmlSubstituteEntitiesDefaultValue = 0; |
| 74 | |
| 75 | /* |
| 76 | * Error handling |
| 77 | */ |
| 78 | |
| 79 | /* xmlGenericErrorFunc xmlGenericError = xmlGenericErrorDefaultFunc; */ |
| 80 | /* Must initialize xmlGenericError in xmlInitParser */ |
| 81 | xmlGenericErrorFunc xmlGenericError; |
| 82 | void *xmlGenericErrorContext = NULL; |
| 83 | |
| 84 | /* |
| 85 | * output defaults |
| 86 | */ |
| 87 | int xmlIndentTreeOutput = 0; |
| 88 | int xmlSaveNoEmptyTags = 0; |
| 89 | |
| 90 | /* |
| 91 | * Default handler for XML, builds the DOM tree |
| 92 | */ |
| 93 | xmlSAXHandler xmlDefaultSAXHandler = { |
| 94 | internalSubset, |
| 95 | isStandalone, |
| 96 | hasInternalSubset, |
| 97 | hasExternalSubset, |
| 98 | resolveEntity, |
| 99 | getEntity, |
| 100 | entityDecl, |
| 101 | notationDecl, |
| 102 | attributeDecl, |
| 103 | elementDecl, |
| 104 | unparsedEntityDecl, |
| 105 | setDocumentLocator, |
| 106 | startDocument, |
| 107 | endDocument, |
| 108 | startElement, |
| 109 | endElement, |
| 110 | reference, |
| 111 | characters, |
| 112 | characters, |
| 113 | processingInstruction, |
| 114 | comment, |
| 115 | xmlParserWarning, |
| 116 | xmlParserError, |
| 117 | xmlParserError, |
| 118 | getParameterEntity, |
| 119 | cdataBlock, |
| 120 | externalSubset, |
| 121 | 0 |
| 122 | }; |
| 123 | |
| 124 | /* |
| 125 | * The default SAX Locator. |
| 126 | */ |
| 127 | |
| 128 | xmlSAXLocator xmlDefaultSAXLocator = { |
| 129 | getPublicId, getSystemId, getLineNumber, getColumnNumber |
| 130 | }; |
| 131 | |
| 132 | #ifdef LIBXML_HTML_ENABLED |
| 133 | /* |
| 134 | * Default handler for HTML, builds the DOM tree |
| 135 | */ |
| 136 | xmlSAXHandler htmlDefaultSAXHandler = { |
| 137 | internalSubset, |
| 138 | NULL, |
| 139 | NULL, |
| 140 | NULL, |
| 141 | NULL, |
| 142 | getEntity, |
| 143 | NULL, |
| 144 | NULL, |
| 145 | NULL, |
| 146 | NULL, |
| 147 | NULL, |
| 148 | setDocumentLocator, |
| 149 | startDocument, |
| 150 | endDocument, |
| 151 | startElement, |
| 152 | endElement, |
| 153 | NULL, |
| 154 | characters, |
| 155 | ignorableWhitespace, |
| 156 | NULL, |
| 157 | comment, |
| 158 | xmlParserWarning, |
| 159 | xmlParserError, |
| 160 | xmlParserError, |
| 161 | getParameterEntity, |
| 162 | cdataBlock, |
| 163 | NULL, |
| 164 | 0 |
| 165 | }; |
| 166 | #endif /* LIBXML_HTML_ENABLED */ |
| 167 | |
| 168 | #ifdef LIBXML_DOCB_ENABLED |
| 169 | /* |
| 170 | * Default handler for SGML DocBook, builds the DOM tree |
| 171 | */ |
| 172 | xmlSAXHandler docbDefaultSAXHandler = { |
| 173 | internalSubset, |
| 174 | isStandalone, |
| 175 | hasInternalSubset, |
| 176 | hasExternalSubset, |
| 177 | resolveEntity, |
| 178 | getEntity, |
| 179 | entityDecl, |
| 180 | NULL, |
| 181 | NULL, |
| 182 | NULL, |
| 183 | NULL, |
| 184 | setDocumentLocator, |
| 185 | startDocument, |
| 186 | endDocument, |
| 187 | startElement, |
| 188 | endElement, |
| 189 | reference, |
| 190 | characters, |
| 191 | ignorableWhitespace, |
| 192 | NULL, |
| 193 | comment, |
| 194 | xmlParserWarning, |
| 195 | xmlParserError, |
| 196 | xmlParserError, |
| 197 | getParameterEntity, |
| 198 | NULL, |
| 199 | NULL, |
| 200 | 0 |
| 201 | }; |
| 202 | #endif /* LIBXML_DOCB_ENABLED */ |
| 203 | |
| 204 | /** |
| 205 | * xmlInitializeGlobalState: |
| 206 | * @gs: a pointer to a newly allocated global state |
| 207 | * |
| 208 | * xmlInitializeGlobalState() initialize a global state with all the |
| 209 | * default values of the library. |
| 210 | */ |
| 211 | void |
| 212 | xmlInitializeGlobalState(xmlGlobalStatePtr gs) |
| 213 | { |
| 214 | /* |
| 215 | * Perform initialisation as required by libxml |
| 216 | */ |
| 217 | initdocbDefaultSAXHandler(&gs->docbDefaultSAXHandler); |
| 218 | inithtmlDefaultSAXHandler(&gs->htmlDefaultSAXHandler); |
| 219 | gs->oldXMLWDcompatibility = 0; |
| 220 | gs->xmlBufferAllocScheme = XML_BUFFER_ALLOC_EXACT; |
| 221 | gs->xmlDefaultBufferSize = BASE_BUFFER_SIZE; |
| 222 | initxmlDefaultSAXHandler(&gs->xmlDefaultSAXHandler, 1); |
| 223 | gs->xmlDefaultSAXLocator.getPublicId = getPublicId; |
| 224 | gs->xmlDefaultSAXLocator.getSystemId = getSystemId; |
| 225 | gs->xmlDefaultSAXLocator.getLineNumber = getLineNumber; |
| 226 | gs->xmlDefaultSAXLocator.getColumnNumber = getColumnNumber; |
| 227 | gs->xmlDoValidityCheckingDefaultValue = 0; |
| 228 | #if defined(DEBUG_MEMORY_LOCATION) | defined(DEBUG_MEMORY) |
| 229 | gs->xmlFree = (xmlFreeFunc) xmlMemFree; |
| 230 | gs->xmlMalloc = (xmlMallocFunc) xmlMemMalloc; |
| 231 | gs->xmlRealloc = (xmlReallocFunc) xmlMemRealloc; |
| 232 | gs->xmlMemStrdup = (xmlStrdupFunc) xmlMemoryStrdup; |
| 233 | #else |
| 234 | gs->xmlFree = (xmlFreeFunc) free; |
| 235 | gs->xmlMalloc = (xmlMallocFunc) malloc; |
| 236 | gs->xmlRealloc = (xmlReallocFunc) realloc; |
| 237 | gs->xmlMemStrdup = (xmlStrdupFunc) strdup; |
| 238 | #endif |
| 239 | initGenericErrorDefaultFunc(&gs->xmlGenericError); |
| 240 | gs->xmlGenericErrorContext = NULL; |
| 241 | gs->xmlGetWarningsDefaultValue = 1; |
| 242 | gs->xmlIndentTreeOutput = 0; |
| 243 | gs->xmlKeepBlanksDefaultValue = 1; |
| 244 | gs->xmlLineNumbersDefaultValue = 0; |
| 245 | gs->xmlLoadExtDtdDefaultValue = 0; |
| 246 | gs->xmlParserDebugEntities = 0; |
| 247 | gs->xmlParserVersion = LIBXML_VERSION_STRING; |
| 248 | gs->xmlPedanticParserDefaultValue = 0; |
| 249 | gs->xmlSaveNoEmptyTags = 0; |
| 250 | gs->xmlSubstituteEntitiesDefaultValue = 0; |
| 251 | } |
| 252 | |
| 253 | /* |
| 254 | * Everything starting from the line below is |
| 255 | * Automatically generated by build_glob.py. |
| 256 | * Do not modify the previous line. |
| 257 | */ |
| 258 | |
| 259 | |
| 260 | extern xmlSAXHandler docbDefaultSAXHandler; |
| 261 | #undef docbDefaultSAXHandler |
| 262 | xmlSAXHandler * |
| 263 | __docbDefaultSAXHandler(void) { |
| 264 | if (IS_MAIN_THREAD) |
| 265 | return (&docbDefaultSAXHandler); |
| 266 | else |
| 267 | return (&get_glob_struct()->docbDefaultSAXHandler); |
| 268 | } |
| 269 | |
| 270 | extern xmlSAXHandler htmlDefaultSAXHandler; |
| 271 | #undef htmlDefaultSAXHandler |
| 272 | xmlSAXHandler * |
| 273 | __htmlDefaultSAXHandler(void) { |
| 274 | if (IS_MAIN_THREAD) |
| 275 | return (&htmlDefaultSAXHandler); |
| 276 | else |
| 277 | return (&get_glob_struct()->htmlDefaultSAXHandler); |
| 278 | } |
| 279 | |
| 280 | extern int oldXMLWDcompatibility; |
| 281 | #undef oldXMLWDcompatibility |
| 282 | int * |
| 283 | __oldXMLWDcompatibility(void) { |
| 284 | if (IS_MAIN_THREAD) |
| 285 | return (&oldXMLWDcompatibility); |
| 286 | else |
| 287 | return (&get_glob_struct()->oldXMLWDcompatibility); |
| 288 | } |
| 289 | |
| 290 | extern xmlBufferAllocationScheme xmlBufferAllocScheme; |
| 291 | #undef xmlBufferAllocScheme |
| 292 | xmlBufferAllocationScheme * |
| 293 | __xmlBufferAllocScheme(void) { |
| 294 | if (IS_MAIN_THREAD) |
| 295 | return (&xmlBufferAllocScheme); |
| 296 | else |
| 297 | return (&get_glob_struct()->xmlBufferAllocScheme); |
| 298 | } |
| 299 | |
| 300 | extern int xmlDefaultBufferSize; |
| 301 | #undef xmlDefaultBufferSize |
| 302 | int * |
| 303 | __xmlDefaultBufferSize(void) { |
| 304 | if (IS_MAIN_THREAD) |
| 305 | return (&xmlDefaultBufferSize); |
| 306 | else |
| 307 | return (&get_glob_struct()->xmlDefaultBufferSize); |
| 308 | } |
| 309 | |
| 310 | extern xmlSAXHandler xmlDefaultSAXHandler; |
| 311 | #undef xmlDefaultSAXHandler |
| 312 | xmlSAXHandler * |
| 313 | __xmlDefaultSAXHandler(void) { |
| 314 | if (IS_MAIN_THREAD) |
| 315 | return (&xmlDefaultSAXHandler); |
| 316 | else |
| 317 | return (&get_glob_struct()->xmlDefaultSAXHandler); |
| 318 | } |
| 319 | |
| 320 | extern xmlSAXLocator xmlDefaultSAXLocator; |
| 321 | #undef xmlDefaultSAXLocator |
| 322 | xmlSAXLocator * |
| 323 | __xmlDefaultSAXLocator(void) { |
| 324 | if (IS_MAIN_THREAD) |
| 325 | return (&xmlDefaultSAXLocator); |
| 326 | else |
| 327 | return (&get_glob_struct()->xmlDefaultSAXLocator); |
| 328 | } |
| 329 | |
| 330 | extern int xmlDoValidityCheckingDefaultValue; |
| 331 | #undef xmlDoValidityCheckingDefaultValue |
| 332 | int * |
| 333 | __xmlDoValidityCheckingDefaultValue(void) { |
| 334 | if (IS_MAIN_THREAD) |
| 335 | return (&xmlDoValidityCheckingDefaultValue); |
| 336 | else |
| 337 | return (&get_glob_struct()->xmlDoValidityCheckingDefaultValue); |
| 338 | } |
| 339 | |
| 340 | extern xmlFreeFunc xmlFree; |
| 341 | #undef xmlFree |
| 342 | xmlFreeFunc * |
| 343 | __xmlFree(void) { |
| 344 | if (IS_MAIN_THREAD) |
| 345 | return (&xmlFree); |
| 346 | else |
| 347 | return (&get_glob_struct()->xmlFree); |
| 348 | } |
| 349 | |
| 350 | extern xmlGenericErrorFunc xmlGenericError; |
| 351 | #undef xmlGenericError |
| 352 | xmlGenericErrorFunc * |
| 353 | __xmlGenericError(void) { |
| 354 | if (IS_MAIN_THREAD) |
| 355 | return (&xmlGenericError); |
| 356 | else |
| 357 | return (&get_glob_struct()->xmlGenericError); |
| 358 | } |
| 359 | |
| 360 | extern void * xmlGenericErrorContext; |
| 361 | #undef xmlGenericErrorContext |
| 362 | void * * |
| 363 | __xmlGenericErrorContext(void) { |
| 364 | if (IS_MAIN_THREAD) |
| 365 | return (&xmlGenericErrorContext); |
| 366 | else |
| 367 | return (&get_glob_struct()->xmlGenericErrorContext); |
| 368 | } |
| 369 | |
| 370 | extern int xmlGetWarningsDefaultValue; |
| 371 | #undef xmlGetWarningsDefaultValue |
| 372 | int * |
| 373 | __xmlGetWarningsDefaultValue(void) { |
| 374 | if (IS_MAIN_THREAD) |
| 375 | return (&xmlGetWarningsDefaultValue); |
| 376 | else |
| 377 | return (&get_glob_struct()->xmlGetWarningsDefaultValue); |
| 378 | } |
| 379 | |
| 380 | extern int xmlIndentTreeOutput; |
| 381 | #undef xmlIndentTreeOutput |
| 382 | int * |
| 383 | __xmlIndentTreeOutput(void) { |
| 384 | if (IS_MAIN_THREAD) |
| 385 | return (&xmlIndentTreeOutput); |
| 386 | else |
| 387 | return (&get_glob_struct()->xmlIndentTreeOutput); |
| 388 | } |
| 389 | |
| 390 | extern int xmlKeepBlanksDefaultValue; |
| 391 | #undef xmlKeepBlanksDefaultValue |
| 392 | int * |
| 393 | __xmlKeepBlanksDefaultValue(void) { |
| 394 | if (IS_MAIN_THREAD) |
| 395 | return (&xmlKeepBlanksDefaultValue); |
| 396 | else |
| 397 | return (&get_glob_struct()->xmlKeepBlanksDefaultValue); |
| 398 | } |
| 399 | |
| 400 | extern int xmlLineNumbersDefaultValue; |
| 401 | #undef xmlLineNumbersDefaultValue |
| 402 | int * |
| 403 | __xmlLineNumbersDefaultValue(void) { |
| 404 | if (IS_MAIN_THREAD) |
| 405 | return (&xmlLineNumbersDefaultValue); |
| 406 | else |
| 407 | return (&get_glob_struct()->xmlLineNumbersDefaultValue); |
| 408 | } |
| 409 | |
| 410 | extern int xmlLoadExtDtdDefaultValue; |
| 411 | #undef xmlLoadExtDtdDefaultValue |
| 412 | int * |
| 413 | __xmlLoadExtDtdDefaultValue(void) { |
| 414 | if (IS_MAIN_THREAD) |
| 415 | return (&xmlLoadExtDtdDefaultValue); |
| 416 | else |
| 417 | return (&get_glob_struct()->xmlLoadExtDtdDefaultValue); |
| 418 | } |
| 419 | |
| 420 | extern xmlMallocFunc xmlMalloc; |
| 421 | #undef xmlMalloc |
| 422 | xmlMallocFunc * |
| 423 | __xmlMalloc(void) { |
| 424 | if (IS_MAIN_THREAD) |
| 425 | return (&xmlMalloc); |
| 426 | else |
| 427 | return (&get_glob_struct()->xmlMalloc); |
| 428 | } |
| 429 | |
| 430 | extern xmlStrdupFunc xmlMemStrdup; |
| 431 | #undef xmlMemStrdup |
| 432 | xmlStrdupFunc * |
| 433 | __xmlMemStrdup(void) { |
| 434 | if (IS_MAIN_THREAD) |
| 435 | return (&xmlMemStrdup); |
| 436 | else |
| 437 | return (&get_glob_struct()->xmlMemStrdup); |
| 438 | } |
| 439 | |
| 440 | extern int xmlParserDebugEntities; |
| 441 | #undef xmlParserDebugEntities |
| 442 | int * |
| 443 | __xmlParserDebugEntities(void) { |
| 444 | if (IS_MAIN_THREAD) |
| 445 | return (&xmlParserDebugEntities); |
| 446 | else |
| 447 | return (&get_glob_struct()->xmlParserDebugEntities); |
| 448 | } |
| 449 | |
| 450 | extern const char * xmlParserVersion; |
| 451 | #undef xmlParserVersion |
| 452 | const char * * |
| 453 | __xmlParserVersion(void) { |
| 454 | if (IS_MAIN_THREAD) |
| 455 | return (&xmlParserVersion); |
| 456 | else |
| 457 | return (&get_glob_struct()->xmlParserVersion); |
| 458 | } |
| 459 | |
| 460 | extern int xmlPedanticParserDefaultValue; |
| 461 | #undef xmlPedanticParserDefaultValue |
| 462 | int * |
| 463 | __xmlPedanticParserDefaultValue(void) { |
| 464 | if (IS_MAIN_THREAD) |
| 465 | return (&xmlPedanticParserDefaultValue); |
| 466 | else |
| 467 | return (&get_glob_struct()->xmlPedanticParserDefaultValue); |
| 468 | } |
| 469 | |
| 470 | extern xmlReallocFunc xmlRealloc; |
| 471 | #undef xmlRealloc |
| 472 | xmlReallocFunc * |
| 473 | __xmlRealloc(void) { |
| 474 | if (IS_MAIN_THREAD) |
| 475 | return (&xmlRealloc); |
| 476 | else |
| 477 | return (&get_glob_struct()->xmlRealloc); |
| 478 | } |
| 479 | |
| 480 | extern int xmlSaveNoEmptyTags; |
| 481 | #undef xmlSaveNoEmptyTags |
| 482 | int * |
| 483 | __xmlSaveNoEmptyTags(void) { |
| 484 | if (IS_MAIN_THREAD) |
| 485 | return (&xmlSaveNoEmptyTags); |
| 486 | else |
| 487 | return (&get_glob_struct()->xmlSaveNoEmptyTags); |
| 488 | } |
| 489 | |
| 490 | extern int xmlSubstituteEntitiesDefaultValue; |
| 491 | #undef xmlSubstituteEntitiesDefaultValue |
| 492 | int * |
| 493 | __xmlSubstituteEntitiesDefaultValue(void) { |
| 494 | if (IS_MAIN_THREAD) |
| 495 | return (&xmlSubstituteEntitiesDefaultValue); |
| 496 | else |
| 497 | return (&get_glob_struct()->xmlSubstituteEntitiesDefaultValue); |
| 498 | } |