Commit 3c01b1d8 authored by Daniel Veillard's avatar Daniel Veillard
Browse files

- include/libxml/globals.h include/libxml/threads.h threads.c

  testThreads.c: far more testing, cleaning up bugs
- *.c : make sure globals.h is always included.
Daniel
parent 7cc95c0b
Wed Oct 17 11:56:25 EDT 2001 Daniel Veillard <daniel@veillard.com>
* include/libxml/globals.h include/libxml/threads.h threads.c
testThreads.c: far more testing, cleaning up bugs
* *.c : make sure globals.h is always included.
Wed Oct 17 17:41:41 CEST 2001 Daniel Veillard <daniel@veillard.com>
* HTMLparser.c: try to get rid of parser loops for good.
......
......@@ -45,6 +45,7 @@
#include <libxml/valid.h>
#include <libxml/xmlIO.h>
#include <libxml/uri.h>
#include <libxml/globals.h>
/*
* Internal description of an SGML entity
......
......@@ -40,6 +40,7 @@
#include <libxml/encoding.h>
#include <libxml/valid.h>
#include <libxml/xmlIO.h>
#include <libxml/globals.h>
#define HTML_MAX_NAMELEN 1000
#define HTML_PARSER_BIG_BUFFER_SIZE 1000
......
......@@ -24,6 +24,7 @@
#include <libxml/valid.h>
#include <libxml/xmlerror.h>
#include <libxml/parserInternals.h>
#include <libxml/globals.h>
/************************************************************************
* *
......
......@@ -23,6 +23,7 @@
#include <libxml/uri.h>
#include <libxml/valid.h>
#include <libxml/HTMLtree.h>
#include <libxml/globals.h>
/* #define DEBUG_SAX */
/* #define DEBUG_SAX_TREE */
......@@ -1713,7 +1714,7 @@ initxmlDefaultSAXHandler(xmlSAXHandler *hdlr, int warning)
void
xmlDefaultSAXHandlerInit(void)
{
initxmlDefaultSAXHandler(&xmlDefaultSAXHandler, xmlGetWarningsDefaultValue);
initxmlDefaultSAXHandler(&xmlDefaultSAXHandler, xmlGetWarningsDefaultValue);
}
#ifdef LIBXML_HTML_ENABLED
......@@ -1820,7 +1821,7 @@ initdocbDefaultSAXHandler(xmlSAXHandler *hdlr)
void
docbDefaultSAXHandlerInit(void)
{
initdocbDefaultSAXHandler(&docbDefaultSAXHandler);
initdocbDefaultSAXHandler(&docbDefaultSAXHandler);
}
#endif /* LIBXML_DOCB_ENABLED */
......@@ -38,6 +38,7 @@
#include <libxml/catalog.h>
#include <libxml/xmlerror.h>
#include <libxml/threads.h>
#include <libxml/globals.h>
#define MAX_DELEGATE 50
......@@ -1217,7 +1218,7 @@ xmlParseXMLCatalogFile(xmlCatalogPrefer prefer, const xmlChar *filename) {
if (xmlDebugCatalogs)
xmlGenericError(xmlGenericErrorContext,
"Parsing catalog %s\n", filename);
"%d Parsing catalog %s\n", xmlGetThreadId(), filename);
cur = xmlDocGetRootElement(doc);
if ((cur != NULL) && (xmlStrEqual(cur->name, BAD_CAST "catalog")) &&
......
......@@ -26,6 +26,7 @@
#include <libxml/HTMLtree.h>
#include <libxml/HTMLparser.h>
#include <libxml/xmlerror.h>
#include <libxml/globals.h>
/**
* xmlDebugDumpString:
......
......@@ -17,6 +17,7 @@
#include <libxml/entities.h>
#include <libxml/parser.h>
#include <libxml/xmlerror.h>
#include <libxml/globals.h>
/*
* The XML predefined entities.
......
......@@ -12,6 +12,7 @@
#include <libxml/parser.h>
#include <libxml/xmlerror.h>
#include <libxml/xmlmemory.h>
#include <libxml/globals.h>
#define XML_GET_VAR_STR(msg, str) { \
int size; \
......
......@@ -18,19 +18,17 @@
#endif
#include <string.h>
#include <libxml/xmlversion.h>
#include <libxml/globals.h>
#include <libxml/xmlmemory.h>
/* #define DEBUG_GLOBALS */
/*
* Helpful Macro
*/
#ifdef WITH_PTHREAD_H
#if defined(SOLARIS)
#define THR_MAIN(tid) (-1 == thr_main() || tid == thr_main())
#else
#define THR_MAIN(tid) (tid == 0 || tid == 1024)
#endif
#define IS_MAIN_THREAD (THR_MAIN(pthread_self()))
#ifdef LIBXML_THREAD_ENABLED
#define IS_MAIN_THREAD (xmlIsMainThread())
#else
#define IS_MAIN_THREAD 1
#endif
......@@ -41,8 +39,6 @@
* *
************************************************************************/
const char *xmlParserVersion = LIBXML_VERSION_STRING;
/*
* Memory allocation routines
*/
......@@ -93,6 +89,8 @@ xmlStrdupFunc xmlMemStrdup = (xmlStrdupFunc) strdup;
#undef xmlMemStrdup
#undef xmlRealloc
const char *xmlParserVersion = LIBXML_VERSION_STRING;
/*
* Buffers stuff
*/
......@@ -252,11 +250,19 @@ xmlSAXHandler docbDefaultSAXHandler = {
void
xmlInitializeGlobalState(xmlGlobalStatePtr gs)
{
#ifdef DEBUG_GLOBALS
fprintf(stderr, "Initializing globals at %lu for thread %d\n",
(unsigned long) gs, xmlGetThreadId());
#endif
/*
* Perform initialisation as required by libxml
*/
initxmlDefaultSAXHandler(&gs->xmlDefaultSAXHandler, 1);
initdocbDefaultSAXHandler(&gs->docbDefaultSAXHandler);
inithtmlDefaultSAXHandler(&gs->htmlDefaultSAXHandler);
initGenericErrorDefaultFunc(&gs->xmlGenericError);
gs->oldXMLWDcompatibility = 0;
gs->xmlBufferAllocScheme = XML_BUFFER_ALLOC_EXACT;
gs->xmlDefaultBufferSize = BASE_BUFFER_SIZE;
......@@ -277,7 +283,6 @@ xmlInitializeGlobalState(xmlGlobalStatePtr gs)
gs->xmlRealloc = (xmlReallocFunc) realloc;
gs->xmlMemStrdup = (xmlStrdupFunc) strdup;
#endif
initGenericErrorDefaultFunc(&gs->xmlGenericError);
gs->xmlGenericErrorContext = NULL;
gs->xmlGetWarningsDefaultValue = 1;
gs->xmlIndentTreeOutput = 0;
......
......@@ -24,6 +24,7 @@
#include <libxml/xmlmemory.h>
#include <libxml/parser.h>
#include <libxml/xmlerror.h>
#include <libxml/globals.h>
#define MAX_HASH_LEN 8
......
......@@ -57,6 +57,11 @@ struct _xmlGlobalState
{
const char *xmlParserVersion;
xmlSAXLocator xmlDefaultSAXLocator;
xmlSAXHandler xmlDefaultSAXHandler;
xmlSAXHandler docbDefaultSAXHandler;
xmlSAXHandler htmlDefaultSAXHandler;
xmlFreeFunc xmlFree;
xmlMallocFunc xmlMalloc;
xmlStrdupFunc xmlMemStrdup;
......@@ -65,11 +70,6 @@ struct _xmlGlobalState
xmlGenericErrorFunc xmlGenericError;
void *xmlGenericErrorContext;
xmlSAXLocator xmlDefaultSAXLocator;
xmlSAXHandler xmlDefaultSAXHandler;
xmlSAXHandler docbDefaultSAXHandler;
xmlSAXHandler htmlDefaultSAXHandler;
int oldXMLWDcompatibility;
xmlBufferAllocationScheme xmlBufferAllocScheme;
......
......@@ -43,6 +43,8 @@ void xmlFreeRMutex (xmlRMutexPtr tok);
void xmlInitThreads (void);
void xmlLockLibrary (void);
void xmlUnlockLibrary(void);
int xmlGetThreadId (void);
int xmlIsMainThread (void);
void xmlCleanupThreads(void);
xmlGlobalStatePtr xmlGetGlobalState(void);
......
......@@ -21,6 +21,7 @@
#include <string.h>
#include <libxml/xmlmemory.h>
#include <libxml/list.h>
#include <libxml/globals.h>
/*
* Type definition are kept internal
......
......@@ -59,6 +59,7 @@
#include <libxml/parser.h>
#include <libxml/xmlerror.h>
#include <libxml/nanoftp.h>
#include <libxml/globals.h>
/* #define DEBUG_FTP 1 */
#ifdef STANDALONE
......
......@@ -68,6 +68,7 @@
#include <libxml/xmlmemory.h>
#include <libxml/parser.h> /* for xmlStr(n)casecmp() */
#include <libxml/nanohttp.h>
#include <libxml/globals.h>
/**
* A couple portability macros
......
......@@ -10186,7 +10186,8 @@ static int xmlParserInitialized = 0;
void
xmlInitParser(void) {
if (xmlParserInitialized) return;
if (xmlParserInitialized != 0)
return;
initGenericErrorDefaultFunc(NULL);
xmlInitThreads();
......
......@@ -50,6 +50,7 @@
#ifdef LIBXML_CATALOG_ENABLED
#include <libxml/catalog.h>
#endif
#include <libxml/globals.h>
void xmlUpgradeOldNs(xmlDocPtr doc);
......@@ -2234,7 +2235,7 @@ xmlInitParserCtxt(xmlParserCtxtPtr ctxt)
ctxt->space = &ctxt->spaceTab[0];
ctxt->sax = sax;
memcpy(sax, &xmlDefaultSAXHandler, sizeof(xmlSAXHandler));
initxmlDefaultSAXHandler(sax, xmlGetWarningsDefaultValue);
ctxt->userData = ctxt;
ctxt->myDoc = NULL;
......
......@@ -35,6 +35,7 @@
#include <libxml/DOCBparser.h>
#include <libxml/tree.h>
#include <libxml/debugXML.h>
#include <libxml/globals.h>
#ifdef LIBXML_DEBUG_ENABLED
static int debug = 0;
......
......@@ -35,6 +35,7 @@
#include <libxml/HTMLtree.h>
#include <libxml/debugXML.h>
#include <libxml/xmlerror.h>
#include <libxml/globals.h>
#ifdef LIBXML_DEBUG_ENABLED
static int debug = 0;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment