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 (at) uk.sun.com> 11 * daniel (at) veillard.com 12 */ 13 14 #define IN_LIBXML 15 #include "libxml.h" 16 17 #ifdef HAVE_STDLIB_H 18 #include <stdlib.h> 19 #endif 20 #include <string.h> 21 22 #include <libxml/globals.h> 23 #include <libxml/xmlmemory.h> 24 #include <libxml/threads.h> 25 26 /* #define DEBUG_GLOBALS */ 27 28 /* 29 * Helpful Macro 30 */ 31 #ifdef LIBXML_THREAD_ENABLED 32 #define IS_MAIN_THREAD (xmlIsMainThread()) 33 #else 34 #define IS_MAIN_THREAD 1 35 #endif 36 37 /* 38 * Mutex to protect "ForNewThreads" variables 39 */ 40 static xmlMutexPtr xmlThrDefMutex = NULL; 41 42 /** 43 * xmlInitGlobals: 44 * 45 * Additional initialisation for multi-threading 46 */ 47 void xmlInitGlobals(void) 48 { 49 xmlThrDefMutex = xmlNewMutex(); 50 } 51 52 /** 53 * xmlCleanupGlobals: 54 * 55 * Additional cleanup for multi-threading 56 */ 57 void xmlCleanupGlobals(void) 58 { 59 if (xmlThrDefMutex != NULL) { 60 xmlFreeMutex(xmlThrDefMutex); 61 xmlThrDefMutex = NULL; 62 } 63 __xmlGlobalInitMutexDestroy(); 64 } 65 66 /************************************************************************ 67 * * 68 * All the user accessible global variables of the library * 69 * * 70 ************************************************************************/ 71 72 /* 73 * Memory allocation routines 74 */ 75 #undef xmlFree 76 #undef xmlMalloc 77 #undef xmlMallocAtomic 78 #undef xmlMemStrdup 79 #undef xmlRealloc 80 81 #if defined(DEBUG_MEMORY_LOCATION) || defined(DEBUG_MEMORY) 82 xmlFreeFunc xmlFree = (xmlFreeFunc) xmlMemFree; 83 xmlMallocFunc xmlMalloc = (xmlMallocFunc) xmlMemMalloc; 84 xmlMallocFunc xmlMallocAtomic = (xmlMallocFunc) xmlMemMalloc; 85 xmlReallocFunc xmlRealloc = (xmlReallocFunc) xmlMemRealloc; 86 xmlStrdupFunc xmlMemStrdup = (xmlStrdupFunc) xmlMemoryStrdup; 87 #else 88 /** 89 * xmlFree: 90 * @mem: an already allocated block of memory 91 * 92 * The variable holding the libxml free() implementation 93 */ 94 xmlFreeFunc xmlFree = (xmlFreeFunc) free; 95 /** 96 * xmlMalloc: 97 * @size: the size requested in bytes 98 * 99 * The variable holding the libxml malloc() implementation 100 * 101 * Returns a pointer to the newly allocated block or NULL in case of error 102 */ 103 xmlMallocFunc xmlMalloc = (xmlMallocFunc) malloc; 104 /** 105 * xmlMallocAtomic: 106 * @size: the size requested in bytes 107 * 108 * The variable holding the libxml malloc() implementation for atomic 109 * data (i.e. blocks not containings pointers), useful when using a 110 * garbage collecting allocator. 111 * 112 * Returns a pointer to the newly allocated block or NULL in case of error 113 */ 114 xmlMallocFunc xmlMallocAtomic = (xmlMallocFunc) malloc; 115 /** 116 * xmlRealloc: 117 * @mem: an already allocated block of memory 118 * @size: the new size requested in bytes 119 * 120 * The variable holding the libxml realloc() implementation 121 * 122 * Returns a pointer to the newly reallocated block or NULL in case of error 123 */ 124 xmlReallocFunc xmlRealloc = (xmlReallocFunc) realloc; 125 /** 126 * xmlMemStrdup: 127 * @str: a zero terminated string 128 * 129 * The variable holding the libxml strdup() implementation 130 * 131 * Returns the copy of the string or NULL in case of error 132 */ 133 xmlStrdupFunc xmlMemStrdup = (xmlStrdupFunc) xmlStrdup; 134 #endif /* DEBUG_MEMORY_LOCATION || DEBUG_MEMORY */ 135 136 #include <libxml/threads.h> 137 #include <libxml/globals.h> 138 #include <libxml/SAX.h> 139 140 #undef docbDefaultSAXHandler 141 #undef htmlDefaultSAXHandler 142 #undef oldXMLWDcompatibility 143 #undef xmlBufferAllocScheme 144 #undef xmlDefaultBufferSize 145 #undef xmlDefaultSAXHandler 146 #undef xmlDefaultSAXLocator 147 #undef xmlDoValidityCheckingDefaultValue 148 #undef xmlGenericError 149 #undef xmlStructuredError 150 #undef xmlGenericErrorContext 151 #undef xmlGetWarningsDefaultValue 152 #undef xmlIndentTreeOutput 153 #undef xmlTreeIndentString 154 #undef xmlKeepBlanksDefaultValue 155 #undef xmlLineNumbersDefaultValue 156 #undef xmlLoadExtDtdDefaultValue 157 #undef xmlParserDebugEntities 158 #undef xmlParserVersion 159 #undef xmlPedanticParserDefaultValue 160 #undef xmlSaveNoEmptyTags 161 #undef xmlSubstituteEntitiesDefaultValue 162 #undef xmlRegisterNodeDefaultValue 163 #undef xmlDeregisterNodeDefaultValue 164 #undef xmlLastError 165 166 #undef xmlParserInputBufferCreateFilenameValue 167 #undef xmlOutputBufferCreateFilenameValue 168 /** 169 * xmlParserVersion: 170 * 171 * Constant string describing the internal version of the library 172 */ 173 const char *xmlParserVersion = LIBXML_VERSION_STRING LIBXML_VERSION_EXTRA; 174 175 /** 176 * xmlBufferAllocScheme: 177 * 178 * Global setting, default allocation policy for buffers, default is 179 * XML_BUFFER_ALLOC_EXACT 180 */ 181 xmlBufferAllocationScheme xmlBufferAllocScheme = XML_BUFFER_ALLOC_EXACT; 182 static xmlBufferAllocationScheme xmlBufferAllocSchemeThrDef = XML_BUFFER_ALLOC_EXACT; 183 /** 184 * xmlDefaultBufferSize: 185 * 186 * Global setting, default buffer size. Default value is BASE_BUFFER_SIZE 187 */ 188 int xmlDefaultBufferSize = BASE_BUFFER_SIZE; 189 static int xmlDefaultBufferSizeThrDef = BASE_BUFFER_SIZE; 190 191 /* 192 * Parser defaults 193 */ 194 195 /** 196 * oldXMLWDcompatibility: 197 * 198 * Global setting, DEPRECATED. 199 */ 200 int oldXMLWDcompatibility = 0; /* DEPRECATED */ 201 /** 202 * xmlParserDebugEntities: 203 * 204 * Global setting, asking the parser to print out debugging informations. 205 * while handling entities. 206 * Disabled by default 207 */ 208 int xmlParserDebugEntities = 0; 209 static int xmlParserDebugEntitiesThrDef = 0; 210 /** 211 * xmlDoValidityCheckingDefaultValue: 212 * 213 * Global setting, indicate that the parser should work in validating mode. 214 * Disabled by default. 215 */ 216 int xmlDoValidityCheckingDefaultValue = 0; 217 static int xmlDoValidityCheckingDefaultValueThrDef = 0; 218 /** 219 * xmlGetWarningsDefaultValue: 220 * 221 * Global setting, indicate that the parser should provide warnings. 222 * Activated by default. 223 */ 224 int xmlGetWarningsDefaultValue = 1; 225 static int xmlGetWarningsDefaultValueThrDef = 1; 226 /** 227 * xmlLoadExtDtdDefaultValue: 228 * 229 * Global setting, indicate that the parser should load DTD while not 230 * validating. 231 * Disabled by default. 232 */ 233 int xmlLoadExtDtdDefaultValue = 0; 234 static int xmlLoadExtDtdDefaultValueThrDef = 0; 235 /** 236 * xmlPedanticParserDefaultValue: 237 * 238 * Global setting, indicate that the parser be pedantic 239 * Disabled by default. 240 */ 241 int xmlPedanticParserDefaultValue = 0; 242 static int xmlPedanticParserDefaultValueThrDef = 0; 243 /** 244 * xmlLineNumbersDefaultValue: 245 * 246 * Global setting, indicate that the parser should store the line number 247 * in the content field of elements in the DOM tree. 248 * Disabled by default since this may not be safe for old classes of 249 * applicaton. 250 */ 251 int xmlLineNumbersDefaultValue = 0; 252 static int xmlLineNumbersDefaultValueThrDef = 0; 253 /** 254 * xmlKeepBlanksDefaultValue: 255 * 256 * Global setting, indicate that the parser should keep all blanks 257 * nodes found in the content 258 * Activated by default, this is actually needed to have the parser 259 * conformant to the XML Recommendation, however the option is kept 260 * for some applications since this was libxml1 default behaviour. 261 */ 262 int xmlKeepBlanksDefaultValue = 1; 263 static int xmlKeepBlanksDefaultValueThrDef = 1; 264 /** 265 * xmlSubstituteEntitiesDefaultValue: 266 * 267 * Global setting, indicate that the parser should not generate entity 268 * references but replace them with the actual content of the entity 269 * Disabled by default, this should be activated when using XPath since 270 * the XPath data model requires entities replacement and the XPath 271 * engine does not handle entities references transparently. 272 */ 273 int xmlSubstituteEntitiesDefaultValue = 0; 274 static int xmlSubstituteEntitiesDefaultValueThrDef = 0; 275 276 xmlRegisterNodeFunc xmlRegisterNodeDefaultValue = NULL; 277 static xmlRegisterNodeFunc xmlRegisterNodeDefaultValueThrDef = NULL; 278 xmlDeregisterNodeFunc xmlDeregisterNodeDefaultValue = NULL; 279 static xmlDeregisterNodeFunc xmlDeregisterNodeDefaultValueThrDef = NULL; 280 281 xmlParserInputBufferCreateFilenameFunc xmlParserInputBufferCreateFilenameValue = NULL; 282 static xmlParserInputBufferCreateFilenameFunc xmlParserInputBufferCreateFilenameValueThrDef = NULL; 283 284 xmlOutputBufferCreateFilenameFunc xmlOutputBufferCreateFilenameValue = NULL; 285 static xmlOutputBufferCreateFilenameFunc xmlOutputBufferCreateFilenameValueThrDef = NULL; 286 287 /* 288 * Error handling 289 */ 290 291 /* xmlGenericErrorFunc xmlGenericError = xmlGenericErrorDefaultFunc; */ 292 /* Must initialize xmlGenericError in xmlInitParser */ 293 void XMLCDECL xmlGenericErrorDefaultFunc (void *ctx ATTRIBUTE_UNUSED, 294 const char *msg, 295 ...); 296 /** 297 * xmlGenericError: 298 * 299 * Global setting: function used for generic error callbacks 300 */ 301 xmlGenericErrorFunc xmlGenericError = xmlGenericErrorDefaultFunc; 302 static xmlGenericErrorFunc xmlGenericErrorThrDef = xmlGenericErrorDefaultFunc; 303 /** 304 * xmlStructuredError: 305 * 306 * Global setting: function used for structured error callbacks 307 */ 308 xmlStructuredErrorFunc xmlStructuredError = NULL; 309 static xmlStructuredErrorFunc xmlStructuredErrorThrDef = NULL; 310 /** 311 * xmlGenericErrorContext: 312 * 313 * Global setting passed to generic error callbacks 314 */ 315 void *xmlGenericErrorContext = NULL; 316 static void *xmlGenericErrorContextThrDef = NULL; 317 xmlError xmlLastError; 318 319 /* 320 * output defaults 321 */ 322 /** 323 * xmlIndentTreeOutput: 324 * 325 * Global setting, asking the serializer to indent the output tree by default 326 * Enabled by default 327 */ 328 int xmlIndentTreeOutput = 1; 329 static int xmlIndentTreeOutputThrDef = 1; 330 331 /** 332 * xmlTreeIndentString: 333 * 334 * The string used to do one-level indent. By default is equal to " " (two spaces) 335 */ 336 const char *xmlTreeIndentString = " "; 337 static const char *xmlTreeIndentStringThrDef = " "; 338 339 /** 340 * xmlSaveNoEmptyTags: 341 * 342 * Global setting, asking the serializer to not output empty tags 343 * as <empty/> but <empty></empty>. those two forms are undistinguishable 344 * once parsed. 345 * Disabled by default 346 */ 347 int xmlSaveNoEmptyTags = 0; 348 static int xmlSaveNoEmptyTagsThrDef = 0; 349 350 #ifdef LIBXML_SAX1_ENABLED 351 /** 352 * xmlDefaultSAXHandler: 353 * 354 * Default SAX version1 handler for XML, builds the DOM tree 355 */ 356 xmlSAXHandlerV1 xmlDefaultSAXHandler = { 357 xmlSAX2InternalSubset, 358 xmlSAX2IsStandalone, 359 xmlSAX2HasInternalSubset, 360 xmlSAX2HasExternalSubset, 361 xmlSAX2ResolveEntity, 362 xmlSAX2GetEntity, 363 xmlSAX2EntityDecl, 364 xmlSAX2NotationDecl, 365 xmlSAX2AttributeDecl, 366 xmlSAX2ElementDecl, 367 xmlSAX2UnparsedEntityDecl, 368 xmlSAX2SetDocumentLocator, 369 xmlSAX2StartDocument, 370 xmlSAX2EndDocument, 371 xmlSAX2StartElement, 372 xmlSAX2EndElement, 373 xmlSAX2Reference, 374 xmlSAX2Characters, 375 xmlSAX2Characters, 376 xmlSAX2ProcessingInstruction, 377 xmlSAX2Comment, 378 xmlParserWarning, 379 xmlParserError, 380 xmlParserError, 381 xmlSAX2GetParameterEntity, 382 xmlSAX2CDataBlock, 383 xmlSAX2ExternalSubset, 384 0, 385 }; 386 #endif /* LIBXML_SAX1_ENABLED */ 387 388 /** 389 * xmlDefaultSAXLocator: 390 * 391 * The default SAX Locator 392 * { getPublicId, getSystemId, getLineNumber, getColumnNumber} 393 */ 394 xmlSAXLocator xmlDefaultSAXLocator = { 395 xmlSAX2GetPublicId, 396 xmlSAX2GetSystemId, 397 xmlSAX2GetLineNumber, 398 xmlSAX2GetColumnNumber 399 }; 400 401 #ifdef LIBXML_HTML_ENABLED 402 /** 403 * htmlDefaultSAXHandler: 404 * 405 * Default old SAX v1 handler for HTML, builds the DOM tree 406 */ 407 xmlSAXHandlerV1 htmlDefaultSAXHandler = { 408 xmlSAX2InternalSubset, 409 NULL, 410 NULL, 411 NULL, 412 NULL, 413 xmlSAX2GetEntity, 414 NULL, 415 NULL, 416 NULL, 417 NULL, 418 NULL, 419 xmlSAX2SetDocumentLocator, 420 xmlSAX2StartDocument, 421 xmlSAX2EndDocument, 422 xmlSAX2StartElement, 423 xmlSAX2EndElement, 424 NULL, 425 xmlSAX2Characters, 426 xmlSAX2IgnorableWhitespace, 427 xmlSAX2ProcessingInstruction, 428 xmlSAX2Comment, 429 xmlParserWarning, 430 xmlParserError, 431 xmlParserError, 432 xmlSAX2GetParameterEntity, 433 xmlSAX2CDataBlock, 434 NULL, 435 0, 436 }; 437 #endif /* LIBXML_HTML_ENABLED */ 438 439 #ifdef LIBXML_DOCB_ENABLED 440 /** 441 * docbDefaultSAXHandler: 442 * 443 * Default old SAX v1 handler for SGML DocBook, builds the DOM tree 444 */ 445 xmlSAXHandlerV1 docbDefaultSAXHandler = { 446 xmlSAX2InternalSubset, 447 xmlSAX2IsStandalone, 448 xmlSAX2HasInternalSubset, 449 xmlSAX2HasExternalSubset, 450 xmlSAX2ResolveEntity, 451 xmlSAX2GetEntity, 452 xmlSAX2EntityDecl, 453 NULL, 454 NULL, 455 NULL, 456 NULL, 457 xmlSAX2SetDocumentLocator, 458 xmlSAX2StartDocument, 459 xmlSAX2EndDocument, 460 xmlSAX2StartElement, 461 xmlSAX2EndElement, 462 xmlSAX2Reference, 463 xmlSAX2Characters, 464 xmlSAX2IgnorableWhitespace, 465 NULL, 466 xmlSAX2Comment, 467 xmlParserWarning, 468 xmlParserError, 469 xmlParserError, 470 xmlSAX2GetParameterEntity, 471 NULL, 472 NULL, 473 0, 474 }; 475 #endif /* LIBXML_DOCB_ENABLED */ 476 477 /** 478 * xmlInitializeGlobalState: 479 * @gs: a pointer to a newly allocated global state 480 * 481 * xmlInitializeGlobalState() initialize a global state with all the 482 * default values of the library. 483 */ 484 void 485 xmlInitializeGlobalState(xmlGlobalStatePtr gs) 486 { 487 #ifdef DEBUG_GLOBALS 488 fprintf(stderr, "Initializing globals at %lu for thread %d\n", 489 (unsigned long) gs, xmlGetThreadId()); 490 #endif 491 492 /* 493 * Perform initialization as required by libxml 494 */ 495 if (xmlThrDefMutex == NULL) 496 xmlInitGlobals(); 497 498 xmlMutexLock(xmlThrDefMutex); 499 500 #if defined(LIBXML_DOCB_ENABLED) && defined(LIBXML_LEGACY_ENABLED) && defined(LIBXML_SAX1_ENABLED) 501 initdocbDefaultSAXHandler(&gs->docbDefaultSAXHandler); 502 #endif 503 #if defined(LIBXML_HTML_ENABLED) && defined(LIBXML_LEGACY_ENABLED) 504 inithtmlDefaultSAXHandler(&gs->htmlDefaultSAXHandler); 505 #endif 506 507 gs->oldXMLWDcompatibility = 0; 508 gs->xmlBufferAllocScheme = xmlBufferAllocSchemeThrDef; 509 gs->xmlDefaultBufferSize = xmlDefaultBufferSizeThrDef; 510 #if defined(LIBXML_SAX1_ENABLED) && defined(LIBXML_LEGACY_ENABLED) 511 initxmlDefaultSAXHandler(&gs->xmlDefaultSAXHandler, 1); 512 #endif /* LIBXML_SAX1_ENABLED */ 513 gs->xmlDefaultSAXLocator.getPublicId = xmlSAX2GetPublicId; 514 gs->xmlDefaultSAXLocator.getSystemId = xmlSAX2GetSystemId; 515 gs->xmlDefaultSAXLocator.getLineNumber = xmlSAX2GetLineNumber; 516 gs->xmlDefaultSAXLocator.getColumnNumber = xmlSAX2GetColumnNumber; 517 gs->xmlDoValidityCheckingDefaultValue = 518 xmlDoValidityCheckingDefaultValueThrDef; 519 #if defined(DEBUG_MEMORY_LOCATION) | defined(DEBUG_MEMORY) 520 gs->xmlFree = (xmlFreeFunc) xmlMemFree; 521 gs->xmlMalloc = (xmlMallocFunc) xmlMemMalloc; 522 gs->xmlMallocAtomic = (xmlMallocFunc) xmlMemMalloc; 523 gs->xmlRealloc = (xmlReallocFunc) xmlMemRealloc; 524 gs->xmlMemStrdup = (xmlStrdupFunc) xmlMemoryStrdup; 525 #else 526 gs->xmlFree = (xmlFreeFunc) free; 527 gs->xmlMalloc = (xmlMallocFunc) malloc; 528 gs->xmlMallocAtomic = (xmlMallocFunc) malloc; 529 gs->xmlRealloc = (xmlReallocFunc) realloc; 530 gs->xmlMemStrdup = (xmlStrdupFunc) xmlStrdup; 531 #endif 532 gs->xmlGetWarningsDefaultValue = xmlGetWarningsDefaultValueThrDef; 533 gs->xmlIndentTreeOutput = xmlIndentTreeOutputThrDef; 534 gs->xmlTreeIndentString = xmlTreeIndentStringThrDef; 535 gs->xmlKeepBlanksDefaultValue = xmlKeepBlanksDefaultValueThrDef; 536 gs->xmlLineNumbersDefaultValue = xmlLineNumbersDefaultValueThrDef; 537 gs->xmlLoadExtDtdDefaultValue = xmlLoadExtDtdDefaultValueThrDef; 538 gs->xmlParserDebugEntities = xmlParserDebugEntitiesThrDef; 539 gs->xmlParserVersion = LIBXML_VERSION_STRING; 540 gs->xmlPedanticParserDefaultValue = xmlPedanticParserDefaultValueThrDef; 541 gs->xmlSaveNoEmptyTags = xmlSaveNoEmptyTagsThrDef; 542 gs->xmlSubstituteEntitiesDefaultValue = 543 xmlSubstituteEntitiesDefaultValueThrDef; 544 545 gs->xmlGenericError = xmlGenericErrorThrDef; 546 gs->xmlStructuredError = xmlStructuredErrorThrDef; 547 gs->xmlGenericErrorContext = xmlGenericErrorContextThrDef; 548 gs->xmlRegisterNodeDefaultValue = xmlRegisterNodeDefaultValueThrDef; 549 gs->xmlDeregisterNodeDefaultValue = xmlDeregisterNodeDefaultValueThrDef; 550 551 gs->xmlParserInputBufferCreateFilenameValue = xmlParserInputBufferCreateFilenameValueThrDef; 552 gs->xmlOutputBufferCreateFilenameValue = xmlOutputBufferCreateFilenameValueThrDef; 553 memset(&gs->xmlLastError, 0, sizeof(xmlError)); 554 555 xmlMutexUnlock(xmlThrDefMutex); 556 } 557 558 /** 559 * DOC_DISABLE : we ignore missing doc for the xmlThrDef functions, 560 * those are really internal work 561 */ 562 void 563 xmlThrDefSetGenericErrorFunc(void *ctx, xmlGenericErrorFunc handler) { 564 xmlMutexLock(xmlThrDefMutex); 565 xmlGenericErrorContextThrDef = ctx; 566 if (handler != NULL) 567 xmlGenericErrorThrDef = handler; 568 else 569 xmlGenericErrorThrDef = xmlGenericErrorDefaultFunc; 570 xmlMutexUnlock(xmlThrDefMutex); 571 } 572 573 void 574 xmlThrDefSetStructuredErrorFunc(void *ctx, xmlStructuredErrorFunc handler) { 575 xmlMutexLock(xmlThrDefMutex); 576 xmlGenericErrorContextThrDef = ctx; 577 xmlStructuredErrorThrDef = handler; 578 xmlMutexUnlock(xmlThrDefMutex); 579 } 580 581 /** 582 * xmlRegisterNodeDefault: 583 * @func: function pointer to the new RegisterNodeFunc 584 * 585 * Registers a callback for node creation 586 * 587 * Returns the old value of the registration function 588 */ 589 xmlRegisterNodeFunc 590 xmlRegisterNodeDefault(xmlRegisterNodeFunc func) 591 { 592 xmlRegisterNodeFunc old = xmlRegisterNodeDefaultValue; 593 594 __xmlRegisterCallbacks = 1; 595 xmlRegisterNodeDefaultValue = func; 596 return(old); 597 } 598 599 xmlRegisterNodeFunc 600 xmlThrDefRegisterNodeDefault(xmlRegisterNodeFunc func) 601 { 602 xmlRegisterNodeFunc old; 603 604 xmlMutexLock(xmlThrDefMutex); 605 old = xmlRegisterNodeDefaultValueThrDef; 606 607 __xmlRegisterCallbacks = 1; 608 xmlRegisterNodeDefaultValueThrDef = func; 609 xmlMutexUnlock(xmlThrDefMutex); 610 611 return(old); 612 } 613 614 /** 615 * xmlDeregisterNodeDefault: 616 * @func: function pointer to the new DeregisterNodeFunc 617 * 618 * Registers a callback for node destruction 619 * 620 * Returns the previous value of the deregistration function 621 */ 622 xmlDeregisterNodeFunc 623 xmlDeregisterNodeDefault(xmlDeregisterNodeFunc func) 624 { 625 xmlDeregisterNodeFunc old = xmlDeregisterNodeDefaultValue; 626 627 __xmlRegisterCallbacks = 1; 628 xmlDeregisterNodeDefaultValue = func; 629 return(old); 630 } 631 632 xmlDeregisterNodeFunc 633 xmlThrDefDeregisterNodeDefault(xmlDeregisterNodeFunc func) 634 { 635 xmlDeregisterNodeFunc old; 636 637 xmlMutexLock(xmlThrDefMutex); 638 old = xmlDeregisterNodeDefaultValueThrDef; 639 640 __xmlRegisterCallbacks = 1; 641 xmlDeregisterNodeDefaultValueThrDef = func; 642 xmlMutexUnlock(xmlThrDefMutex); 643 644 return(old); 645 } 646 647 xmlParserInputBufferCreateFilenameFunc 648 xmlThrDefParserInputBufferCreateFilenameDefault(xmlParserInputBufferCreateFilenameFunc func) 649 { 650 xmlParserInputBufferCreateFilenameFunc old; 651 652 xmlMutexLock(xmlThrDefMutex); 653 old = xmlParserInputBufferCreateFilenameValueThrDef; 654 if (old == NULL) { 655 old = __xmlParserInputBufferCreateFilename; 656 } 657 658 xmlParserInputBufferCreateFilenameValueThrDef = func; 659 xmlMutexUnlock(xmlThrDefMutex); 660 661 return(old); 662 } 663 664 xmlOutputBufferCreateFilenameFunc 665 xmlThrDefOutputBufferCreateFilenameDefault(xmlOutputBufferCreateFilenameFunc func) 666 { 667 xmlOutputBufferCreateFilenameFunc old; 668 669 xmlMutexLock(xmlThrDefMutex); 670 old = xmlOutputBufferCreateFilenameValueThrDef; 671 #ifdef LIBXML_OUTPUT_ENABLED 672 if (old == NULL) { 673 old = __xmlOutputBufferCreateFilename; 674 } 675 #endif 676 xmlOutputBufferCreateFilenameValueThrDef = func; 677 xmlMutexUnlock(xmlThrDefMutex); 678 679 return(old); 680 } 681 682 #ifdef LIBXML_DOCB_ENABLED 683 #undef docbDefaultSAXHandler 684 xmlSAXHandlerV1 * 685 __docbDefaultSAXHandler(void) { 686 if (IS_MAIN_THREAD) 687 return (&docbDefaultSAXHandler); 688 else 689 return (&xmlGetGlobalState()->docbDefaultSAXHandler); 690 } 691 #endif 692 693 #ifdef LIBXML_HTML_ENABLED 694 #undef htmlDefaultSAXHandler 695 xmlSAXHandlerV1 * 696 __htmlDefaultSAXHandler(void) { 697 if (IS_MAIN_THREAD) 698 return (&htmlDefaultSAXHandler); 699 else 700 return (&xmlGetGlobalState()->htmlDefaultSAXHandler); 701 } 702 #endif 703 704 #undef xmlLastError 705 xmlError * 706 __xmlLastError(void) { 707 if (IS_MAIN_THREAD) 708 return (&xmlLastError); 709 else 710 return (&xmlGetGlobalState()->xmlLastError); 711 } 712 713 /* 714 * The following memory routines were apparently lost at some point, 715 * and were re-inserted at this point on June 10, 2004. Hope it's 716 * the right place for them :-) 717 */ 718 #if defined(LIBXML_THREAD_ALLOC_ENABLED) && defined(LIBXML_THREAD_ENABLED) 719 #undef xmlMalloc 720 xmlMallocFunc * 721 __xmlMalloc(void){ 722 if (IS_MAIN_THREAD) 723 return (&xmlMalloc); 724 else 725 return (&xmlGetGlobalState()->xmlMalloc); 726 } 727 728 #undef xmlMallocAtomic 729 xmlMallocFunc * 730 __xmlMallocAtomic(void){ 731 if (IS_MAIN_THREAD) 732 return (&xmlMallocAtomic); 733 else 734 return (&xmlGetGlobalState()->xmlMallocAtomic); 735 } 736 737 #undef xmlRealloc 738 xmlReallocFunc * 739 __xmlRealloc(void){ 740 if (IS_MAIN_THREAD) 741 return (&xmlRealloc); 742 else 743 return (&xmlGetGlobalState()->xmlRealloc); 744 } 745 746 #undef xmlFree 747 xmlFreeFunc * 748 __xmlFree(void){ 749 if (IS_MAIN_THREAD) 750 return (&xmlFree); 751 else 752 return (&xmlGetGlobalState()->xmlFree); 753 } 754 755 xmlStrdupFunc * 756 __xmlMemStrdup(void){ 757 if (IS_MAIN_THREAD) 758 return (&xmlMemStrdup); 759 else 760 return (&xmlGetGlobalState()->xmlMemStrdup); 761 } 762 763 #endif 764 765 /* 766 * Everything starting from the line below is 767 * Automatically generated by build_glob.py. 768 * Do not modify the previous line. 769 */ 770 771 772 #undef oldXMLWDcompatibility 773 int * 774 __oldXMLWDcompatibility(void) { 775 if (IS_MAIN_THREAD) 776 return (&oldXMLWDcompatibility); 777 else 778 return (&xmlGetGlobalState()->oldXMLWDcompatibility); 779 } 780 781 #undef xmlBufferAllocScheme 782 xmlBufferAllocationScheme * 783 __xmlBufferAllocScheme(void) { 784 if (IS_MAIN_THREAD) 785 return (&xmlBufferAllocScheme); 786 else 787 return (&xmlGetGlobalState()->xmlBufferAllocScheme); 788 } 789 xmlBufferAllocationScheme xmlThrDefBufferAllocScheme(xmlBufferAllocationScheme v) { 790 xmlBufferAllocationScheme ret; 791 xmlMutexLock(xmlThrDefMutex); 792 ret = xmlBufferAllocSchemeThrDef; 793 xmlBufferAllocSchemeThrDef = v; 794 xmlMutexUnlock(xmlThrDefMutex); 795 return ret; 796 } 797 798 #undef xmlDefaultBufferSize 799 int * 800 __xmlDefaultBufferSize(void) { 801 if (IS_MAIN_THREAD) 802 return (&xmlDefaultBufferSize); 803 else 804 return (&xmlGetGlobalState()->xmlDefaultBufferSize); 805 } 806 int xmlThrDefDefaultBufferSize(int v) { 807 int ret; 808 xmlMutexLock(xmlThrDefMutex); 809 ret = xmlDefaultBufferSizeThrDef; 810 xmlDefaultBufferSizeThrDef = v; 811 xmlMutexUnlock(xmlThrDefMutex); 812 return ret; 813 } 814 815 #ifdef LIBXML_SAX1_ENABLED 816 #undef xmlDefaultSAXHandler 817 xmlSAXHandlerV1 * 818 __xmlDefaultSAXHandler(void) { 819 if (IS_MAIN_THREAD) 820 return (&xmlDefaultSAXHandler); 821 else 822 return (&xmlGetGlobalState()->xmlDefaultSAXHandler); 823 } 824 #endif /* LIBXML_SAX1_ENABLED */ 825 826 #undef xmlDefaultSAXLocator 827 xmlSAXLocator * 828 __xmlDefaultSAXLocator(void) { 829 if (IS_MAIN_THREAD) 830 return (&xmlDefaultSAXLocator); 831 else 832 return (&xmlGetGlobalState()->xmlDefaultSAXLocator); 833 } 834 835 #undef xmlDoValidityCheckingDefaultValue 836 int * 837 __xmlDoValidityCheckingDefaultValue(void) { 838 if (IS_MAIN_THREAD) 839 return (&xmlDoValidityCheckingDefaultValue); 840 else 841 return (&xmlGetGlobalState()->xmlDoValidityCheckingDefaultValue); 842 } 843 int xmlThrDefDoValidityCheckingDefaultValue(int v) { 844 int ret; 845 xmlMutexLock(xmlThrDefMutex); 846 ret = xmlDoValidityCheckingDefaultValueThrDef; 847 xmlDoValidityCheckingDefaultValueThrDef = v; 848 xmlMutexUnlock(xmlThrDefMutex); 849 return ret; 850 } 851 852 #undef xmlGenericError 853 xmlGenericErrorFunc * 854 __xmlGenericError(void) { 855 if (IS_MAIN_THREAD) 856 return (&xmlGenericError); 857 else 858 return (&xmlGetGlobalState()->xmlGenericError); 859 } 860 861 #undef xmlStructuredError 862 xmlStructuredErrorFunc * 863 __xmlStructuredError(void) { 864 if (IS_MAIN_THREAD) 865 return (&xmlStructuredError); 866 else 867 return (&xmlGetGlobalState()->xmlStructuredError); 868 } 869 870 #undef xmlGenericErrorContext 871 void * * 872 __xmlGenericErrorContext(void) { 873 if (IS_MAIN_THREAD) 874 return (&xmlGenericErrorContext); 875 else 876 return (&xmlGetGlobalState()->xmlGenericErrorContext); 877 } 878 879 #undef xmlGetWarningsDefaultValue 880 int * 881 __xmlGetWarningsDefaultValue(void) { 882 if (IS_MAIN_THREAD) 883 return (&xmlGetWarningsDefaultValue); 884 else 885 return (&xmlGetGlobalState()->xmlGetWarningsDefaultValue); 886 } 887 int xmlThrDefGetWarningsDefaultValue(int v) { 888 int ret; 889 xmlMutexLock(xmlThrDefMutex); 890 ret = xmlGetWarningsDefaultValueThrDef; 891 xmlGetWarningsDefaultValueThrDef = v; 892 xmlMutexUnlock(xmlThrDefMutex); 893 return ret; 894 } 895 896 #undef xmlIndentTreeOutput 897 int * 898 __xmlIndentTreeOutput(void) { 899 if (IS_MAIN_THREAD) 900 return (&xmlIndentTreeOutput); 901 else 902 return (&xmlGetGlobalState()->xmlIndentTreeOutput); 903 } 904 int xmlThrDefIndentTreeOutput(int v) { 905 int ret; 906 xmlMutexLock(xmlThrDefMutex); 907 ret = xmlIndentTreeOutputThrDef; 908 xmlIndentTreeOutputThrDef = v; 909 xmlMutexUnlock(xmlThrDefMutex); 910 return ret; 911 } 912 913 #undef xmlTreeIndentString 914 const char * * 915 __xmlTreeIndentString(void) { 916 if (IS_MAIN_THREAD) 917 return (&xmlTreeIndentString); 918 else 919 return (&xmlGetGlobalState()->xmlTreeIndentString); 920 } 921 const char * xmlThrDefTreeIndentString(const char * v) { 922 const char * ret; 923 xmlMutexLock(xmlThrDefMutex); 924 ret = xmlTreeIndentStringThrDef; 925 xmlTreeIndentStringThrDef = v; 926 xmlMutexUnlock(xmlThrDefMutex); 927 return ret; 928 } 929 930 #undef xmlKeepBlanksDefaultValue 931 int * 932 __xmlKeepBlanksDefaultValue(void) { 933 if (IS_MAIN_THREAD) 934 return (&xmlKeepBlanksDefaultValue); 935 else 936 return (&xmlGetGlobalState()->xmlKeepBlanksDefaultValue); 937 } 938 int xmlThrDefKeepBlanksDefaultValue(int v) { 939 int ret; 940 xmlMutexLock(xmlThrDefMutex); 941 ret = xmlKeepBlanksDefaultValueThrDef; 942 xmlKeepBlanksDefaultValueThrDef = v; 943 xmlMutexUnlock(xmlThrDefMutex); 944 return ret; 945 } 946 947 #undef xmlLineNumbersDefaultValue 948 int * 949 __xmlLineNumbersDefaultValue(void) { 950 if (IS_MAIN_THREAD) 951 return (&xmlLineNumbersDefaultValue); 952 else 953 return (&xmlGetGlobalState()->xmlLineNumbersDefaultValue); 954 } 955 int xmlThrDefLineNumbersDefaultValue(int v) { 956 int ret; 957 xmlMutexLock(xmlThrDefMutex); 958 ret = xmlLineNumbersDefaultValueThrDef; 959 xmlLineNumbersDefaultValueThrDef = v; 960 xmlMutexUnlock(xmlThrDefMutex); 961 return ret; 962 } 963 964 #undef xmlLoadExtDtdDefaultValue 965 int * 966 __xmlLoadExtDtdDefaultValue(void) { 967 if (IS_MAIN_THREAD) 968 return (&xmlLoadExtDtdDefaultValue); 969 else 970 return (&xmlGetGlobalState()->xmlLoadExtDtdDefaultValue); 971 } 972 int xmlThrDefLoadExtDtdDefaultValue(int v) { 973 int ret; 974 xmlMutexLock(xmlThrDefMutex); 975 ret = xmlLoadExtDtdDefaultValueThrDef; 976 xmlLoadExtDtdDefaultValueThrDef = v; 977 xmlMutexUnlock(xmlThrDefMutex); 978 return ret; 979 } 980 981 #undef xmlParserDebugEntities 982 int * 983 __xmlParserDebugEntities(void) { 984 if (IS_MAIN_THREAD) 985 return (&xmlParserDebugEntities); 986 else 987 return (&xmlGetGlobalState()->xmlParserDebugEntities); 988 } 989 int xmlThrDefParserDebugEntities(int v) { 990 int ret; 991 xmlMutexLock(xmlThrDefMutex); 992 ret = xmlParserDebugEntitiesThrDef; 993 xmlParserDebugEntitiesThrDef = v; 994 xmlMutexUnlock(xmlThrDefMutex); 995 return ret; 996 } 997 998 #undef xmlParserVersion 999 const char * * 1000 __xmlParserVersion(void) { 1001 if (IS_MAIN_THREAD) 1002 return (&xmlParserVersion); 1003 else 1004 return (&xmlGetGlobalState()->xmlParserVersion); 1005 } 1006 1007 #undef xmlPedanticParserDefaultValue 1008 int * 1009 __xmlPedanticParserDefaultValue(void) { 1010 if (IS_MAIN_THREAD) 1011 return (&xmlPedanticParserDefaultValue); 1012 else 1013 return (&xmlGetGlobalState()->xmlPedanticParserDefaultValue); 1014 } 1015 int xmlThrDefPedanticParserDefaultValue(int v) { 1016 int ret; 1017 xmlMutexLock(xmlThrDefMutex); 1018 ret = xmlPedanticParserDefaultValueThrDef; 1019 xmlPedanticParserDefaultValueThrDef = v; 1020 xmlMutexUnlock(xmlThrDefMutex); 1021 return ret; 1022 } 1023 1024 #undef xmlSaveNoEmptyTags 1025 int * 1026 __xmlSaveNoEmptyTags(void) { 1027 if (IS_MAIN_THREAD) 1028 return (&xmlSaveNoEmptyTags); 1029 else 1030 return (&xmlGetGlobalState()->xmlSaveNoEmptyTags); 1031 } 1032 int xmlThrDefSaveNoEmptyTags(int v) { 1033 int ret; 1034 xmlMutexLock(xmlThrDefMutex); 1035 ret = xmlSaveNoEmptyTagsThrDef; 1036 xmlSaveNoEmptyTagsThrDef = v; 1037 xmlMutexUnlock(xmlThrDefMutex); 1038 return ret; 1039 } 1040 1041 #undef xmlSubstituteEntitiesDefaultValue 1042 int * 1043 __xmlSubstituteEntitiesDefaultValue(void) { 1044 if (IS_MAIN_THREAD) 1045 return (&xmlSubstituteEntitiesDefaultValue); 1046 else 1047 return (&xmlGetGlobalState()->xmlSubstituteEntitiesDefaultValue); 1048 } 1049 int xmlThrDefSubstituteEntitiesDefaultValue(int v) { 1050 int ret; 1051 xmlMutexLock(xmlThrDefMutex); 1052 ret = xmlSubstituteEntitiesDefaultValueThrDef; 1053 xmlSubstituteEntitiesDefaultValueThrDef = v; 1054 xmlMutexUnlock(xmlThrDefMutex); 1055 return ret; 1056 } 1057 1058 #undef xmlRegisterNodeDefaultValue 1059 xmlRegisterNodeFunc * 1060 __xmlRegisterNodeDefaultValue(void) { 1061 if (IS_MAIN_THREAD) 1062 return (&xmlRegisterNodeDefaultValue); 1063 else 1064 return (&xmlGetGlobalState()->xmlRegisterNodeDefaultValue); 1065 } 1066 1067 #undef xmlDeregisterNodeDefaultValue 1068 xmlDeregisterNodeFunc * 1069 __xmlDeregisterNodeDefaultValue(void) { 1070 if (IS_MAIN_THREAD) 1071 return (&xmlDeregisterNodeDefaultValue); 1072 else 1073 return (&xmlGetGlobalState()->xmlDeregisterNodeDefaultValue); 1074 } 1075 1076 #undef xmlParserInputBufferCreateFilenameValue 1077 xmlParserInputBufferCreateFilenameFunc * 1078 __xmlParserInputBufferCreateFilenameValue(void) { 1079 if (IS_MAIN_THREAD) 1080 return (&xmlParserInputBufferCreateFilenameValue); 1081 else 1082 return (&xmlGetGlobalState()->xmlParserInputBufferCreateFilenameValue); 1083 } 1084 1085 #undef xmlOutputBufferCreateFilenameValue 1086 xmlOutputBufferCreateFilenameFunc * 1087 __xmlOutputBufferCreateFilenameValue(void) { 1088 if (IS_MAIN_THREAD) 1089 return (&xmlOutputBufferCreateFilenameValue); 1090 else 1091 return (&xmlGetGlobalState()->xmlOutputBufferCreateFilenameValue); 1092 } 1093 1094 #define bottom_globals 1095 #include "elfgcchack.h" 1096