Coverage Report

Created: 2025-08-04 07:15

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