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 #define IN_LIBXML
15 #include "libxml.h"
16
17 #include <stdlib.h>
18 #include <string.h>
19
20 #include <libxml/globals.h>
21 #include <libxml/xmlmemory.h>
22 #include <libxml/threads.h>
23
24 /* #define DEBUG_GLOBALS */
25
26 /*
27 * Helpful Macro
28 */
29 #ifdef LIBXML_THREAD_ENABLED
30 #define IS_MAIN_THREAD (xmlIsMainThread())
31 #else
32 #define IS_MAIN_THREAD 1
33 #endif
34
35 /*
36 * Mutex to protect "ForNewThreads" variables
37 */
38 static xmlMutexPtr xmlThrDefMutex = NULL;
39
40 /**
41 * xmlInitGlobals:
42 *
43 * DEPRECATED: This function will be made private. Call xmlInitParser to
44 * initialize the library.
45 *
46 * Additional initialisation for multi-threading
47 */
xmlInitGlobals(void)48 void xmlInitGlobals(void)
49 {
50 if (xmlThrDefMutex == NULL)
51 xmlThrDefMutex = xmlNewMutex();
52 }
53
54 /************************************************************************
55 * *
56 * All the user accessible global variables of the library *
57 * *
58 ************************************************************************/
59
60 /*
61 * Memory allocation routines
62 */
63 #undef xmlFree
64 #undef xmlMalloc
65 #undef xmlMallocAtomic
66 #undef xmlMemStrdup
67 #undef xmlRealloc
68
69 #if defined(DEBUG_MEMORY_LOCATION) || defined(DEBUG_MEMORY)
70 xmlFreeFunc xmlFree = (xmlFreeFunc) xmlMemFree;
71 xmlMallocFunc xmlMalloc = (xmlMallocFunc) xmlMemMalloc;
72 xmlMallocFunc xmlMallocAtomic = (xmlMallocFunc) xmlMemMalloc;
73 xmlReallocFunc xmlRealloc = (xmlReallocFunc) xmlMemRealloc;
74 xmlStrdupFunc xmlMemStrdup = (xmlStrdupFunc) xmlMemoryStrdup;
75 #else
76 /**
77 * xmlFree:
78 * @mem: an already allocated block of memory
79 *
80 * The variable holding the libxml free() implementation
81 */
82 xmlFreeFunc xmlFree = free;
83 /**
84 * xmlMalloc:
85 * @size: the size requested in bytes
86 *
87 * The variable holding the libxml malloc() implementation
88 *
89 * Returns a pointer to the newly allocated block or NULL in case of error
90 */
91 xmlMallocFunc xmlMalloc = malloc;
92 /**
93 * xmlMallocAtomic:
94 * @size: the size requested in bytes
95 *
96 * The variable holding the libxml malloc() implementation for atomic
97 * data (i.e. blocks not containing pointers), useful when using a
98 * garbage collecting allocator.
99 *
100 * Returns a pointer to the newly allocated block or NULL in case of error
101 */
102 xmlMallocFunc xmlMallocAtomic = malloc;
103 /**
104 * xmlRealloc:
105 * @mem: an already allocated block of memory
106 * @size: the new size requested in bytes
107 *
108 * The variable holding the libxml realloc() implementation
109 *
110 * Returns a pointer to the newly reallocated block or NULL in case of error
111 */
112 xmlReallocFunc xmlRealloc = realloc;
113 /**
114 * xmlPosixStrdup
115 * @cur: the input char *
116 *
117 * a strdup implementation with a type signature matching POSIX
118 *
119 * Returns a new xmlChar * or NULL
120 */
121 static char *
xmlPosixStrdup(const char * cur)122 xmlPosixStrdup(const char *cur) {
123 return((char*) xmlCharStrdup(cur));
124 }
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 = xmlPosixStrdup;
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 htmlDefaultSAXHandler
141 #undef oldXMLWDcompatibility
142 #undef xmlBufferAllocScheme
143 #undef xmlDefaultBufferSize
144 #undef xmlDefaultSAXHandler
145 #undef xmlDefaultSAXLocator
146 #undef xmlDoValidityCheckingDefaultValue
147 #undef xmlGenericError
148 #undef xmlStructuredError
149 #undef xmlGenericErrorContext
150 #undef xmlStructuredErrorContext
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 information.
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 * application.
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 /**
318 * xmlStructuredErrorContext:
319 *
320 * Global setting passed to structured error callbacks
321 */
322 void *xmlStructuredErrorContext = NULL;
323 static void *xmlStructuredErrorContextThrDef = NULL;
324 xmlError xmlLastError;
325
326 /*
327 * output defaults
328 */
329 /**
330 * xmlIndentTreeOutput:
331 *
332 * Global setting, asking the serializer to indent the output tree by default
333 * Enabled by default
334 */
335 int xmlIndentTreeOutput = 1;
336 static int xmlIndentTreeOutputThrDef = 1;
337
338 /**
339 * xmlTreeIndentString:
340 *
341 * The string used to do one-level indent. By default is equal to " " (two spaces)
342 */
343 const char *xmlTreeIndentString = " ";
344 static const char *xmlTreeIndentStringThrDef = " ";
345
346 /**
347 * xmlSaveNoEmptyTags:
348 *
349 * Global setting, asking the serializer to not output empty tags
350 * as <empty/> but <empty></empty>. those two forms are indistinguishable
351 * once parsed.
352 * Disabled by default
353 */
354 int xmlSaveNoEmptyTags = 0;
355 static int xmlSaveNoEmptyTagsThrDef = 0;
356
357 #ifdef LIBXML_SAX1_ENABLED
358 /**
359 * xmlDefaultSAXHandler:
360 *
361 * Default SAX version1 handler for XML, builds the DOM tree
362 */
363 xmlSAXHandlerV1 xmlDefaultSAXHandler = {
364 xmlSAX2InternalSubset,
365 xmlSAX2IsStandalone,
366 xmlSAX2HasInternalSubset,
367 xmlSAX2HasExternalSubset,
368 xmlSAX2ResolveEntity,
369 xmlSAX2GetEntity,
370 xmlSAX2EntityDecl,
371 xmlSAX2NotationDecl,
372 xmlSAX2AttributeDecl,
373 xmlSAX2ElementDecl,
374 xmlSAX2UnparsedEntityDecl,
375 xmlSAX2SetDocumentLocator,
376 xmlSAX2StartDocument,
377 xmlSAX2EndDocument,
378 xmlSAX2StartElement,
379 xmlSAX2EndElement,
380 xmlSAX2Reference,
381 xmlSAX2Characters,
382 xmlSAX2Characters,
383 xmlSAX2ProcessingInstruction,
384 xmlSAX2Comment,
385 xmlParserWarning,
386 xmlParserError,
387 xmlParserError,
388 xmlSAX2GetParameterEntity,
389 xmlSAX2CDataBlock,
390 xmlSAX2ExternalSubset,
391 0,
392 };
393 #endif /* LIBXML_SAX1_ENABLED */
394
395 /**
396 * xmlDefaultSAXLocator:
397 *
398 * The default SAX Locator
399 * { getPublicId, getSystemId, getLineNumber, getColumnNumber}
400 */
401 xmlSAXLocator xmlDefaultSAXLocator = {
402 xmlSAX2GetPublicId,
403 xmlSAX2GetSystemId,
404 xmlSAX2GetLineNumber,
405 xmlSAX2GetColumnNumber
406 };
407
408 #ifdef LIBXML_HTML_ENABLED
409 /**
410 * htmlDefaultSAXHandler:
411 *
412 * Default old SAX v1 handler for HTML, builds the DOM tree
413 */
414 xmlSAXHandlerV1 htmlDefaultSAXHandler = {
415 xmlSAX2InternalSubset,
416 NULL,
417 NULL,
418 NULL,
419 NULL,
420 xmlSAX2GetEntity,
421 NULL,
422 NULL,
423 NULL,
424 NULL,
425 NULL,
426 xmlSAX2SetDocumentLocator,
427 xmlSAX2StartDocument,
428 xmlSAX2EndDocument,
429 xmlSAX2StartElement,
430 xmlSAX2EndElement,
431 NULL,
432 xmlSAX2Characters,
433 xmlSAX2IgnorableWhitespace,
434 xmlSAX2ProcessingInstruction,
435 xmlSAX2Comment,
436 xmlParserWarning,
437 xmlParserError,
438 xmlParserError,
439 xmlSAX2GetParameterEntity,
440 xmlSAX2CDataBlock,
441 NULL,
442 0,
443 };
444 #endif /* LIBXML_HTML_ENABLED */
445
446 /**
447 * xmlInitializeGlobalState:
448 * @gs: a pointer to a newly allocated global state
449 *
450 * xmlInitializeGlobalState() initialize a global state with all the
451 * default values of the library.
452 */
453 void
xmlInitializeGlobalState(xmlGlobalStatePtr gs)454 xmlInitializeGlobalState(xmlGlobalStatePtr gs)
455 {
456 #ifdef DEBUG_GLOBALS
457 fprintf(stderr, "Initializing globals at %lu for thread %d\n",
458 (unsigned long) gs, xmlGetThreadId());
459 #endif
460
461 /*
462 * Perform initialization as required by libxml
463 */
464 if (xmlThrDefMutex == NULL)
465 xmlInitGlobals();
466
467 xmlMutexLock(xmlThrDefMutex);
468
469 #if defined(LIBXML_HTML_ENABLED) && defined(LIBXML_LEGACY_ENABLED) && defined(LIBXML_SAX1_ENABLED)
470 inithtmlDefaultSAXHandler(&gs->htmlDefaultSAXHandler);
471 #endif
472
473 gs->oldXMLWDcompatibility = 0;
474 gs->xmlBufferAllocScheme = xmlBufferAllocSchemeThrDef;
475 gs->xmlDefaultBufferSize = xmlDefaultBufferSizeThrDef;
476 #if defined(LIBXML_SAX1_ENABLED) && defined(LIBXML_LEGACY_ENABLED)
477 initxmlDefaultSAXHandler(&gs->xmlDefaultSAXHandler, 1);
478 #endif /* LIBXML_SAX1_ENABLED */
479 gs->xmlDefaultSAXLocator.getPublicId = xmlSAX2GetPublicId;
480 gs->xmlDefaultSAXLocator.getSystemId = xmlSAX2GetSystemId;
481 gs->xmlDefaultSAXLocator.getLineNumber = xmlSAX2GetLineNumber;
482 gs->xmlDefaultSAXLocator.getColumnNumber = xmlSAX2GetColumnNumber;
483 gs->xmlDoValidityCheckingDefaultValue =
484 xmlDoValidityCheckingDefaultValueThrDef;
485 #if defined(DEBUG_MEMORY_LOCATION) | defined(DEBUG_MEMORY)
486 gs->xmlFree = (xmlFreeFunc) xmlMemFree;
487 gs->xmlMalloc = (xmlMallocFunc) xmlMemMalloc;
488 gs->xmlMallocAtomic = (xmlMallocFunc) xmlMemMalloc;
489 gs->xmlRealloc = (xmlReallocFunc) xmlMemRealloc;
490 gs->xmlMemStrdup = (xmlStrdupFunc) xmlMemoryStrdup;
491 #else
492 gs->xmlFree = (xmlFreeFunc) free;
493 gs->xmlMalloc = (xmlMallocFunc) malloc;
494 gs->xmlMallocAtomic = (xmlMallocFunc) malloc;
495 gs->xmlRealloc = (xmlReallocFunc) realloc;
496 gs->xmlMemStrdup = (xmlStrdupFunc) xmlStrdup;
497 #endif
498 gs->xmlGetWarningsDefaultValue = xmlGetWarningsDefaultValueThrDef;
499 gs->xmlIndentTreeOutput = xmlIndentTreeOutputThrDef;
500 gs->xmlTreeIndentString = xmlTreeIndentStringThrDef;
501 gs->xmlKeepBlanksDefaultValue = xmlKeepBlanksDefaultValueThrDef;
502 gs->xmlLineNumbersDefaultValue = xmlLineNumbersDefaultValueThrDef;
503 gs->xmlLoadExtDtdDefaultValue = xmlLoadExtDtdDefaultValueThrDef;
504 gs->xmlParserDebugEntities = xmlParserDebugEntitiesThrDef;
505 gs->xmlParserVersion = LIBXML_VERSION_STRING;
506 gs->xmlPedanticParserDefaultValue = xmlPedanticParserDefaultValueThrDef;
507 gs->xmlSaveNoEmptyTags = xmlSaveNoEmptyTagsThrDef;
508 gs->xmlSubstituteEntitiesDefaultValue =
509 xmlSubstituteEntitiesDefaultValueThrDef;
510
511 gs->xmlGenericError = xmlGenericErrorThrDef;
512 gs->xmlStructuredError = xmlStructuredErrorThrDef;
513 gs->xmlGenericErrorContext = xmlGenericErrorContextThrDef;
514 gs->xmlStructuredErrorContext = xmlStructuredErrorContextThrDef;
515 gs->xmlRegisterNodeDefaultValue = xmlRegisterNodeDefaultValueThrDef;
516 gs->xmlDeregisterNodeDefaultValue = xmlDeregisterNodeDefaultValueThrDef;
517
518 gs->xmlParserInputBufferCreateFilenameValue = xmlParserInputBufferCreateFilenameValueThrDef;
519 gs->xmlOutputBufferCreateFilenameValue = xmlOutputBufferCreateFilenameValueThrDef;
520 memset(&gs->xmlLastError, 0, sizeof(xmlError));
521
522 xmlMutexUnlock(xmlThrDefMutex);
523 }
524
525 /**
526 * xmlCleanupGlobals:
527 *
528 * DEPRECATED: This function will be made private. Call xmlCleanupParser
529 * to free global state but see the warnings there. xmlCleanupParser
530 * should be only called once at program exit. In most cases, you don't
531 * have call cleanup functions at all.
532 *
533 * Additional cleanup for multi-threading
534 */
xmlCleanupGlobals(void)535 void xmlCleanupGlobals(void)
536 {
537 xmlResetError(&xmlLastError);
538
539 if (xmlThrDefMutex != NULL) {
540 xmlFreeMutex(xmlThrDefMutex);
541 xmlThrDefMutex = NULL;
542 }
543 __xmlGlobalInitMutexDestroy();
544 }
545
546 /**
547 * DOC_DISABLE : we ignore missing doc for the xmlThrDef functions,
548 * those are really internal work
549 */
550 void
xmlThrDefSetGenericErrorFunc(void * ctx,xmlGenericErrorFunc handler)551 xmlThrDefSetGenericErrorFunc(void *ctx, xmlGenericErrorFunc handler) {
552 xmlMutexLock(xmlThrDefMutex);
553 xmlGenericErrorContextThrDef = ctx;
554 if (handler != NULL)
555 xmlGenericErrorThrDef = handler;
556 else
557 xmlGenericErrorThrDef = xmlGenericErrorDefaultFunc;
558 xmlMutexUnlock(xmlThrDefMutex);
559 }
560
561 void
xmlThrDefSetStructuredErrorFunc(void * ctx,xmlStructuredErrorFunc handler)562 xmlThrDefSetStructuredErrorFunc(void *ctx, xmlStructuredErrorFunc handler) {
563 xmlMutexLock(xmlThrDefMutex);
564 xmlStructuredErrorContextThrDef = ctx;
565 xmlStructuredErrorThrDef = handler;
566 xmlMutexUnlock(xmlThrDefMutex);
567 }
568
569 /**
570 * xmlRegisterNodeDefault:
571 * @func: function pointer to the new RegisterNodeFunc
572 *
573 * Registers a callback for node creation
574 *
575 * Returns the old value of the registration function
576 */
577 xmlRegisterNodeFunc
xmlRegisterNodeDefault(xmlRegisterNodeFunc func)578 xmlRegisterNodeDefault(xmlRegisterNodeFunc func)
579 {
580 xmlRegisterNodeFunc old = xmlRegisterNodeDefaultValue;
581
582 __xmlRegisterCallbacks = 1;
583 xmlRegisterNodeDefaultValue = func;
584 return(old);
585 }
586
587 xmlRegisterNodeFunc
xmlThrDefRegisterNodeDefault(xmlRegisterNodeFunc func)588 xmlThrDefRegisterNodeDefault(xmlRegisterNodeFunc func)
589 {
590 xmlRegisterNodeFunc old;
591
592 xmlMutexLock(xmlThrDefMutex);
593 old = xmlRegisterNodeDefaultValueThrDef;
594
595 __xmlRegisterCallbacks = 1;
596 xmlRegisterNodeDefaultValueThrDef = func;
597 xmlMutexUnlock(xmlThrDefMutex);
598
599 return(old);
600 }
601
602 /**
603 * xmlDeregisterNodeDefault:
604 * @func: function pointer to the new DeregisterNodeFunc
605 *
606 * Registers a callback for node destruction
607 *
608 * Returns the previous value of the deregistration function
609 */
610 xmlDeregisterNodeFunc
xmlDeregisterNodeDefault(xmlDeregisterNodeFunc func)611 xmlDeregisterNodeDefault(xmlDeregisterNodeFunc func)
612 {
613 xmlDeregisterNodeFunc old = xmlDeregisterNodeDefaultValue;
614
615 __xmlRegisterCallbacks = 1;
616 xmlDeregisterNodeDefaultValue = func;
617 return(old);
618 }
619
620 xmlDeregisterNodeFunc
xmlThrDefDeregisterNodeDefault(xmlDeregisterNodeFunc func)621 xmlThrDefDeregisterNodeDefault(xmlDeregisterNodeFunc func)
622 {
623 xmlDeregisterNodeFunc old;
624
625 xmlMutexLock(xmlThrDefMutex);
626 old = xmlDeregisterNodeDefaultValueThrDef;
627
628 __xmlRegisterCallbacks = 1;
629 xmlDeregisterNodeDefaultValueThrDef = func;
630 xmlMutexUnlock(xmlThrDefMutex);
631
632 return(old);
633 }
634
635 xmlParserInputBufferCreateFilenameFunc
xmlThrDefParserInputBufferCreateFilenameDefault(xmlParserInputBufferCreateFilenameFunc func)636 xmlThrDefParserInputBufferCreateFilenameDefault(xmlParserInputBufferCreateFilenameFunc func)
637 {
638 xmlParserInputBufferCreateFilenameFunc old;
639
640 xmlMutexLock(xmlThrDefMutex);
641 old = xmlParserInputBufferCreateFilenameValueThrDef;
642 if (old == NULL) {
643 old = __xmlParserInputBufferCreateFilename;
644 }
645
646 xmlParserInputBufferCreateFilenameValueThrDef = func;
647 xmlMutexUnlock(xmlThrDefMutex);
648
649 return(old);
650 }
651
652 xmlOutputBufferCreateFilenameFunc
xmlThrDefOutputBufferCreateFilenameDefault(xmlOutputBufferCreateFilenameFunc func)653 xmlThrDefOutputBufferCreateFilenameDefault(xmlOutputBufferCreateFilenameFunc func)
654 {
655 xmlOutputBufferCreateFilenameFunc old;
656
657 xmlMutexLock(xmlThrDefMutex);
658 old = xmlOutputBufferCreateFilenameValueThrDef;
659 #ifdef LIBXML_OUTPUT_ENABLED
660 if (old == NULL) {
661 old = __xmlOutputBufferCreateFilename;
662 }
663 #endif
664 xmlOutputBufferCreateFilenameValueThrDef = func;
665 xmlMutexUnlock(xmlThrDefMutex);
666
667 return(old);
668 }
669
670 #ifdef LIBXML_HTML_ENABLED
671 #undef htmlDefaultSAXHandler
672 xmlSAXHandlerV1 *
__htmlDefaultSAXHandler(void)673 __htmlDefaultSAXHandler(void) {
674 if (IS_MAIN_THREAD)
675 return (&htmlDefaultSAXHandler);
676 else
677 return (&xmlGetGlobalState()->htmlDefaultSAXHandler);
678 }
679 #endif
680
681 #undef xmlLastError
682 xmlError *
__xmlLastError(void)683 __xmlLastError(void) {
684 if (IS_MAIN_THREAD)
685 return (&xmlLastError);
686 else
687 return (&xmlGetGlobalState()->xmlLastError);
688 }
689
690 /*
691 * The following memory routines were apparently lost at some point,
692 * and were re-inserted at this point on June 10, 2004. Hope it's
693 * the right place for them :-)
694 */
695 #if defined(LIBXML_THREAD_ALLOC_ENABLED) && defined(LIBXML_THREAD_ENABLED)
696 #undef xmlMalloc
697 xmlMallocFunc *
__xmlMalloc(void)698 __xmlMalloc(void){
699 if (IS_MAIN_THREAD)
700 return (&xmlMalloc);
701 else
702 return (&xmlGetGlobalState()->xmlMalloc);
703 }
704
705 #undef xmlMallocAtomic
706 xmlMallocFunc *
__xmlMallocAtomic(void)707 __xmlMallocAtomic(void){
708 if (IS_MAIN_THREAD)
709 return (&xmlMallocAtomic);
710 else
711 return (&xmlGetGlobalState()->xmlMallocAtomic);
712 }
713
714 #undef xmlRealloc
715 xmlReallocFunc *
__xmlRealloc(void)716 __xmlRealloc(void){
717 if (IS_MAIN_THREAD)
718 return (&xmlRealloc);
719 else
720 return (&xmlGetGlobalState()->xmlRealloc);
721 }
722
723 #undef xmlFree
724 xmlFreeFunc *
__xmlFree(void)725 __xmlFree(void){
726 if (IS_MAIN_THREAD)
727 return (&xmlFree);
728 else
729 return (&xmlGetGlobalState()->xmlFree);
730 }
731
732 xmlStrdupFunc *
__xmlMemStrdup(void)733 __xmlMemStrdup(void){
734 if (IS_MAIN_THREAD)
735 return (&xmlMemStrdup);
736 else
737 return (&xmlGetGlobalState()->xmlMemStrdup);
738 }
739
740 #endif
741
742 /*
743 * Everything starting from the line below is
744 * Automatically generated by build_glob.py.
745 * Do not modify the previous line.
746 */
747
748
749 #undef oldXMLWDcompatibility
750 int *
__oldXMLWDcompatibility(void)751 __oldXMLWDcompatibility(void) {
752 if (IS_MAIN_THREAD)
753 return (&oldXMLWDcompatibility);
754 else
755 return (&xmlGetGlobalState()->oldXMLWDcompatibility);
756 }
757
758 #undef xmlBufferAllocScheme
759 xmlBufferAllocationScheme *
__xmlBufferAllocScheme(void)760 __xmlBufferAllocScheme(void) {
761 if (IS_MAIN_THREAD)
762 return (&xmlBufferAllocScheme);
763 else
764 return (&xmlGetGlobalState()->xmlBufferAllocScheme);
765 }
xmlThrDefBufferAllocScheme(xmlBufferAllocationScheme v)766 xmlBufferAllocationScheme xmlThrDefBufferAllocScheme(xmlBufferAllocationScheme v) {
767 xmlBufferAllocationScheme ret;
768 xmlMutexLock(xmlThrDefMutex);
769 ret = xmlBufferAllocSchemeThrDef;
770 xmlBufferAllocSchemeThrDef = v;
771 xmlMutexUnlock(xmlThrDefMutex);
772 return ret;
773 }
774
775 #undef xmlDefaultBufferSize
776 int *
__xmlDefaultBufferSize(void)777 __xmlDefaultBufferSize(void) {
778 if (IS_MAIN_THREAD)
779 return (&xmlDefaultBufferSize);
780 else
781 return (&xmlGetGlobalState()->xmlDefaultBufferSize);
782 }
xmlThrDefDefaultBufferSize(int v)783 int xmlThrDefDefaultBufferSize(int v) {
784 int ret;
785 xmlMutexLock(xmlThrDefMutex);
786 ret = xmlDefaultBufferSizeThrDef;
787 xmlDefaultBufferSizeThrDef = v;
788 xmlMutexUnlock(xmlThrDefMutex);
789 return ret;
790 }
791
792 #ifdef LIBXML_SAX1_ENABLED
793 #undef xmlDefaultSAXHandler
794 xmlSAXHandlerV1 *
__xmlDefaultSAXHandler(void)795 __xmlDefaultSAXHandler(void) {
796 if (IS_MAIN_THREAD)
797 return (&xmlDefaultSAXHandler);
798 else
799 return (&xmlGetGlobalState()->xmlDefaultSAXHandler);
800 }
801 #endif /* LIBXML_SAX1_ENABLED */
802
803 #undef xmlDefaultSAXLocator
804 xmlSAXLocator *
__xmlDefaultSAXLocator(void)805 __xmlDefaultSAXLocator(void) {
806 if (IS_MAIN_THREAD)
807 return (&xmlDefaultSAXLocator);
808 else
809 return (&xmlGetGlobalState()->xmlDefaultSAXLocator);
810 }
811
812 #undef xmlDoValidityCheckingDefaultValue
813 int *
__xmlDoValidityCheckingDefaultValue(void)814 __xmlDoValidityCheckingDefaultValue(void) {
815 if (IS_MAIN_THREAD)
816 return (&xmlDoValidityCheckingDefaultValue);
817 else
818 return (&xmlGetGlobalState()->xmlDoValidityCheckingDefaultValue);
819 }
xmlThrDefDoValidityCheckingDefaultValue(int v)820 int xmlThrDefDoValidityCheckingDefaultValue(int v) {
821 int ret;
822 xmlMutexLock(xmlThrDefMutex);
823 ret = xmlDoValidityCheckingDefaultValueThrDef;
824 xmlDoValidityCheckingDefaultValueThrDef = v;
825 xmlMutexUnlock(xmlThrDefMutex);
826 return ret;
827 }
828
829 #undef xmlGenericError
830 xmlGenericErrorFunc *
__xmlGenericError(void)831 __xmlGenericError(void) {
832 if (IS_MAIN_THREAD)
833 return (&xmlGenericError);
834 else
835 return (&xmlGetGlobalState()->xmlGenericError);
836 }
837
838 #undef xmlStructuredError
839 xmlStructuredErrorFunc *
__xmlStructuredError(void)840 __xmlStructuredError(void) {
841 if (IS_MAIN_THREAD)
842 return (&xmlStructuredError);
843 else
844 return (&xmlGetGlobalState()->xmlStructuredError);
845 }
846
847 #undef xmlGenericErrorContext
848 void * *
__xmlGenericErrorContext(void)849 __xmlGenericErrorContext(void) {
850 if (IS_MAIN_THREAD)
851 return (&xmlGenericErrorContext);
852 else
853 return (&xmlGetGlobalState()->xmlGenericErrorContext);
854 }
855
856 #undef xmlStructuredErrorContext
857 void * *
__xmlStructuredErrorContext(void)858 __xmlStructuredErrorContext(void) {
859 if (IS_MAIN_THREAD)
860 return (&xmlStructuredErrorContext);
861 else
862 return (&xmlGetGlobalState()->xmlStructuredErrorContext);
863 }
864
865 #undef xmlGetWarningsDefaultValue
866 int *
__xmlGetWarningsDefaultValue(void)867 __xmlGetWarningsDefaultValue(void) {
868 if (IS_MAIN_THREAD)
869 return (&xmlGetWarningsDefaultValue);
870 else
871 return (&xmlGetGlobalState()->xmlGetWarningsDefaultValue);
872 }
xmlThrDefGetWarningsDefaultValue(int v)873 int xmlThrDefGetWarningsDefaultValue(int v) {
874 int ret;
875 xmlMutexLock(xmlThrDefMutex);
876 ret = xmlGetWarningsDefaultValueThrDef;
877 xmlGetWarningsDefaultValueThrDef = v;
878 xmlMutexUnlock(xmlThrDefMutex);
879 return ret;
880 }
881
882 #undef xmlIndentTreeOutput
883 int *
__xmlIndentTreeOutput(void)884 __xmlIndentTreeOutput(void) {
885 if (IS_MAIN_THREAD)
886 return (&xmlIndentTreeOutput);
887 else
888 return (&xmlGetGlobalState()->xmlIndentTreeOutput);
889 }
xmlThrDefIndentTreeOutput(int v)890 int xmlThrDefIndentTreeOutput(int v) {
891 int ret;
892 xmlMutexLock(xmlThrDefMutex);
893 ret = xmlIndentTreeOutputThrDef;
894 xmlIndentTreeOutputThrDef = v;
895 xmlMutexUnlock(xmlThrDefMutex);
896 return ret;
897 }
898
899 #undef xmlTreeIndentString
900 const char * *
__xmlTreeIndentString(void)901 __xmlTreeIndentString(void) {
902 if (IS_MAIN_THREAD)
903 return (&xmlTreeIndentString);
904 else
905 return (&xmlGetGlobalState()->xmlTreeIndentString);
906 }
xmlThrDefTreeIndentString(const char * v)907 const char * xmlThrDefTreeIndentString(const char * v) {
908 const char * ret;
909 xmlMutexLock(xmlThrDefMutex);
910 ret = xmlTreeIndentStringThrDef;
911 xmlTreeIndentStringThrDef = v;
912 xmlMutexUnlock(xmlThrDefMutex);
913 return ret;
914 }
915
916 #undef xmlKeepBlanksDefaultValue
917 int *
__xmlKeepBlanksDefaultValue(void)918 __xmlKeepBlanksDefaultValue(void) {
919 if (IS_MAIN_THREAD)
920 return (&xmlKeepBlanksDefaultValue);
921 else
922 return (&xmlGetGlobalState()->xmlKeepBlanksDefaultValue);
923 }
xmlThrDefKeepBlanksDefaultValue(int v)924 int xmlThrDefKeepBlanksDefaultValue(int v) {
925 int ret;
926 xmlMutexLock(xmlThrDefMutex);
927 ret = xmlKeepBlanksDefaultValueThrDef;
928 xmlKeepBlanksDefaultValueThrDef = v;
929 xmlMutexUnlock(xmlThrDefMutex);
930 return ret;
931 }
932
933 #undef xmlLineNumbersDefaultValue
934 int *
__xmlLineNumbersDefaultValue(void)935 __xmlLineNumbersDefaultValue(void) {
936 if (IS_MAIN_THREAD)
937 return (&xmlLineNumbersDefaultValue);
938 else
939 return (&xmlGetGlobalState()->xmlLineNumbersDefaultValue);
940 }
xmlThrDefLineNumbersDefaultValue(int v)941 int xmlThrDefLineNumbersDefaultValue(int v) {
942 int ret;
943 xmlMutexLock(xmlThrDefMutex);
944 ret = xmlLineNumbersDefaultValueThrDef;
945 xmlLineNumbersDefaultValueThrDef = v;
946 xmlMutexUnlock(xmlThrDefMutex);
947 return ret;
948 }
949
950 #undef xmlLoadExtDtdDefaultValue
951 int *
__xmlLoadExtDtdDefaultValue(void)952 __xmlLoadExtDtdDefaultValue(void) {
953 if (IS_MAIN_THREAD)
954 return (&xmlLoadExtDtdDefaultValue);
955 else
956 return (&xmlGetGlobalState()->xmlLoadExtDtdDefaultValue);
957 }
xmlThrDefLoadExtDtdDefaultValue(int v)958 int xmlThrDefLoadExtDtdDefaultValue(int v) {
959 int ret;
960 xmlMutexLock(xmlThrDefMutex);
961 ret = xmlLoadExtDtdDefaultValueThrDef;
962 xmlLoadExtDtdDefaultValueThrDef = v;
963 xmlMutexUnlock(xmlThrDefMutex);
964 return ret;
965 }
966
967 #undef xmlParserDebugEntities
968 int *
__xmlParserDebugEntities(void)969 __xmlParserDebugEntities(void) {
970 if (IS_MAIN_THREAD)
971 return (&xmlParserDebugEntities);
972 else
973 return (&xmlGetGlobalState()->xmlParserDebugEntities);
974 }
xmlThrDefParserDebugEntities(int v)975 int xmlThrDefParserDebugEntities(int v) {
976 int ret;
977 xmlMutexLock(xmlThrDefMutex);
978 ret = xmlParserDebugEntitiesThrDef;
979 xmlParserDebugEntitiesThrDef = v;
980 xmlMutexUnlock(xmlThrDefMutex);
981 return ret;
982 }
983
984 #undef xmlParserVersion
985 const char * *
__xmlParserVersion(void)986 __xmlParserVersion(void) {
987 if (IS_MAIN_THREAD)
988 return (&xmlParserVersion);
989 else
990 return (&xmlGetGlobalState()->xmlParserVersion);
991 }
992
993 #undef xmlPedanticParserDefaultValue
994 int *
__xmlPedanticParserDefaultValue(void)995 __xmlPedanticParserDefaultValue(void) {
996 if (IS_MAIN_THREAD)
997 return (&xmlPedanticParserDefaultValue);
998 else
999 return (&xmlGetGlobalState()->xmlPedanticParserDefaultValue);
1000 }
xmlThrDefPedanticParserDefaultValue(int v)1001 int xmlThrDefPedanticParserDefaultValue(int v) {
1002 int ret;
1003 xmlMutexLock(xmlThrDefMutex);
1004 ret = xmlPedanticParserDefaultValueThrDef;
1005 xmlPedanticParserDefaultValueThrDef = v;
1006 xmlMutexUnlock(xmlThrDefMutex);
1007 return ret;
1008 }
1009
1010 #undef xmlSaveNoEmptyTags
1011 int *
__xmlSaveNoEmptyTags(void)1012 __xmlSaveNoEmptyTags(void) {
1013 if (IS_MAIN_THREAD)
1014 return (&xmlSaveNoEmptyTags);
1015 else
1016 return (&xmlGetGlobalState()->xmlSaveNoEmptyTags);
1017 }
xmlThrDefSaveNoEmptyTags(int v)1018 int xmlThrDefSaveNoEmptyTags(int v) {
1019 int ret;
1020 xmlMutexLock(xmlThrDefMutex);
1021 ret = xmlSaveNoEmptyTagsThrDef;
1022 xmlSaveNoEmptyTagsThrDef = v;
1023 xmlMutexUnlock(xmlThrDefMutex);
1024 return ret;
1025 }
1026
1027 #undef xmlSubstituteEntitiesDefaultValue
1028 int *
__xmlSubstituteEntitiesDefaultValue(void)1029 __xmlSubstituteEntitiesDefaultValue(void) {
1030 if (IS_MAIN_THREAD)
1031 return (&xmlSubstituteEntitiesDefaultValue);
1032 else
1033 return (&xmlGetGlobalState()->xmlSubstituteEntitiesDefaultValue);
1034 }
xmlThrDefSubstituteEntitiesDefaultValue(int v)1035 int xmlThrDefSubstituteEntitiesDefaultValue(int v) {
1036 int ret;
1037 xmlMutexLock(xmlThrDefMutex);
1038 ret = xmlSubstituteEntitiesDefaultValueThrDef;
1039 xmlSubstituteEntitiesDefaultValueThrDef = v;
1040 xmlMutexUnlock(xmlThrDefMutex);
1041 return ret;
1042 }
1043
1044 #undef xmlRegisterNodeDefaultValue
1045 xmlRegisterNodeFunc *
__xmlRegisterNodeDefaultValue(void)1046 __xmlRegisterNodeDefaultValue(void) {
1047 if (IS_MAIN_THREAD)
1048 return (&xmlRegisterNodeDefaultValue);
1049 else
1050 return (&xmlGetGlobalState()->xmlRegisterNodeDefaultValue);
1051 }
1052
1053 #undef xmlDeregisterNodeDefaultValue
1054 xmlDeregisterNodeFunc *
__xmlDeregisterNodeDefaultValue(void)1055 __xmlDeregisterNodeDefaultValue(void) {
1056 if (IS_MAIN_THREAD)
1057 return (&xmlDeregisterNodeDefaultValue);
1058 else
1059 return (&xmlGetGlobalState()->xmlDeregisterNodeDefaultValue);
1060 }
1061
1062 #undef xmlParserInputBufferCreateFilenameValue
1063 xmlParserInputBufferCreateFilenameFunc *
__xmlParserInputBufferCreateFilenameValue(void)1064 __xmlParserInputBufferCreateFilenameValue(void) {
1065 if (IS_MAIN_THREAD)
1066 return (&xmlParserInputBufferCreateFilenameValue);
1067 else
1068 return (&xmlGetGlobalState()->xmlParserInputBufferCreateFilenameValue);
1069 }
1070
1071 #undef xmlOutputBufferCreateFilenameValue
1072 xmlOutputBufferCreateFilenameFunc *
__xmlOutputBufferCreateFilenameValue(void)1073 __xmlOutputBufferCreateFilenameValue(void) {
1074 if (IS_MAIN_THREAD)
1075 return (&xmlOutputBufferCreateFilenameValue);
1076 else
1077 return (&xmlGetGlobalState()->xmlOutputBufferCreateFilenameValue);
1078 }
1079
1080