Coverage Report

Created: 2023-12-13 20:02

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