mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-08-07 06:43:02 +03:00
applied patch from Geert Jansen to implement the save function to a
* xmlsave.c xmlIO.c include/libxml/xmlIO.h include/libxml/xmlsave.h: applied patch from Geert Jansen to implement the save function to a xmlBuffer, and a bit of cleanup. Daniel
This commit is contained in:
@@ -1,3 +1,9 @@
|
|||||||
|
Wed Nov 9 09:54:54 CET 2005 Daniel Veillard <daniel@veillard.com>
|
||||||
|
|
||||||
|
* xmlsave.c xmlIO.c include/libxml/xmlIO.h include/libxml/xmlsave.h:
|
||||||
|
applied patch from Geert Jansen to implement the save function to
|
||||||
|
a xmlBuffer, and a bit of cleanup.
|
||||||
|
|
||||||
Mon Nov 7 14:58:39 CET 2005 Kasimier Buchcik <libxml2-cvs@cazic.net>
|
Mon Nov 7 14:58:39 CET 2005 Kasimier Buchcik <libxml2-cvs@cazic.net>
|
||||||
|
|
||||||
* xmlschemas.c xmlschemastypes.c: Fixed the type of the
|
* xmlschemas.c xmlschemastypes.c: Fixed the type of the
|
||||||
|
@@ -231,6 +231,10 @@ XMLPUBFUN xmlOutputBufferPtr XMLCALL
|
|||||||
xmlOutputBufferCreateFile (FILE *file,
|
xmlOutputBufferCreateFile (FILE *file,
|
||||||
xmlCharEncodingHandlerPtr encoder);
|
xmlCharEncodingHandlerPtr encoder);
|
||||||
|
|
||||||
|
XMLPUBFUN xmlOutputBufferPtr XMLCALL
|
||||||
|
xmlOutputBufferCreateBuffer (xmlBufferPtr buffer,
|
||||||
|
xmlCharEncodingHandlerPtr encoder);
|
||||||
|
|
||||||
XMLPUBFUN xmlOutputBufferPtr XMLCALL
|
XMLPUBFUN xmlOutputBufferPtr XMLCALL
|
||||||
xmlOutputBufferCreateFd (int fd,
|
xmlOutputBufferCreateFd (int fd,
|
||||||
xmlCharEncodingHandlerPtr encoder);
|
xmlCharEncodingHandlerPtr encoder);
|
||||||
|
@@ -45,14 +45,12 @@ XMLPUBFUN xmlSaveCtxtPtr XMLCALL
|
|||||||
xmlSaveToFilename (const char *filename,
|
xmlSaveToFilename (const char *filename,
|
||||||
const char *encoding,
|
const char *encoding,
|
||||||
int options);
|
int options);
|
||||||
/******
|
|
||||||
Not yet implemented.
|
|
||||||
|
|
||||||
XMLPUBFUN xmlSaveCtxtPtr XMLCALL
|
XMLPUBFUN xmlSaveCtxtPtr XMLCALL
|
||||||
xmlSaveToBuffer (xmlBufferPtr buffer,
|
xmlSaveToBuffer (xmlBufferPtr buffer,
|
||||||
const char *encoding,
|
const char *encoding,
|
||||||
int options);
|
int options);
|
||||||
******/
|
|
||||||
XMLPUBFUN xmlSaveCtxtPtr XMLCALL
|
XMLPUBFUN xmlSaveCtxtPtr XMLCALL
|
||||||
xmlSaveToIO (xmlOutputWriteCallback iowrite,
|
xmlSaveToIO (xmlOutputWriteCallback iowrite,
|
||||||
xmlOutputCloseCallback ioclose,
|
xmlOutputCloseCallback ioclose,
|
||||||
|
62
xmlIO.c
62
xmlIO.c
@@ -862,6 +862,41 @@ xmlFileFlush (void * context) {
|
|||||||
return(ret);
|
return(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef LIBXML_OUTPUT_ENABLED
|
||||||
|
/**
|
||||||
|
* xmlBufferWrite:
|
||||||
|
* @context: the xmlBuffer
|
||||||
|
* @buffer: the data to write
|
||||||
|
* @len: number of bytes to write
|
||||||
|
*
|
||||||
|
* Write @len bytes from @buffer to the xml buffer
|
||||||
|
*
|
||||||
|
* Returns the number of bytes written
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
xmlBufferWrite (void * context, const char * buffer, int len) {
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = xmlBufferAdd((xmlBufferPtr) context, (const xmlChar *) buffer, len);
|
||||||
|
if (ret != 0)
|
||||||
|
return(-1);
|
||||||
|
return(len);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xmlBufferClose:
|
||||||
|
* @context: the xmlBuffer
|
||||||
|
*
|
||||||
|
* Close a buffer
|
||||||
|
*
|
||||||
|
* Returns 0 or -1 in case of error
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
xmlBufferClose (void * context) {
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_ZLIB_H
|
#ifdef HAVE_ZLIB_H
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* *
|
* *
|
||||||
@@ -2438,6 +2473,33 @@ xmlOutputBufferCreateFile(FILE *file, xmlCharEncodingHandlerPtr encoder) {
|
|||||||
|
|
||||||
return(ret);
|
return(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xmlOutputBufferCreateBuffer:
|
||||||
|
* @buffer: a xmlBufferPtr
|
||||||
|
* @encoder: the encoding converter or NULL
|
||||||
|
*
|
||||||
|
* Create a buffered output for the progressive saving to a xmlBuffer
|
||||||
|
*
|
||||||
|
* Returns the new parser output or NULL
|
||||||
|
*/
|
||||||
|
xmlOutputBufferPtr
|
||||||
|
xmlOutputBufferCreateBuffer(xmlBufferPtr buffer,
|
||||||
|
xmlCharEncodingHandlerPtr encoder) {
|
||||||
|
xmlOutputBufferPtr ret;
|
||||||
|
|
||||||
|
if (buffer == NULL) return(NULL);
|
||||||
|
|
||||||
|
ret = xmlAllocOutputBuffer(encoder);
|
||||||
|
if (ret != NULL) {
|
||||||
|
ret->context = buffer;
|
||||||
|
ret->writecallback = xmlBufferWrite;
|
||||||
|
ret->closecallback = xmlBufferClose;
|
||||||
|
}
|
||||||
|
|
||||||
|
return(ret);
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* LIBXML_OUTPUT_ENABLED */
|
#endif /* LIBXML_OUTPUT_ENABLED */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -1526,8 +1526,8 @@ xmlFAGenerateTransitions(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr from,
|
|||||||
} else {
|
} else {
|
||||||
newstate = xmlRegNewState(ctxt);
|
newstate = xmlRegNewState(ctxt);
|
||||||
xmlRegStatePush(ctxt, newstate);
|
xmlRegStatePush(ctxt, newstate);
|
||||||
ctxt->state = newstate;
|
|
||||||
}
|
}
|
||||||
|
ctxt->state = newstate;
|
||||||
xmlFAGenerateCountedTransition(ctxt, atom->stop,
|
xmlFAGenerateCountedTransition(ctxt, atom->stop,
|
||||||
newstate, counter);
|
newstate, counter);
|
||||||
}
|
}
|
||||||
|
27
xmlsave.c
27
xmlsave.c
@@ -1477,13 +1477,36 @@ xmlSaveToFilename(const char *filename, const char *encoding, int options)
|
|||||||
* with the encoding and the options given
|
* with the encoding and the options given
|
||||||
*
|
*
|
||||||
* Returns a new serialization context or NULL in case of error.
|
* Returns a new serialization context or NULL in case of error.
|
||||||
|
*/
|
||||||
|
|
||||||
xmlSaveCtxtPtr
|
xmlSaveCtxtPtr
|
||||||
xmlSaveToBuffer(xmlBufferPtr buffer, const char *encoding, int options)
|
xmlSaveToBuffer(xmlBufferPtr buffer, const char *encoding, int options)
|
||||||
{
|
{
|
||||||
TODO
|
xmlSaveCtxtPtr ret;
|
||||||
|
xmlOutputBufferPtr out_buff;
|
||||||
|
xmlCharEncodingHandlerPtr handler;
|
||||||
|
|
||||||
|
ret = xmlNewSaveCtxt(encoding, options);
|
||||||
|
if (ret == NULL) return(NULL);
|
||||||
|
|
||||||
|
if (encoding != NULL) {
|
||||||
|
handler = xmlFindCharEncodingHandler(encoding);
|
||||||
|
if (handler == NULL) {
|
||||||
|
xmlFree(ret);
|
||||||
return(NULL);
|
return(NULL);
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
handler = NULL;
|
||||||
|
out_buff = xmlOutputBufferCreateBuffer(buffer, handler);
|
||||||
|
if (out_buff == NULL) {
|
||||||
|
xmlFree(ret);
|
||||||
|
if (handler) xmlCharEncCloseFunc(handler);
|
||||||
|
return(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
ret->buf = out_buff;
|
||||||
|
return(ret);
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xmlSaveToIO:
|
* xmlSaveToIO:
|
||||||
|
Reference in New Issue
Block a user