summaryrefslogtreecommitdiff
path: root/xmlwriter.c
diff options
context:
space:
mode:
authorAron Xu <aron@debian.org>2014-10-26 07:02:25 +0800
committerAron Xu <aron@debian.org>2014-10-26 07:02:25 +0800
commit3871a83a5f0aebd8c00879eab14fe901c93dbfcf (patch)
treeb022967f880b7fb1e56c8cc4c3f200d6ffbc9efd /xmlwriter.c
parent7042e17490515a990a45aa7237d11bc49ab0eaf0 (diff)
downloadlibxml2-3871a83a5f0aebd8c00879eab14fe901c93dbfcf.tar.gz
Imported Upstream version 2.9.2+dfsg1
Diffstat (limited to 'xmlwriter.c')
-rw-r--r--xmlwriter.c70
1 files changed, 50 insertions, 20 deletions
diff --git a/xmlwriter.c b/xmlwriter.c
index 11b15e0..fac20ac 100644
--- a/xmlwriter.c
+++ b/xmlwriter.c
@@ -21,15 +21,18 @@
#include <libxml/xmlwriter.h>
+#include "buf.h"
+#include "enc.h"
+#include "save.h"
+
#define B64LINELEN 72
#define B64CRLF "\r\n"
/*
* The following VA_COPY was coded following an example in
* the Samba project. It may not be sufficient for some
- * esoteric implementations of va_list (i.e. it may need
- * something involving a memcpy) but (hopefully) will be
- * sufficient for libxml2.
+ * esoteric implementations of va_list but (hopefully) will
+ * be sufficient for libxml2.
*/
#ifndef VA_COPY
#ifdef HAVE_VA_COPY
@@ -38,7 +41,12 @@
#ifdef HAVE___VA_COPY
#define VA_COPY(dest,src) __va_copy(dest, src)
#else
- #define VA_COPY(dest,src) (dest) = (src)
+ #ifndef VA_LIST_IS_ARRAY
+ #define VA_COPY(dest,src) (dest) = (src)
+ #else
+ #include <string.h>
+ #define VA_COPY(dest,src) memcpy((char *)(dest),(char *)(src),sizeof(va_list))
+ #endif
#endif
#endif
#endif
@@ -548,9 +556,9 @@ xmlTextWriterStartDocument(xmlTextWriterPtr writer, const char *version,
writer->out->encoder = encoder;
if (encoder != NULL) {
if (writer->out->conv == NULL) {
- writer->out->conv = xmlBufferCreateSize(4000);
+ writer->out->conv = xmlBufCreateSize(4000);
}
- xmlCharEncOutFunc(encoder, writer->out->conv, NULL);
+ xmlCharEncOutput(writer->out, 1);
if ((writer->doc != NULL) && (writer->doc->encoding == NULL))
writer->doc->encoding = xmlStrdup((xmlChar *)writer->out->encoder->name);
} else
@@ -1074,10 +1082,10 @@ xmlTextWriterStartElementNS(xmlTextWriterPtr writer,
sum += count;
if (namespaceURI != 0) {
- xmlTextWriterNsStackEntry *p = (xmlTextWriterNsStackEntry *)
+ xmlTextWriterNsStackEntry *p = (xmlTextWriterNsStackEntry *)
xmlMalloc(sizeof(xmlTextWriterNsStackEntry));
if (p == 0) {
- xmlWriterErrMsg(writer, XML_ERR_NO_MEMORY,
+ xmlWriterErrMsg(writer, XML_ERR_NO_MEMORY,
"xmlTextWriterStartElementNS : out of memory!\n");
return -1;
}
@@ -1501,8 +1509,8 @@ xmlTextWriterWriteString(xmlTextWriterPtr writer, const xmlChar * content)
break;
case XML_TEXTWRITER_ATTRIBUTE:
buf = NULL;
- xmlAttrSerializeTxtContent(writer->out->buffer, writer->doc,
- NULL, content);
+ xmlBufAttrSerializeTxtContent(writer->out->buffer,
+ writer->doc, NULL, content);
break;
default:
break;
@@ -1663,7 +1671,7 @@ xmlTextWriterWriteBase64(xmlTextWriterPtr writer, const char *data,
* Write hqx encoded data to an xmlOutputBuffer.
* ::todo
*
- * Returns the bytes written (may be 0 because of buffering)
+ * Returns the bytes written (may be 0 because of buffering)
* or -1 in case of error
*/
static int
@@ -1672,8 +1680,8 @@ xmlOutputBufferWriteBinHex(xmlOutputBufferPtr out,
{
int count;
int sum;
- static char hex[16] =
- {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
+ static char hex[16] =
+ {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
int i;
if ((out == NULL) || (data == NULL) || (len < 0)) {
@@ -1849,7 +1857,7 @@ xmlTextWriterStartAttributeNS(xmlTextWriterPtr writer,
nsentry.uri = (xmlChar *)namespaceURI;
nsentry.elem = xmlListFront(writer->nodes);
- curns = (xmlTextWriterNsStackEntry *)xmlListSearch(writer->nsstack,
+ curns = (xmlTextWriterNsStackEntry *)xmlListSearch(writer->nsstack,
(void *)&nsentry);
if ((curns != NULL)) {
xmlFree(buf);
@@ -2234,10 +2242,12 @@ xmlTextWriterWriteElement(xmlTextWriterPtr writer, const xmlChar * name,
if (count == -1)
return -1;
sum += count;
- count = xmlTextWriterWriteString(writer, content);
- if (count == -1)
- return -1;
- sum += count;
+ if (content != NULL) {
+ count = xmlTextWriterWriteString(writer, content);
+ if (count == -1)
+ return -1;
+ sum += count;
+ }
count = xmlTextWriterEndElement(writer);
if (count == -1)
return -1;
@@ -2496,8 +2506,8 @@ xmlTextWriterEndPI(xmlTextWriterPtr writer)
if (writer->indent) {
count = xmlOutputBufferWriteString(writer->out, "\n");
- if (count < 0)
- return -1;
+ if (count < 0)
+ return -1;
sum += count;
}
@@ -4606,6 +4616,26 @@ xmlTextWriterSetIndentString(xmlTextWriterPtr writer, const xmlChar * str)
}
/**
+ * xmlTextWriterSetQuoteChar:
+ * @writer: the xmlTextWriterPtr
+ * @quotechar: the quote character
+ *
+ * Set the character used for quoting attributes.
+ *
+ * Returns -1 on error or 0 otherwise.
+ */
+int
+xmlTextWriterSetQuoteChar(xmlTextWriterPtr writer, xmlChar quotechar)
+{
+ if ((writer == NULL) || ((quotechar != '\'') && (quotechar != '"')))
+ return -1;
+
+ writer->qchar = quotechar;
+
+ return 0;
+}
+
+/**
* xmlTextWriterWriteIndent:
* @writer: the xmlTextWriterPtr
*