Coverage Report

Created: 2024-05-15 07:10

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