summaryrefslogtreecommitdiff
path: root/xmlIO.c
diff options
context:
space:
mode:
authorMike Hommey <glandium@debian.org>2006-01-06 18:28:17 +0100
committerMike Hommey <glandium@debian.org>2006-01-06 18:28:17 +0100
commit0fd83af441e251fc23fc1af7959fd6ecfa105fe1 (patch)
treea2b35749a66abce02e6f07983ef50618d93bef58 /xmlIO.c
parent17049f05f9ef09b3dc2a9c5d1de3f21de7c03193 (diff)
downloadlibxml2-0fd83af441e251fc23fc1af7959fd6ecfa105fe1.tar.gz
Load /tmp/tmp.U9vXwU/libxml2-2.6.23 intoupstream/2.6.23
local/libxml2/branches/upstream/current.
Diffstat (limited to 'xmlIO.c')
-rw-r--r--xmlIO.c55
1 files changed, 52 insertions, 3 deletions
diff --git a/xmlIO.c b/xmlIO.c
index 1e73b6d..2610e25 100644
--- a/xmlIO.c
+++ b/xmlIO.c
@@ -610,10 +610,12 @@ xmlFdRead (void * context, char * buffer, int len) {
*/
static int
xmlFdWrite (void * context, const char * buffer, int len) {
- int ret;
+ int ret = 0;
- ret = write((int) (long) context, &buffer[0], len);
- if (ret < 0) xmlIOErr(0, "write()");
+ if (len > 0) {
+ ret = write((int) (long) context, &buffer[0], len);
+ if (ret < 0) xmlIOErr(0, "write()");
+ }
return(ret);
}
#endif /* LIBXML_OUTPUT_ENABLED */
@@ -860,6 +862,28 @@ xmlFileFlush (void * context) {
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);
+}
+#endif
+
#ifdef HAVE_ZLIB_H
/************************************************************************
* *
@@ -2436,6 +2460,31 @@ xmlOutputBufferCreateFile(FILE *file, xmlCharEncodingHandlerPtr encoder) {
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 = xmlOutputBufferCreateIO((xmlOutputWriteCallback)
+ xmlBufferWrite,
+ (xmlOutputCloseCallback)
+ NULL, (void *) buffer, encoder);
+
+ return(ret);
+}
+
#endif /* LIBXML_OUTPUT_ENABLED */
/**