applied patch from Rob Richards for custom I/O BufferCreateFilenane fixes

* globals.c xmlIO.c include/libxml/globals.h: applied patch from
  Rob Richards for custom I/O BufferCreateFilenane fixes bug
  #143366
Daniel
This commit is contained in:
Daniel Veillard 2004-06-02 16:18:40 +00:00
parent 8fad8bff2c
commit 0335a846ad
4 changed files with 171 additions and 27 deletions

View File

@ -1,3 +1,9 @@
Wed Jun 2 18:15:51 CEST 2004 Daniel Veillard <daniel@veillard.com>
* globals.c xmlIO.c include/libxml/globals.h: applied patch from
Rob Richards for custom I/O BufferCreateFilenane fixes bug
#143366
Wed Jun 02 16:25:32 HKT 2004 William Brack <wbrack@mmm.com.hk>
* xpath.c: fixed problem with predicate evaluation on an

View File

@ -169,6 +169,8 @@ xmlStrdupFunc xmlMemStrdup = (xmlStrdupFunc) xmlStrdup;
#undef xmlMemStrdup
#undef xmlRealloc
#undef xmlParserInputBufferCreateFilenameValue
#undef xmlOutputBufferCreateFilenameValue
/**
* xmlParserVersion:
*
@ -282,6 +284,12 @@ static xmlRegisterNodeFunc xmlRegisterNodeDefaultValueThrDef = NULL;
xmlDeregisterNodeFunc xmlDeregisterNodeDefaultValue = NULL;
static xmlDeregisterNodeFunc xmlDeregisterNodeDefaultValueThrDef = NULL;
xmlParserInputBufferCreateFilenameFunc xmlParserInputBufferCreateFilenameValue = NULL;
static xmlParserInputBufferCreateFilenameFunc xmlParserInputBufferCreateFilenameValueThrDef = NULL;
xmlOutputBufferCreateFilenameFunc xmlOutputBufferCreateFilenameValue = NULL;
static xmlOutputBufferCreateFilenameFunc xmlOutputBufferCreateFilenameValueThrDef = NULL;
/*
* Error handling
*/
@ -545,6 +553,9 @@ xmlInitializeGlobalState(xmlGlobalStatePtr gs)
gs->xmlGenericErrorContext = xmlGenericErrorContextThrDef;
gs->xmlRegisterNodeDefaultValue = xmlRegisterNodeDefaultValueThrDef;
gs->xmlDeregisterNodeDefaultValue = xmlDeregisterNodeDefaultValueThrDef;
gs->xmlParserInputBufferCreateFilenameValue = xmlParserInputBufferCreateFilenameValueThrDef;
gs->xmlOutputBufferCreateFilenameValue = xmlOutputBufferCreateFilenameValueThrDef;
memset(&gs->xmlLastError, 0, sizeof(xmlError));
xmlMutexUnlock(xmlThrDefMutex);
@ -639,6 +650,67 @@ xmlThrDefDeregisterNodeDefault(xmlDeregisterNodeFunc func)
return(old);
}
/**
* xmlParserInputBufferCreateFilename:
* @func: function pointer to the new ParserInputBufferCreateFilenameFunc
*
* Registers a callback for URI input file handling
*
* Returns the old value of the registration function
*/
xmlParserInputBufferCreateFilenameFunc
xmlParserInputBufferCreateFilenameDefault(xmlParserInputBufferCreateFilenameFunc func)
{
xmlParserInputBufferCreateFilenameFunc old = xmlParserInputBufferCreateFilenameValue;
xmlParserInputBufferCreateFilenameValue = func;
return(old);
}
xmlParserInputBufferCreateFilenameFunc
xmlThrDefParserInputBufferCreateFilenameDefault(xmlParserInputBufferCreateFilenameFunc func)
{
xmlParserInputBufferCreateFilenameFunc old;
xmlMutexLock(xmlThrDefMutex);
old = xmlParserInputBufferCreateFilenameValueThrDef;
xmlParserInputBufferCreateFilenameValueThrDef = func;
xmlMutexUnlock(xmlThrDefMutex);
return(old);
}
/**
* xmlOutputBufferCreateFilename:
* @func: function pointer to the new OutputBufferCreateFilenameFunc
*
* Registers a callback for URI output file handling
*
* Returns the old value of the registration function
*/
xmlOutputBufferCreateFilenameFunc
xmlOutputBufferCreateFilenameDefault(xmlOutputBufferCreateFilenameFunc func)
{
xmlOutputBufferCreateFilenameFunc old = xmlOutputBufferCreateFilenameValue;
xmlOutputBufferCreateFilenameValue = func;
return(old);
}
xmlOutputBufferCreateFilenameFunc
xmlThrDefOutputBufferCreateFilenameDefault(xmlOutputBufferCreateFilenameFunc func)
{
xmlOutputBufferCreateFilenameFunc old;
xmlMutexLock(xmlThrDefMutex);
old = xmlOutputBufferCreateFilenameValueThrDef;
xmlOutputBufferCreateFilenameValueThrDef = func;
xmlMutexUnlock(xmlThrDefMutex);
return(old);
}
#ifdef LIBXML_DOCB_ENABLED
#undef docbDefaultSAXHandler
@ -981,3 +1053,21 @@ __xmlDeregisterNodeDefaultValue(void) {
else
return (&xmlGetGlobalState()->xmlDeregisterNodeDefaultValue);
}
#undef xmlParserInputBufferCreateFilenameValue
xmlParserInputBufferCreateFilenameFunc *
__xmlParserInputBufferCreateFilenameValue(void) {
if (IS_MAIN_THREAD)
return (&xmlParserInputBufferCreateFilenameValue);
else
return (&xmlGetGlobalState()->xmlParserInputBufferCreateFilenameValue);
}
#undef xmlOutputBufferCreateFilenameValue
xmlOutputBufferCreateFilenameFunc *
__xmlOutputBufferCreateFilenameValue(void) {
if (IS_MAIN_THREAD)
return (&xmlOutputBufferCreateFilenameValue);
else
return (&xmlGetGlobalState()->xmlOutputBufferCreateFilenameValue);
}

View File

@ -63,10 +63,15 @@ XMLPUBFUN void XMLCALL xmlCleanupGlobals(void);
#undef xmlRegisterNodeDefaultValue
#undef xmlDeregisterNodeDefaultValue
#undef xmlLastError
#undef xmlParserInputBufferCreateFilenameValue
#undef xmlOutputBufferCreateFilenameValue
typedef void (*xmlRegisterNodeFunc) (xmlNodePtr node);
typedef void (*xmlDeregisterNodeFunc) (xmlNodePtr node);
typedef xmlParserInputBufferPtr (*xmlParserInputBufferCreateFilenameFunc) (const char *URI, xmlCharEncoding enc);
typedef xmlOutputBufferPtr (*xmlOutputBufferCreateFilenameFunc) (const char *URI, xmlCharEncodingHandlerPtr encoder, int compression);
typedef struct _xmlGlobalState xmlGlobalState;
typedef xmlGlobalState *xmlGlobalStatePtr;
struct _xmlGlobalState
@ -110,6 +115,9 @@ struct _xmlGlobalState
xmlMallocFunc xmlMallocAtomic;
xmlError xmlLastError;
xmlParserInputBufferCreateFilenameFunc xmlParserInputBufferCreateFilenameValue;
xmlOutputBufferCreateFilenameFunc xmlOutputBufferCreateFilenameValue;
};
#ifdef __cplusplus
@ -131,6 +139,12 @@ XMLPUBFUN xmlRegisterNodeFunc XMLCALL xmlThrDefRegisterNodeDefault(xmlRegisterNo
XMLPUBFUN xmlDeregisterNodeFunc XMLCALL xmlDeregisterNodeDefault(xmlDeregisterNodeFunc func);
XMLPUBFUN xmlDeregisterNodeFunc XMLCALL xmlThrDefDeregisterNodeDefault(xmlDeregisterNodeFunc func);
XMLPUBFUN xmlParserInputBufferCreateFilenameFunc XMLCALL xmlParserInputBufferCreateFilenameDefault(xmlParserInputBufferCreateFilenameFunc func);
XMLPUBFUN xmlParserInputBufferCreateFilenameFunc XMLCALL xmlThrDefParserInputBufferCreateFilenameDefault(xmlParserInputBufferCreateFilenameFunc func);
XMLPUBFUN xmlOutputBufferCreateFilenameFunc XMLCALL xmlOutputBufferCreateFilenameDefault(xmlOutputBufferCreateFilenameFunc func);
XMLPUBFUN xmlOutputBufferCreateFilenameFunc XMLCALL xmlThrDefOutputBufferCreateFilenameDefault(xmlOutputBufferCreateFilenameFunc func);
/** DOC_DISABLE */
/*
* In general the memory allocation entry points are not kept
@ -415,6 +429,22 @@ XMLPUBFUN xmlDeregisterNodeFunc * XMLCALL __xmlDeregisterNodeDefaultValue(void);
XMLPUBVAR xmlDeregisterNodeFunc xmlDeregisterNodeDefaultValue;
#endif
XMLPUBFUN xmlParserInputBufferCreateFilenameFunc * XMLCALL __xmlParserInputBufferCreateFilenameValue(void);
#ifdef LIBXML_THREAD_ENABLED
#define xmlParserInputBufferCreateFilenameValue \
(*(__xmlParserInputBufferCreateFilenameValue()))
#else
XMLPUBVAR xmlParserInputBufferCreateFilenameFunc xmlParserInputBufferCreateFilenameValue;
#endif
XMLPUBFUN xmlOutputBufferCreateFilenameFunc * XMLCALL __xmlOutputBufferCreateFilenameValue(void);
#ifdef LIBXML_THREAD_ENABLED
#define xmlOutputBufferCreateFilenameValue \
(*(__xmlOutputBufferCreateFilenameValue()))
#else
XMLPUBVAR xmlOutputBufferCreateFilenameFunc xmlOutputBufferCreateFilenameValue;
#endif
#ifdef __cplusplus
}
#endif

72
xmlIO.c
View File

@ -2125,21 +2125,8 @@ xmlOutputBufferClose(xmlOutputBufferPtr out)
}
#endif /* LIBXML_OUTPUT_ENABLED */
/**
* xmlParserInputBufferCreateFilename:
* @URI: a C string containing the URI or filename
* @enc: the charset encoding if known
*
* Create a buffered parser input for the progressive parsing of a file
* If filename is "-' then we use stdin as the input.
* Automatic support for ZLIB/Compress compressed document is provided
* by default if found at compile-time.
* Do an encoding check if enc == XML_CHAR_ENCODING_NONE
*
* Returns the new parser input or NULL
*/
xmlParserInputBufferPtr
xmlParserInputBufferCreateFilename(const char *URI, xmlCharEncoding enc) {
static xmlParserInputBufferPtr
__xmlParserInputBufferCreateFilename(const char *URI, xmlCharEncoding enc) {
xmlParserInputBufferPtr ret;
int i = 0;
void *context = NULL;
@ -2196,26 +2183,32 @@ xmlParserInputBufferCreateFilename(const char *URI, xmlCharEncoding enc) {
return(ret);
}
#ifdef LIBXML_OUTPUT_ENABLED
/**
* xmlOutputBufferCreateFilename:
* xmlParserInputBufferCreateFilename:
* @URI: a C string containing the URI or filename
* @encoder: the encoding converter or NULL
* @compression: the compression ration (0 none, 9 max).
* @enc: the charset encoding if known
*
* Create a buffered output for the progressive saving of a file
* If filename is "-' then we use stdout as the output.
* Create a buffered parser input for the progressive parsing of a file
* If filename is "-' then we use stdin as the input.
* Automatic support for ZLIB/Compress compressed document is provided
* by default if found at compile-time.
* TODO: currently if compression is set, the library only support
* writing to a local file.
* Do an encoding check if enc == XML_CHAR_ENCODING_NONE
*
* Returns the new output or NULL
* Returns the new parser input or NULL
*/
xmlOutputBufferPtr
xmlOutputBufferCreateFilename(const char *URI,
xmlParserInputBufferPtr
xmlParserInputBufferCreateFilename(const char *URI, xmlCharEncoding enc) {
if ((xmlParserInputBufferCreateFilenameValue)) {
return xmlParserInputBufferCreateFilenameValue(URI, enc);
}
return __xmlParserInputBufferCreateFilename(URI, enc);
}
#ifdef LIBXML_OUTPUT_ENABLED
static xmlOutputBufferPtr
__xmlOutputBufferCreateFilename(const char *URI,
xmlCharEncodingHandlerPtr encoder,
int compression ATTRIBUTE_UNUSED) {
int compression ATTRIBUTE_UNUSED) {
xmlOutputBufferPtr ret;
xmlURIPtr puri;
int i = 0;
@ -2329,6 +2322,31 @@ xmlOutputBufferCreateFilename(const char *URI,
}
return(ret);
}
/**
* xmlOutputBufferCreateFilename:
* @URI: a C string containing the URI or filename
* @encoder: the encoding converter or NULL
* @compression: the compression ration (0 none, 9 max).
*
* Create a buffered output for the progressive saving of a file
* If filename is "-' then we use stdout as the output.
* Automatic support for ZLIB/Compress compressed document is provided
* by default if found at compile-time.
* TODO: currently if compression is set, the library only support
* writing to a local file.
*
* Returns the new output or NULL
*/
xmlOutputBufferPtr
xmlOutputBufferCreateFilename(const char *URI,
xmlCharEncodingHandlerPtr encoder,
int compression ATTRIBUTE_UNUSED) {
if ((xmlOutputBufferCreateFilenameValue)) {
return xmlOutputBufferCreateFilenameValue(URI, encoder, compression);
}
return __xmlOutputBufferCreateFilename(URI, encoder, compression);
}
#endif /* LIBXML_OUTPUT_ENABLED */
/**