globals.c 29 KB

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