diff --git a/android/native/jni/Android.mk b/android/native/jni/Android.mk index 5aed71432d..97b35c2997 100644 --- a/android/native/jni/Android.mk +++ b/android/native/jni/Android.mk @@ -50,8 +50,7 @@ LOCAL_LIBXML_SRC_FILES = $(LIBXML_PATH)/c14n.c \ $(LIBXML_PATH)/xmlregexp.c \ $(LIBXML_PATH)/xmlsave.c \ $(LIBXML_PATH)/xmlstring.c \ - $(LIBXML_PATH)/xmlunicode.c \ - $(LIBXML_PATH)/xmlwriter.c + $(LIBXML_PATH)/xmlunicode.c LOCAL_SRC_FILES = $(RARCH_PATH)/console/griffin/griffin.c $(LOCAL_LIBXML_SRC_FILES) diff --git a/android/native/libxml2/SAX2.c b/android/native/libxml2/SAX2.c index 10dfdc5766..671d36361b 100644 --- a/android/native/libxml2/SAX2.c +++ b/android/native/libxml2/SAX2.c @@ -1037,746 +1037,6 @@ xmlSAX2EndDocument(void *ctx) } } -#if defined(LIBXML_WRITER_ENABLED) -/** - * xmlSAX2AttributeInternal: - * @ctx: the user data (XML parser context) - * @fullname: The attribute name, including namespace prefix - * @value: The attribute value - * @prefix: the prefix on the element node - * - * Handle an attribute that has been read by the parser. - * The default handling is to convert the attribute into an - * DOM subtree and past it in a new xmlAttr element added to - * the element. - */ -static void -xmlSAX2AttributeInternal(void *ctx, const xmlChar *fullname, - const xmlChar *value, const xmlChar *prefix ATTRIBUTE_UNUSED) -{ - xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; - xmlAttrPtr ret; - xmlChar *name; - xmlChar *ns; - xmlChar *nval; - xmlNsPtr namespace; - - if (ctxt->html) { - name = xmlStrdup(fullname); - ns = NULL; - namespace = NULL; - } else { - /* - * Split the full name into a namespace prefix and the tag name - */ - name = xmlSplitQName(ctxt, fullname, &ns); - if ((name != NULL) && (name[0] == 0)) { - if (xmlStrEqual(ns, BAD_CAST "xmlns")) { - xmlNsErrMsg(ctxt, XML_ERR_NS_DECL_ERROR, - "invalid namespace declaration '%s'\n", - fullname, NULL); - } else { - xmlNsWarnMsg(ctxt, XML_WAR_NS_COLUMN, - "Avoid attribute ending with ':' like '%s'\n", - fullname, NULL); - } - if (ns != NULL) - xmlFree(ns); - ns = NULL; - xmlFree(name); - name = xmlStrdup(fullname); - } - } - if (name == NULL) { - xmlSAX2ErrMemory(ctxt, "xmlSAX2StartElement"); - if (ns != NULL) - xmlFree(ns); - return; - } - - { -#ifdef LIBXML_VALID_ENABLED - /* - * Do the last stage of the attribute normalization - * Needed for HTML too: - * http://www.w3.org/TR/html4/types.html#h-6.2 - */ - ctxt->vctxt.valid = 1; - nval = xmlValidCtxtNormalizeAttributeValue(&ctxt->vctxt, - ctxt->myDoc, ctxt->node, - fullname, value); - if (ctxt->vctxt.valid != 1) { - ctxt->valid = 0; - } - if (nval != NULL) - value = nval; -#else - nval = NULL; -#endif /* LIBXML_VALID_ENABLED */ - } - - /* - * Check whether it's a namespace definition - */ - if ((!ctxt->html) && (ns == NULL) && - (name[0] == 'x') && (name[1] == 'm') && (name[2] == 'l') && - (name[3] == 'n') && (name[4] == 's') && (name[5] == 0)) { - xmlNsPtr nsret; - xmlChar *val; - - if (!ctxt->replaceEntities) { - ctxt->depth++; - val = xmlStringDecodeEntities(ctxt, value, XML_SUBSTITUTE_REF, - 0,0,0); - ctxt->depth--; - } else { - val = (xmlChar *) value; - } - - if (val[0] != 0) { - xmlURIPtr uri; - - uri = xmlParseURI((const char *)val); - if (uri == NULL) { - if ((ctxt->sax != NULL) && (ctxt->sax->warning != NULL)) - ctxt->sax->warning(ctxt->userData, - "xmlns: %s not a valid URI\n", val); - } else { - if (uri->scheme == NULL) { - if ((ctxt->sax != NULL) && (ctxt->sax->warning != NULL)) - ctxt->sax->warning(ctxt->userData, - "xmlns: URI %s is not absolute\n", val); - } - xmlFreeURI(uri); - } - } - - /* a default namespace definition */ - nsret = xmlNewNs(ctxt->node, val, NULL); - -#ifdef LIBXML_VALID_ENABLED - /* - * Validate also for namespace decls, they are attributes from - * an XML-1.0 perspective - */ - if (nsret != NULL && ctxt->validate && ctxt->wellFormed && - ctxt->myDoc && ctxt->myDoc->intSubset) - ctxt->valid &= xmlValidateOneNamespace(&ctxt->vctxt, ctxt->myDoc, - ctxt->node, prefix, nsret, val); -#endif /* LIBXML_VALID_ENABLED */ - if (name != NULL) - xmlFree(name); - if (nval != NULL) - xmlFree(nval); - if (val != value) - xmlFree(val); - return; - } - if ((!ctxt->html) && - (ns != NULL) && (ns[0] == 'x') && (ns[1] == 'm') && (ns[2] == 'l') && - (ns[3] == 'n') && (ns[4] == 's') && (ns[5] == 0)) { - xmlNsPtr nsret; - xmlChar *val; - - if (!ctxt->replaceEntities) { - ctxt->depth++; - val = xmlStringDecodeEntities(ctxt, value, XML_SUBSTITUTE_REF, - 0,0,0); - ctxt->depth--; - if (val == NULL) { - xmlSAX2ErrMemory(ctxt, "xmlSAX2StartElement"); - xmlFree(ns); - if (name != NULL) - xmlFree(name); - return; - } - } else { - val = (xmlChar *) value; - } - - if (val[0] == 0) { - xmlNsErrMsg(ctxt, XML_NS_ERR_EMPTY, - "Empty namespace name for prefix %s\n", name, NULL); - } - if ((ctxt->pedantic != 0) && (val[0] != 0)) { - xmlURIPtr uri; - - uri = xmlParseURI((const char *)val); - if (uri == NULL) { - xmlNsWarnMsg(ctxt, XML_WAR_NS_URI, - "xmlns:%s: %s not a valid URI\n", name, value); - } else { - if (uri->scheme == NULL) { - xmlNsWarnMsg(ctxt, XML_WAR_NS_URI_RELATIVE, - "xmlns:%s: URI %s is not absolute\n", name, value); - } - xmlFreeURI(uri); - } - } - - /* a standard namespace definition */ - nsret = xmlNewNs(ctxt->node, val, name); - xmlFree(ns); -#ifdef LIBXML_VALID_ENABLED - /* - * Validate also for namespace decls, they are attributes from - * an XML-1.0 perspective - */ - if (nsret != NULL && ctxt->validate && ctxt->wellFormed && - ctxt->myDoc && ctxt->myDoc->intSubset) - ctxt->valid &= xmlValidateOneNamespace(&ctxt->vctxt, ctxt->myDoc, - ctxt->node, prefix, nsret, value); -#endif /* LIBXML_VALID_ENABLED */ - if (name != NULL) - xmlFree(name); - if (nval != NULL) - xmlFree(nval); - if (val != value) - xmlFree(val); - return; - } - - if (ns != NULL) { - namespace = xmlSearchNs(ctxt->myDoc, ctxt->node, ns); - - if (namespace == NULL) { - xmlNsErrMsg(ctxt, XML_NS_ERR_UNDEFINED_NAMESPACE, - "Namespace prefix %s of attribute %s is not defined\n", - ns, name); - } else { - xmlAttrPtr prop; - - prop = ctxt->node->properties; - while (prop != NULL) { - if (prop->ns != NULL) { - if ((xmlStrEqual(name, prop->name)) && - ((namespace == prop->ns) || - (xmlStrEqual(namespace->href, prop->ns->href)))) { - xmlNsErrMsg(ctxt, XML_ERR_ATTRIBUTE_REDEFINED, - "Attribute %s in %s redefined\n", - name, namespace->href); - ctxt->wellFormed = 0; - if (ctxt->recovery == 0) ctxt->disableSAX = 1; - goto error; - } - } - prop = prop->next; - } - } - } else { - namespace = NULL; - } - - /* !!!!!! */ - ret = xmlNewNsPropEatName(ctxt->node, namespace, name, NULL); - - if (ret != NULL) { - if ((ctxt->replaceEntities == 0) && (!ctxt->html)) { - xmlNodePtr tmp; - - ret->children = xmlStringGetNodeList(ctxt->myDoc, value); - tmp = ret->children; - while (tmp != NULL) { - tmp->parent = (xmlNodePtr) ret; - if (tmp->next == NULL) - ret->last = tmp; - tmp = tmp->next; - } - } else if (value != NULL) { - ret->children = xmlNewDocText(ctxt->myDoc, value); - ret->last = ret->children; - if (ret->children != NULL) - ret->children->parent = (xmlNodePtr) ret; - } - } - -#ifdef LIBXML_VALID_ENABLED - if ((!ctxt->html) && ctxt->validate && ctxt->wellFormed && - ctxt->myDoc && ctxt->myDoc->intSubset) { - - /* - * If we don't substitute entities, the validation should be - * done on a value with replaced entities anyway. - */ - if (!ctxt->replaceEntities) { - xmlChar *val; - - ctxt->depth++; - val = xmlStringDecodeEntities(ctxt, value, XML_SUBSTITUTE_REF, - 0,0,0); - ctxt->depth--; - - if (val == NULL) - ctxt->valid &= xmlValidateOneAttribute(&ctxt->vctxt, - ctxt->myDoc, ctxt->node, ret, value); - else { - xmlChar *nvalnorm; - - /* - * Do the last stage of the attribute normalization - * It need to be done twice ... it's an extra burden related - * to the ability to keep xmlSAX2References in attributes - */ - nvalnorm = xmlValidNormalizeAttributeValue(ctxt->myDoc, - ctxt->node, fullname, val); - if (nvalnorm != NULL) { - xmlFree(val); - val = nvalnorm; - } - - ctxt->valid &= xmlValidateOneAttribute(&ctxt->vctxt, - ctxt->myDoc, ctxt->node, ret, val); - xmlFree(val); - } - } else { - ctxt->valid &= xmlValidateOneAttribute(&ctxt->vctxt, ctxt->myDoc, - ctxt->node, ret, value); - } - } else -#endif /* LIBXML_VALID_ENABLED */ - if (((ctxt->loadsubset & XML_SKIP_IDS) == 0) && - (((ctxt->replaceEntities == 0) && (ctxt->external != 2)) || - ((ctxt->replaceEntities != 0) && (ctxt->inSubset == 0)))) { - /* - * when validating, the ID registration is done at the attribute - * validation level. Otherwise we have to do specific handling here. - */ - if (xmlStrEqual(fullname, BAD_CAST "xml:id")) { - /* - * Add the xml:id value - * - * Open issue: normalization of the value. - */ - if (xmlValidateNCName(value, 1) != 0) { - xmlErrValid(ctxt, XML_DTD_XMLID_VALUE, - "xml:id : attribute value %s is not an NCName\n", - (const char *) value, NULL); - } - xmlAddID(&ctxt->vctxt, ctxt->myDoc, value, ret); - } else if (xmlIsID(ctxt->myDoc, ctxt->node, ret)) - xmlAddID(&ctxt->vctxt, ctxt->myDoc, value, ret); - else if (xmlIsRef(ctxt->myDoc, ctxt->node, ret)) - xmlAddRef(&ctxt->vctxt, ctxt->myDoc, value, ret); - } - -error: - if (nval != NULL) - xmlFree(nval); - if (ns != NULL) - xmlFree(ns); -} - -/* - * xmlCheckDefaultedAttributes: - * - * Check defaulted attributes from the DTD - */ -static void -xmlCheckDefaultedAttributes(xmlParserCtxtPtr ctxt, const xmlChar *name, - const xmlChar *prefix, const xmlChar **atts) { - xmlElementPtr elemDecl; - const xmlChar *att; - int internal = 1; - int i; - - elemDecl = xmlGetDtdQElementDesc(ctxt->myDoc->intSubset, name, prefix); - if (elemDecl == NULL) { - elemDecl = xmlGetDtdQElementDesc(ctxt->myDoc->extSubset, name, prefix); - internal = 0; - } - -process_external_subset: - - if (elemDecl != NULL) { - xmlAttributePtr attr = elemDecl->attributes; - /* - * Check against defaulted attributes from the external subset - * if the document is stamped as standalone - */ - if ((ctxt->myDoc->standalone == 1) && - (ctxt->myDoc->extSubset != NULL) && - (ctxt->validate)) { - while (attr != NULL) { - if ((attr->defaultValue != NULL) && - (xmlGetDtdQAttrDesc(ctxt->myDoc->extSubset, - attr->elem, attr->name, - attr->prefix) == attr) && - (xmlGetDtdQAttrDesc(ctxt->myDoc->intSubset, - attr->elem, attr->name, - attr->prefix) == NULL)) { - xmlChar *fulln; - - if (attr->prefix != NULL) { - fulln = xmlStrdup(attr->prefix); - fulln = xmlStrcat(fulln, BAD_CAST ":"); - fulln = xmlStrcat(fulln, attr->name); - } else { - fulln = xmlStrdup(attr->name); - } - if (fulln == NULL) { - xmlSAX2ErrMemory(ctxt, "xmlSAX2StartElement"); - break; - } - - /* - * Check that the attribute is not declared in the - * serialization - */ - att = NULL; - if (atts != NULL) { - i = 0; - att = atts[i]; - while (att != NULL) { - if (xmlStrEqual(att, fulln)) - break; - i += 2; - att = atts[i]; - } - } - if (att == NULL) { - xmlErrValid(ctxt, XML_DTD_STANDALONE_DEFAULTED, - "standalone: attribute %s on %s defaulted from external subset\n", - (const char *)fulln, - (const char *)attr->elem); - } - xmlFree(fulln); - } - attr = attr->nexth; - } - } - - /* - * Actually insert defaulted values when needed - */ - attr = elemDecl->attributes; - while (attr != NULL) { - /* - * Make sure that attributes redefinition occuring in the - * internal subset are not overriden by definitions in the - * external subset. - */ - if (attr->defaultValue != NULL) { - /* - * the element should be instantiated in the tree if: - * - this is a namespace prefix - * - the user required for completion in the tree - * like XSLT - * - there isn't already an attribute definition - * in the internal subset overriding it. - */ - if (((attr->prefix != NULL) && - (xmlStrEqual(attr->prefix, BAD_CAST "xmlns"))) || - ((attr->prefix == NULL) && - (xmlStrEqual(attr->name, BAD_CAST "xmlns"))) || - (ctxt->loadsubset & XML_COMPLETE_ATTRS)) { - xmlAttributePtr tst; - - tst = xmlGetDtdQAttrDesc(ctxt->myDoc->intSubset, - attr->elem, attr->name, - attr->prefix); - if ((tst == attr) || (tst == NULL)) { - xmlChar fn[50]; - xmlChar *fulln; - - fulln = xmlBuildQName(attr->name, attr->prefix, fn, 50); - if (fulln == NULL) { - xmlSAX2ErrMemory(ctxt, "xmlSAX2StartElement"); - return; - } - - /* - * Check that the attribute is not declared in the - * serialization - */ - att = NULL; - if (atts != NULL) { - i = 0; - att = atts[i]; - while (att != NULL) { - if (xmlStrEqual(att, fulln)) - break; - i += 2; - att = atts[i]; - } - } - if (att == NULL) { - xmlSAX2AttributeInternal(ctxt, fulln, - attr->defaultValue, prefix); - } - if ((fulln != fn) && (fulln != attr->name)) - xmlFree(fulln); - } - } - } - attr = attr->nexth; - } - if (internal == 1) { - elemDecl = xmlGetDtdQElementDesc(ctxt->myDoc->extSubset, - name, prefix); - internal = 0; - goto process_external_subset; - } - } -} - -/** - * xmlSAX2StartElement: - * @ctx: the user data (XML parser context) - * @fullname: The element name, including namespace prefix - * @atts: An array of name/value attributes pairs, NULL terminated - * - * called when an opening tag has been processed. - */ -void -xmlSAX2StartElement(void *ctx, const xmlChar *fullname, const xmlChar **atts) -{ - xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; - xmlNodePtr ret; - xmlNodePtr parent; - xmlNsPtr ns; - xmlChar *name; - xmlChar *prefix; - const xmlChar *att; - const xmlChar *value; - int i; - - if ((ctx == NULL) || (fullname == NULL) || (ctxt->myDoc == NULL)) return; - parent = ctxt->node; -#ifdef DEBUG_SAX - xmlGenericError(xmlGenericErrorContext, - "SAX.xmlSAX2StartElement(%s)\n", fullname); -#endif - - /* - * First check on validity: - */ - if (ctxt->validate && (ctxt->myDoc->extSubset == NULL) && - ((ctxt->myDoc->intSubset == NULL) || - ((ctxt->myDoc->intSubset->notations == NULL) && - (ctxt->myDoc->intSubset->elements == NULL) && - (ctxt->myDoc->intSubset->attributes == NULL) && - (ctxt->myDoc->intSubset->entities == NULL)))) { - xmlErrValid(ctxt, XML_ERR_NO_DTD, - "Validation failed: no DTD found !", NULL, NULL); - ctxt->validate = 0; - } - - - /* - * Split the full name into a namespace prefix and the tag name - */ - name = xmlSplitQName(ctxt, fullname, &prefix); - - - /* - * Note : the namespace resolution is deferred until the end of the - * attributes parsing, since local namespace can be defined as - * an attribute at this level. - */ - ret = xmlNewDocNodeEatName(ctxt->myDoc, NULL, name, NULL); - if (ret == NULL) { - if (prefix != NULL) - xmlFree(prefix); - xmlSAX2ErrMemory(ctxt, "xmlSAX2StartElement"); - return; - } - if (ctxt->myDoc->children == NULL) { -#ifdef DEBUG_SAX_TREE - xmlGenericError(xmlGenericErrorContext, "Setting %s as root\n", name); -#endif - xmlAddChild((xmlNodePtr) ctxt->myDoc, (xmlNodePtr) ret); - } else if (parent == NULL) { - parent = ctxt->myDoc->children; - } - ctxt->nodemem = -1; - if (ctxt->linenumbers) { - if (ctxt->input != NULL) { - if (ctxt->input->line < 65535) - ret->line = (short) ctxt->input->line; - else - ret->line = 65535; - } - } - - /* - * We are parsing a new node. - */ -#ifdef DEBUG_SAX_TREE - xmlGenericError(xmlGenericErrorContext, "pushing(%s)\n", name); -#endif - nodePush(ctxt, ret); - - /* - * Link the child element - */ - if (parent != NULL) { - if (parent->type == XML_ELEMENT_NODE) { -#ifdef DEBUG_SAX_TREE - xmlGenericError(xmlGenericErrorContext, - "adding child %s to %s\n", name, parent->name); -#endif - xmlAddChild(parent, ret); - } else { -#ifdef DEBUG_SAX_TREE - xmlGenericError(xmlGenericErrorContext, - "adding sibling %s to ", name); - xmlDebugDumpOneNode(stderr, parent, 0); -#endif - xmlAddSibling(parent, ret); - } - } - - /* - * Insert all the defaulted attributes from the DTD especially namespaces - */ - if ((!ctxt->html) && - ((ctxt->myDoc->intSubset != NULL) || - (ctxt->myDoc->extSubset != NULL))) { - xmlCheckDefaultedAttributes(ctxt, name, prefix, atts); - } - - /* - * process all the attributes whose name start with "xmlns" - */ - if (atts != NULL) { - i = 0; - att = atts[i++]; - value = atts[i++]; - if (!ctxt->html) { - while ((att != NULL) && (value != NULL)) { - if ((att[0] == 'x') && (att[1] == 'm') && (att[2] == 'l') && - (att[3] == 'n') && (att[4] == 's')) - xmlSAX2AttributeInternal(ctxt, att, value, prefix); - - att = atts[i++]; - value = atts[i++]; - } - } - } - - /* - * Search the namespace, note that since the attributes have been - * processed, the local namespaces are available. - */ - ns = xmlSearchNs(ctxt->myDoc, ret, prefix); - if ((ns == NULL) && (parent != NULL)) - ns = xmlSearchNs(ctxt->myDoc, parent, prefix); - if ((prefix != NULL) && (ns == NULL)) { - ns = xmlNewNs(ret, NULL, prefix); - xmlNsWarnMsg(ctxt, XML_NS_ERR_UNDEFINED_NAMESPACE, - "Namespace prefix %s is not defined\n", - prefix, NULL); - } - - /* - * set the namespace node, making sure that if the default namspace - * is unbound on a parent we simply kee it NULL - */ - if ((ns != NULL) && (ns->href != NULL) && - ((ns->href[0] != 0) || (ns->prefix != NULL))) - xmlSetNs(ret, ns); - - /* - * process all the other attributes - */ - if (atts != NULL) { - i = 0; - att = atts[i++]; - value = atts[i++]; - if (ctxt->html) { - while (att != NULL) { - xmlSAX2AttributeInternal(ctxt, att, value, NULL); - att = atts[i++]; - value = atts[i++]; - } - } else { - while ((att != NULL) && (value != NULL)) { - if ((att[0] != 'x') || (att[1] != 'm') || (att[2] != 'l') || - (att[3] != 'n') || (att[4] != 's')) - xmlSAX2AttributeInternal(ctxt, att, value, NULL); - - /* - * Next ones - */ - att = atts[i++]; - value = atts[i++]; - } - } - } - -#ifdef LIBXML_VALID_ENABLED - /* - * If it's the Document root, finish the DTD validation and - * check the document root element for validity - */ - if ((ctxt->validate) && (ctxt->vctxt.finishDtd == XML_CTXT_FINISH_DTD_0)) { - int chk; - - chk = xmlValidateDtdFinal(&ctxt->vctxt, ctxt->myDoc); - if (chk <= 0) - ctxt->valid = 0; - if (chk < 0) - ctxt->wellFormed = 0; - ctxt->valid &= xmlValidateRoot(&ctxt->vctxt, ctxt->myDoc); - ctxt->vctxt.finishDtd = XML_CTXT_FINISH_DTD_1; - } -#endif /* LIBXML_VALID_ENABLED */ - - if (prefix != NULL) - xmlFree(prefix); - -} - -/** - * xmlSAX2EndElement: - * @ctx: the user data (XML parser context) - * @name: The element name - * - * called when the end of an element has been detected. - */ -void -xmlSAX2EndElement(void *ctx, const xmlChar *name ATTRIBUTE_UNUSED) -{ - xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; - xmlParserNodeInfo node_info; - xmlNodePtr cur; - - if (ctx == NULL) return; - cur = ctxt->node; -#ifdef DEBUG_SAX - if (name == NULL) - xmlGenericError(xmlGenericErrorContext, "SAX.xmlSAX2EndElement(NULL)\n"); - else - xmlGenericError(xmlGenericErrorContext, "SAX.xmlSAX2EndElement(%s)\n", name); -#endif - - /* Capture end position and add node */ - if (cur != NULL && ctxt->record_info) { - node_info.end_pos = ctxt->input->cur - ctxt->input->base; - node_info.end_line = ctxt->input->line; - node_info.node = cur; - xmlParserAddNodeInfo(ctxt, &node_info); - } - ctxt->nodemem = -1; - -#ifdef LIBXML_VALID_ENABLED - if (ctxt->validate && ctxt->wellFormed && - ctxt->myDoc && ctxt->myDoc->intSubset) - ctxt->valid &= xmlValidateOneElement(&ctxt->vctxt, ctxt->myDoc, - cur); -#endif /* LIBXML_VALID_ENABLED */ - - - /* - * end of parsing of this node. - */ -#ifdef DEBUG_SAX_TREE - xmlGenericError(xmlGenericErrorContext, "popping(%s)\n", cur->name); -#endif - nodePop(ctxt); -} -#endif /* LIBXML_HTML_ENABLE */ - /* * xmlSAX2TextNode: * @ctxt: the parser context diff --git a/android/native/libxml2/elfgcchack.h b/android/native/libxml2/elfgcchack.h index f372e62626..d422398a1b 100644 --- a/android/native/libxml2/elfgcchack.h +++ b/android/native/libxml2/elfgcchack.h @@ -1757,7 +1757,7 @@ extern __typeof (xmlDocGetRootElement) xmlDocGetRootElement__internal_alias __at #endif #endif -#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_WRITER_ENABLED) +#if defined(LIBXML_TREE_ENABLED) #ifdef bottom_tree #undef xmlDocSetRootElement extern __typeof (xmlDocSetRootElement) xmlDocSetRootElement __attribute((alias("xmlDocSetRootElement__internal_alias"))); @@ -2441,18 +2441,6 @@ extern __typeof (xmlFreeTextReader) xmlFreeTextReader__internal_alias __attribut #endif #endif -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlwriter -#undef xmlFreeTextWriter -extern __typeof (xmlFreeTextWriter) xmlFreeTextWriter __attribute((alias("xmlFreeTextWriter__internal_alias"))); -#else -#ifndef xmlFreeTextWriter -extern __typeof (xmlFreeTextWriter) xmlFreeTextWriter__internal_alias __attribute((visibility("hidden"))); -#define xmlFreeTextWriter xmlFreeTextWriter__internal_alias -#endif -#endif -#endif - #ifdef bottom_uri #undef xmlFreeURI extern __typeof (xmlFreeURI) xmlFreeURI __attribute((alias("xmlFreeURI__internal_alias"))); @@ -4268,78 +4256,6 @@ extern __typeof (xmlNewTextReaderFilename) xmlNewTextReaderFilename__internal_al #endif #endif -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlwriter -#undef xmlNewTextWriter -extern __typeof (xmlNewTextWriter) xmlNewTextWriter __attribute((alias("xmlNewTextWriter__internal_alias"))); -#else -#ifndef xmlNewTextWriter -extern __typeof (xmlNewTextWriter) xmlNewTextWriter__internal_alias __attribute((visibility("hidden"))); -#define xmlNewTextWriter xmlNewTextWriter__internal_alias -#endif -#endif -#endif - -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlwriter -#undef xmlNewTextWriterDoc -extern __typeof (xmlNewTextWriterDoc) xmlNewTextWriterDoc __attribute((alias("xmlNewTextWriterDoc__internal_alias"))); -#else -#ifndef xmlNewTextWriterDoc -extern __typeof (xmlNewTextWriterDoc) xmlNewTextWriterDoc__internal_alias __attribute((visibility("hidden"))); -#define xmlNewTextWriterDoc xmlNewTextWriterDoc__internal_alias -#endif -#endif -#endif - -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlwriter -#undef xmlNewTextWriterFilename -extern __typeof (xmlNewTextWriterFilename) xmlNewTextWriterFilename __attribute((alias("xmlNewTextWriterFilename__internal_alias"))); -#else -#ifndef xmlNewTextWriterFilename -extern __typeof (xmlNewTextWriterFilename) xmlNewTextWriterFilename__internal_alias __attribute((visibility("hidden"))); -#define xmlNewTextWriterFilename xmlNewTextWriterFilename__internal_alias -#endif -#endif -#endif - -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlwriter -#undef xmlNewTextWriterMemory -extern __typeof (xmlNewTextWriterMemory) xmlNewTextWriterMemory __attribute((alias("xmlNewTextWriterMemory__internal_alias"))); -#else -#ifndef xmlNewTextWriterMemory -extern __typeof (xmlNewTextWriterMemory) xmlNewTextWriterMemory__internal_alias __attribute((visibility("hidden"))); -#define xmlNewTextWriterMemory xmlNewTextWriterMemory__internal_alias -#endif -#endif -#endif - -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlwriter -#undef xmlNewTextWriterPushParser -extern __typeof (xmlNewTextWriterPushParser) xmlNewTextWriterPushParser __attribute((alias("xmlNewTextWriterPushParser__internal_alias"))); -#else -#ifndef xmlNewTextWriterPushParser -extern __typeof (xmlNewTextWriterPushParser) xmlNewTextWriterPushParser__internal_alias __attribute((visibility("hidden"))); -#define xmlNewTextWriterPushParser xmlNewTextWriterPushParser__internal_alias -#endif -#endif -#endif - -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlwriter -#undef xmlNewTextWriterTree -extern __typeof (xmlNewTextWriterTree) xmlNewTextWriterTree __attribute((alias("xmlNewTextWriterTree__internal_alias"))); -#else -#ifndef xmlNewTextWriterTree -extern __typeof (xmlNewTextWriterTree) xmlNewTextWriterTree__internal_alias __attribute((visibility("hidden"))); -#define xmlNewTextWriterTree xmlNewTextWriterTree__internal_alias -#endif -#endif -#endif - #if defined(LIBXML_VALID_ENABLED) #ifdef bottom_valid #undef xmlNewValidCtxt @@ -6019,7 +5935,7 @@ extern __typeof (xmlRemoveRef) xmlRemoveRef__internal_alias __attribute((visibil #endif #endif -#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_WRITER_ENABLED) +#if defined(LIBXML_TREE_ENABLED) #ifdef bottom_tree #undef xmlReplaceNode extern __typeof (xmlReplaceNode) xmlReplaceNode __attribute((alias("xmlReplaceNode__internal_alias"))); @@ -6111,18 +6027,6 @@ extern __typeof (xmlSAX2EndDocument) xmlSAX2EndDocument__internal_alias __attrib #endif #endif -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_SAX2 -#undef xmlSAX2EndElement -extern __typeof (xmlSAX2EndElement) xmlSAX2EndElement __attribute((alias("xmlSAX2EndElement__internal_alias"))); -#else -#ifndef xmlSAX2EndElement -extern __typeof (xmlSAX2EndElement) xmlSAX2EndElement__internal_alias __attribute((visibility("hidden"))); -#define xmlSAX2EndElement xmlSAX2EndElement__internal_alias -#endif -#endif -#endif - #ifdef bottom_SAX2 #undef xmlSAX2EndElementNs extern __typeof (xmlSAX2EndElementNs) xmlSAX2EndElementNs __attribute((alias("xmlSAX2EndElementNs__internal_alias"))); @@ -6333,18 +6237,6 @@ extern __typeof (xmlSAX2StartDocument) xmlSAX2StartDocument__internal_alias __at #endif #endif -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_SAX2 -#undef xmlSAX2StartElement -extern __typeof (xmlSAX2StartElement) xmlSAX2StartElement __attribute((alias("xmlSAX2StartElement__internal_alias"))); -#else -#ifndef xmlSAX2StartElement -extern __typeof (xmlSAX2StartElement) xmlSAX2StartElement__internal_alias __attribute((visibility("hidden"))); -#define xmlSAX2StartElement xmlSAX2StartElement__internal_alias -#endif -#endif -#endif - #ifdef bottom_SAX2 #undef xmlSAX2StartElementNs extern __typeof (xmlSAX2StartElementNs) xmlSAX2StartElementNs __attribute((alias("xmlSAX2StartElementNs__internal_alias"))); @@ -7722,30 +7614,6 @@ extern __typeof (xmlTextReaderReadAttributeValue) xmlTextReaderReadAttributeValu #endif #endif -#if defined(LIBXML_READER_ENABLED) && defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlreader -#undef xmlTextReaderReadInnerXml -extern __typeof (xmlTextReaderReadInnerXml) xmlTextReaderReadInnerXml __attribute((alias("xmlTextReaderReadInnerXml__internal_alias"))); -#else -#ifndef xmlTextReaderReadInnerXml -extern __typeof (xmlTextReaderReadInnerXml) xmlTextReaderReadInnerXml__internal_alias __attribute((visibility("hidden"))); -#define xmlTextReaderReadInnerXml xmlTextReaderReadInnerXml__internal_alias -#endif -#endif -#endif - -#if defined(LIBXML_READER_ENABLED) && defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlreader -#undef xmlTextReaderReadOuterXml -extern __typeof (xmlTextReaderReadOuterXml) xmlTextReaderReadOuterXml __attribute((alias("xmlTextReaderReadOuterXml__internal_alias"))); -#else -#ifndef xmlTextReaderReadOuterXml -extern __typeof (xmlTextReaderReadOuterXml) xmlTextReaderReadOuterXml__internal_alias __attribute((visibility("hidden"))); -#define xmlTextReaderReadOuterXml xmlTextReaderReadOuterXml__internal_alias -#endif -#endif -#endif - #if defined(LIBXML_READER_ENABLED) #ifdef bottom_xmlreader #undef xmlTextReaderReadState @@ -7854,870 +7722,6 @@ extern __typeof (xmlTextReaderXmlLang) xmlTextReaderXmlLang__internal_alias __at #endif #endif -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlwriter -#undef xmlTextWriterEndAttribute -extern __typeof (xmlTextWriterEndAttribute) xmlTextWriterEndAttribute __attribute((alias("xmlTextWriterEndAttribute__internal_alias"))); -#else -#ifndef xmlTextWriterEndAttribute -extern __typeof (xmlTextWriterEndAttribute) xmlTextWriterEndAttribute__internal_alias __attribute((visibility("hidden"))); -#define xmlTextWriterEndAttribute xmlTextWriterEndAttribute__internal_alias -#endif -#endif -#endif - -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlwriter -#undef xmlTextWriterEndCDATA -extern __typeof (xmlTextWriterEndCDATA) xmlTextWriterEndCDATA __attribute((alias("xmlTextWriterEndCDATA__internal_alias"))); -#else -#ifndef xmlTextWriterEndCDATA -extern __typeof (xmlTextWriterEndCDATA) xmlTextWriterEndCDATA__internal_alias __attribute((visibility("hidden"))); -#define xmlTextWriterEndCDATA xmlTextWriterEndCDATA__internal_alias -#endif -#endif -#endif - -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlwriter -#undef xmlTextWriterEndComment -extern __typeof (xmlTextWriterEndComment) xmlTextWriterEndComment __attribute((alias("xmlTextWriterEndComment__internal_alias"))); -#else -#ifndef xmlTextWriterEndComment -extern __typeof (xmlTextWriterEndComment) xmlTextWriterEndComment__internal_alias __attribute((visibility("hidden"))); -#define xmlTextWriterEndComment xmlTextWriterEndComment__internal_alias -#endif -#endif -#endif - -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlwriter -#undef xmlTextWriterEndDTD -extern __typeof (xmlTextWriterEndDTD) xmlTextWriterEndDTD __attribute((alias("xmlTextWriterEndDTD__internal_alias"))); -#else -#ifndef xmlTextWriterEndDTD -extern __typeof (xmlTextWriterEndDTD) xmlTextWriterEndDTD__internal_alias __attribute((visibility("hidden"))); -#define xmlTextWriterEndDTD xmlTextWriterEndDTD__internal_alias -#endif -#endif -#endif - -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlwriter -#undef xmlTextWriterEndDTDAttlist -extern __typeof (xmlTextWriterEndDTDAttlist) xmlTextWriterEndDTDAttlist __attribute((alias("xmlTextWriterEndDTDAttlist__internal_alias"))); -#else -#ifndef xmlTextWriterEndDTDAttlist -extern __typeof (xmlTextWriterEndDTDAttlist) xmlTextWriterEndDTDAttlist__internal_alias __attribute((visibility("hidden"))); -#define xmlTextWriterEndDTDAttlist xmlTextWriterEndDTDAttlist__internal_alias -#endif -#endif -#endif - -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlwriter -#undef xmlTextWriterEndDTDElement -extern __typeof (xmlTextWriterEndDTDElement) xmlTextWriterEndDTDElement __attribute((alias("xmlTextWriterEndDTDElement__internal_alias"))); -#else -#ifndef xmlTextWriterEndDTDElement -extern __typeof (xmlTextWriterEndDTDElement) xmlTextWriterEndDTDElement__internal_alias __attribute((visibility("hidden"))); -#define xmlTextWriterEndDTDElement xmlTextWriterEndDTDElement__internal_alias -#endif -#endif -#endif - -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlwriter -#undef xmlTextWriterEndDTDEntity -extern __typeof (xmlTextWriterEndDTDEntity) xmlTextWriterEndDTDEntity __attribute((alias("xmlTextWriterEndDTDEntity__internal_alias"))); -#else -#ifndef xmlTextWriterEndDTDEntity -extern __typeof (xmlTextWriterEndDTDEntity) xmlTextWriterEndDTDEntity__internal_alias __attribute((visibility("hidden"))); -#define xmlTextWriterEndDTDEntity xmlTextWriterEndDTDEntity__internal_alias -#endif -#endif -#endif - -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlwriter -#undef xmlTextWriterEndDocument -extern __typeof (xmlTextWriterEndDocument) xmlTextWriterEndDocument __attribute((alias("xmlTextWriterEndDocument__internal_alias"))); -#else -#ifndef xmlTextWriterEndDocument -extern __typeof (xmlTextWriterEndDocument) xmlTextWriterEndDocument__internal_alias __attribute((visibility("hidden"))); -#define xmlTextWriterEndDocument xmlTextWriterEndDocument__internal_alias -#endif -#endif -#endif - -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlwriter -#undef xmlTextWriterEndElement -extern __typeof (xmlTextWriterEndElement) xmlTextWriterEndElement __attribute((alias("xmlTextWriterEndElement__internal_alias"))); -#else -#ifndef xmlTextWriterEndElement -extern __typeof (xmlTextWriterEndElement) xmlTextWriterEndElement__internal_alias __attribute((visibility("hidden"))); -#define xmlTextWriterEndElement xmlTextWriterEndElement__internal_alias -#endif -#endif -#endif - -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlwriter -#undef xmlTextWriterEndPI -extern __typeof (xmlTextWriterEndPI) xmlTextWriterEndPI __attribute((alias("xmlTextWriterEndPI__internal_alias"))); -#else -#ifndef xmlTextWriterEndPI -extern __typeof (xmlTextWriterEndPI) xmlTextWriterEndPI__internal_alias __attribute((visibility("hidden"))); -#define xmlTextWriterEndPI xmlTextWriterEndPI__internal_alias -#endif -#endif -#endif - -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlwriter -#undef xmlTextWriterFlush -extern __typeof (xmlTextWriterFlush) xmlTextWriterFlush __attribute((alias("xmlTextWriterFlush__internal_alias"))); -#else -#ifndef xmlTextWriterFlush -extern __typeof (xmlTextWriterFlush) xmlTextWriterFlush__internal_alias __attribute((visibility("hidden"))); -#define xmlTextWriterFlush xmlTextWriterFlush__internal_alias -#endif -#endif -#endif - -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlwriter -#undef xmlTextWriterFullEndElement -extern __typeof (xmlTextWriterFullEndElement) xmlTextWriterFullEndElement __attribute((alias("xmlTextWriterFullEndElement__internal_alias"))); -#else -#ifndef xmlTextWriterFullEndElement -extern __typeof (xmlTextWriterFullEndElement) xmlTextWriterFullEndElement__internal_alias __attribute((visibility("hidden"))); -#define xmlTextWriterFullEndElement xmlTextWriterFullEndElement__internal_alias -#endif -#endif -#endif - -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlwriter -#undef xmlTextWriterSetIndent -extern __typeof (xmlTextWriterSetIndent) xmlTextWriterSetIndent __attribute((alias("xmlTextWriterSetIndent__internal_alias"))); -#else -#ifndef xmlTextWriterSetIndent -extern __typeof (xmlTextWriterSetIndent) xmlTextWriterSetIndent__internal_alias __attribute((visibility("hidden"))); -#define xmlTextWriterSetIndent xmlTextWriterSetIndent__internal_alias -#endif -#endif -#endif - -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlwriter -#undef xmlTextWriterSetIndentString -extern __typeof (xmlTextWriterSetIndentString) xmlTextWriterSetIndentString __attribute((alias("xmlTextWriterSetIndentString__internal_alias"))); -#else -#ifndef xmlTextWriterSetIndentString -extern __typeof (xmlTextWriterSetIndentString) xmlTextWriterSetIndentString__internal_alias __attribute((visibility("hidden"))); -#define xmlTextWriterSetIndentString xmlTextWriterSetIndentString__internal_alias -#endif -#endif -#endif - -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlwriter -#undef xmlTextWriterStartAttribute -extern __typeof (xmlTextWriterStartAttribute) xmlTextWriterStartAttribute __attribute((alias("xmlTextWriterStartAttribute__internal_alias"))); -#else -#ifndef xmlTextWriterStartAttribute -extern __typeof (xmlTextWriterStartAttribute) xmlTextWriterStartAttribute__internal_alias __attribute((visibility("hidden"))); -#define xmlTextWriterStartAttribute xmlTextWriterStartAttribute__internal_alias -#endif -#endif -#endif - -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlwriter -#undef xmlTextWriterStartAttributeNS -extern __typeof (xmlTextWriterStartAttributeNS) xmlTextWriterStartAttributeNS __attribute((alias("xmlTextWriterStartAttributeNS__internal_alias"))); -#else -#ifndef xmlTextWriterStartAttributeNS -extern __typeof (xmlTextWriterStartAttributeNS) xmlTextWriterStartAttributeNS__internal_alias __attribute((visibility("hidden"))); -#define xmlTextWriterStartAttributeNS xmlTextWriterStartAttributeNS__internal_alias -#endif -#endif -#endif - -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlwriter -#undef xmlTextWriterStartCDATA -extern __typeof (xmlTextWriterStartCDATA) xmlTextWriterStartCDATA __attribute((alias("xmlTextWriterStartCDATA__internal_alias"))); -#else -#ifndef xmlTextWriterStartCDATA -extern __typeof (xmlTextWriterStartCDATA) xmlTextWriterStartCDATA__internal_alias __attribute((visibility("hidden"))); -#define xmlTextWriterStartCDATA xmlTextWriterStartCDATA__internal_alias -#endif -#endif -#endif - -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlwriter -#undef xmlTextWriterStartComment -extern __typeof (xmlTextWriterStartComment) xmlTextWriterStartComment __attribute((alias("xmlTextWriterStartComment__internal_alias"))); -#else -#ifndef xmlTextWriterStartComment -extern __typeof (xmlTextWriterStartComment) xmlTextWriterStartComment__internal_alias __attribute((visibility("hidden"))); -#define xmlTextWriterStartComment xmlTextWriterStartComment__internal_alias -#endif -#endif -#endif - -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlwriter -#undef xmlTextWriterStartDTD -extern __typeof (xmlTextWriterStartDTD) xmlTextWriterStartDTD __attribute((alias("xmlTextWriterStartDTD__internal_alias"))); -#else -#ifndef xmlTextWriterStartDTD -extern __typeof (xmlTextWriterStartDTD) xmlTextWriterStartDTD__internal_alias __attribute((visibility("hidden"))); -#define xmlTextWriterStartDTD xmlTextWriterStartDTD__internal_alias -#endif -#endif -#endif - -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlwriter -#undef xmlTextWriterStartDTDAttlist -extern __typeof (xmlTextWriterStartDTDAttlist) xmlTextWriterStartDTDAttlist __attribute((alias("xmlTextWriterStartDTDAttlist__internal_alias"))); -#else -#ifndef xmlTextWriterStartDTDAttlist -extern __typeof (xmlTextWriterStartDTDAttlist) xmlTextWriterStartDTDAttlist__internal_alias __attribute((visibility("hidden"))); -#define xmlTextWriterStartDTDAttlist xmlTextWriterStartDTDAttlist__internal_alias -#endif -#endif -#endif - -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlwriter -#undef xmlTextWriterStartDTDElement -extern __typeof (xmlTextWriterStartDTDElement) xmlTextWriterStartDTDElement __attribute((alias("xmlTextWriterStartDTDElement__internal_alias"))); -#else -#ifndef xmlTextWriterStartDTDElement -extern __typeof (xmlTextWriterStartDTDElement) xmlTextWriterStartDTDElement__internal_alias __attribute((visibility("hidden"))); -#define xmlTextWriterStartDTDElement xmlTextWriterStartDTDElement__internal_alias -#endif -#endif -#endif - -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlwriter -#undef xmlTextWriterStartDTDEntity -extern __typeof (xmlTextWriterStartDTDEntity) xmlTextWriterStartDTDEntity __attribute((alias("xmlTextWriterStartDTDEntity__internal_alias"))); -#else -#ifndef xmlTextWriterStartDTDEntity -extern __typeof (xmlTextWriterStartDTDEntity) xmlTextWriterStartDTDEntity__internal_alias __attribute((visibility("hidden"))); -#define xmlTextWriterStartDTDEntity xmlTextWriterStartDTDEntity__internal_alias -#endif -#endif -#endif - -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlwriter -#undef xmlTextWriterStartDocument -extern __typeof (xmlTextWriterStartDocument) xmlTextWriterStartDocument __attribute((alias("xmlTextWriterStartDocument__internal_alias"))); -#else -#ifndef xmlTextWriterStartDocument -extern __typeof (xmlTextWriterStartDocument) xmlTextWriterStartDocument__internal_alias __attribute((visibility("hidden"))); -#define xmlTextWriterStartDocument xmlTextWriterStartDocument__internal_alias -#endif -#endif -#endif - -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlwriter -#undef xmlTextWriterStartElement -extern __typeof (xmlTextWriterStartElement) xmlTextWriterStartElement __attribute((alias("xmlTextWriterStartElement__internal_alias"))); -#else -#ifndef xmlTextWriterStartElement -extern __typeof (xmlTextWriterStartElement) xmlTextWriterStartElement__internal_alias __attribute((visibility("hidden"))); -#define xmlTextWriterStartElement xmlTextWriterStartElement__internal_alias -#endif -#endif -#endif - -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlwriter -#undef xmlTextWriterStartElementNS -extern __typeof (xmlTextWriterStartElementNS) xmlTextWriterStartElementNS __attribute((alias("xmlTextWriterStartElementNS__internal_alias"))); -#else -#ifndef xmlTextWriterStartElementNS -extern __typeof (xmlTextWriterStartElementNS) xmlTextWriterStartElementNS__internal_alias __attribute((visibility("hidden"))); -#define xmlTextWriterStartElementNS xmlTextWriterStartElementNS__internal_alias -#endif -#endif -#endif - -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlwriter -#undef xmlTextWriterStartPI -extern __typeof (xmlTextWriterStartPI) xmlTextWriterStartPI __attribute((alias("xmlTextWriterStartPI__internal_alias"))); -#else -#ifndef xmlTextWriterStartPI -extern __typeof (xmlTextWriterStartPI) xmlTextWriterStartPI__internal_alias __attribute((visibility("hidden"))); -#define xmlTextWriterStartPI xmlTextWriterStartPI__internal_alias -#endif -#endif -#endif - -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlwriter -#undef xmlTextWriterWriteAttribute -extern __typeof (xmlTextWriterWriteAttribute) xmlTextWriterWriteAttribute __attribute((alias("xmlTextWriterWriteAttribute__internal_alias"))); -#else -#ifndef xmlTextWriterWriteAttribute -extern __typeof (xmlTextWriterWriteAttribute) xmlTextWriterWriteAttribute__internal_alias __attribute((visibility("hidden"))); -#define xmlTextWriterWriteAttribute xmlTextWriterWriteAttribute__internal_alias -#endif -#endif -#endif - -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlwriter -#undef xmlTextWriterWriteAttributeNS -extern __typeof (xmlTextWriterWriteAttributeNS) xmlTextWriterWriteAttributeNS __attribute((alias("xmlTextWriterWriteAttributeNS__internal_alias"))); -#else -#ifndef xmlTextWriterWriteAttributeNS -extern __typeof (xmlTextWriterWriteAttributeNS) xmlTextWriterWriteAttributeNS__internal_alias __attribute((visibility("hidden"))); -#define xmlTextWriterWriteAttributeNS xmlTextWriterWriteAttributeNS__internal_alias -#endif -#endif -#endif - -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlwriter -#undef xmlTextWriterWriteBase64 -extern __typeof (xmlTextWriterWriteBase64) xmlTextWriterWriteBase64 __attribute((alias("xmlTextWriterWriteBase64__internal_alias"))); -#else -#ifndef xmlTextWriterWriteBase64 -extern __typeof (xmlTextWriterWriteBase64) xmlTextWriterWriteBase64__internal_alias __attribute((visibility("hidden"))); -#define xmlTextWriterWriteBase64 xmlTextWriterWriteBase64__internal_alias -#endif -#endif -#endif - -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlwriter -#undef xmlTextWriterWriteBinHex -extern __typeof (xmlTextWriterWriteBinHex) xmlTextWriterWriteBinHex __attribute((alias("xmlTextWriterWriteBinHex__internal_alias"))); -#else -#ifndef xmlTextWriterWriteBinHex -extern __typeof (xmlTextWriterWriteBinHex) xmlTextWriterWriteBinHex__internal_alias __attribute((visibility("hidden"))); -#define xmlTextWriterWriteBinHex xmlTextWriterWriteBinHex__internal_alias -#endif -#endif -#endif - -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlwriter -#undef xmlTextWriterWriteCDATA -extern __typeof (xmlTextWriterWriteCDATA) xmlTextWriterWriteCDATA __attribute((alias("xmlTextWriterWriteCDATA__internal_alias"))); -#else -#ifndef xmlTextWriterWriteCDATA -extern __typeof (xmlTextWriterWriteCDATA) xmlTextWriterWriteCDATA__internal_alias __attribute((visibility("hidden"))); -#define xmlTextWriterWriteCDATA xmlTextWriterWriteCDATA__internal_alias -#endif -#endif -#endif - -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlwriter -#undef xmlTextWriterWriteComment -extern __typeof (xmlTextWriterWriteComment) xmlTextWriterWriteComment __attribute((alias("xmlTextWriterWriteComment__internal_alias"))); -#else -#ifndef xmlTextWriterWriteComment -extern __typeof (xmlTextWriterWriteComment) xmlTextWriterWriteComment__internal_alias __attribute((visibility("hidden"))); -#define xmlTextWriterWriteComment xmlTextWriterWriteComment__internal_alias -#endif -#endif -#endif - -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlwriter -#undef xmlTextWriterWriteDTD -extern __typeof (xmlTextWriterWriteDTD) xmlTextWriterWriteDTD __attribute((alias("xmlTextWriterWriteDTD__internal_alias"))); -#else -#ifndef xmlTextWriterWriteDTD -extern __typeof (xmlTextWriterWriteDTD) xmlTextWriterWriteDTD__internal_alias __attribute((visibility("hidden"))); -#define xmlTextWriterWriteDTD xmlTextWriterWriteDTD__internal_alias -#endif -#endif -#endif - -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlwriter -#undef xmlTextWriterWriteDTDAttlist -extern __typeof (xmlTextWriterWriteDTDAttlist) xmlTextWriterWriteDTDAttlist __attribute((alias("xmlTextWriterWriteDTDAttlist__internal_alias"))); -#else -#ifndef xmlTextWriterWriteDTDAttlist -extern __typeof (xmlTextWriterWriteDTDAttlist) xmlTextWriterWriteDTDAttlist__internal_alias __attribute((visibility("hidden"))); -#define xmlTextWriterWriteDTDAttlist xmlTextWriterWriteDTDAttlist__internal_alias -#endif -#endif -#endif - -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlwriter -#undef xmlTextWriterWriteDTDElement -extern __typeof (xmlTextWriterWriteDTDElement) xmlTextWriterWriteDTDElement __attribute((alias("xmlTextWriterWriteDTDElement__internal_alias"))); -#else -#ifndef xmlTextWriterWriteDTDElement -extern __typeof (xmlTextWriterWriteDTDElement) xmlTextWriterWriteDTDElement__internal_alias __attribute((visibility("hidden"))); -#define xmlTextWriterWriteDTDElement xmlTextWriterWriteDTDElement__internal_alias -#endif -#endif -#endif - -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlwriter -#undef xmlTextWriterWriteDTDEntity -extern __typeof (xmlTextWriterWriteDTDEntity) xmlTextWriterWriteDTDEntity __attribute((alias("xmlTextWriterWriteDTDEntity__internal_alias"))); -#else -#ifndef xmlTextWriterWriteDTDEntity -extern __typeof (xmlTextWriterWriteDTDEntity) xmlTextWriterWriteDTDEntity__internal_alias __attribute((visibility("hidden"))); -#define xmlTextWriterWriteDTDEntity xmlTextWriterWriteDTDEntity__internal_alias -#endif -#endif -#endif - -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlwriter -#undef xmlTextWriterWriteDTDExternalEntity -extern __typeof (xmlTextWriterWriteDTDExternalEntity) xmlTextWriterWriteDTDExternalEntity __attribute((alias("xmlTextWriterWriteDTDExternalEntity__internal_alias"))); -#else -#ifndef xmlTextWriterWriteDTDExternalEntity -extern __typeof (xmlTextWriterWriteDTDExternalEntity) xmlTextWriterWriteDTDExternalEntity__internal_alias __attribute((visibility("hidden"))); -#define xmlTextWriterWriteDTDExternalEntity xmlTextWriterWriteDTDExternalEntity__internal_alias -#endif -#endif -#endif - -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlwriter -#undef xmlTextWriterWriteDTDExternalEntityContents -extern __typeof (xmlTextWriterWriteDTDExternalEntityContents) xmlTextWriterWriteDTDExternalEntityContents __attribute((alias("xmlTextWriterWriteDTDExternalEntityContents__internal_alias"))); -#else -#ifndef xmlTextWriterWriteDTDExternalEntityContents -extern __typeof (xmlTextWriterWriteDTDExternalEntityContents) xmlTextWriterWriteDTDExternalEntityContents__internal_alias __attribute((visibility("hidden"))); -#define xmlTextWriterWriteDTDExternalEntityContents xmlTextWriterWriteDTDExternalEntityContents__internal_alias -#endif -#endif -#endif - -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlwriter -#undef xmlTextWriterWriteDTDInternalEntity -extern __typeof (xmlTextWriterWriteDTDInternalEntity) xmlTextWriterWriteDTDInternalEntity __attribute((alias("xmlTextWriterWriteDTDInternalEntity__internal_alias"))); -#else -#ifndef xmlTextWriterWriteDTDInternalEntity -extern __typeof (xmlTextWriterWriteDTDInternalEntity) xmlTextWriterWriteDTDInternalEntity__internal_alias __attribute((visibility("hidden"))); -#define xmlTextWriterWriteDTDInternalEntity xmlTextWriterWriteDTDInternalEntity__internal_alias -#endif -#endif -#endif - -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlwriter -#undef xmlTextWriterWriteDTDNotation -extern __typeof (xmlTextWriterWriteDTDNotation) xmlTextWriterWriteDTDNotation __attribute((alias("xmlTextWriterWriteDTDNotation__internal_alias"))); -#else -#ifndef xmlTextWriterWriteDTDNotation -extern __typeof (xmlTextWriterWriteDTDNotation) xmlTextWriterWriteDTDNotation__internal_alias __attribute((visibility("hidden"))); -#define xmlTextWriterWriteDTDNotation xmlTextWriterWriteDTDNotation__internal_alias -#endif -#endif -#endif - -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlwriter -#undef xmlTextWriterWriteElement -extern __typeof (xmlTextWriterWriteElement) xmlTextWriterWriteElement __attribute((alias("xmlTextWriterWriteElement__internal_alias"))); -#else -#ifndef xmlTextWriterWriteElement -extern __typeof (xmlTextWriterWriteElement) xmlTextWriterWriteElement__internal_alias __attribute((visibility("hidden"))); -#define xmlTextWriterWriteElement xmlTextWriterWriteElement__internal_alias -#endif -#endif -#endif - -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlwriter -#undef xmlTextWriterWriteElementNS -extern __typeof (xmlTextWriterWriteElementNS) xmlTextWriterWriteElementNS __attribute((alias("xmlTextWriterWriteElementNS__internal_alias"))); -#else -#ifndef xmlTextWriterWriteElementNS -extern __typeof (xmlTextWriterWriteElementNS) xmlTextWriterWriteElementNS__internal_alias __attribute((visibility("hidden"))); -#define xmlTextWriterWriteElementNS xmlTextWriterWriteElementNS__internal_alias -#endif -#endif -#endif - -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlwriter -#undef xmlTextWriterWriteFormatAttribute -extern __typeof (xmlTextWriterWriteFormatAttribute) xmlTextWriterWriteFormatAttribute __attribute((alias("xmlTextWriterWriteFormatAttribute__internal_alias"))); -#else -#ifndef xmlTextWriterWriteFormatAttribute -extern __typeof (xmlTextWriterWriteFormatAttribute) xmlTextWriterWriteFormatAttribute__internal_alias __attribute((visibility("hidden"))); -#define xmlTextWriterWriteFormatAttribute xmlTextWriterWriteFormatAttribute__internal_alias -#endif -#endif -#endif - -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlwriter -#undef xmlTextWriterWriteFormatAttributeNS -extern __typeof (xmlTextWriterWriteFormatAttributeNS) xmlTextWriterWriteFormatAttributeNS __attribute((alias("xmlTextWriterWriteFormatAttributeNS__internal_alias"))); -#else -#ifndef xmlTextWriterWriteFormatAttributeNS -extern __typeof (xmlTextWriterWriteFormatAttributeNS) xmlTextWriterWriteFormatAttributeNS__internal_alias __attribute((visibility("hidden"))); -#define xmlTextWriterWriteFormatAttributeNS xmlTextWriterWriteFormatAttributeNS__internal_alias -#endif -#endif -#endif - -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlwriter -#undef xmlTextWriterWriteFormatCDATA -extern __typeof (xmlTextWriterWriteFormatCDATA) xmlTextWriterWriteFormatCDATA __attribute((alias("xmlTextWriterWriteFormatCDATA__internal_alias"))); -#else -#ifndef xmlTextWriterWriteFormatCDATA -extern __typeof (xmlTextWriterWriteFormatCDATA) xmlTextWriterWriteFormatCDATA__internal_alias __attribute((visibility("hidden"))); -#define xmlTextWriterWriteFormatCDATA xmlTextWriterWriteFormatCDATA__internal_alias -#endif -#endif -#endif - -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlwriter -#undef xmlTextWriterWriteFormatComment -extern __typeof (xmlTextWriterWriteFormatComment) xmlTextWriterWriteFormatComment __attribute((alias("xmlTextWriterWriteFormatComment__internal_alias"))); -#else -#ifndef xmlTextWriterWriteFormatComment -extern __typeof (xmlTextWriterWriteFormatComment) xmlTextWriterWriteFormatComment__internal_alias __attribute((visibility("hidden"))); -#define xmlTextWriterWriteFormatComment xmlTextWriterWriteFormatComment__internal_alias -#endif -#endif -#endif - -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlwriter -#undef xmlTextWriterWriteFormatDTD -extern __typeof (xmlTextWriterWriteFormatDTD) xmlTextWriterWriteFormatDTD __attribute((alias("xmlTextWriterWriteFormatDTD__internal_alias"))); -#else -#ifndef xmlTextWriterWriteFormatDTD -extern __typeof (xmlTextWriterWriteFormatDTD) xmlTextWriterWriteFormatDTD__internal_alias __attribute((visibility("hidden"))); -#define xmlTextWriterWriteFormatDTD xmlTextWriterWriteFormatDTD__internal_alias -#endif -#endif -#endif - -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlwriter -#undef xmlTextWriterWriteFormatDTDAttlist -extern __typeof (xmlTextWriterWriteFormatDTDAttlist) xmlTextWriterWriteFormatDTDAttlist __attribute((alias("xmlTextWriterWriteFormatDTDAttlist__internal_alias"))); -#else -#ifndef xmlTextWriterWriteFormatDTDAttlist -extern __typeof (xmlTextWriterWriteFormatDTDAttlist) xmlTextWriterWriteFormatDTDAttlist__internal_alias __attribute((visibility("hidden"))); -#define xmlTextWriterWriteFormatDTDAttlist xmlTextWriterWriteFormatDTDAttlist__internal_alias -#endif -#endif -#endif - -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlwriter -#undef xmlTextWriterWriteFormatDTDElement -extern __typeof (xmlTextWriterWriteFormatDTDElement) xmlTextWriterWriteFormatDTDElement __attribute((alias("xmlTextWriterWriteFormatDTDElement__internal_alias"))); -#else -#ifndef xmlTextWriterWriteFormatDTDElement -extern __typeof (xmlTextWriterWriteFormatDTDElement) xmlTextWriterWriteFormatDTDElement__internal_alias __attribute((visibility("hidden"))); -#define xmlTextWriterWriteFormatDTDElement xmlTextWriterWriteFormatDTDElement__internal_alias -#endif -#endif -#endif - -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlwriter -#undef xmlTextWriterWriteFormatDTDInternalEntity -extern __typeof (xmlTextWriterWriteFormatDTDInternalEntity) xmlTextWriterWriteFormatDTDInternalEntity __attribute((alias("xmlTextWriterWriteFormatDTDInternalEntity__internal_alias"))); -#else -#ifndef xmlTextWriterWriteFormatDTDInternalEntity -extern __typeof (xmlTextWriterWriteFormatDTDInternalEntity) xmlTextWriterWriteFormatDTDInternalEntity__internal_alias __attribute((visibility("hidden"))); -#define xmlTextWriterWriteFormatDTDInternalEntity xmlTextWriterWriteFormatDTDInternalEntity__internal_alias -#endif -#endif -#endif - -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlwriter -#undef xmlTextWriterWriteFormatElement -extern __typeof (xmlTextWriterWriteFormatElement) xmlTextWriterWriteFormatElement __attribute((alias("xmlTextWriterWriteFormatElement__internal_alias"))); -#else -#ifndef xmlTextWriterWriteFormatElement -extern __typeof (xmlTextWriterWriteFormatElement) xmlTextWriterWriteFormatElement__internal_alias __attribute((visibility("hidden"))); -#define xmlTextWriterWriteFormatElement xmlTextWriterWriteFormatElement__internal_alias -#endif -#endif -#endif - -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlwriter -#undef xmlTextWriterWriteFormatElementNS -extern __typeof (xmlTextWriterWriteFormatElementNS) xmlTextWriterWriteFormatElementNS __attribute((alias("xmlTextWriterWriteFormatElementNS__internal_alias"))); -#else -#ifndef xmlTextWriterWriteFormatElementNS -extern __typeof (xmlTextWriterWriteFormatElementNS) xmlTextWriterWriteFormatElementNS__internal_alias __attribute((visibility("hidden"))); -#define xmlTextWriterWriteFormatElementNS xmlTextWriterWriteFormatElementNS__internal_alias -#endif -#endif -#endif - -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlwriter -#undef xmlTextWriterWriteFormatPI -extern __typeof (xmlTextWriterWriteFormatPI) xmlTextWriterWriteFormatPI __attribute((alias("xmlTextWriterWriteFormatPI__internal_alias"))); -#else -#ifndef xmlTextWriterWriteFormatPI -extern __typeof (xmlTextWriterWriteFormatPI) xmlTextWriterWriteFormatPI__internal_alias __attribute((visibility("hidden"))); -#define xmlTextWriterWriteFormatPI xmlTextWriterWriteFormatPI__internal_alias -#endif -#endif -#endif - -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlwriter -#undef xmlTextWriterWriteFormatRaw -extern __typeof (xmlTextWriterWriteFormatRaw) xmlTextWriterWriteFormatRaw __attribute((alias("xmlTextWriterWriteFormatRaw__internal_alias"))); -#else -#ifndef xmlTextWriterWriteFormatRaw -extern __typeof (xmlTextWriterWriteFormatRaw) xmlTextWriterWriteFormatRaw__internal_alias __attribute((visibility("hidden"))); -#define xmlTextWriterWriteFormatRaw xmlTextWriterWriteFormatRaw__internal_alias -#endif -#endif -#endif - -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlwriter -#undef xmlTextWriterWriteFormatString -extern __typeof (xmlTextWriterWriteFormatString) xmlTextWriterWriteFormatString __attribute((alias("xmlTextWriterWriteFormatString__internal_alias"))); -#else -#ifndef xmlTextWriterWriteFormatString -extern __typeof (xmlTextWriterWriteFormatString) xmlTextWriterWriteFormatString__internal_alias __attribute((visibility("hidden"))); -#define xmlTextWriterWriteFormatString xmlTextWriterWriteFormatString__internal_alias -#endif -#endif -#endif - -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlwriter -#undef xmlTextWriterWritePI -extern __typeof (xmlTextWriterWritePI) xmlTextWriterWritePI __attribute((alias("xmlTextWriterWritePI__internal_alias"))); -#else -#ifndef xmlTextWriterWritePI -extern __typeof (xmlTextWriterWritePI) xmlTextWriterWritePI__internal_alias __attribute((visibility("hidden"))); -#define xmlTextWriterWritePI xmlTextWriterWritePI__internal_alias -#endif -#endif -#endif - -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlwriter -#undef xmlTextWriterWriteRaw -extern __typeof (xmlTextWriterWriteRaw) xmlTextWriterWriteRaw __attribute((alias("xmlTextWriterWriteRaw__internal_alias"))); -#else -#ifndef xmlTextWriterWriteRaw -extern __typeof (xmlTextWriterWriteRaw) xmlTextWriterWriteRaw__internal_alias __attribute((visibility("hidden"))); -#define xmlTextWriterWriteRaw xmlTextWriterWriteRaw__internal_alias -#endif -#endif -#endif - -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlwriter -#undef xmlTextWriterWriteRawLen -extern __typeof (xmlTextWriterWriteRawLen) xmlTextWriterWriteRawLen __attribute((alias("xmlTextWriterWriteRawLen__internal_alias"))); -#else -#ifndef xmlTextWriterWriteRawLen -extern __typeof (xmlTextWriterWriteRawLen) xmlTextWriterWriteRawLen__internal_alias __attribute((visibility("hidden"))); -#define xmlTextWriterWriteRawLen xmlTextWriterWriteRawLen__internal_alias -#endif -#endif -#endif - -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlwriter -#undef xmlTextWriterWriteString -extern __typeof (xmlTextWriterWriteString) xmlTextWriterWriteString __attribute((alias("xmlTextWriterWriteString__internal_alias"))); -#else -#ifndef xmlTextWriterWriteString -extern __typeof (xmlTextWriterWriteString) xmlTextWriterWriteString__internal_alias __attribute((visibility("hidden"))); -#define xmlTextWriterWriteString xmlTextWriterWriteString__internal_alias -#endif -#endif -#endif - -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlwriter -#undef xmlTextWriterWriteVFormatAttribute -extern __typeof (xmlTextWriterWriteVFormatAttribute) xmlTextWriterWriteVFormatAttribute __attribute((alias("xmlTextWriterWriteVFormatAttribute__internal_alias"))); -#else -#ifndef xmlTextWriterWriteVFormatAttribute -extern __typeof (xmlTextWriterWriteVFormatAttribute) xmlTextWriterWriteVFormatAttribute__internal_alias __attribute((visibility("hidden"))); -#define xmlTextWriterWriteVFormatAttribute xmlTextWriterWriteVFormatAttribute__internal_alias -#endif -#endif -#endif - -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlwriter -#undef xmlTextWriterWriteVFormatAttributeNS -extern __typeof (xmlTextWriterWriteVFormatAttributeNS) xmlTextWriterWriteVFormatAttributeNS __attribute((alias("xmlTextWriterWriteVFormatAttributeNS__internal_alias"))); -#else -#ifndef xmlTextWriterWriteVFormatAttributeNS -extern __typeof (xmlTextWriterWriteVFormatAttributeNS) xmlTextWriterWriteVFormatAttributeNS__internal_alias __attribute((visibility("hidden"))); -#define xmlTextWriterWriteVFormatAttributeNS xmlTextWriterWriteVFormatAttributeNS__internal_alias -#endif -#endif -#endif - -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlwriter -#undef xmlTextWriterWriteVFormatCDATA -extern __typeof (xmlTextWriterWriteVFormatCDATA) xmlTextWriterWriteVFormatCDATA __attribute((alias("xmlTextWriterWriteVFormatCDATA__internal_alias"))); -#else -#ifndef xmlTextWriterWriteVFormatCDATA -extern __typeof (xmlTextWriterWriteVFormatCDATA) xmlTextWriterWriteVFormatCDATA__internal_alias __attribute((visibility("hidden"))); -#define xmlTextWriterWriteVFormatCDATA xmlTextWriterWriteVFormatCDATA__internal_alias -#endif -#endif -#endif - -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlwriter -#undef xmlTextWriterWriteVFormatComment -extern __typeof (xmlTextWriterWriteVFormatComment) xmlTextWriterWriteVFormatComment __attribute((alias("xmlTextWriterWriteVFormatComment__internal_alias"))); -#else -#ifndef xmlTextWriterWriteVFormatComment -extern __typeof (xmlTextWriterWriteVFormatComment) xmlTextWriterWriteVFormatComment__internal_alias __attribute((visibility("hidden"))); -#define xmlTextWriterWriteVFormatComment xmlTextWriterWriteVFormatComment__internal_alias -#endif -#endif -#endif - -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlwriter -#undef xmlTextWriterWriteVFormatDTD -extern __typeof (xmlTextWriterWriteVFormatDTD) xmlTextWriterWriteVFormatDTD __attribute((alias("xmlTextWriterWriteVFormatDTD__internal_alias"))); -#else -#ifndef xmlTextWriterWriteVFormatDTD -extern __typeof (xmlTextWriterWriteVFormatDTD) xmlTextWriterWriteVFormatDTD__internal_alias __attribute((visibility("hidden"))); -#define xmlTextWriterWriteVFormatDTD xmlTextWriterWriteVFormatDTD__internal_alias -#endif -#endif -#endif - -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlwriter -#undef xmlTextWriterWriteVFormatDTDAttlist -extern __typeof (xmlTextWriterWriteVFormatDTDAttlist) xmlTextWriterWriteVFormatDTDAttlist __attribute((alias("xmlTextWriterWriteVFormatDTDAttlist__internal_alias"))); -#else -#ifndef xmlTextWriterWriteVFormatDTDAttlist -extern __typeof (xmlTextWriterWriteVFormatDTDAttlist) xmlTextWriterWriteVFormatDTDAttlist__internal_alias __attribute((visibility("hidden"))); -#define xmlTextWriterWriteVFormatDTDAttlist xmlTextWriterWriteVFormatDTDAttlist__internal_alias -#endif -#endif -#endif - -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlwriter -#undef xmlTextWriterWriteVFormatDTDElement -extern __typeof (xmlTextWriterWriteVFormatDTDElement) xmlTextWriterWriteVFormatDTDElement __attribute((alias("xmlTextWriterWriteVFormatDTDElement__internal_alias"))); -#else -#ifndef xmlTextWriterWriteVFormatDTDElement -extern __typeof (xmlTextWriterWriteVFormatDTDElement) xmlTextWriterWriteVFormatDTDElement__internal_alias __attribute((visibility("hidden"))); -#define xmlTextWriterWriteVFormatDTDElement xmlTextWriterWriteVFormatDTDElement__internal_alias -#endif -#endif -#endif - -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlwriter -#undef xmlTextWriterWriteVFormatDTDInternalEntity -extern __typeof (xmlTextWriterWriteVFormatDTDInternalEntity) xmlTextWriterWriteVFormatDTDInternalEntity __attribute((alias("xmlTextWriterWriteVFormatDTDInternalEntity__internal_alias"))); -#else -#ifndef xmlTextWriterWriteVFormatDTDInternalEntity -extern __typeof (xmlTextWriterWriteVFormatDTDInternalEntity) xmlTextWriterWriteVFormatDTDInternalEntity__internal_alias __attribute((visibility("hidden"))); -#define xmlTextWriterWriteVFormatDTDInternalEntity xmlTextWriterWriteVFormatDTDInternalEntity__internal_alias -#endif -#endif -#endif - -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlwriter -#undef xmlTextWriterWriteVFormatElement -extern __typeof (xmlTextWriterWriteVFormatElement) xmlTextWriterWriteVFormatElement __attribute((alias("xmlTextWriterWriteVFormatElement__internal_alias"))); -#else -#ifndef xmlTextWriterWriteVFormatElement -extern __typeof (xmlTextWriterWriteVFormatElement) xmlTextWriterWriteVFormatElement__internal_alias __attribute((visibility("hidden"))); -#define xmlTextWriterWriteVFormatElement xmlTextWriterWriteVFormatElement__internal_alias -#endif -#endif -#endif - -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlwriter -#undef xmlTextWriterWriteVFormatElementNS -extern __typeof (xmlTextWriterWriteVFormatElementNS) xmlTextWriterWriteVFormatElementNS __attribute((alias("xmlTextWriterWriteVFormatElementNS__internal_alias"))); -#else -#ifndef xmlTextWriterWriteVFormatElementNS -extern __typeof (xmlTextWriterWriteVFormatElementNS) xmlTextWriterWriteVFormatElementNS__internal_alias __attribute((visibility("hidden"))); -#define xmlTextWriterWriteVFormatElementNS xmlTextWriterWriteVFormatElementNS__internal_alias -#endif -#endif -#endif - -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlwriter -#undef xmlTextWriterWriteVFormatPI -extern __typeof (xmlTextWriterWriteVFormatPI) xmlTextWriterWriteVFormatPI __attribute((alias("xmlTextWriterWriteVFormatPI__internal_alias"))); -#else -#ifndef xmlTextWriterWriteVFormatPI -extern __typeof (xmlTextWriterWriteVFormatPI) xmlTextWriterWriteVFormatPI__internal_alias __attribute((visibility("hidden"))); -#define xmlTextWriterWriteVFormatPI xmlTextWriterWriteVFormatPI__internal_alias -#endif -#endif -#endif - -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlwriter -#undef xmlTextWriterWriteVFormatRaw -extern __typeof (xmlTextWriterWriteVFormatRaw) xmlTextWriterWriteVFormatRaw __attribute((alias("xmlTextWriterWriteVFormatRaw__internal_alias"))); -#else -#ifndef xmlTextWriterWriteVFormatRaw -extern __typeof (xmlTextWriterWriteVFormatRaw) xmlTextWriterWriteVFormatRaw__internal_alias __attribute((visibility("hidden"))); -#define xmlTextWriterWriteVFormatRaw xmlTextWriterWriteVFormatRaw__internal_alias -#endif -#endif -#endif - -#if defined(LIBXML_WRITER_ENABLED) -#ifdef bottom_xmlwriter -#undef xmlTextWriterWriteVFormatString -extern __typeof (xmlTextWriterWriteVFormatString) xmlTextWriterWriteVFormatString __attribute((alias("xmlTextWriterWriteVFormatString__internal_alias"))); -#else -#ifndef xmlTextWriterWriteVFormatString -extern __typeof (xmlTextWriterWriteVFormatString) xmlTextWriterWriteVFormatString__internal_alias __attribute((visibility("hidden"))); -#define xmlTextWriterWriteVFormatString xmlTextWriterWriteVFormatString__internal_alias -#endif -#endif -#endif - #ifdef bottom_globals #undef xmlThrDefBufferAllocScheme extern __typeof (xmlThrDefBufferAllocScheme) xmlThrDefBufferAllocScheme __attribute((alias("xmlThrDefBufferAllocScheme__internal_alias"))); @@ -11210,7 +10214,7 @@ extern __typeof (xmlValidateElementDecl) xmlValidateElementDecl__internal_alias #endif #endif -#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_WRITER_ENABLED) +#if defined(LIBXML_TREE_ENABLED) #ifdef bottom_tree #undef xmlValidateNCName extern __typeof (xmlValidateNCName) xmlValidateNCName __attribute((alias("xmlValidateNCName__internal_alias"))); diff --git a/android/native/libxml2/libxml/SAX2.h b/android/native/libxml2/libxml/SAX2.h index d22fea5571..67de7d7789 100644 --- a/android/native/libxml2/libxml/SAX2.h +++ b/android/native/libxml2/libxml/SAX2.h @@ -98,15 +98,6 @@ XMLPUBFUN void XMLCALL xmlSAX2StartDocument (void *ctx); XMLPUBFUN void XMLCALL xmlSAX2EndDocument (void *ctx); -#if defined(LIBXML_WRITER_ENABLED) -XMLPUBFUN void XMLCALL - xmlSAX2StartElement (void *ctx, - const xmlChar *fullname, - const xmlChar **atts); -XMLPUBFUN void XMLCALL - xmlSAX2EndElement (void *ctx, - const xmlChar *name); -#endif /* */ XMLPUBFUN void XMLCALL xmlSAX2StartElementNs (void *ctx, const xmlChar *localname, diff --git a/android/native/libxml2/libxml/tree.h b/android/native/libxml2/libxml/tree.h index ad8f679521..f60e0285ab 100644 --- a/android/native/libxml2/libxml/tree.h +++ b/android/native/libxml2/libxml/tree.h @@ -613,7 +613,7 @@ struct _xmlDOMWrapCtxt { /* * Some helper functions */ -#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_WRITER_ENABLED) +#if defined(LIBXML_TREE_ENABLED) XMLPUBFUN int XMLCALL xmlValidateNCName (const xmlChar *value, int space); @@ -873,11 +873,11 @@ XMLPUBFUN int XMLCALL /* * Changing the structure. */ -#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_WRITER_ENABLED) +#if defined(LIBXML_TREE_ENABLED) XMLPUBFUN xmlNodePtr XMLCALL xmlDocSetRootElement (xmlDocPtr doc, xmlNodePtr root); -#endif /* defined(LIBXML_TREE_ENABLED) || defined(LIBXML_WRITER_ENABLED) */ +#endif /* defined(LIBXML_TREE_ENABLED) */ #ifdef LIBXML_TREE_ENABLED XMLPUBFUN void XMLCALL xmlNodeSetName (xmlNodePtr cur, @@ -889,11 +889,11 @@ XMLPUBFUN xmlNodePtr XMLCALL XMLPUBFUN xmlNodePtr XMLCALL xmlAddChildList (xmlNodePtr parent, xmlNodePtr cur); -#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_WRITER_ENABLED) +#if defined(LIBXML_TREE_ENABLED) XMLPUBFUN xmlNodePtr XMLCALL xmlReplaceNode (xmlNodePtr old, xmlNodePtr cur); -#endif /* defined(LIBXML_TREE_ENABLED) || defined(LIBXML_WRITER_ENABLED) */ +#endif /* defined(LIBXML_TREE_ENABLED) */ #if defined(LIBXML_TREE_ENABLED) XMLPUBFUN xmlNodePtr XMLCALL xmlAddPrevSibling (xmlNodePtr cur, diff --git a/android/native/libxml2/libxml/xmlreader.h b/android/native/libxml2/libxml/xmlreader.h index da838bf4bf..febcf4fa43 100644 --- a/android/native/libxml2/libxml/xmlreader.h +++ b/android/native/libxml2/libxml/xmlreader.h @@ -124,14 +124,6 @@ XMLPUBFUN int XMLCALL XMLPUBFUN int XMLCALL xmlTextReaderRead (xmlTextReaderPtr reader); -#ifdef LIBXML_WRITER_ENABLED -XMLPUBFUN xmlChar * XMLCALL - xmlTextReaderReadInnerXml (xmlTextReaderPtr reader); - -XMLPUBFUN xmlChar * XMLCALL - xmlTextReaderReadOuterXml (xmlTextReaderPtr reader); -#endif - XMLPUBFUN xmlChar * XMLCALL xmlTextReaderReadString (xmlTextReaderPtr reader); XMLPUBFUN int XMLCALL diff --git a/android/native/libxml2/libxml/xmlversion.h b/android/native/libxml2/libxml/xmlversion.h index 676901deb6..0aa421b1c7 100644 --- a/android/native/libxml2/libxml/xmlversion.h +++ b/android/native/libxml2/libxml/xmlversion.h @@ -133,15 +133,6 @@ XMLPUBFUN void XMLCALL xmlCheckVersion(int version); #define LIBXML_READER_ENABLED #endif -/** - * LIBXML_WRITER_ENABLED: - * - * Whether the xmlWriter saving interface is configured in - */ -#if 1 -#define LIBXML_WRITER_ENABLED -#endif - /** * LIBXML_VALID_ENABLED: * @@ -256,15 +247,6 @@ XMLPUBFUN void XMLCALL xmlCheckVersion(int version); #define LIBXML_MODULE_EXTENSION "" #endif -/** - * LIBXML_ZLIB_ENABLED: - * - * Whether the Zlib support is compiled in - */ -#if 0 -#define LIBXML_ZLIB_ENABLED -#endif - /** * LIBXML_LZMA_ENABLED: * diff --git a/android/native/libxml2/libxml/xmlwriter.h b/android/native/libxml2/libxml/xmlwriter.h index 91e683c88c..715b3d58fc 100644 --- a/android/native/libxml2/libxml/xmlwriter.h +++ b/android/native/libxml2/libxml/xmlwriter.h @@ -13,473 +13,5 @@ #include -#ifdef LIBXML_WRITER_ENABLED - -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - - typedef struct _xmlTextWriter xmlTextWriter; - typedef xmlTextWriter *xmlTextWriterPtr; - -/* - * Constructors & Destructor - */ - XMLPUBFUN xmlTextWriterPtr XMLCALL - xmlNewTextWriter(xmlOutputBufferPtr out); - XMLPUBFUN xmlTextWriterPtr XMLCALL - xmlNewTextWriterFilename(const char *uri, int compression); - XMLPUBFUN xmlTextWriterPtr XMLCALL - xmlNewTextWriterMemory(xmlBufferPtr buf, int compression); - XMLPUBFUN xmlTextWriterPtr XMLCALL - xmlNewTextWriterPushParser(xmlParserCtxtPtr ctxt, int compression); - XMLPUBFUN xmlTextWriterPtr XMLCALL - xmlNewTextWriterDoc(xmlDocPtr * doc, int compression); - XMLPUBFUN xmlTextWriterPtr XMLCALL - xmlNewTextWriterTree(xmlDocPtr doc, xmlNodePtr node, - int compression); - XMLPUBFUN void XMLCALL xmlFreeTextWriter(xmlTextWriterPtr writer); - -/* - * Functions - */ - - -/* - * Document - */ - XMLPUBFUN int XMLCALL - xmlTextWriterStartDocument(xmlTextWriterPtr writer, - const char *version, - const char *encoding, - const char *standalone); - XMLPUBFUN int XMLCALL xmlTextWriterEndDocument(xmlTextWriterPtr - writer); - -/* - * Comments - */ - XMLPUBFUN int XMLCALL xmlTextWriterStartComment(xmlTextWriterPtr - writer); - XMLPUBFUN int XMLCALL xmlTextWriterEndComment(xmlTextWriterPtr writer); - XMLPUBFUN int XMLCALL - xmlTextWriterWriteFormatComment(xmlTextWriterPtr writer, - const char *format, ...) - LIBXML_ATTR_FORMAT(2,3); - XMLPUBFUN int XMLCALL - xmlTextWriterWriteVFormatComment(xmlTextWriterPtr writer, - const char *format, - va_list argptr) - LIBXML_ATTR_FORMAT(2,0); - XMLPUBFUN int XMLCALL xmlTextWriterWriteComment(xmlTextWriterPtr - writer, - const xmlChar * - content); - -/* - * Elements - */ - XMLPUBFUN int XMLCALL - xmlTextWriterStartElement(xmlTextWriterPtr writer, - const xmlChar * name); - XMLPUBFUN int XMLCALL xmlTextWriterStartElementNS(xmlTextWriterPtr - writer, - const xmlChar * - prefix, - const xmlChar * name, - const xmlChar * - namespaceURI); - XMLPUBFUN int XMLCALL xmlTextWriterEndElement(xmlTextWriterPtr writer); - XMLPUBFUN int XMLCALL xmlTextWriterFullEndElement(xmlTextWriterPtr - writer); - -/* - * Elements conveniency functions - */ - XMLPUBFUN int XMLCALL - xmlTextWriterWriteFormatElement(xmlTextWriterPtr writer, - const xmlChar * name, - const char *format, ...) - LIBXML_ATTR_FORMAT(3,4); - XMLPUBFUN int XMLCALL - xmlTextWriterWriteVFormatElement(xmlTextWriterPtr writer, - const xmlChar * name, - const char *format, - va_list argptr) - LIBXML_ATTR_FORMAT(3,0); - XMLPUBFUN int XMLCALL xmlTextWriterWriteElement(xmlTextWriterPtr - writer, - const xmlChar * name, - const xmlChar * - content); - XMLPUBFUN int XMLCALL - xmlTextWriterWriteFormatElementNS(xmlTextWriterPtr writer, - const xmlChar * prefix, - const xmlChar * name, - const xmlChar * namespaceURI, - const char *format, ...) - LIBXML_ATTR_FORMAT(5,6); - XMLPUBFUN int XMLCALL - xmlTextWriterWriteVFormatElementNS(xmlTextWriterPtr writer, - const xmlChar * prefix, - const xmlChar * name, - const xmlChar * namespaceURI, - const char *format, - va_list argptr) - LIBXML_ATTR_FORMAT(5,0); - XMLPUBFUN int XMLCALL xmlTextWriterWriteElementNS(xmlTextWriterPtr - writer, - const xmlChar * - prefix, - const xmlChar * name, - const xmlChar * - namespaceURI, - const xmlChar * - content); - -/* - * Text - */ - XMLPUBFUN int XMLCALL - xmlTextWriterWriteFormatRaw(xmlTextWriterPtr writer, - const char *format, ...) - LIBXML_ATTR_FORMAT(2,3); - XMLPUBFUN int XMLCALL - xmlTextWriterWriteVFormatRaw(xmlTextWriterPtr writer, - const char *format, va_list argptr) - LIBXML_ATTR_FORMAT(2,0); - XMLPUBFUN int XMLCALL - xmlTextWriterWriteRawLen(xmlTextWriterPtr writer, - const xmlChar * content, int len); - XMLPUBFUN int XMLCALL - xmlTextWriterWriteRaw(xmlTextWriterPtr writer, - const xmlChar * content); - XMLPUBFUN int XMLCALL xmlTextWriterWriteFormatString(xmlTextWriterPtr - writer, - const char - *format, ...) - LIBXML_ATTR_FORMAT(2,3); - XMLPUBFUN int XMLCALL xmlTextWriterWriteVFormatString(xmlTextWriterPtr - writer, - const char - *format, - va_list argptr) - LIBXML_ATTR_FORMAT(2,0); - XMLPUBFUN int XMLCALL xmlTextWriterWriteString(xmlTextWriterPtr writer, - const xmlChar * - content); - XMLPUBFUN int XMLCALL xmlTextWriterWriteBase64(xmlTextWriterPtr writer, - const char *data, - int start, int len); - XMLPUBFUN int XMLCALL xmlTextWriterWriteBinHex(xmlTextWriterPtr writer, - const char *data, - int start, int len); - -/* - * Attributes - */ - XMLPUBFUN int XMLCALL - xmlTextWriterStartAttribute(xmlTextWriterPtr writer, - const xmlChar * name); - XMLPUBFUN int XMLCALL xmlTextWriterStartAttributeNS(xmlTextWriterPtr - writer, - const xmlChar * - prefix, - const xmlChar * - name, - const xmlChar * - namespaceURI); - XMLPUBFUN int XMLCALL xmlTextWriterEndAttribute(xmlTextWriterPtr - writer); - -/* - * Attributes conveniency functions - */ - XMLPUBFUN int XMLCALL - xmlTextWriterWriteFormatAttribute(xmlTextWriterPtr writer, - const xmlChar * name, - const char *format, ...) - LIBXML_ATTR_FORMAT(3,4); - XMLPUBFUN int XMLCALL - xmlTextWriterWriteVFormatAttribute(xmlTextWriterPtr writer, - const xmlChar * name, - const char *format, - va_list argptr) - LIBXML_ATTR_FORMAT(3,0); - XMLPUBFUN int XMLCALL xmlTextWriterWriteAttribute(xmlTextWriterPtr - writer, - const xmlChar * name, - const xmlChar * - content); - XMLPUBFUN int XMLCALL - xmlTextWriterWriteFormatAttributeNS(xmlTextWriterPtr writer, - const xmlChar * prefix, - const xmlChar * name, - const xmlChar * namespaceURI, - const char *format, ...) - LIBXML_ATTR_FORMAT(5,6); - XMLPUBFUN int XMLCALL - xmlTextWriterWriteVFormatAttributeNS(xmlTextWriterPtr writer, - const xmlChar * prefix, - const xmlChar * name, - const xmlChar * namespaceURI, - const char *format, - va_list argptr) - LIBXML_ATTR_FORMAT(5,0); - XMLPUBFUN int XMLCALL xmlTextWriterWriteAttributeNS(xmlTextWriterPtr - writer, - const xmlChar * - prefix, - const xmlChar * - name, - const xmlChar * - namespaceURI, - const xmlChar * - content); - -/* - * PI's - */ - XMLPUBFUN int XMLCALL - xmlTextWriterStartPI(xmlTextWriterPtr writer, - const xmlChar * target); - XMLPUBFUN int XMLCALL xmlTextWriterEndPI(xmlTextWriterPtr writer); - -/* - * PI conveniency functions - */ - XMLPUBFUN int XMLCALL - xmlTextWriterWriteFormatPI(xmlTextWriterPtr writer, - const xmlChar * target, - const char *format, ...) - LIBXML_ATTR_FORMAT(3,4); - XMLPUBFUN int XMLCALL - xmlTextWriterWriteVFormatPI(xmlTextWriterPtr writer, - const xmlChar * target, - const char *format, va_list argptr) - LIBXML_ATTR_FORMAT(3,0); - XMLPUBFUN int XMLCALL - xmlTextWriterWritePI(xmlTextWriterPtr writer, - const xmlChar * target, - const xmlChar * content); - -/** - * xmlTextWriterWriteProcessingInstruction: - * - * This macro maps to xmlTextWriterWritePI - */ -#define xmlTextWriterWriteProcessingInstruction xmlTextWriterWritePI - -/* - * CDATA - */ - XMLPUBFUN int XMLCALL xmlTextWriterStartCDATA(xmlTextWriterPtr writer); - XMLPUBFUN int XMLCALL xmlTextWriterEndCDATA(xmlTextWriterPtr writer); - -/* - * CDATA conveniency functions - */ - XMLPUBFUN int XMLCALL - xmlTextWriterWriteFormatCDATA(xmlTextWriterPtr writer, - const char *format, ...) - LIBXML_ATTR_FORMAT(2,3); - XMLPUBFUN int XMLCALL - xmlTextWriterWriteVFormatCDATA(xmlTextWriterPtr writer, - const char *format, va_list argptr) - LIBXML_ATTR_FORMAT(2,0); - XMLPUBFUN int XMLCALL - xmlTextWriterWriteCDATA(xmlTextWriterPtr writer, - const xmlChar * content); - -/* - * DTD - */ - XMLPUBFUN int XMLCALL - xmlTextWriterStartDTD(xmlTextWriterPtr writer, - const xmlChar * name, - const xmlChar * pubid, - const xmlChar * sysid); - XMLPUBFUN int XMLCALL xmlTextWriterEndDTD(xmlTextWriterPtr writer); - -/* - * DTD conveniency functions - */ - XMLPUBFUN int XMLCALL - xmlTextWriterWriteFormatDTD(xmlTextWriterPtr writer, - const xmlChar * name, - const xmlChar * pubid, - const xmlChar * sysid, - const char *format, ...) - LIBXML_ATTR_FORMAT(5,6); - XMLPUBFUN int XMLCALL - xmlTextWriterWriteVFormatDTD(xmlTextWriterPtr writer, - const xmlChar * name, - const xmlChar * pubid, - const xmlChar * sysid, - const char *format, va_list argptr) - LIBXML_ATTR_FORMAT(5,0); - XMLPUBFUN int XMLCALL - xmlTextWriterWriteDTD(xmlTextWriterPtr writer, - const xmlChar * name, - const xmlChar * pubid, - const xmlChar * sysid, - const xmlChar * subset); - -/** - * xmlTextWriterWriteDocType: - * - * this macro maps to xmlTextWriterWriteDTD - */ -#define xmlTextWriterWriteDocType xmlTextWriterWriteDTD - -/* - * DTD element definition - */ - XMLPUBFUN int XMLCALL - xmlTextWriterStartDTDElement(xmlTextWriterPtr writer, - const xmlChar * name); - XMLPUBFUN int XMLCALL xmlTextWriterEndDTDElement(xmlTextWriterPtr - writer); - -/* - * DTD element definition conveniency functions - */ - XMLPUBFUN int XMLCALL - xmlTextWriterWriteFormatDTDElement(xmlTextWriterPtr writer, - const xmlChar * name, - const char *format, ...) - LIBXML_ATTR_FORMAT(3,4); - XMLPUBFUN int XMLCALL - xmlTextWriterWriteVFormatDTDElement(xmlTextWriterPtr writer, - const xmlChar * name, - const char *format, - va_list argptr) - LIBXML_ATTR_FORMAT(3,0); - XMLPUBFUN int XMLCALL xmlTextWriterWriteDTDElement(xmlTextWriterPtr - writer, - const xmlChar * - name, - const xmlChar * - content); - -/* - * DTD attribute list definition - */ - XMLPUBFUN int XMLCALL - xmlTextWriterStartDTDAttlist(xmlTextWriterPtr writer, - const xmlChar * name); - XMLPUBFUN int XMLCALL xmlTextWriterEndDTDAttlist(xmlTextWriterPtr - writer); - -/* - * DTD attribute list definition conveniency functions - */ - XMLPUBFUN int XMLCALL - xmlTextWriterWriteFormatDTDAttlist(xmlTextWriterPtr writer, - const xmlChar * name, - const char *format, ...) - LIBXML_ATTR_FORMAT(3,4); - XMLPUBFUN int XMLCALL - xmlTextWriterWriteVFormatDTDAttlist(xmlTextWriterPtr writer, - const xmlChar * name, - const char *format, - va_list argptr) - LIBXML_ATTR_FORMAT(3,0); - XMLPUBFUN int XMLCALL xmlTextWriterWriteDTDAttlist(xmlTextWriterPtr - writer, - const xmlChar * - name, - const xmlChar * - content); - -/* - * DTD entity definition - */ - XMLPUBFUN int XMLCALL - xmlTextWriterStartDTDEntity(xmlTextWriterPtr writer, - int pe, const xmlChar * name); - XMLPUBFUN int XMLCALL xmlTextWriterEndDTDEntity(xmlTextWriterPtr - writer); - -/* - * DTD entity definition conveniency functions - */ - XMLPUBFUN int XMLCALL - xmlTextWriterWriteFormatDTDInternalEntity(xmlTextWriterPtr writer, - int pe, - const xmlChar * name, - const char *format, ...) - LIBXML_ATTR_FORMAT(4,5); - XMLPUBFUN int XMLCALL - xmlTextWriterWriteVFormatDTDInternalEntity(xmlTextWriterPtr writer, - int pe, - const xmlChar * name, - const char *format, - va_list argptr) - LIBXML_ATTR_FORMAT(4,0); - XMLPUBFUN int XMLCALL - xmlTextWriterWriteDTDInternalEntity(xmlTextWriterPtr writer, - int pe, - const xmlChar * name, - const xmlChar * content); - XMLPUBFUN int XMLCALL - xmlTextWriterWriteDTDExternalEntity(xmlTextWriterPtr writer, - int pe, - const xmlChar * name, - const xmlChar * pubid, - const xmlChar * sysid, - const xmlChar * ndataid); - XMLPUBFUN int XMLCALL - xmlTextWriterWriteDTDExternalEntityContents(xmlTextWriterPtr - writer, - const xmlChar * pubid, - const xmlChar * sysid, - const xmlChar * - ndataid); - XMLPUBFUN int XMLCALL xmlTextWriterWriteDTDEntity(xmlTextWriterPtr - writer, int pe, - const xmlChar * name, - const xmlChar * - pubid, - const xmlChar * - sysid, - const xmlChar * - ndataid, - const xmlChar * - content); - -/* - * DTD notation definition - */ - XMLPUBFUN int XMLCALL - xmlTextWriterWriteDTDNotation(xmlTextWriterPtr writer, - const xmlChar * name, - const xmlChar * pubid, - const xmlChar * sysid); - -/* - * Indentation - */ - XMLPUBFUN int XMLCALL - xmlTextWriterSetIndent(xmlTextWriterPtr writer, int indent); - XMLPUBFUN int XMLCALL - xmlTextWriterSetIndentString(xmlTextWriterPtr writer, - const xmlChar * str); - -/* - * misc - */ - XMLPUBFUN int XMLCALL xmlTextWriterFlush(xmlTextWriterPtr writer); - -#ifdef __cplusplus -} -#endif - -#endif /* LIBXML_WRITER_ENABLED */ #endif /* __XML_XMLWRITER_H__ */ diff --git a/android/native/libxml2/parser.c b/android/native/libxml2/parser.c index 7c9f7c7a50..c2f6d392ff 100644 --- a/android/native/libxml2/parser.c +++ b/android/native/libxml2/parser.c @@ -793,11 +793,7 @@ xmlHasFeature(xmlFeature feature) case XML_WITH_PATTERN: return(0); case XML_WITH_WRITER: -#ifdef LIBXML_WRITER_ENABLED - return(1); -#else return(0); -#endif case XML_WITH_SAX1: return(0); case XML_WITH_FTP: @@ -889,11 +885,7 @@ xmlHasFeature(xmlFeature feature) return(0); #endif case XML_WITH_ZLIB: -#ifdef LIBXML_ZLIB_ENABLED - return(1); -#else return(0); -#endif case XML_WITH_LZMA: #ifdef LIBXML_LZMA_ENABLED return(1); diff --git a/android/native/libxml2/tree.c b/android/native/libxml2/tree.c index 0649e7ec14..2af69cefb6 100644 --- a/android/native/libxml2/tree.c +++ b/android/native/libxml2/tree.c @@ -343,7 +343,7 @@ xmlSplitQName3(const xmlChar *name, int *len) { #define CUR_SCHAR(s, l) xmlStringCurrentChar(NULL, s, &l) -#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_WRITER_ENABLED) +#if defined(LIBXML_TREE_ENABLED) /** * xmlValidateNCName: * @value: the value to check @@ -3781,7 +3781,7 @@ xmlUnlinkNode(xmlNodePtr cur) { cur->next = cur->prev = NULL; } -#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_WRITER_ENABLED) +#if defined(LIBXML_TREE_ENABLED) /** * xmlReplaceNode: * @old: the old node @@ -4781,7 +4781,7 @@ xmlDocGetRootElement(xmlDocPtr doc) { return(ret); } -#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_WRITER_ENABLED) +#if defined(LIBXML_TREE_ENABLED) /** * xmlDocSetRootElement: * @doc: the document diff --git a/android/native/libxml2/xmlreader.c b/android/native/libxml2/xmlreader.c index 989cd73802..294e399122 100644 --- a/android/native/libxml2/xmlreader.c +++ b/android/native/libxml2/xmlreader.c @@ -1497,97 +1497,6 @@ xmlTextReaderNext(xmlTextReaderPtr reader) { return(xmlTextReaderRead(reader)); } -#ifdef LIBXML_WRITER_ENABLED -/** - * xmlTextReaderReadInnerXml: - * @reader: the xmlTextReaderPtr used - * - * Reads the contents of the current node, including child nodes and markup. - * - * Returns a string containing the XML content, or NULL if the current node - * is neither an element nor attribute, or has no child nodes. The - * string must be deallocated by the caller. - */ -xmlChar * -xmlTextReaderReadInnerXml(xmlTextReaderPtr reader ATTRIBUTE_UNUSED) -{ - xmlChar *resbuf; - xmlNodePtr node, cur_node; - xmlBufferPtr buff, buff2; - xmlDocPtr doc; - - if (xmlTextReaderExpand(reader) == NULL) { - return NULL; - } - doc = reader->doc; - buff = xmlBufferCreate(); - for (cur_node = reader->node->children; cur_node != NULL; - cur_node = cur_node->next) { - node = xmlDocCopyNode(cur_node, doc, 1); - buff2 = xmlBufferCreate(); - if (xmlNodeDump(buff2, doc, node, 0, 0) == -1) { - xmlFreeNode(node); - xmlBufferFree(buff2); - xmlBufferFree(buff); - return NULL; - } - xmlBufferCat(buff, buff2->content); - xmlFreeNode(node); - xmlBufferFree(buff2); - } - resbuf = buff->content; - buff->content = NULL; - - xmlBufferFree(buff); - return resbuf; -} -#endif - -#ifdef LIBXML_WRITER_ENABLED -/** - * xmlTextReaderReadOuterXml: - * @reader: the xmlTextReaderPtr used - * - * Reads the contents of the current node, including child nodes and markup. - * - * Returns a string containing the node and any XML content, or NULL if the - * current node cannot be serialized. The string must be deallocated - * by the caller. - */ -xmlChar * -xmlTextReaderReadOuterXml(xmlTextReaderPtr reader ATTRIBUTE_UNUSED) -{ - xmlChar *resbuf; - xmlNodePtr node; - xmlBufferPtr buff; - xmlDocPtr doc; - - node = reader->node; - doc = reader->doc; - if (xmlTextReaderExpand(reader) == NULL) { - return NULL; - } - if (node->type == XML_DTD_NODE) { - node = (xmlNodePtr) xmlCopyDtd((xmlDtdPtr) node); - } else { - node = xmlDocCopyNode(node, doc, 1); - } - buff = xmlBufferCreate(); - if (xmlNodeDump(buff, doc, node, 0, 0) == -1) { - xmlFreeNode(node); - xmlBufferFree(buff); - return NULL; - } - - resbuf = buff->content; - buff->content = NULL; - - xmlFreeNode(node); - xmlBufferFree(buff); - return resbuf; -} -#endif - /** * xmlTextReaderReadString: * @reader: the xmlTextReaderPtr used diff --git a/android/native/libxml2/xmlwriter.c b/android/native/libxml2/xmlwriter.c deleted file mode 100644 index 0103aa2113..0000000000 --- a/android/native/libxml2/xmlwriter.c +++ /dev/null @@ -1,4699 +0,0 @@ - -/* - * xmlwriter.c: XML text writer implementation - * - * For license and disclaimer see the license and disclaimer of - * libxml2. - * - * alfred@mickautsch.de - */ - -#define IN_LIBXML -#include "libxml.h" -#include - -#include -#include -#include -#include - -#ifdef LIBXML_WRITER_ENABLED - -#include - -#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. - */ -#ifndef VA_COPY - #ifdef HAVE_VA_COPY - #define VA_COPY(dest, src) va_copy(dest, src) - #else - #ifdef HAVE___VA_COPY - #define VA_COPY(dest,src) __va_copy(dest, src) - #else - #define VA_COPY(dest,src) (dest) = (src) - #endif - #endif -#endif - -/* - * Types are kept private - */ -typedef enum { - XML_TEXTWRITER_NONE = 0, - XML_TEXTWRITER_NAME, - XML_TEXTWRITER_ATTRIBUTE, - XML_TEXTWRITER_TEXT, - XML_TEXTWRITER_PI, - XML_TEXTWRITER_PI_TEXT, - XML_TEXTWRITER_CDATA, - XML_TEXTWRITER_DTD, - XML_TEXTWRITER_DTD_TEXT, - XML_TEXTWRITER_DTD_ELEM, - XML_TEXTWRITER_DTD_ELEM_TEXT, - XML_TEXTWRITER_DTD_ATTL, - XML_TEXTWRITER_DTD_ATTL_TEXT, - XML_TEXTWRITER_DTD_ENTY, /* entity */ - XML_TEXTWRITER_DTD_ENTY_TEXT, - XML_TEXTWRITER_DTD_PENT, /* parameter entity */ - XML_TEXTWRITER_COMMENT -} xmlTextWriterState; - -typedef struct _xmlTextWriterStackEntry xmlTextWriterStackEntry; - -struct _xmlTextWriterStackEntry { - xmlChar *name; - xmlTextWriterState state; -}; - -typedef struct _xmlTextWriterNsStackEntry xmlTextWriterNsStackEntry; -struct _xmlTextWriterNsStackEntry { - xmlChar *prefix; - xmlChar *uri; - xmlLinkPtr elem; -}; - -struct _xmlTextWriter { - xmlOutputBufferPtr out; /* output buffer */ - xmlListPtr nodes; /* element name stack */ - xmlListPtr nsstack; /* name spaces stack */ - int level; - int indent; /* enable indent */ - int doindent; /* internal indent flag */ - xmlChar *ichar; /* indent character */ - char qchar; /* character used for quoting attribute values */ - xmlParserCtxtPtr ctxt; - int no_doc_free; - xmlDocPtr doc; -}; - -static void xmlFreeTextWriterStackEntry(xmlLinkPtr lk); -static int xmlCmpTextWriterStackEntry(const void *data0, - const void *data1); -static int xmlTextWriterOutputNSDecl(xmlTextWriterPtr writer); -static void xmlFreeTextWriterNsStackEntry(xmlLinkPtr lk); -static int xmlCmpTextWriterNsStackEntry(const void *data0, - const void *data1); -static int xmlTextWriterWriteDocCallback(void *context, - const xmlChar * str, int len); -static int xmlTextWriterCloseDocCallback(void *context); - -static xmlChar *xmlTextWriterVSprintf(const char *format, va_list argptr); -static int xmlOutputBufferWriteBase64(xmlOutputBufferPtr out, int len, - const unsigned char *data); -static void xmlTextWriterStartDocumentCallback(void *ctx); -static int xmlTextWriterWriteIndent(xmlTextWriterPtr writer); -static int - xmlTextWriterHandleStateDependencies(xmlTextWriterPtr writer, - xmlTextWriterStackEntry * p); - -/** - * xmlWriterErrMsg: - * @ctxt: a writer context - * @error: the error number - * @msg: the error message - * - * Handle a writer error - */ -static void -xmlWriterErrMsg(xmlTextWriterPtr ctxt, xmlParserErrors error, - const char *msg) -{ - if (ctxt != NULL) { - __xmlRaiseError(NULL, NULL, NULL, ctxt->ctxt, - NULL, XML_FROM_WRITER, error, XML_ERR_FATAL, - NULL, 0, NULL, NULL, NULL, 0, 0, "%s", msg); - } else { - __xmlRaiseError(NULL, NULL, NULL, NULL, NULL, XML_FROM_WRITER, error, - XML_ERR_FATAL, NULL, 0, NULL, NULL, NULL, 0, 0, "%s", msg); - } -} - -/** - * xmlWriterErrMsgInt: - * @ctxt: a writer context - * @error: the error number - * @msg: the error message - * @val: an int - * - * Handle a writer error - */ -static void -xmlWriterErrMsgInt(xmlTextWriterPtr ctxt, xmlParserErrors error, - const char *msg, int val) -{ - if (ctxt != NULL) { - __xmlRaiseError(NULL, NULL, NULL, ctxt->ctxt, - NULL, XML_FROM_WRITER, error, XML_ERR_FATAL, - NULL, 0, NULL, NULL, NULL, val, 0, msg, val); - } else { - __xmlRaiseError(NULL, NULL, NULL, NULL, NULL, XML_FROM_WRITER, error, - XML_ERR_FATAL, NULL, 0, NULL, NULL, NULL, val, 0, msg, val); - } -} - -/** - * xmlNewTextWriter: - * @out: an xmlOutputBufferPtr - * - * Create a new xmlNewTextWriter structure using an xmlOutputBufferPtr - * NOTE: the @out parameter will be deallocated when the writer is closed - * (if the call succeed.) - * - * Returns the new xmlTextWriterPtr or NULL in case of error - */ -xmlTextWriterPtr -xmlNewTextWriter(xmlOutputBufferPtr out) -{ - xmlTextWriterPtr ret; - - ret = (xmlTextWriterPtr) xmlMalloc(sizeof(xmlTextWriter)); - if (ret == NULL) { - xmlWriterErrMsg(NULL, XML_ERR_NO_MEMORY, - "xmlNewTextWriter : out of memory!\n"); - return NULL; - } - memset(ret, 0, (size_t) sizeof(xmlTextWriter)); - - ret->nodes = xmlListCreate((xmlListDeallocator) - xmlFreeTextWriterStackEntry, - (xmlListDataCompare) - xmlCmpTextWriterStackEntry); - if (ret->nodes == NULL) { - xmlWriterErrMsg(NULL, XML_ERR_NO_MEMORY, - "xmlNewTextWriter : out of memory!\n"); - xmlFree(ret); - return NULL; - } - - ret->nsstack = xmlListCreate((xmlListDeallocator) - xmlFreeTextWriterNsStackEntry, - (xmlListDataCompare) - xmlCmpTextWriterNsStackEntry); - if (ret->nsstack == NULL) { - xmlWriterErrMsg(NULL, XML_ERR_NO_MEMORY, - "xmlNewTextWriter : out of memory!\n"); - xmlListDelete(ret->nodes); - xmlFree(ret); - return NULL; - } - - ret->out = out; - ret->ichar = xmlStrdup(BAD_CAST " "); - ret->qchar = '"'; - - if (!ret->ichar) { - xmlListDelete(ret->nodes); - xmlListDelete(ret->nsstack); - xmlFree(ret); - xmlWriterErrMsg(NULL, XML_ERR_NO_MEMORY, - "xmlNewTextWriter : out of memory!\n"); - return NULL; - } - - ret->doc = xmlNewDoc(NULL); - - ret->no_doc_free = 0; - - return ret; -} - -/** - * xmlNewTextWriterFilename: - * @uri: the URI of the resource for the output - * @compression: compress the output? - * - * Create a new xmlNewTextWriter structure with @uri as output - * - * Returns the new xmlTextWriterPtr or NULL in case of error - */ -xmlTextWriterPtr -xmlNewTextWriterFilename(const char *uri, int compression) -{ - xmlTextWriterPtr ret; - xmlOutputBufferPtr out; - - out = xmlOutputBufferCreateFilename(uri, NULL, compression); - if (out == NULL) { - xmlWriterErrMsg(NULL, XML_IO_EIO, - "xmlNewTextWriterFilename : cannot open uri\n"); - return NULL; - } - - ret = xmlNewTextWriter(out); - if (ret == NULL) { - xmlWriterErrMsg(NULL, XML_ERR_NO_MEMORY, - "xmlNewTextWriterFilename : out of memory!\n"); - xmlOutputBufferClose(out); - return NULL; - } - - ret->indent = 0; - ret->doindent = 0; - return ret; -} - -/** - * xmlNewTextWriterMemory: - * @buf: xmlBufferPtr - * @compression: compress the output? - * - * Create a new xmlNewTextWriter structure with @buf as output - * TODO: handle compression - * - * Returns the new xmlTextWriterPtr or NULL in case of error - */ -xmlTextWriterPtr -xmlNewTextWriterMemory(xmlBufferPtr buf, int compression ATTRIBUTE_UNUSED) -{ - xmlTextWriterPtr ret; - xmlOutputBufferPtr out; - -/*::todo handle compression */ - out = xmlOutputBufferCreateBuffer(buf, NULL); - - if (out == NULL) { - xmlWriterErrMsg(NULL, XML_ERR_NO_MEMORY, - "xmlNewTextWriterMemory : out of memory!\n"); - return NULL; - } - - ret = xmlNewTextWriter(out); - if (ret == NULL) { - xmlWriterErrMsg(NULL, XML_ERR_NO_MEMORY, - "xmlNewTextWriterMemory : out of memory!\n"); - xmlOutputBufferClose(out); - return NULL; - } - - return ret; -} - -/** - * xmlNewTextWriterPushParser: - * @ctxt: xmlParserCtxtPtr to hold the new XML document tree - * @compression: compress the output? - * - * Create a new xmlNewTextWriter structure with @ctxt as output - * NOTE: the @ctxt context will be freed with the resulting writer - * (if the call succeeds). - * TODO: handle compression - * - * Returns the new xmlTextWriterPtr or NULL in case of error - */ -xmlTextWriterPtr -xmlNewTextWriterPushParser(xmlParserCtxtPtr ctxt, - int compression ATTRIBUTE_UNUSED) -{ - xmlTextWriterPtr ret; - xmlOutputBufferPtr out; - - if (ctxt == NULL) { - xmlWriterErrMsg(NULL, XML_ERR_INTERNAL_ERROR, - "xmlNewTextWriterPushParser : invalid context!\n"); - return NULL; - } - - out = xmlOutputBufferCreateIO((xmlOutputWriteCallback) - xmlTextWriterWriteDocCallback, - (xmlOutputCloseCallback) - xmlTextWriterCloseDocCallback, - (void *) ctxt, NULL); - if (out == NULL) { - xmlWriterErrMsg(NULL, XML_ERR_INTERNAL_ERROR, - "xmlNewTextWriterPushParser : error at xmlOutputBufferCreateIO!\n"); - return NULL; - } - - ret = xmlNewTextWriter(out); - if (ret == NULL) { - xmlWriterErrMsg(NULL, XML_ERR_INTERNAL_ERROR, - "xmlNewTextWriterPushParser : error at xmlNewTextWriter!\n"); - xmlOutputBufferClose(out); - return NULL; - } - - ret->ctxt = ctxt; - - return ret; -} - -/** - * xmlNewTextWriterDoc: - * @doc: address of a xmlDocPtr to hold the new XML document tree - * @compression: compress the output? - * - * Create a new xmlNewTextWriter structure with @*doc as output - * - * Returns the new xmlTextWriterPtr or NULL in case of error - */ -xmlTextWriterPtr -xmlNewTextWriterDoc(xmlDocPtr * doc, int compression) -{ - xmlTextWriterPtr ret; - xmlSAXHandler saxHandler; - xmlParserCtxtPtr ctxt; - - memset(&saxHandler, '\0', sizeof(saxHandler)); - xmlSAX2InitDefaultSAXHandler(&saxHandler, 1); - saxHandler.startDocument = xmlTextWriterStartDocumentCallback; - saxHandler.startElement = xmlSAX2StartElement; - saxHandler.endElement = xmlSAX2EndElement; - - ctxt = xmlCreatePushParserCtxt(&saxHandler, NULL, NULL, 0, NULL); - if (ctxt == NULL) { - xmlWriterErrMsg(NULL, XML_ERR_INTERNAL_ERROR, - "xmlNewTextWriterDoc : error at xmlCreatePushParserCtxt!\n"); - return NULL; - } - /* - * For some reason this seems to completely break if node names - * are interned. - */ - ctxt->dictNames = 0; - - ctxt->myDoc = xmlNewDoc(BAD_CAST XML_DEFAULT_VERSION); - if (ctxt->myDoc == NULL) { - xmlFreeParserCtxt(ctxt); - xmlWriterErrMsg(NULL, XML_ERR_INTERNAL_ERROR, - "xmlNewTextWriterDoc : error at xmlNewDoc!\n"); - return NULL; - } - - ret = xmlNewTextWriterPushParser(ctxt, compression); - if (ret == NULL) { - xmlFreeDoc(ctxt->myDoc); - xmlFreeParserCtxt(ctxt); - xmlWriterErrMsg(NULL, XML_ERR_INTERNAL_ERROR, - "xmlNewTextWriterDoc : error at xmlNewTextWriterPushParser!\n"); - return NULL; - } - - xmlSetDocCompressMode(ctxt->myDoc, compression); - - if (doc != NULL) { - *doc = ctxt->myDoc; - ret->no_doc_free = 1; - } - - return ret; -} - -/** - * xmlNewTextWriterTree: - * @doc: xmlDocPtr - * @node: xmlNodePtr or NULL for doc->children - * @compression: compress the output? - * - * Create a new xmlNewTextWriter structure with @doc as output - * starting at @node - * - * Returns the new xmlTextWriterPtr or NULL in case of error - */ -xmlTextWriterPtr -xmlNewTextWriterTree(xmlDocPtr doc, xmlNodePtr node, int compression) -{ - xmlTextWriterPtr ret; - xmlSAXHandler saxHandler; - xmlParserCtxtPtr ctxt; - - if (doc == NULL) { - xmlWriterErrMsg(NULL, XML_ERR_INTERNAL_ERROR, - "xmlNewTextWriterTree : invalid document tree!\n"); - return NULL; - } - - memset(&saxHandler, '\0', sizeof(saxHandler)); - xmlSAX2InitDefaultSAXHandler(&saxHandler, 1); - saxHandler.startDocument = xmlTextWriterStartDocumentCallback; - saxHandler.startElement = xmlSAX2StartElement; - saxHandler.endElement = xmlSAX2EndElement; - - ctxt = xmlCreatePushParserCtxt(&saxHandler, NULL, NULL, 0, NULL); - if (ctxt == NULL) { - xmlWriterErrMsg(NULL, XML_ERR_INTERNAL_ERROR, - "xmlNewTextWriterDoc : error at xmlCreatePushParserCtxt!\n"); - return NULL; - } - /* - * For some reason this seems to completely break if node names - * are interned. - */ - ctxt->dictNames = 0; - - ret = xmlNewTextWriterPushParser(ctxt, compression); - if (ret == NULL) { - xmlFreeParserCtxt(ctxt); - xmlWriterErrMsg(NULL, XML_ERR_INTERNAL_ERROR, - "xmlNewTextWriterDoc : error at xmlNewTextWriterPushParser!\n"); - return NULL; - } - - ctxt->myDoc = doc; - ctxt->node = node; - ret->no_doc_free = 1; - - xmlSetDocCompressMode(doc, compression); - - return ret; -} - -/** - * xmlFreeTextWriter: - * @writer: the xmlTextWriterPtr - * - * Deallocate all the resources associated to the writer - */ -void -xmlFreeTextWriter(xmlTextWriterPtr writer) -{ - if (writer == NULL) - return; - - if (writer->out != NULL) - xmlOutputBufferClose(writer->out); - - if (writer->nodes != NULL) - xmlListDelete(writer->nodes); - - if (writer->nsstack != NULL) - xmlListDelete(writer->nsstack); - - if (writer->ctxt != NULL) { - if ((writer->ctxt->myDoc != NULL) && (writer->no_doc_free == 0)) { - xmlFreeDoc(writer->ctxt->myDoc); - writer->ctxt->myDoc = NULL; - } - xmlFreeParserCtxt(writer->ctxt); - } - - if (writer->doc != NULL) - xmlFreeDoc(writer->doc); - - if (writer->ichar != NULL) - xmlFree(writer->ichar); - xmlFree(writer); -} - -/** - * xmlTextWriterStartDocument: - * @writer: the xmlTextWriterPtr - * @version: the xml version ("1.0") or NULL for default ("1.0") - * @encoding: the encoding or NULL for default - * @standalone: "yes" or "no" or NULL for default - * - * Start a new xml document - * - * Returns the bytes written (may be 0 because of buffering) or -1 in case of error - */ -int -xmlTextWriterStartDocument(xmlTextWriterPtr writer, const char *version, - const char *encoding, const char *standalone) -{ - int count; - int sum; - xmlLinkPtr lk; - xmlCharEncodingHandlerPtr encoder; - - if ((writer == NULL) || (writer->out == NULL)) { - xmlWriterErrMsg(writer, XML_ERR_INTERNAL_ERROR, - "xmlTextWriterStartDocument : invalid writer!\n"); - return -1; - } - - lk = xmlListFront(writer->nodes); - if ((lk != NULL) && (xmlLinkGetData(lk) != NULL)) { - xmlWriterErrMsg(writer, XML_ERR_INTERNAL_ERROR, - "xmlTextWriterStartDocument : not allowed in this context!\n"); - return -1; - } - - encoder = NULL; - if (encoding != NULL) { - encoder = xmlFindCharEncodingHandler(encoding); - if (encoder == NULL) { - xmlWriterErrMsg(writer, XML_ERR_NO_MEMORY, - "xmlTextWriterStartDocument : out of memory!\n"); - return -1; - } - } - - writer->out->encoder = encoder; - if (encoder != NULL) { - if (writer->out->conv == NULL) { - writer->out->conv = xmlBufferCreateSize(4000); - } - xmlCharEncOutFunc(encoder, writer->out->conv, NULL); - if ((writer->doc != NULL) && (writer->doc->encoding == NULL)) - writer->doc->encoding = xmlStrdup((xmlChar *)writer->out->encoder->name); - } else - writer->out->conv = NULL; - - sum = 0; - count = xmlOutputBufferWriteString(writer->out, "out, 1, &writer->qchar); - if (count < 0) - return -1; - sum += count; - if (version != 0) - count = xmlOutputBufferWriteString(writer->out, version); - else - count = xmlOutputBufferWriteString(writer->out, "1.0"); - if (count < 0) - return -1; - sum += count; - count = xmlOutputBufferWrite(writer->out, 1, &writer->qchar); - if (count < 0) - return -1; - sum += count; - if (writer->out->encoder != 0) { - count = xmlOutputBufferWriteString(writer->out, " encoding="); - if (count < 0) - return -1; - sum += count; - count = xmlOutputBufferWrite(writer->out, 1, &writer->qchar); - if (count < 0) - return -1; - sum += count; - count = - xmlOutputBufferWriteString(writer->out, - writer->out->encoder->name); - if (count < 0) - return -1; - sum += count; - count = xmlOutputBufferWrite(writer->out, 1, &writer->qchar); - if (count < 0) - return -1; - sum += count; - } - - if (standalone != 0) { - count = xmlOutputBufferWriteString(writer->out, " standalone="); - if (count < 0) - return -1; - sum += count; - count = xmlOutputBufferWrite(writer->out, 1, &writer->qchar); - if (count < 0) - return -1; - sum += count; - count = xmlOutputBufferWriteString(writer->out, standalone); - if (count < 0) - return -1; - sum += count; - count = xmlOutputBufferWrite(writer->out, 1, &writer->qchar); - if (count < 0) - return -1; - sum += count; - } - - count = xmlOutputBufferWriteString(writer->out, "?>\n"); - if (count < 0) - return -1; - sum += count; - - return sum; -} - -/** - * xmlTextWriterEndDocument: - * @writer: the xmlTextWriterPtr - * - * End an xml document. All open elements are closed, and - * the content is flushed to the output. - * - * Returns the bytes written or -1 in case of error - */ -int -xmlTextWriterEndDocument(xmlTextWriterPtr writer) -{ - int count; - int sum; - xmlLinkPtr lk; - xmlTextWriterStackEntry *p; - - if (writer == NULL) { - xmlWriterErrMsg(writer, XML_ERR_INTERNAL_ERROR, - "xmlTextWriterEndDocument : invalid writer!\n"); - return -1; - } - - sum = 0; - while ((lk = xmlListFront(writer->nodes)) != NULL) { - p = (xmlTextWriterStackEntry *) xmlLinkGetData(lk); - if (p == 0) - break; - switch (p->state) { - case XML_TEXTWRITER_NAME: - case XML_TEXTWRITER_ATTRIBUTE: - case XML_TEXTWRITER_TEXT: - count = xmlTextWriterEndElement(writer); - if (count < 0) - return -1; - sum += count; - break; - case XML_TEXTWRITER_PI: - case XML_TEXTWRITER_PI_TEXT: - count = xmlTextWriterEndPI(writer); - if (count < 0) - return -1; - sum += count; - break; - case XML_TEXTWRITER_CDATA: - count = xmlTextWriterEndCDATA(writer); - if (count < 0) - return -1; - sum += count; - break; - case XML_TEXTWRITER_DTD: - case XML_TEXTWRITER_DTD_TEXT: - case XML_TEXTWRITER_DTD_ELEM: - case XML_TEXTWRITER_DTD_ELEM_TEXT: - case XML_TEXTWRITER_DTD_ATTL: - case XML_TEXTWRITER_DTD_ATTL_TEXT: - case XML_TEXTWRITER_DTD_ENTY: - case XML_TEXTWRITER_DTD_ENTY_TEXT: - case XML_TEXTWRITER_DTD_PENT: - count = xmlTextWriterEndDTD(writer); - if (count < 0) - return -1; - sum += count; - break; - case XML_TEXTWRITER_COMMENT: - count = xmlTextWriterEndComment(writer); - if (count < 0) - return -1; - sum += count; - break; - default: - break; - } - } - - if (!writer->indent) { - count = xmlOutputBufferWriteString(writer->out, "\n"); - if (count < 0) - return -1; - sum += count; - } - - sum += xmlTextWriterFlush(writer); - - return sum; -} - -/** - * xmlTextWriterStartComment: - * @writer: the xmlTextWriterPtr - * - * Start an xml comment. - * - * Returns the bytes written (may be 0 because of buffering) or -1 in case of error - */ -int -xmlTextWriterStartComment(xmlTextWriterPtr writer) -{ - int count; - int sum; - xmlLinkPtr lk; - xmlTextWriterStackEntry *p; - - if (writer == NULL) { - xmlWriterErrMsg(writer, XML_ERR_INTERNAL_ERROR, - "xmlTextWriterStartComment : invalid writer!\n"); - return -1; - } - - sum = 0; - lk = xmlListFront(writer->nodes); - if (lk != 0) { - p = (xmlTextWriterStackEntry *) xmlLinkGetData(lk); - if (p != 0) { - switch (p->state) { - case XML_TEXTWRITER_TEXT: - case XML_TEXTWRITER_NONE: - break; - case XML_TEXTWRITER_NAME: - /* Output namespace declarations */ - count = xmlTextWriterOutputNSDecl(writer); - if (count < 0) - return -1; - sum += count; - count = xmlOutputBufferWriteString(writer->out, ">"); - if (count < 0) - return -1; - sum += count; - if (writer->indent) { - count = - xmlOutputBufferWriteString(writer->out, "\n"); - if (count < 0) - return -1; - sum += count; - } - p->state = XML_TEXTWRITER_TEXT; - break; - default: - return -1; - } - } - } - - p = (xmlTextWriterStackEntry *) - xmlMalloc(sizeof(xmlTextWriterStackEntry)); - if (p == 0) { - xmlWriterErrMsg(writer, XML_ERR_NO_MEMORY, - "xmlTextWriterStartElement : out of memory!\n"); - return -1; - } - - p->name = NULL; - p->state = XML_TEXTWRITER_COMMENT; - - xmlListPushFront(writer->nodes, p); - - if (writer->indent) { - count = xmlTextWriterWriteIndent(writer); - if (count < 0) - return -1; - sum += count; - } - - count = xmlOutputBufferWriteString(writer->out, ""); - if (count < 0) - return -1; - sum += count; - break; - default: - return -1; - } - - if (writer->indent) { - count = xmlOutputBufferWriteString(writer->out, "\n"); - if (count < 0) - return -1; - sum += count; - } - - xmlListPopFront(writer->nodes); - return sum; -} - -/** - * xmlTextWriterWriteFormatComment: - * @writer: the xmlTextWriterPtr - * @format: format string (see printf) - * @...: extra parameters for the format - * - * Write an xml comment. - * - * Returns the bytes written (may be 0 because of buffering) or -1 in case of error - */ -int XMLCDECL -xmlTextWriterWriteFormatComment(xmlTextWriterPtr writer, - const char *format, ...) -{ - int rc; - va_list ap; - - va_start(ap, format); - - rc = xmlTextWriterWriteVFormatComment(writer, format, ap); - - va_end(ap); - return rc; -} - -/** - * xmlTextWriterWriteVFormatComment: - * @writer: the xmlTextWriterPtr - * @format: format string (see printf) - * @argptr: pointer to the first member of the variable argument list. - * - * Write an xml comment. - * - * Returns the bytes written (may be 0 because of buffering) or -1 in case of error - */ -int -xmlTextWriterWriteVFormatComment(xmlTextWriterPtr writer, - const char *format, va_list argptr) -{ - int rc; - xmlChar *buf; - - if (writer == NULL) { - xmlWriterErrMsg(writer, XML_ERR_INTERNAL_ERROR, - "xmlTextWriterWriteVFormatComment : invalid writer!\n"); - return -1; - } - - buf = xmlTextWriterVSprintf(format, argptr); - if (buf == NULL) - return -1; - - rc = xmlTextWriterWriteComment(writer, buf); - - xmlFree(buf); - return rc; -} - -/** - * xmlTextWriterWriteComment: - * @writer: the xmlTextWriterPtr - * @content: comment string - * - * Write an xml comment. - * - * Returns the bytes written (may be 0 because of buffering) or -1 in case of error - */ -int -xmlTextWriterWriteComment(xmlTextWriterPtr writer, const xmlChar * content) -{ - int count; - int sum; - - sum = 0; - count = xmlTextWriterStartComment(writer); - if (count < 0) - return -1; - sum += count; - count = xmlTextWriterWriteString(writer, content); - if (count < 0) - return -1; - sum += count; - count = xmlTextWriterEndComment(writer); - if (count < 0) - return -1; - sum += count; - - return sum; -} - -/** - * xmlTextWriterStartElement: - * @writer: the xmlTextWriterPtr - * @name: element name - * - * Start an xml element. - * - * Returns the bytes written (may be 0 because of buffering) or -1 in case of error - */ -int -xmlTextWriterStartElement(xmlTextWriterPtr writer, const xmlChar * name) -{ - int count; - int sum; - xmlLinkPtr lk; - xmlTextWriterStackEntry *p; - - if ((writer == NULL) || (name == NULL) || (*name == '\0')) - return -1; - - sum = 0; - lk = xmlListFront(writer->nodes); - if (lk != 0) { - p = (xmlTextWriterStackEntry *) xmlLinkGetData(lk); - if (p != 0) { - switch (p->state) { - case XML_TEXTWRITER_PI: - case XML_TEXTWRITER_PI_TEXT: - return -1; - case XML_TEXTWRITER_NONE: - break; - case XML_TEXTWRITER_ATTRIBUTE: - count = xmlTextWriterEndAttribute(writer); - if (count < 0) - return -1; - sum += count; - /* fallthrough */ - case XML_TEXTWRITER_NAME: - /* Output namespace declarations */ - count = xmlTextWriterOutputNSDecl(writer); - if (count < 0) - return -1; - sum += count; - count = xmlOutputBufferWriteString(writer->out, ">"); - if (count < 0) - return -1; - sum += count; - if (writer->indent) - count = - xmlOutputBufferWriteString(writer->out, "\n"); - p->state = XML_TEXTWRITER_TEXT; - break; - default: - break; - } - } - } - - p = (xmlTextWriterStackEntry *) - xmlMalloc(sizeof(xmlTextWriterStackEntry)); - if (p == 0) { - xmlWriterErrMsg(writer, XML_ERR_NO_MEMORY, - "xmlTextWriterStartElement : out of memory!\n"); - return -1; - } - - p->name = xmlStrdup(name); - if (p->name == 0) { - xmlWriterErrMsg(writer, XML_ERR_NO_MEMORY, - "xmlTextWriterStartElement : out of memory!\n"); - xmlFree(p); - return -1; - } - p->state = XML_TEXTWRITER_NAME; - - xmlListPushFront(writer->nodes, p); - - if (writer->indent) { - count = xmlTextWriterWriteIndent(writer); - sum += count; - } - - count = xmlOutputBufferWriteString(writer->out, "<"); - if (count < 0) - return -1; - sum += count; - count = - xmlOutputBufferWriteString(writer->out, (const char *) p->name); - if (count < 0) - return -1; - sum += count; - - return sum; -} - -/** - * xmlTextWriterStartElementNS: - * @writer: the xmlTextWriterPtr - * @prefix: namespace prefix or NULL - * @name: element local name - * @namespaceURI: namespace URI or NULL - * - * Start an xml element with namespace support. - * - * Returns the bytes written (may be 0 because of buffering) or -1 in case of error - */ -int -xmlTextWriterStartElementNS(xmlTextWriterPtr writer, - const xmlChar * prefix, const xmlChar * name, - const xmlChar * namespaceURI) -{ - int count; - int sum; - xmlChar *buf; - - if ((writer == NULL) || (name == NULL) || (*name == '\0')) - return -1; - - buf = NULL; - if (prefix != 0) { - buf = xmlStrdup(prefix); - buf = xmlStrcat(buf, BAD_CAST ":"); - } - buf = xmlStrcat(buf, name); - - sum = 0; - count = xmlTextWriterStartElement(writer, buf); - xmlFree(buf); - if (count < 0) - return -1; - sum += count; - - if (namespaceURI != 0) { - xmlTextWriterNsStackEntry *p = (xmlTextWriterNsStackEntry *) - xmlMalloc(sizeof(xmlTextWriterNsStackEntry)); - if (p == 0) { - xmlWriterErrMsg(writer, XML_ERR_NO_MEMORY, - "xmlTextWriterStartElementNS : out of memory!\n"); - return -1; - } - - buf = xmlStrdup(BAD_CAST "xmlns"); - if (prefix != 0) { - buf = xmlStrcat(buf, BAD_CAST ":"); - buf = xmlStrcat(buf, prefix); - } - - p->prefix = buf; - p->uri = xmlStrdup(namespaceURI); - if (p->uri == 0) { - xmlWriterErrMsg(writer, XML_ERR_NO_MEMORY, - "xmlTextWriterStartElementNS : out of memory!\n"); - xmlFree(p); - return -1; - } - p->elem = xmlListFront(writer->nodes); - - xmlListPushFront(writer->nsstack, p); - } - - return sum; -} - -/** - * xmlTextWriterEndElement: - * @writer: the xmlTextWriterPtr - * - * End the current xml element. - * - * Returns the bytes written (may be 0 because of buffering) or -1 in case of error - */ -int -xmlTextWriterEndElement(xmlTextWriterPtr writer) -{ - int count; - int sum; - xmlLinkPtr lk; - xmlTextWriterStackEntry *p; - - if (writer == NULL) - return -1; - - lk = xmlListFront(writer->nodes); - if (lk == 0) { - xmlListDelete(writer->nsstack); - writer->nsstack = NULL; - return -1; - } - - p = (xmlTextWriterStackEntry *) xmlLinkGetData(lk); - if (p == 0) { - xmlListDelete(writer->nsstack); - writer->nsstack = NULL; - return -1; - } - - sum = 0; - switch (p->state) { - case XML_TEXTWRITER_ATTRIBUTE: - count = xmlTextWriterEndAttribute(writer); - if (count < 0) { - xmlListDelete(writer->nsstack); - writer->nsstack = NULL; - return -1; - } - sum += count; - /* fallthrough */ - case XML_TEXTWRITER_NAME: - /* Output namespace declarations */ - count = xmlTextWriterOutputNSDecl(writer); - if (count < 0) - return -1; - sum += count; - - if (writer->indent) /* next element needs indent */ - writer->doindent = 1; - count = xmlOutputBufferWriteString(writer->out, "/>"); - if (count < 0) - return -1; - sum += count; - break; - case XML_TEXTWRITER_TEXT: - if ((writer->indent) && (writer->doindent)) { - count = xmlTextWriterWriteIndent(writer); - sum += count; - writer->doindent = 1; - } else - writer->doindent = 1; - count = xmlOutputBufferWriteString(writer->out, "out, - (const char *) p->name); - if (count < 0) - return -1; - sum += count; - count = xmlOutputBufferWriteString(writer->out, ">"); - if (count < 0) - return -1; - sum += count; - break; - default: - return -1; - } - - if (writer->indent) { - count = xmlOutputBufferWriteString(writer->out, "\n"); - sum += count; - } - - xmlListPopFront(writer->nodes); - return sum; -} - -/** - * xmlTextWriterFullEndElement: - * @writer: the xmlTextWriterPtr - * - * End the current xml element. Writes an end tag even if the element is empty - * - * Returns the bytes written (may be 0 because of buffering) or -1 in case of error - */ -int -xmlTextWriterFullEndElement(xmlTextWriterPtr writer) -{ - int count; - int sum; - xmlLinkPtr lk; - xmlTextWriterStackEntry *p; - - if (writer == NULL) - return -1; - - lk = xmlListFront(writer->nodes); - if (lk == 0) - return -1; - - p = (xmlTextWriterStackEntry *) xmlLinkGetData(lk); - if (p == 0) - return -1; - - sum = 0; - switch (p->state) { - case XML_TEXTWRITER_ATTRIBUTE: - count = xmlTextWriterEndAttribute(writer); - if (count < 0) - return -1; - sum += count; - /* fallthrough */ - case XML_TEXTWRITER_NAME: - /* Output namespace declarations */ - count = xmlTextWriterOutputNSDecl(writer); - if (count < 0) - return -1; - sum += count; - - count = xmlOutputBufferWriteString(writer->out, ">"); - if (count < 0) - return -1; - sum += count; - if (writer->indent) - writer->doindent = 0; - /* fallthrough */ - case XML_TEXTWRITER_TEXT: - if ((writer->indent) && (writer->doindent)) { - count = xmlTextWriterWriteIndent(writer); - sum += count; - writer->doindent = 1; - } else - writer->doindent = 1; - count = xmlOutputBufferWriteString(writer->out, "out, - (const char *) p->name); - if (count < 0) - return -1; - sum += count; - count = xmlOutputBufferWriteString(writer->out, ">"); - if (count < 0) - return -1; - sum += count; - break; - default: - return -1; - } - - if (writer->indent) { - count = xmlOutputBufferWriteString(writer->out, "\n"); - sum += count; - } - - xmlListPopFront(writer->nodes); - return sum; -} - -/** - * xmlTextWriterWriteFormatRaw: - * @writer: the xmlTextWriterPtr - * @format: format string (see printf) - * @...: extra parameters for the format - * - * Write a formatted raw xml text. - * - * Returns the bytes written (may be 0 because of buffering) or -1 in case of error - */ -int XMLCDECL -xmlTextWriterWriteFormatRaw(xmlTextWriterPtr writer, const char *format, - ...) -{ - int rc; - va_list ap; - - va_start(ap, format); - - rc = xmlTextWriterWriteVFormatRaw(writer, format, ap); - - va_end(ap); - return rc; -} - -/** - * xmlTextWriterWriteVFormatRaw: - * @writer: the xmlTextWriterPtr - * @format: format string (see printf) - * @argptr: pointer to the first member of the variable argument list. - * - * Write a formatted raw xml text. - * - * Returns the bytes written (may be 0 because of buffering) or -1 in case of error - */ -int -xmlTextWriterWriteVFormatRaw(xmlTextWriterPtr writer, const char *format, - va_list argptr) -{ - int rc; - xmlChar *buf; - - if (writer == NULL) - return -1; - - buf = xmlTextWriterVSprintf(format, argptr); - if (buf == NULL) - return -1; - - rc = xmlTextWriterWriteRaw(writer, buf); - - xmlFree(buf); - return rc; -} - -/** - * xmlTextWriterWriteRawLen: - * @writer: the xmlTextWriterPtr - * @content: text string - * @len: length of the text string - * - * Write an xml text. - * TODO: what about entities and special chars?? - * - * Returns the bytes written (may be 0 because of buffering) or -1 in case of error - */ -int -xmlTextWriterWriteRawLen(xmlTextWriterPtr writer, const xmlChar * content, - int len) -{ - int count; - int sum; - xmlLinkPtr lk; - xmlTextWriterStackEntry *p; - - if (writer == NULL) { - xmlWriterErrMsg(writer, XML_ERR_INTERNAL_ERROR, - "xmlTextWriterWriteRawLen : invalid writer!\n"); - return -1; - } - - if ((content == NULL) || (len < 0)) { - xmlWriterErrMsg(writer, XML_ERR_INTERNAL_ERROR, - "xmlTextWriterWriteRawLen : invalid content!\n"); - return -1; - } - - sum = 0; - lk = xmlListFront(writer->nodes); - if (lk != 0) { - p = (xmlTextWriterStackEntry *) xmlLinkGetData(lk); - count = xmlTextWriterHandleStateDependencies(writer, p); - if (count < 0) - return -1; - sum += count; - } - - if (writer->indent) - writer->doindent = 0; - - if (content != NULL) { - count = - xmlOutputBufferWrite(writer->out, len, (const char *) content); - if (count < 0) - return -1; - sum += count; - } - - return sum; -} - -/** - * xmlTextWriterWriteRaw: - * @writer: the xmlTextWriterPtr - * @content: text string - * - * Write a raw xml text. - * - * Returns the bytes written (may be 0 because of buffering) or -1 in case of error - */ -int -xmlTextWriterWriteRaw(xmlTextWriterPtr writer, const xmlChar * content) -{ - return xmlTextWriterWriteRawLen(writer, content, xmlStrlen(content)); -} - -/** - * xmlTextWriterWriteFormatString: - * @writer: the xmlTextWriterPtr - * @format: format string (see printf) - * @...: extra parameters for the format - * - * Write a formatted xml text. - * - * Returns the bytes written (may be 0 because of buffering) or -1 in case of error - */ -int XMLCDECL -xmlTextWriterWriteFormatString(xmlTextWriterPtr writer, const char *format, - ...) -{ - int rc; - va_list ap; - - if ((writer == NULL) || (format == NULL)) - return -1; - - va_start(ap, format); - - rc = xmlTextWriterWriteVFormatString(writer, format, ap); - - va_end(ap); - return rc; -} - -/** - * xmlTextWriterWriteVFormatString: - * @writer: the xmlTextWriterPtr - * @format: format string (see printf) - * @argptr: pointer to the first member of the variable argument list. - * - * Write a formatted xml text. - * - * Returns the bytes written (may be 0 because of buffering) or -1 in case of error - */ -int -xmlTextWriterWriteVFormatString(xmlTextWriterPtr writer, - const char *format, va_list argptr) -{ - int rc; - xmlChar *buf; - - if ((writer == NULL) || (format == NULL)) - return -1; - - buf = xmlTextWriterVSprintf(format, argptr); - if (buf == NULL) - return -1; - - rc = xmlTextWriterWriteString(writer, buf); - - xmlFree(buf); - return rc; -} - -/** - * xmlTextWriterWriteString: - * @writer: the xmlTextWriterPtr - * @content: text string - * - * Write an xml text. - * - * Returns the bytes written (may be 0 because of buffering) or -1 in case of error - */ -int -xmlTextWriterWriteString(xmlTextWriterPtr writer, const xmlChar * content) -{ - int count; - int sum; - xmlLinkPtr lk; - xmlTextWriterStackEntry *p; - xmlChar *buf; - - if ((writer == NULL) || (content == NULL)) - return -1; - - sum = 0; - buf = (xmlChar *) content; - lk = xmlListFront(writer->nodes); - if (lk != 0) { - p = (xmlTextWriterStackEntry *) xmlLinkGetData(lk); - if (p != 0) { - switch (p->state) { - case XML_TEXTWRITER_NAME: - case XML_TEXTWRITER_TEXT: -#if 0 - buf = NULL; - xmlOutputBufferWriteEscape(writer->out, content, NULL); -#endif - buf = xmlEncodeSpecialChars(NULL, content); - break; - case XML_TEXTWRITER_ATTRIBUTE: - buf = NULL; - xmlAttrSerializeTxtContent(writer->out->buffer, writer->doc, - NULL, content); - break; - default: - break; - } - } - } - - if (buf != NULL) { - count = xmlTextWriterWriteRaw(writer, buf); - - if (buf != content) /* buf was allocated by us, so free it */ - xmlFree(buf); - - if (count < 0) - return -1; - sum += count; - } - - return sum; -} - -/** - * xmlOutputBufferWriteBase64: - * @out: the xmlOutputBufferPtr - * @data: binary data - * @len: the number of bytes to encode - * - * Write base64 encoded data to an xmlOutputBuffer. - * Adapted from John Walker's base64.c (http://www.fourmilab.ch/). - * - * Returns the bytes written (may be 0 because of buffering) or -1 in case of error - */ -static int -xmlOutputBufferWriteBase64(xmlOutputBufferPtr out, int len, - const unsigned char *data) -{ - static unsigned char dtable[64] = - {'A','B','C','D','E','F','G','H','I','J','K','L','M', - 'N','O','P','Q','R','S','T','U','V','W','X','Y','Z', - 'a','b','c','d','e','f','g','h','i','j','k','l','m', - 'n','o','p','q','r','s','t','u','v','w','x','y','z', - '0','1','2','3','4','5','6','7','8','9','+','/'}; - - int i; - int linelen; - int count; - int sum; - - if ((out == NULL) || (len < 0) || (data == NULL)) - return(-1); - - linelen = 0; - sum = 0; - - i = 0; - while (1) { - unsigned char igroup[3]; - unsigned char ogroup[4]; - int c; - int n; - - igroup[0] = igroup[1] = igroup[2] = 0; - for (n = 0; n < 3 && i < len; n++, i++) { - c = data[i]; - igroup[n] = (unsigned char) c; - } - - if (n > 0) { - ogroup[0] = dtable[igroup[0] >> 2]; - ogroup[1] = dtable[((igroup[0] & 3) << 4) | (igroup[1] >> 4)]; - ogroup[2] = - dtable[((igroup[1] & 0xF) << 2) | (igroup[2] >> 6)]; - ogroup[3] = dtable[igroup[2] & 0x3F]; - - if (n < 3) { - ogroup[3] = '='; - if (n < 2) { - ogroup[2] = '='; - } - } - - if (linelen >= B64LINELEN) { - count = xmlOutputBufferWrite(out, 2, B64CRLF); - if (count == -1) - return -1; - sum += count; - linelen = 0; - } - count = xmlOutputBufferWrite(out, 4, (const char *) ogroup); - if (count == -1) - return -1; - sum += count; - - linelen += 4; - } - - if (i >= len) - break; - } - - return sum; -} - -/** - * xmlTextWriterWriteBase64: - * @writer: the xmlTextWriterPtr - * @data: binary data - * @start: the position within the data of the first byte to encode - * @len: the number of bytes to encode - * - * Write an base64 encoded xml text. - * - * Returns the bytes written (may be 0 because of buffering) or -1 in case of error - */ -int -xmlTextWriterWriteBase64(xmlTextWriterPtr writer, const char *data, - int start, int len) -{ - int count; - int sum; - xmlLinkPtr lk; - xmlTextWriterStackEntry *p; - - if ((writer == NULL) || (data == NULL) || (start < 0) || (len < 0)) - return -1; - - sum = 0; - lk = xmlListFront(writer->nodes); - if (lk != 0) { - p = (xmlTextWriterStackEntry *) xmlLinkGetData(lk); - if (p != 0) { - count = xmlTextWriterHandleStateDependencies(writer, p); - if (count < 0) - return -1; - sum += count; - } - } - - if (writer->indent) - writer->doindent = 0; - - count = - xmlOutputBufferWriteBase64(writer->out, len, - (unsigned char *) data + start); - if (count < 0) - return -1; - sum += count; - - return sum; -} - -/** - * xmlOutputBufferWriteBinHex: - * @out: the xmlOutputBufferPtr - * @data: binary data - * @len: the number of bytes to encode - * - * Write hqx encoded data to an xmlOutputBuffer. - * ::todo - * - * Returns the bytes written (may be 0 because of buffering) - * or -1 in case of error - */ -static int -xmlOutputBufferWriteBinHex(xmlOutputBufferPtr out, - int len, const unsigned char *data) -{ - int count; - int sum; - 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)) { - return -1; - } - - sum = 0; - for (i = 0; i < len; i++) { - count = - xmlOutputBufferWrite(out, 1, - (const char *) &hex[data[i] >> 4]); - if (count == -1) - return -1; - sum += count; - count = - xmlOutputBufferWrite(out, 1, - (const char *) &hex[data[i] & 0xF]); - if (count == -1) - return -1; - sum += count; - } - - return sum; -} - -/** - * xmlTextWriterWriteBinHex: - * @writer: the xmlTextWriterPtr - * @data: binary data - * @start: the position within the data of the first byte to encode - * @len: the number of bytes to encode - * - * Write a BinHex encoded xml text. - * - * Returns the bytes written (may be 0 because of buffering) or -1 in case of error - */ -int -xmlTextWriterWriteBinHex(xmlTextWriterPtr writer, const char *data, - int start, int len) -{ - int count; - int sum; - xmlLinkPtr lk; - xmlTextWriterStackEntry *p; - - if ((writer == NULL) || (data == NULL) || (start < 0) || (len < 0)) - return -1; - - sum = 0; - lk = xmlListFront(writer->nodes); - if (lk != 0) { - p = (xmlTextWriterStackEntry *) xmlLinkGetData(lk); - if (p != 0) { - count = xmlTextWriterHandleStateDependencies(writer, p); - if (count < 0) - return -1; - sum += count; - } - } - - if (writer->indent) - writer->doindent = 0; - - count = - xmlOutputBufferWriteBinHex(writer->out, len, - (unsigned char *) data + start); - if (count < 0) - return -1; - sum += count; - - return sum; -} - -/** - * xmlTextWriterStartAttribute: - * @writer: the xmlTextWriterPtr - * @name: element name - * - * Start an xml attribute. - * - * Returns the bytes written (may be 0 because of buffering) or -1 in case of error - */ -int -xmlTextWriterStartAttribute(xmlTextWriterPtr writer, const xmlChar * name) -{ - int count; - int sum; - xmlLinkPtr lk; - xmlTextWriterStackEntry *p; - - if ((writer == NULL) || (name == NULL) || (*name == '\0')) - return -1; - - sum = 0; - lk = xmlListFront(writer->nodes); - if (lk == 0) - return -1; - - p = (xmlTextWriterStackEntry *) xmlLinkGetData(lk); - if (p == 0) - return -1; - - switch (p->state) { - case XML_TEXTWRITER_ATTRIBUTE: - count = xmlTextWriterEndAttribute(writer); - if (count < 0) - return -1; - sum += count; - /* fallthrough */ - case XML_TEXTWRITER_NAME: - count = xmlOutputBufferWriteString(writer->out, " "); - if (count < 0) - return -1; - sum += count; - count = - xmlOutputBufferWriteString(writer->out, - (const char *) name); - if (count < 0) - return -1; - sum += count; - count = xmlOutputBufferWriteString(writer->out, "="); - if (count < 0) - return -1; - sum += count; - count = xmlOutputBufferWrite(writer->out, 1, &writer->qchar); - if (count < 0) - return -1; - sum += count; - p->state = XML_TEXTWRITER_ATTRIBUTE; - break; - default: - return -1; - } - - return sum; -} - -/** - * xmlTextWriterStartAttributeNS: - * @writer: the xmlTextWriterPtr - * @prefix: namespace prefix or NULL - * @name: element local name - * @namespaceURI: namespace URI or NULL - * - * Start an xml attribute with namespace support. - * - * Returns the bytes written (may be 0 because of buffering) or -1 in case of error - */ -int -xmlTextWriterStartAttributeNS(xmlTextWriterPtr writer, - const xmlChar * prefix, const xmlChar * name, - const xmlChar * namespaceURI) -{ - int count; - int sum; - xmlChar *buf; - xmlTextWriterNsStackEntry *p; - - if ((writer == NULL) || (name == NULL) || (*name == '\0')) - return -1; - - /* Handle namespace first in case of error */ - if (namespaceURI != 0) { - xmlTextWriterNsStackEntry nsentry, *curns; - - buf = xmlStrdup(BAD_CAST "xmlns"); - if (prefix != 0) { - buf = xmlStrcat(buf, BAD_CAST ":"); - buf = xmlStrcat(buf, prefix); - } - - nsentry.prefix = buf; - nsentry.uri = (xmlChar *)namespaceURI; - nsentry.elem = xmlListFront(writer->nodes); - - curns = (xmlTextWriterNsStackEntry *)xmlListSearch(writer->nsstack, - (void *)&nsentry); - if ((curns != NULL)) { - xmlFree(buf); - if (xmlStrcmp(curns->uri, namespaceURI) == 0) { - /* Namespace already defined on element skip */ - buf = NULL; - } else { - /* Prefix mismatch so error out */ - return -1; - } - } - - /* Do not add namespace decl to list - it is already there */ - if (buf != NULL) { - p = (xmlTextWriterNsStackEntry *) - xmlMalloc(sizeof(xmlTextWriterNsStackEntry)); - if (p == 0) { - xmlWriterErrMsg(writer, XML_ERR_NO_MEMORY, - "xmlTextWriterStartAttributeNS : out of memory!\n"); - return -1; - } - - p->prefix = buf; - p->uri = xmlStrdup(namespaceURI); - if (p->uri == 0) { - xmlWriterErrMsg(writer, XML_ERR_NO_MEMORY, - "xmlTextWriterStartAttributeNS : out of memory!\n"); - xmlFree(p); - return -1; - } - p->elem = xmlListFront(writer->nodes); - - xmlListPushFront(writer->nsstack, p); - } - } - - buf = NULL; - if (prefix != 0) { - buf = xmlStrdup(prefix); - buf = xmlStrcat(buf, BAD_CAST ":"); - } - buf = xmlStrcat(buf, name); - - sum = 0; - count = xmlTextWriterStartAttribute(writer, buf); - xmlFree(buf); - if (count < 0) - return -1; - sum += count; - - return sum; -} - -/** - * xmlTextWriterEndAttribute: - * @writer: the xmlTextWriterPtr - * - * End the current xml element. - * - * Returns the bytes written (may be 0 because of buffering) or -1 in case of error - */ -int -xmlTextWriterEndAttribute(xmlTextWriterPtr writer) -{ - int count; - int sum; - xmlLinkPtr lk; - xmlTextWriterStackEntry *p; - - if (writer == NULL) - return -1; - - lk = xmlListFront(writer->nodes); - if (lk == 0) { - return -1; - } - - p = (xmlTextWriterStackEntry *) xmlLinkGetData(lk); - if (p == 0) { - return -1; - } - - sum = 0; - switch (p->state) { - case XML_TEXTWRITER_ATTRIBUTE: - p->state = XML_TEXTWRITER_NAME; - - count = xmlOutputBufferWrite(writer->out, 1, &writer->qchar); - if (count < 0) { - return -1; - } - sum += count; - break; - default: - return -1; - } - - return sum; -} - -/** - * xmlTextWriterWriteFormatAttribute: - * @writer: the xmlTextWriterPtr - * @name: attribute name - * @format: format string (see printf) - * @...: extra parameters for the format - * - * Write a formatted xml attribute. - * - * Returns the bytes written (may be 0 because of buffering) or -1 in case of error - */ -int XMLCDECL -xmlTextWriterWriteFormatAttribute(xmlTextWriterPtr writer, - const xmlChar * name, const char *format, - ...) -{ - int rc; - va_list ap; - - va_start(ap, format); - - rc = xmlTextWriterWriteVFormatAttribute(writer, name, format, ap); - - va_end(ap); - return rc; -} - -/** - * xmlTextWriterWriteVFormatAttribute: - * @writer: the xmlTextWriterPtr - * @name: attribute name - * @format: format string (see printf) - * @argptr: pointer to the first member of the variable argument list. - * - * Write a formatted xml attribute. - * - * Returns the bytes written (may be 0 because of buffering) or -1 in case of error - */ -int -xmlTextWriterWriteVFormatAttribute(xmlTextWriterPtr writer, - const xmlChar * name, - const char *format, va_list argptr) -{ - int rc; - xmlChar *buf; - - if (writer == NULL) - return -1; - - buf = xmlTextWriterVSprintf(format, argptr); - if (buf == NULL) - return -1; - - rc = xmlTextWriterWriteAttribute(writer, name, buf); - - xmlFree(buf); - return rc; -} - -/** - * xmlTextWriterWriteAttribute: - * @writer: the xmlTextWriterPtr - * @name: attribute name - * @content: attribute content - * - * Write an xml attribute. - * - * Returns the bytes written (may be 0 because of buffering) or -1 in case of error - */ -int -xmlTextWriterWriteAttribute(xmlTextWriterPtr writer, const xmlChar * name, - const xmlChar * content) -{ - int count; - int sum; - - sum = 0; - count = xmlTextWriterStartAttribute(writer, name); - if (count < 0) - return -1; - sum += count; - count = xmlTextWriterWriteString(writer, content); - if (count < 0) - return -1; - sum += count; - count = xmlTextWriterEndAttribute(writer); - if (count < 0) - return -1; - sum += count; - - return sum; -} - -/** - * xmlTextWriterWriteFormatAttributeNS: - * @writer: the xmlTextWriterPtr - * @prefix: namespace prefix - * @name: attribute local name - * @namespaceURI: namespace URI - * @format: format string (see printf) - * @...: extra parameters for the format - * - * Write a formatted xml attribute.with namespace support - * - * Returns the bytes written (may be 0 because of buffering) or -1 in case of error - */ -int XMLCDECL -xmlTextWriterWriteFormatAttributeNS(xmlTextWriterPtr writer, - const xmlChar * prefix, - const xmlChar * name, - const xmlChar * namespaceURI, - const char *format, ...) -{ - int rc; - va_list ap; - - va_start(ap, format); - - rc = xmlTextWriterWriteVFormatAttributeNS(writer, prefix, name, - namespaceURI, format, ap); - - va_end(ap); - return rc; -} - -/** - * xmlTextWriterWriteVFormatAttributeNS: - * @writer: the xmlTextWriterPtr - * @prefix: namespace prefix - * @name: attribute local name - * @namespaceURI: namespace URI - * @format: format string (see printf) - * @argptr: pointer to the first member of the variable argument list. - * - * Write a formatted xml attribute.with namespace support - * - * Returns the bytes written (may be 0 because of buffering) or -1 in case of error - */ -int -xmlTextWriterWriteVFormatAttributeNS(xmlTextWriterPtr writer, - const xmlChar * prefix, - const xmlChar * name, - const xmlChar * namespaceURI, - const char *format, va_list argptr) -{ - int rc; - xmlChar *buf; - - if (writer == NULL) - return -1; - - buf = xmlTextWriterVSprintf(format, argptr); - if (buf == NULL) - return -1; - - rc = xmlTextWriterWriteAttributeNS(writer, prefix, name, namespaceURI, - buf); - - xmlFree(buf); - return rc; -} - -/** - * xmlTextWriterWriteAttributeNS: - * @writer: the xmlTextWriterPtr - * @prefix: namespace prefix - * @name: attribute local name - * @namespaceURI: namespace URI - * @content: attribute content - * - * Write an xml attribute. - * - * Returns the bytes written (may be 0 because of buffering) or -1 in case of error - */ -int -xmlTextWriterWriteAttributeNS(xmlTextWriterPtr writer, - const xmlChar * prefix, const xmlChar * name, - const xmlChar * namespaceURI, - const xmlChar * content) -{ - int count; - int sum; - - if ((writer == NULL) || (name == NULL) || (*name == '\0')) - return -1; - - sum = 0; - count = xmlTextWriterStartAttributeNS(writer, prefix, name, namespaceURI); - if (count < 0) - return -1; - sum += count; - count = xmlTextWriterWriteString(writer, content); - if (count < 0) - return -1; - sum += count; - count = xmlTextWriterEndAttribute(writer); - if (count < 0) - return -1; - sum += count; - - return sum; -} - -/** - * xmlTextWriterWriteFormatElement: - * @writer: the xmlTextWriterPtr - * @name: element name - * @format: format string (see printf) - * @...: extra parameters for the format - * - * Write a formatted xml element. - * - * Returns the bytes written (may be 0 because of buffering) or -1 in case of error - */ -int XMLCDECL -xmlTextWriterWriteFormatElement(xmlTextWriterPtr writer, - const xmlChar * name, const char *format, - ...) -{ - int rc; - va_list ap; - - va_start(ap, format); - - rc = xmlTextWriterWriteVFormatElement(writer, name, format, ap); - - va_end(ap); - return rc; -} - -/** - * xmlTextWriterWriteVFormatElement: - * @writer: the xmlTextWriterPtr - * @name: element name - * @format: format string (see printf) - * @argptr: pointer to the first member of the variable argument list. - * - * Write a formatted xml element. - * - * Returns the bytes written (may be 0 because of buffering) or -1 in case of error - */ -int -xmlTextWriterWriteVFormatElement(xmlTextWriterPtr writer, - const xmlChar * name, const char *format, - va_list argptr) -{ - int rc; - xmlChar *buf; - - if (writer == NULL) - return -1; - - buf = xmlTextWriterVSprintf(format, argptr); - if (buf == NULL) - return -1; - - rc = xmlTextWriterWriteElement(writer, name, buf); - - xmlFree(buf); - return rc; -} - -/** - * xmlTextWriterWriteElement: - * @writer: the xmlTextWriterPtr - * @name: element name - * @content: element content - * - * Write an xml element. - * - * Returns the bytes written (may be 0 because of buffering) or -1 in case of error - */ -int -xmlTextWriterWriteElement(xmlTextWriterPtr writer, const xmlChar * name, - const xmlChar * content) -{ - int count; - int sum; - - sum = 0; - count = xmlTextWriterStartElement(writer, name); - if (count == -1) - return -1; - sum += count; - count = xmlTextWriterWriteString(writer, content); - if (count == -1) - return -1; - sum += count; - count = xmlTextWriterEndElement(writer); - if (count == -1) - return -1; - sum += count; - - return sum; -} - -/** - * xmlTextWriterWriteFormatElementNS: - * @writer: the xmlTextWriterPtr - * @prefix: namespace prefix - * @name: element local name - * @namespaceURI: namespace URI - * @format: format string (see printf) - * @...: extra parameters for the format - * - * Write a formatted xml element with namespace support. - * - * Returns the bytes written (may be 0 because of buffering) or -1 in case of error - */ -int XMLCDECL -xmlTextWriterWriteFormatElementNS(xmlTextWriterPtr writer, - const xmlChar * prefix, - const xmlChar * name, - const xmlChar * namespaceURI, - const char *format, ...) -{ - int rc; - va_list ap; - - va_start(ap, format); - - rc = xmlTextWriterWriteVFormatElementNS(writer, prefix, name, - namespaceURI, format, ap); - - va_end(ap); - return rc; -} - -/** - * xmlTextWriterWriteVFormatElementNS: - * @writer: the xmlTextWriterPtr - * @prefix: namespace prefix - * @name: element local name - * @namespaceURI: namespace URI - * @format: format string (see printf) - * @argptr: pointer to the first member of the variable argument list. - * - * Write a formatted xml element with namespace support. - * - * Returns the bytes written (may be 0 because of buffering) or -1 in case of error - */ -int -xmlTextWriterWriteVFormatElementNS(xmlTextWriterPtr writer, - const xmlChar * prefix, - const xmlChar * name, - const xmlChar * namespaceURI, - const char *format, va_list argptr) -{ - int rc; - xmlChar *buf; - - if (writer == NULL) - return -1; - - buf = xmlTextWriterVSprintf(format, argptr); - if (buf == NULL) - return -1; - - rc = xmlTextWriterWriteElementNS(writer, prefix, name, namespaceURI, - buf); - - xmlFree(buf); - return rc; -} - -/** - * xmlTextWriterWriteElementNS: - * @writer: the xmlTextWriterPtr - * @prefix: namespace prefix - * @name: element local name - * @namespaceURI: namespace URI - * @content: element content - * - * Write an xml element with namespace support. - * - * Returns the bytes written (may be 0 because of buffering) or -1 in case of error - */ -int -xmlTextWriterWriteElementNS(xmlTextWriterPtr writer, - const xmlChar * prefix, const xmlChar * name, - const xmlChar * namespaceURI, - const xmlChar * content) -{ - int count; - int sum; - - if ((writer == NULL) || (name == NULL) || (*name == '\0')) - return -1; - - sum = 0; - count = - xmlTextWriterStartElementNS(writer, prefix, name, namespaceURI); - if (count < 0) - return -1; - sum += count; - count = xmlTextWriterWriteString(writer, content); - if (count == -1) - return -1; - sum += count; - count = xmlTextWriterEndElement(writer); - if (count == -1) - return -1; - sum += count; - - return sum; -} - -/** - * xmlTextWriterStartPI: - * @writer: the xmlTextWriterPtr - * @target: PI target - * - * Start an xml PI. - * - * Returns the bytes written (may be 0 because of buffering) or -1 in case of error - */ -int -xmlTextWriterStartPI(xmlTextWriterPtr writer, const xmlChar * target) -{ - int count; - int sum; - xmlLinkPtr lk; - xmlTextWriterStackEntry *p; - - if ((writer == NULL) || (target == NULL) || (*target == '\0')) - return -1; - - if (xmlStrcasecmp(target, (const xmlChar *) "xml") == 0) { - xmlWriterErrMsg(writer, XML_ERR_INTERNAL_ERROR, - "xmlTextWriterStartPI : target name [Xx][Mm][Ll] is reserved for xml standardization!\n"); - return -1; - } - - sum = 0; - lk = xmlListFront(writer->nodes); - if (lk != 0) { - p = (xmlTextWriterStackEntry *) xmlLinkGetData(lk); - if (p != 0) { - switch (p->state) { - case XML_TEXTWRITER_ATTRIBUTE: - count = xmlTextWriterEndAttribute(writer); - if (count < 0) - return -1; - sum += count; - /* fallthrough */ - case XML_TEXTWRITER_NAME: - /* Output namespace declarations */ - count = xmlTextWriterOutputNSDecl(writer); - if (count < 0) - return -1; - sum += count; - count = xmlOutputBufferWriteString(writer->out, ">"); - if (count < 0) - return -1; - sum += count; - p->state = XML_TEXTWRITER_TEXT; - break; - case XML_TEXTWRITER_NONE: - case XML_TEXTWRITER_TEXT: - case XML_TEXTWRITER_DTD: - break; - case XML_TEXTWRITER_PI: - case XML_TEXTWRITER_PI_TEXT: - xmlWriterErrMsg(writer, XML_ERR_INTERNAL_ERROR, - "xmlTextWriterStartPI : nested PI!\n"); - return -1; - default: - return -1; - } - } - } - - p = (xmlTextWriterStackEntry *) - xmlMalloc(sizeof(xmlTextWriterStackEntry)); - if (p == 0) { - xmlWriterErrMsg(writer, XML_ERR_NO_MEMORY, - "xmlTextWriterStartPI : out of memory!\n"); - return -1; - } - - p->name = xmlStrdup(target); - if (p->name == 0) { - xmlWriterErrMsg(writer, XML_ERR_NO_MEMORY, - "xmlTextWriterStartPI : out of memory!\n"); - xmlFree(p); - return -1; - } - p->state = XML_TEXTWRITER_PI; - - xmlListPushFront(writer->nodes, p); - - count = xmlOutputBufferWriteString(writer->out, "out, (const char *) p->name); - if (count < 0) - return -1; - sum += count; - - return sum; -} - -/** - * xmlTextWriterEndPI: - * @writer: the xmlTextWriterPtr - * - * End the current xml PI. - * - * Returns the bytes written (may be 0 because of buffering) or -1 in case of error - */ -int -xmlTextWriterEndPI(xmlTextWriterPtr writer) -{ - int count; - int sum; - xmlLinkPtr lk; - xmlTextWriterStackEntry *p; - - if (writer == NULL) - return -1; - - lk = xmlListFront(writer->nodes); - if (lk == 0) - return 0; - - p = (xmlTextWriterStackEntry *) xmlLinkGetData(lk); - if (p == 0) - return 0; - - sum = 0; - switch (p->state) { - case XML_TEXTWRITER_PI: - case XML_TEXTWRITER_PI_TEXT: - count = xmlOutputBufferWriteString(writer->out, "?>"); - if (count < 0) - return -1; - sum += count; - break; - default: - return -1; - } - - if (writer->indent) { - count = xmlOutputBufferWriteString(writer->out, "\n"); - if (count < 0) - return -1; - sum += count; - } - - xmlListPopFront(writer->nodes); - return sum; -} - -/** - * xmlTextWriterWriteFormatPI: - * @writer: the xmlTextWriterPtr - * @target: PI target - * @format: format string (see printf) - * @...: extra parameters for the format - * - * Write a formatted PI. - * - * Returns the bytes written (may be 0 because of buffering) or -1 in case of error - */ -int XMLCDECL -xmlTextWriterWriteFormatPI(xmlTextWriterPtr writer, const xmlChar * target, - const char *format, ...) -{ - int rc; - va_list ap; - - va_start(ap, format); - - rc = xmlTextWriterWriteVFormatPI(writer, target, format, ap); - - va_end(ap); - return rc; -} - -/** - * xmlTextWriterWriteVFormatPI: - * @writer: the xmlTextWriterPtr - * @target: PI target - * @format: format string (see printf) - * @argptr: pointer to the first member of the variable argument list. - * - * Write a formatted xml PI. - * - * Returns the bytes written (may be 0 because of buffering) or -1 in case of error - */ -int -xmlTextWriterWriteVFormatPI(xmlTextWriterPtr writer, - const xmlChar * target, const char *format, - va_list argptr) -{ - int rc; - xmlChar *buf; - - if (writer == NULL) - return -1; - - buf = xmlTextWriterVSprintf(format, argptr); - if (buf == NULL) - return -1; - - rc = xmlTextWriterWritePI(writer, target, buf); - - xmlFree(buf); - return rc; -} - -/** - * xmlTextWriterWritePI: - * @writer: the xmlTextWriterPtr - * @target: PI target - * @content: PI content - * - * Write an xml PI. - * - * Returns the bytes written (may be 0 because of buffering) or -1 in case of error - */ -int -xmlTextWriterWritePI(xmlTextWriterPtr writer, const xmlChar * target, - const xmlChar * content) -{ - int count; - int sum; - - sum = 0; - count = xmlTextWriterStartPI(writer, target); - if (count == -1) - return -1; - sum += count; - if (content != 0) { - count = xmlTextWriterWriteString(writer, content); - if (count == -1) - return -1; - sum += count; - } - count = xmlTextWriterEndPI(writer); - if (count == -1) - return -1; - sum += count; - - return sum; -} - -/** - * xmlTextWriterStartCDATA: - * @writer: the xmlTextWriterPtr - * - * Start an xml CDATA section. - * - * Returns the bytes written (may be 0 because of buffering) or -1 in case of error - */ -int -xmlTextWriterStartCDATA(xmlTextWriterPtr writer) -{ - int count; - int sum; - xmlLinkPtr lk; - xmlTextWriterStackEntry *p; - - if (writer == NULL) - return -1; - - sum = 0; - lk = xmlListFront(writer->nodes); - if (lk != 0) { - p = (xmlTextWriterStackEntry *) xmlLinkGetData(lk); - if (p != 0) { - switch (p->state) { - case XML_TEXTWRITER_NONE: - case XML_TEXTWRITER_TEXT: - case XML_TEXTWRITER_PI: - case XML_TEXTWRITER_PI_TEXT: - break; - case XML_TEXTWRITER_ATTRIBUTE: - count = xmlTextWriterEndAttribute(writer); - if (count < 0) - return -1; - sum += count; - /* fallthrough */ - case XML_TEXTWRITER_NAME: - /* Output namespace declarations */ - count = xmlTextWriterOutputNSDecl(writer); - if (count < 0) - return -1; - sum += count; - count = xmlOutputBufferWriteString(writer->out, ">"); - if (count < 0) - return -1; - sum += count; - p->state = XML_TEXTWRITER_TEXT; - break; - case XML_TEXTWRITER_CDATA: - xmlWriterErrMsg(writer, XML_ERR_INTERNAL_ERROR, - "xmlTextWriterStartCDATA : CDATA not allowed in this context!\n"); - return -1; - default: - return -1; - } - } - } - - p = (xmlTextWriterStackEntry *) - xmlMalloc(sizeof(xmlTextWriterStackEntry)); - if (p == 0) { - xmlWriterErrMsg(writer, XML_ERR_NO_MEMORY, - "xmlTextWriterStartCDATA : out of memory!\n"); - return -1; - } - - p->name = NULL; - p->state = XML_TEXTWRITER_CDATA; - - xmlListPushFront(writer->nodes, p); - - count = xmlOutputBufferWriteString(writer->out, "nodes); - if (lk == 0) - return -1; - - p = (xmlTextWriterStackEntry *) xmlLinkGetData(lk); - if (p == 0) - return -1; - - sum = 0; - switch (p->state) { - case XML_TEXTWRITER_CDATA: - count = xmlOutputBufferWriteString(writer->out, "]]>"); - if (count < 0) - return -1; - sum += count; - break; - default: - return -1; - } - - xmlListPopFront(writer->nodes); - return sum; -} - -/** - * xmlTextWriterWriteFormatCDATA: - * @writer: the xmlTextWriterPtr - * @format: format string (see printf) - * @...: extra parameters for the format - * - * Write a formatted xml CDATA. - * - * Returns the bytes written (may be 0 because of buffering) or -1 in case of error - */ -int XMLCDECL -xmlTextWriterWriteFormatCDATA(xmlTextWriterPtr writer, const char *format, - ...) -{ - int rc; - va_list ap; - - va_start(ap, format); - - rc = xmlTextWriterWriteVFormatCDATA(writer, format, ap); - - va_end(ap); - return rc; -} - -/** - * xmlTextWriterWriteVFormatCDATA: - * @writer: the xmlTextWriterPtr - * @format: format string (see printf) - * @argptr: pointer to the first member of the variable argument list. - * - * Write a formatted xml CDATA. - * - * Returns the bytes written (may be 0 because of buffering) or -1 in case of error - */ -int -xmlTextWriterWriteVFormatCDATA(xmlTextWriterPtr writer, const char *format, - va_list argptr) -{ - int rc; - xmlChar *buf; - - if (writer == NULL) - return -1; - - buf = xmlTextWriterVSprintf(format, argptr); - if (buf == NULL) - return -1; - - rc = xmlTextWriterWriteCDATA(writer, buf); - - xmlFree(buf); - return rc; -} - -/** - * xmlTextWriterWriteCDATA: - * @writer: the xmlTextWriterPtr - * @content: CDATA content - * - * Write an xml CDATA. - * - * Returns the bytes written (may be 0 because of buffering) or -1 in case of error - */ -int -xmlTextWriterWriteCDATA(xmlTextWriterPtr writer, const xmlChar * content) -{ - int count; - int sum; - - sum = 0; - count = xmlTextWriterStartCDATA(writer); - if (count == -1) - return -1; - sum += count; - if (content != 0) { - count = xmlTextWriterWriteString(writer, content); - if (count == -1) - return -1; - sum += count; - } - count = xmlTextWriterEndCDATA(writer); - if (count == -1) - return -1; - sum += count; - - return sum; -} - -/** - * xmlTextWriterStartDTD: - * @writer: the xmlTextWriterPtr - * @name: the name of the DTD - * @pubid: the public identifier, which is an alternative to the system identifier - * @sysid: the system identifier, which is the URI of the DTD - * - * Start an xml DTD. - * - * Returns the bytes written (may be 0 because of buffering) or -1 in case of error - */ -int -xmlTextWriterStartDTD(xmlTextWriterPtr writer, - const xmlChar * name, - const xmlChar * pubid, const xmlChar * sysid) -{ - int count; - int sum; - xmlLinkPtr lk; - xmlTextWriterStackEntry *p; - - if (writer == NULL || name == NULL || *name == '\0') - return -1; - - sum = 0; - lk = xmlListFront(writer->nodes); - if ((lk != NULL) && (xmlLinkGetData(lk) != NULL)) { - xmlWriterErrMsg(writer, XML_ERR_INTERNAL_ERROR, - "xmlTextWriterStartDTD : DTD allowed only in prolog!\n"); - return -1; - } - - p = (xmlTextWriterStackEntry *) - xmlMalloc(sizeof(xmlTextWriterStackEntry)); - if (p == 0) { - xmlWriterErrMsg(writer, XML_ERR_NO_MEMORY, - "xmlTextWriterStartDTD : out of memory!\n"); - return -1; - } - - p->name = xmlStrdup(name); - if (p->name == 0) { - xmlWriterErrMsg(writer, XML_ERR_NO_MEMORY, - "xmlTextWriterStartDTD : out of memory!\n"); - xmlFree(p); - return -1; - } - p->state = XML_TEXTWRITER_DTD; - - xmlListPushFront(writer->nodes, p); - - count = xmlOutputBufferWriteString(writer->out, "out, (const char *) name); - if (count < 0) - return -1; - sum += count; - - if (pubid != 0) { - if (sysid == 0) { - xmlWriterErrMsg(writer, XML_ERR_INTERNAL_ERROR, - "xmlTextWriterStartDTD : system identifier needed!\n"); - return -1; - } - - if (writer->indent) - count = xmlOutputBufferWrite(writer->out, 1, "\n"); - else - count = xmlOutputBufferWrite(writer->out, 1, " "); - if (count < 0) - return -1; - sum += count; - - count = xmlOutputBufferWriteString(writer->out, "PUBLIC "); - if (count < 0) - return -1; - sum += count; - - count = xmlOutputBufferWrite(writer->out, 1, &writer->qchar); - if (count < 0) - return -1; - sum += count; - - count = - xmlOutputBufferWriteString(writer->out, (const char *) pubid); - if (count < 0) - return -1; - sum += count; - - count = xmlOutputBufferWrite(writer->out, 1, &writer->qchar); - if (count < 0) - return -1; - sum += count; - } - - if (sysid != 0) { - if (pubid == 0) { - if (writer->indent) - count = xmlOutputBufferWrite(writer->out, 1, "\n"); - else - count = xmlOutputBufferWrite(writer->out, 1, " "); - if (count < 0) - return -1; - sum += count; - count = xmlOutputBufferWriteString(writer->out, "SYSTEM "); - if (count < 0) - return -1; - sum += count; - } else { - if (writer->indent) - count = xmlOutputBufferWriteString(writer->out, "\n "); - else - count = xmlOutputBufferWrite(writer->out, 1, " "); - if (count < 0) - return -1; - sum += count; - } - - count = xmlOutputBufferWrite(writer->out, 1, &writer->qchar); - if (count < 0) - return -1; - sum += count; - - count = - xmlOutputBufferWriteString(writer->out, (const char *) sysid); - if (count < 0) - return -1; - sum += count; - - count = xmlOutputBufferWrite(writer->out, 1, &writer->qchar); - if (count < 0) - return -1; - sum += count; - } - - return sum; -} - -/** - * xmlTextWriterEndDTD: - * @writer: the xmlTextWriterPtr - * - * End an xml DTD. - * - * Returns the bytes written (may be 0 because of buffering) or -1 in case of error - */ -int -xmlTextWriterEndDTD(xmlTextWriterPtr writer) -{ - int loop; - int count; - int sum; - xmlLinkPtr lk; - xmlTextWriterStackEntry *p; - - if (writer == NULL) - return -1; - - sum = 0; - loop = 1; - while (loop) { - lk = xmlListFront(writer->nodes); - if (lk == NULL) - break; - p = (xmlTextWriterStackEntry *) xmlLinkGetData(lk); - if (p == 0) - break; - switch (p->state) { - case XML_TEXTWRITER_DTD_TEXT: - count = xmlOutputBufferWriteString(writer->out, "]"); - if (count < 0) - return -1; - sum += count; - /* fallthrough */ - case XML_TEXTWRITER_DTD: - count = xmlOutputBufferWriteString(writer->out, ">"); - - if (writer->indent) { - if (count < 0) - return -1; - sum += count; - count = xmlOutputBufferWriteString(writer->out, "\n"); - } - - xmlListPopFront(writer->nodes); - break; - case XML_TEXTWRITER_DTD_ELEM: - case XML_TEXTWRITER_DTD_ELEM_TEXT: - count = xmlTextWriterEndDTDElement(writer); - break; - case XML_TEXTWRITER_DTD_ATTL: - case XML_TEXTWRITER_DTD_ATTL_TEXT: - count = xmlTextWriterEndDTDAttlist(writer); - break; - case XML_TEXTWRITER_DTD_ENTY: - case XML_TEXTWRITER_DTD_PENT: - case XML_TEXTWRITER_DTD_ENTY_TEXT: - count = xmlTextWriterEndDTDEntity(writer); - break; - case XML_TEXTWRITER_COMMENT: - count = xmlTextWriterEndComment(writer); - break; - default: - loop = 0; - continue; - } - - if (count < 0) - return -1; - sum += count; - } - - return sum; -} - -/** - * xmlTextWriterWriteFormatDTD: - * @writer: the xmlTextWriterPtr - * @name: the name of the DTD - * @pubid: the public identifier, which is an alternative to the system identifier - * @sysid: the system identifier, which is the URI of the DTD - * @format: format string (see printf) - * @...: extra parameters for the format - * - * Write a DTD with a formatted markup declarations part. - * - * Returns the bytes written (may be 0 because of buffering) or -1 in case of error - */ -int XMLCDECL -xmlTextWriterWriteFormatDTD(xmlTextWriterPtr writer, - const xmlChar * name, - const xmlChar * pubid, - const xmlChar * sysid, const char *format, ...) -{ - int rc; - va_list ap; - - va_start(ap, format); - - rc = xmlTextWriterWriteVFormatDTD(writer, name, pubid, sysid, format, - ap); - - va_end(ap); - return rc; -} - -/** - * xmlTextWriterWriteVFormatDTD: - * @writer: the xmlTextWriterPtr - * @name: the name of the DTD - * @pubid: the public identifier, which is an alternative to the system identifier - * @sysid: the system identifier, which is the URI of the DTD - * @format: format string (see printf) - * @argptr: pointer to the first member of the variable argument list. - * - * Write a DTD with a formatted markup declarations part. - * - * Returns the bytes written (may be 0 because of buffering) or -1 in case of error - */ -int -xmlTextWriterWriteVFormatDTD(xmlTextWriterPtr writer, - const xmlChar * name, - const xmlChar * pubid, - const xmlChar * sysid, - const char *format, va_list argptr) -{ - int rc; - xmlChar *buf; - - if (writer == NULL) - return -1; - - buf = xmlTextWriterVSprintf(format, argptr); - if (buf == NULL) - return -1; - - rc = xmlTextWriterWriteDTD(writer, name, pubid, sysid, buf); - - xmlFree(buf); - return rc; -} - -/** - * xmlTextWriterWriteDTD: - * @writer: the xmlTextWriterPtr - * @name: the name of the DTD - * @pubid: the public identifier, which is an alternative to the system identifier - * @sysid: the system identifier, which is the URI of the DTD - * @subset: string content of the DTD - * - * Write a DTD. - * - * Returns the bytes written (may be 0 because of buffering) or -1 in case of error - */ -int -xmlTextWriterWriteDTD(xmlTextWriterPtr writer, - const xmlChar * name, - const xmlChar * pubid, - const xmlChar * sysid, const xmlChar * subset) -{ - int count; - int sum; - - sum = 0; - count = xmlTextWriterStartDTD(writer, name, pubid, sysid); - if (count == -1) - return -1; - sum += count; - if (subset != 0) { - count = xmlTextWriterWriteString(writer, subset); - if (count == -1) - return -1; - sum += count; - } - count = xmlTextWriterEndDTD(writer); - if (count == -1) - return -1; - sum += count; - - return sum; -} - -/** - * xmlTextWriterStartDTDElement: - * @writer: the xmlTextWriterPtr - * @name: the name of the DTD element - * - * Start an xml DTD element. - * - * Returns the bytes written (may be 0 because of buffering) or -1 in case of error - */ -int -xmlTextWriterStartDTDElement(xmlTextWriterPtr writer, const xmlChar * name) -{ - int count; - int sum; - xmlLinkPtr lk; - xmlTextWriterStackEntry *p; - - if (writer == NULL || name == NULL || *name == '\0') - return -1; - - sum = 0; - lk = xmlListFront(writer->nodes); - if (lk == 0) { - return -1; - } - - p = (xmlTextWriterStackEntry *) xmlLinkGetData(lk); - if (p != 0) { - switch (p->state) { - case XML_TEXTWRITER_DTD: - count = xmlOutputBufferWriteString(writer->out, " ["); - if (count < 0) - return -1; - sum += count; - if (writer->indent) { - count = xmlOutputBufferWriteString(writer->out, "\n"); - if (count < 0) - return -1; - sum += count; - } - p->state = XML_TEXTWRITER_DTD_TEXT; - /* fallthrough */ - case XML_TEXTWRITER_DTD_TEXT: - case XML_TEXTWRITER_NONE: - break; - default: - return -1; - } - } - - p = (xmlTextWriterStackEntry *) - xmlMalloc(sizeof(xmlTextWriterStackEntry)); - if (p == 0) { - xmlWriterErrMsg(writer, XML_ERR_NO_MEMORY, - "xmlTextWriterStartDTDElement : out of memory!\n"); - return -1; - } - - p->name = xmlStrdup(name); - if (p->name == 0) { - xmlWriterErrMsg(writer, XML_ERR_NO_MEMORY, - "xmlTextWriterStartDTDElement : out of memory!\n"); - xmlFree(p); - return -1; - } - p->state = XML_TEXTWRITER_DTD_ELEM; - - xmlListPushFront(writer->nodes, p); - - if (writer->indent) { - count = xmlTextWriterWriteIndent(writer); - if (count < 0) - return -1; - sum += count; - } - - count = xmlOutputBufferWriteString(writer->out, "out, (const char *) name); - if (count < 0) - return -1; - sum += count; - - return sum; -} - -/** - * xmlTextWriterEndDTDElement: - * @writer: the xmlTextWriterPtr - * - * End an xml DTD element. - * - * Returns the bytes written (may be 0 because of buffering) or -1 in case of error - */ -int -xmlTextWriterEndDTDElement(xmlTextWriterPtr writer) -{ - int count; - int sum; - xmlLinkPtr lk; - xmlTextWriterStackEntry *p; - - if (writer == NULL) - return -1; - - sum = 0; - lk = xmlListFront(writer->nodes); - if (lk == 0) - return -1; - - p = (xmlTextWriterStackEntry *) xmlLinkGetData(lk); - if (p == 0) - return -1; - - switch (p->state) { - case XML_TEXTWRITER_DTD_ELEM: - case XML_TEXTWRITER_DTD_ELEM_TEXT: - count = xmlOutputBufferWriteString(writer->out, ">"); - if (count < 0) - return -1; - sum += count; - break; - default: - return -1; - } - - if (writer->indent) { - count = xmlOutputBufferWriteString(writer->out, "\n"); - if (count < 0) - return -1; - sum += count; - } - - xmlListPopFront(writer->nodes); - return sum; -} - -/** - * xmlTextWriterWriteFormatDTDElement: - * @writer: the xmlTextWriterPtr - * @name: the name of the DTD element - * @format: format string (see printf) - * @...: extra parameters for the format - * - * Write a formatted DTD element. - * - * Returns the bytes written (may be 0 because of buffering) or -1 in case of error - */ -int XMLCDECL -xmlTextWriterWriteFormatDTDElement(xmlTextWriterPtr writer, - const xmlChar * name, - const char *format, ...) -{ - int rc; - va_list ap; - - va_start(ap, format); - - rc = xmlTextWriterWriteVFormatDTDElement(writer, name, format, ap); - - va_end(ap); - return rc; -} - -/** - * xmlTextWriterWriteVFormatDTDElement: - * @writer: the xmlTextWriterPtr - * @name: the name of the DTD element - * @format: format string (see printf) - * @argptr: pointer to the first member of the variable argument list. - * - * Write a formatted DTD element. - * - * Returns the bytes written (may be 0 because of buffering) or -1 in case of error - */ -int -xmlTextWriterWriteVFormatDTDElement(xmlTextWriterPtr writer, - const xmlChar * name, - const char *format, va_list argptr) -{ - int rc; - xmlChar *buf; - - if (writer == NULL) - return -1; - - buf = xmlTextWriterVSprintf(format, argptr); - if (buf == NULL) - return -1; - - rc = xmlTextWriterWriteDTDElement(writer, name, buf); - - xmlFree(buf); - return rc; -} - -/** - * xmlTextWriterWriteDTDElement: - * @writer: the xmlTextWriterPtr - * @name: the name of the DTD element - * @content: content of the element - * - * Write a DTD element. - * - * Returns the bytes written (may be 0 because of buffering) or -1 in case of error - */ -int -xmlTextWriterWriteDTDElement(xmlTextWriterPtr writer, - const xmlChar * name, const xmlChar * content) -{ - int count; - int sum; - - if (content == NULL) - return -1; - - sum = 0; - count = xmlTextWriterStartDTDElement(writer, name); - if (count == -1) - return -1; - sum += count; - - count = xmlTextWriterWriteString(writer, content); - if (count == -1) - return -1; - sum += count; - - count = xmlTextWriterEndDTDElement(writer); - if (count == -1) - return -1; - sum += count; - - return sum; -} - -/** - * xmlTextWriterStartDTDAttlist: - * @writer: the xmlTextWriterPtr - * @name: the name of the DTD ATTLIST - * - * Start an xml DTD ATTLIST. - * - * Returns the bytes written (may be 0 because of buffering) or -1 in case of error - */ -int -xmlTextWriterStartDTDAttlist(xmlTextWriterPtr writer, const xmlChar * name) -{ - int count; - int sum; - xmlLinkPtr lk; - xmlTextWriterStackEntry *p; - - if (writer == NULL || name == NULL || *name == '\0') - return -1; - - sum = 0; - lk = xmlListFront(writer->nodes); - if (lk == 0) { - return -1; - } - - p = (xmlTextWriterStackEntry *) xmlLinkGetData(lk); - if (p != 0) { - switch (p->state) { - case XML_TEXTWRITER_DTD: - count = xmlOutputBufferWriteString(writer->out, " ["); - if (count < 0) - return -1; - sum += count; - if (writer->indent) { - count = xmlOutputBufferWriteString(writer->out, "\n"); - if (count < 0) - return -1; - sum += count; - } - p->state = XML_TEXTWRITER_DTD_TEXT; - /* fallthrough */ - case XML_TEXTWRITER_DTD_TEXT: - case XML_TEXTWRITER_NONE: - break; - default: - return -1; - } - } - - p = (xmlTextWriterStackEntry *) - xmlMalloc(sizeof(xmlTextWriterStackEntry)); - if (p == 0) { - xmlWriterErrMsg(writer, XML_ERR_NO_MEMORY, - "xmlTextWriterStartDTDAttlist : out of memory!\n"); - return -1; - } - - p->name = xmlStrdup(name); - if (p->name == 0) { - xmlWriterErrMsg(writer, XML_ERR_NO_MEMORY, - "xmlTextWriterStartDTDAttlist : out of memory!\n"); - xmlFree(p); - return -1; - } - p->state = XML_TEXTWRITER_DTD_ATTL; - - xmlListPushFront(writer->nodes, p); - - if (writer->indent) { - count = xmlTextWriterWriteIndent(writer); - if (count < 0) - return -1; - sum += count; - } - - count = xmlOutputBufferWriteString(writer->out, "out, (const char *) name); - if (count < 0) - return -1; - sum += count; - - return sum; -} - -/** - * xmlTextWriterEndDTDAttlist: - * @writer: the xmlTextWriterPtr - * - * End an xml DTD attribute list. - * - * Returns the bytes written (may be 0 because of buffering) or -1 in case of error - */ -int -xmlTextWriterEndDTDAttlist(xmlTextWriterPtr writer) -{ - int count; - int sum; - xmlLinkPtr lk; - xmlTextWriterStackEntry *p; - - if (writer == NULL) - return -1; - - sum = 0; - lk = xmlListFront(writer->nodes); - if (lk == 0) - return -1; - - p = (xmlTextWriterStackEntry *) xmlLinkGetData(lk); - if (p == 0) - return -1; - - switch (p->state) { - case XML_TEXTWRITER_DTD_ATTL: - case XML_TEXTWRITER_DTD_ATTL_TEXT: - count = xmlOutputBufferWriteString(writer->out, ">"); - if (count < 0) - return -1; - sum += count; - break; - default: - return -1; - } - - if (writer->indent) { - count = xmlOutputBufferWriteString(writer->out, "\n"); - if (count < 0) - return -1; - sum += count; - } - - xmlListPopFront(writer->nodes); - return sum; -} - -/** - * xmlTextWriterWriteFormatDTDAttlist: - * @writer: the xmlTextWriterPtr - * @name: the name of the DTD ATTLIST - * @format: format string (see printf) - * @...: extra parameters for the format - * - * Write a formatted DTD ATTLIST. - * - * Returns the bytes written (may be 0 because of buffering) or -1 in case of error - */ -int XMLCDECL -xmlTextWriterWriteFormatDTDAttlist(xmlTextWriterPtr writer, - const xmlChar * name, - const char *format, ...) -{ - int rc; - va_list ap; - - va_start(ap, format); - - rc = xmlTextWriterWriteVFormatDTDAttlist(writer, name, format, ap); - - va_end(ap); - return rc; -} - -/** - * xmlTextWriterWriteVFormatDTDAttlist: - * @writer: the xmlTextWriterPtr - * @name: the name of the DTD ATTLIST - * @format: format string (see printf) - * @argptr: pointer to the first member of the variable argument list. - * - * Write a formatted DTD ATTLIST. - * - * Returns the bytes written (may be 0 because of buffering) or -1 in case of error - */ -int -xmlTextWriterWriteVFormatDTDAttlist(xmlTextWriterPtr writer, - const xmlChar * name, - const char *format, va_list argptr) -{ - int rc; - xmlChar *buf; - - if (writer == NULL) - return -1; - - buf = xmlTextWriterVSprintf(format, argptr); - if (buf == NULL) - return -1; - - rc = xmlTextWriterWriteDTDAttlist(writer, name, buf); - - xmlFree(buf); - return rc; -} - -/** - * xmlTextWriterWriteDTDAttlist: - * @writer: the xmlTextWriterPtr - * @name: the name of the DTD ATTLIST - * @content: content of the ATTLIST - * - * Write a DTD ATTLIST. - * - * Returns the bytes written (may be 0 because of buffering) or -1 in case of error - */ -int -xmlTextWriterWriteDTDAttlist(xmlTextWriterPtr writer, - const xmlChar * name, const xmlChar * content) -{ - int count; - int sum; - - if (content == NULL) - return -1; - - sum = 0; - count = xmlTextWriterStartDTDAttlist(writer, name); - if (count == -1) - return -1; - sum += count; - - count = xmlTextWriterWriteString(writer, content); - if (count == -1) - return -1; - sum += count; - - count = xmlTextWriterEndDTDAttlist(writer); - if (count == -1) - return -1; - sum += count; - - return sum; -} - -/** - * xmlTextWriterStartDTDEntity: - * @writer: the xmlTextWriterPtr - * @pe: TRUE if this is a parameter entity, FALSE if not - * @name: the name of the DTD ATTLIST - * - * Start an xml DTD ATTLIST. - * - * Returns the bytes written (may be 0 because of buffering) or -1 in case of error - */ -int -xmlTextWriterStartDTDEntity(xmlTextWriterPtr writer, - int pe, const xmlChar * name) -{ - int count; - int sum; - xmlLinkPtr lk; - xmlTextWriterStackEntry *p; - - if (writer == NULL || name == NULL || *name == '\0') - return -1; - - sum = 0; - lk = xmlListFront(writer->nodes); - if (lk != 0) { - - p = (xmlTextWriterStackEntry *) xmlLinkGetData(lk); - if (p != 0) { - switch (p->state) { - case XML_TEXTWRITER_DTD: - count = xmlOutputBufferWriteString(writer->out, " ["); - if (count < 0) - return -1; - sum += count; - if (writer->indent) { - count = - xmlOutputBufferWriteString(writer->out, "\n"); - if (count < 0) - return -1; - sum += count; - } - p->state = XML_TEXTWRITER_DTD_TEXT; - /* fallthrough */ - case XML_TEXTWRITER_DTD_TEXT: - case XML_TEXTWRITER_NONE: - break; - default: - return -1; - } - } - } - - p = (xmlTextWriterStackEntry *) - xmlMalloc(sizeof(xmlTextWriterStackEntry)); - if (p == 0) { - xmlWriterErrMsg(writer, XML_ERR_NO_MEMORY, - "xmlTextWriterStartDTDElement : out of memory!\n"); - return -1; - } - - p->name = xmlStrdup(name); - if (p->name == 0) { - xmlWriterErrMsg(writer, XML_ERR_NO_MEMORY, - "xmlTextWriterStartDTDElement : out of memory!\n"); - xmlFree(p); - return -1; - } - - if (pe != 0) - p->state = XML_TEXTWRITER_DTD_PENT; - else - p->state = XML_TEXTWRITER_DTD_ENTY; - - xmlListPushFront(writer->nodes, p); - - if (writer->indent) { - count = xmlTextWriterWriteIndent(writer); - if (count < 0) - return -1; - sum += count; - } - - count = xmlOutputBufferWriteString(writer->out, "out, "% "); - if (count < 0) - return -1; - sum += count; - } - - count = xmlOutputBufferWriteString(writer->out, (const char *) name); - if (count < 0) - return -1; - sum += count; - - return sum; -} - -/** - * xmlTextWriterEndDTDEntity: - * @writer: the xmlTextWriterPtr - * - * End an xml DTD entity. - * - * Returns the bytes written (may be 0 because of buffering) or -1 in case of error - */ -int -xmlTextWriterEndDTDEntity(xmlTextWriterPtr writer) -{ - int count; - int sum; - xmlLinkPtr lk; - xmlTextWriterStackEntry *p; - - if (writer == NULL) - return -1; - - sum = 0; - lk = xmlListFront(writer->nodes); - if (lk == 0) - return -1; - - p = (xmlTextWriterStackEntry *) xmlLinkGetData(lk); - if (p == 0) - return -1; - - switch (p->state) { - case XML_TEXTWRITER_DTD_ENTY_TEXT: - count = xmlOutputBufferWrite(writer->out, 1, &writer->qchar); - if (count < 0) - return -1; - sum += count; - case XML_TEXTWRITER_DTD_ENTY: - case XML_TEXTWRITER_DTD_PENT: - count = xmlOutputBufferWriteString(writer->out, ">"); - if (count < 0) - return -1; - sum += count; - break; - default: - return -1; - } - - if (writer->indent) { - count = xmlOutputBufferWriteString(writer->out, "\n"); - if (count < 0) - return -1; - sum += count; - } - - xmlListPopFront(writer->nodes); - return sum; -} - -/** - * xmlTextWriterWriteFormatDTDInternalEntity: - * @writer: the xmlTextWriterPtr - * @pe: TRUE if this is a parameter entity, FALSE if not - * @name: the name of the DTD entity - * @format: format string (see printf) - * @...: extra parameters for the format - * - * Write a formatted DTD internal entity. - * - * Returns the bytes written (may be 0 because of buffering) or -1 in case of error - */ -int XMLCDECL -xmlTextWriterWriteFormatDTDInternalEntity(xmlTextWriterPtr writer, - int pe, - const xmlChar * name, - const char *format, ...) -{ - int rc; - va_list ap; - - va_start(ap, format); - - rc = xmlTextWriterWriteVFormatDTDInternalEntity(writer, pe, name, - format, ap); - - va_end(ap); - return rc; -} - -/** - * xmlTextWriterWriteVFormatDTDInternalEntity: - * @writer: the xmlTextWriterPtr - * @pe: TRUE if this is a parameter entity, FALSE if not - * @name: the name of the DTD entity - * @format: format string (see printf) - * @argptr: pointer to the first member of the variable argument list. - * - * Write a formatted DTD internal entity. - * - * Returns the bytes written (may be 0 because of buffering) or -1 in case of error - */ -int -xmlTextWriterWriteVFormatDTDInternalEntity(xmlTextWriterPtr writer, - int pe, - const xmlChar * name, - const char *format, - va_list argptr) -{ - int rc; - xmlChar *buf; - - if (writer == NULL) - return -1; - - buf = xmlTextWriterVSprintf(format, argptr); - if (buf == NULL) - return -1; - - rc = xmlTextWriterWriteDTDInternalEntity(writer, pe, name, buf); - - xmlFree(buf); - return rc; -} - -/** - * xmlTextWriterWriteDTDEntity: - * @writer: the xmlTextWriterPtr - * @pe: TRUE if this is a parameter entity, FALSE if not - * @name: the name of the DTD entity - * @pubid: the public identifier, which is an alternative to the system identifier - * @sysid: the system identifier, which is the URI of the DTD - * @ndataid: the xml notation name. - * @content: content of the entity - * - * Write a DTD entity. - * - * Returns the bytes written (may be 0 because of buffering) or -1 in case of error - */ -int -xmlTextWriterWriteDTDEntity(xmlTextWriterPtr writer, - int pe, - const xmlChar * name, - const xmlChar * pubid, - const xmlChar * sysid, - const xmlChar * ndataid, - const xmlChar * content) -{ - if ((content == NULL) && (pubid == NULL) && (sysid == NULL)) - return -1; - if ((pe != 0) && (ndataid != NULL)) - return -1; - - if ((pubid == NULL) && (sysid == NULL)) - return xmlTextWriterWriteDTDInternalEntity(writer, pe, name, - content); - - return xmlTextWriterWriteDTDExternalEntity(writer, pe, name, pubid, - sysid, ndataid); -} - -/** - * xmlTextWriterWriteDTDInternalEntity: - * @writer: the xmlTextWriterPtr - * @pe: TRUE if this is a parameter entity, FALSE if not - * @name: the name of the DTD entity - * @content: content of the entity - * - * Write a DTD internal entity. - * - * Returns the bytes written (may be 0 because of buffering) or -1 in case of error - */ -int -xmlTextWriterWriteDTDInternalEntity(xmlTextWriterPtr writer, - int pe, - const xmlChar * name, - const xmlChar * content) -{ - int count; - int sum; - - if ((name == NULL) || (*name == '\0') || (content == NULL)) - return -1; - - sum = 0; - count = xmlTextWriterStartDTDEntity(writer, pe, name); - if (count == -1) - return -1; - sum += count; - - count = xmlTextWriterWriteString(writer, content); - if (count == -1) - return -1; - sum += count; - - count = xmlTextWriterEndDTDEntity(writer); - if (count == -1) - return -1; - sum += count; - - return sum; -} - -/** - * xmlTextWriterWriteDTDExternalEntity: - * @writer: the xmlTextWriterPtr - * @pe: TRUE if this is a parameter entity, FALSE if not - * @name: the name of the DTD entity - * @pubid: the public identifier, which is an alternative to the system identifier - * @sysid: the system identifier, which is the URI of the DTD - * @ndataid: the xml notation name. - * - * Write a DTD external entity. The entity must have been started with xmlTextWriterStartDTDEntity - * - * Returns the bytes written (may be 0 because of buffering) or -1 in case of error - */ -int -xmlTextWriterWriteDTDExternalEntity(xmlTextWriterPtr writer, - int pe, - const xmlChar * name, - const xmlChar * pubid, - const xmlChar * sysid, - const xmlChar * ndataid) -{ - int count; - int sum; - - if (((pubid == NULL) && (sysid == NULL))) - return -1; - if ((pe != 0) && (ndataid != NULL)) - return -1; - - sum = 0; - count = xmlTextWriterStartDTDEntity(writer, pe, name); - if (count == -1) - return -1; - sum += count; - - count = - xmlTextWriterWriteDTDExternalEntityContents(writer, pubid, sysid, - ndataid); - if (count < 0) - return -1; - sum += count; - - count = xmlTextWriterEndDTDEntity(writer); - if (count == -1) - return -1; - sum += count; - - return sum; -} - -/** - * xmlTextWriterWriteDTDExternalEntityContents: - * @writer: the xmlTextWriterPtr - * @pubid: the public identifier, which is an alternative to the system identifier - * @sysid: the system identifier, which is the URI of the DTD - * @ndataid: the xml notation name. - * - * Write the contents of a DTD external entity. - * - * Returns the bytes written (may be 0 because of buffering) or -1 in case of error - */ -int -xmlTextWriterWriteDTDExternalEntityContents(xmlTextWriterPtr writer, - const xmlChar * pubid, - const xmlChar * sysid, - const xmlChar * ndataid) -{ - int count; - int sum; - xmlLinkPtr lk; - xmlTextWriterStackEntry *p; - - if (writer == NULL) { - xmlWriterErrMsg(writer, XML_ERR_INTERNAL_ERROR, - "xmlTextWriterWriteDTDExternalEntityContents: xmlTextWriterPtr invalid!\n"); - return -1; - } - - sum = 0; - lk = xmlListFront(writer->nodes); - if (lk == 0) { - xmlWriterErrMsg(writer, XML_ERR_INTERNAL_ERROR, - "xmlTextWriterWriteDTDExternalEntityContents: you must call xmlTextWriterStartDTDEntity before the call to this function!\n"); - return -1; - } - - p = (xmlTextWriterStackEntry *) xmlLinkGetData(lk); - if (p == 0) - return -1; - - switch (p->state) { - case XML_TEXTWRITER_DTD_ENTY: - break; - case XML_TEXTWRITER_DTD_PENT: - if (ndataid != NULL) { - xmlWriterErrMsg(writer, XML_ERR_INTERNAL_ERROR, - "xmlTextWriterWriteDTDExternalEntityContents: notation not allowed with parameter entities!\n"); - return -1; - } - break; - default: - xmlWriterErrMsg(writer, XML_ERR_INTERNAL_ERROR, - "xmlTextWriterWriteDTDExternalEntityContents: you must call xmlTextWriterStartDTDEntity before the call to this function!\n"); - return -1; - } - - if (pubid != 0) { - if (sysid == 0) { - xmlWriterErrMsg(writer, XML_ERR_INTERNAL_ERROR, - "xmlTextWriterWriteDTDExternalEntityContents: system identifier needed!\n"); - return -1; - } - - count = xmlOutputBufferWriteString(writer->out, " PUBLIC "); - if (count < 0) - return -1; - sum += count; - - count = xmlOutputBufferWrite(writer->out, 1, &writer->qchar); - if (count < 0) - return -1; - sum += count; - - count = - xmlOutputBufferWriteString(writer->out, (const char *) pubid); - if (count < 0) - return -1; - sum += count; - - count = xmlOutputBufferWrite(writer->out, 1, &writer->qchar); - if (count < 0) - return -1; - sum += count; - } - - if (sysid != 0) { - if (pubid == 0) { - count = xmlOutputBufferWriteString(writer->out, " SYSTEM"); - if (count < 0) - return -1; - sum += count; - } - - count = xmlOutputBufferWriteString(writer->out, " "); - if (count < 0) - return -1; - sum += count; - - count = xmlOutputBufferWrite(writer->out, 1, &writer->qchar); - if (count < 0) - return -1; - sum += count; - - count = - xmlOutputBufferWriteString(writer->out, (const char *) sysid); - if (count < 0) - return -1; - sum += count; - - count = xmlOutputBufferWrite(writer->out, 1, &writer->qchar); - if (count < 0) - return -1; - sum += count; - } - - if (ndataid != NULL) { - count = xmlOutputBufferWriteString(writer->out, " NDATA "); - if (count < 0) - return -1; - sum += count; - - count = - xmlOutputBufferWriteString(writer->out, - (const char *) ndataid); - if (count < 0) - return -1; - sum += count; - } - - return sum; -} - -/** - * xmlTextWriterWriteDTDNotation: - * @writer: the xmlTextWriterPtr - * @name: the name of the xml notation - * @pubid: the public identifier, which is an alternative to the system identifier - * @sysid: the system identifier, which is the URI of the DTD - * - * Write a DTD entity. - * - * Returns the bytes written (may be 0 because of buffering) or -1 in case of error - */ -int -xmlTextWriterWriteDTDNotation(xmlTextWriterPtr writer, - const xmlChar * name, - const xmlChar * pubid, const xmlChar * sysid) -{ - int count; - int sum; - xmlLinkPtr lk; - xmlTextWriterStackEntry *p; - - if (writer == NULL || name == NULL || *name == '\0') - return -1; - - sum = 0; - lk = xmlListFront(writer->nodes); - if (lk == 0) { - return -1; - } - - p = (xmlTextWriterStackEntry *) xmlLinkGetData(lk); - if (p != 0) { - switch (p->state) { - case XML_TEXTWRITER_DTD: - count = xmlOutputBufferWriteString(writer->out, " ["); - if (count < 0) - return -1; - sum += count; - if (writer->indent) { - count = xmlOutputBufferWriteString(writer->out, "\n"); - if (count < 0) - return -1; - sum += count; - } - p->state = XML_TEXTWRITER_DTD_TEXT; - /* fallthrough */ - case XML_TEXTWRITER_DTD_TEXT: - break; - default: - return -1; - } - } - - if (writer->indent) { - count = xmlTextWriterWriteIndent(writer); - if (count < 0) - return -1; - sum += count; - } - - count = xmlOutputBufferWriteString(writer->out, "out, (const char *) name); - if (count < 0) - return -1; - sum += count; - - if (pubid != 0) { - count = xmlOutputBufferWriteString(writer->out, " PUBLIC "); - if (count < 0) - return -1; - sum += count; - count = xmlOutputBufferWrite(writer->out, 1, &writer->qchar); - if (count < 0) - return -1; - sum += count; - count = - xmlOutputBufferWriteString(writer->out, (const char *) pubid); - if (count < 0) - return -1; - sum += count; - count = xmlOutputBufferWrite(writer->out, 1, &writer->qchar); - if (count < 0) - return -1; - sum += count; - } - - if (sysid != 0) { - if (pubid == 0) { - count = xmlOutputBufferWriteString(writer->out, " SYSTEM"); - if (count < 0) - return -1; - sum += count; - } - count = xmlOutputBufferWriteString(writer->out, " "); - if (count < 0) - return -1; - sum += count; - count = xmlOutputBufferWrite(writer->out, 1, &writer->qchar); - if (count < 0) - return -1; - sum += count; - count = - xmlOutputBufferWriteString(writer->out, (const char *) sysid); - if (count < 0) - return -1; - sum += count; - count = xmlOutputBufferWrite(writer->out, 1, &writer->qchar); - if (count < 0) - return -1; - sum += count; - } - - count = xmlOutputBufferWriteString(writer->out, ">"); - if (count < 0) - return -1; - sum += count; - - return sum; -} - -/** - * xmlTextWriterFlush: - * @writer: the xmlTextWriterPtr - * - * Flush the output buffer. - * - * Returns the bytes written (may be 0 because of buffering) or -1 in case of error - */ -int -xmlTextWriterFlush(xmlTextWriterPtr writer) -{ - int count; - - if (writer == NULL) - return -1; - - if (writer->out == NULL) - count = 0; - else - count = xmlOutputBufferFlush(writer->out); - - return count; -} - -/** - * misc - */ - -/** - * xmlFreeTextWriterStackEntry: - * @lk: the xmlLinkPtr - * - * Free callback for the xmlList. - */ -static void -xmlFreeTextWriterStackEntry(xmlLinkPtr lk) -{ - xmlTextWriterStackEntry *p; - - p = (xmlTextWriterStackEntry *) xmlLinkGetData(lk); - if (p == 0) - return; - - if (p->name != 0) - xmlFree(p->name); - xmlFree(p); -} - -/** - * xmlCmpTextWriterStackEntry: - * @data0: the first data - * @data1: the second data - * - * Compare callback for the xmlList. - * - * Returns -1, 0, 1 - */ -static int -xmlCmpTextWriterStackEntry(const void *data0, const void *data1) -{ - xmlTextWriterStackEntry *p0; - xmlTextWriterStackEntry *p1; - - if (data0 == data1) - return 0; - - if (data0 == 0) - return -1; - - if (data1 == 0) - return 1; - - p0 = (xmlTextWriterStackEntry *) data0; - p1 = (xmlTextWriterStackEntry *) data1; - - return xmlStrcmp(p0->name, p1->name); -} - -/** - * misc - */ - -/** - * xmlTextWriterOutputNSDecl: - * @writer: the xmlTextWriterPtr - * - * Output the current namespace declarations. - */ -static int -xmlTextWriterOutputNSDecl(xmlTextWriterPtr writer) -{ - xmlLinkPtr lk; - xmlTextWriterNsStackEntry *np; - int count; - int sum; - - sum = 0; - while (!xmlListEmpty(writer->nsstack)) { - xmlChar *namespaceURI = NULL; - xmlChar *prefix = NULL; - - lk = xmlListFront(writer->nsstack); - np = (xmlTextWriterNsStackEntry *) xmlLinkGetData(lk); - - if (np != 0) { - namespaceURI = xmlStrdup(np->uri); - prefix = xmlStrdup(np->prefix); - } - - xmlListPopFront(writer->nsstack); - - if (np != 0) { - count = xmlTextWriterWriteAttribute(writer, prefix, namespaceURI); - xmlFree(namespaceURI); - xmlFree(prefix); - - if (count < 0) { - xmlListDelete(writer->nsstack); - writer->nsstack = NULL; - return -1; - } - sum += count; - } - } - return sum; -} - -/** - * xmlFreeTextWriterNsStackEntry: - * @lk: the xmlLinkPtr - * - * Free callback for the xmlList. - */ -static void -xmlFreeTextWriterNsStackEntry(xmlLinkPtr lk) -{ - xmlTextWriterNsStackEntry *p; - - p = (xmlTextWriterNsStackEntry *) xmlLinkGetData(lk); - if (p == 0) - return; - - if (p->prefix != 0) - xmlFree(p->prefix); - if (p->uri != 0) - xmlFree(p->uri); - - xmlFree(p); -} - -/** - * xmlCmpTextWriterNsStackEntry: - * @data0: the first data - * @data1: the second data - * - * Compare callback for the xmlList. - * - * Returns -1, 0, 1 - */ -static int -xmlCmpTextWriterNsStackEntry(const void *data0, const void *data1) -{ - xmlTextWriterNsStackEntry *p0; - xmlTextWriterNsStackEntry *p1; - int rc; - - if (data0 == data1) - return 0; - - if (data0 == 0) - return -1; - - if (data1 == 0) - return 1; - - p0 = (xmlTextWriterNsStackEntry *) data0; - p1 = (xmlTextWriterNsStackEntry *) data1; - - rc = xmlStrcmp(p0->prefix, p1->prefix); - - if ((rc != 0) || (p0->elem != p1->elem)) - rc = -1; - - return rc; -} - -/** - * xmlTextWriterWriteDocCallback: - * @context: the xmlBufferPtr - * @str: the data to write - * @len: the length of the data - * - * Write callback for the xmlOutputBuffer with target xmlBuffer - * - * Returns -1, 0, 1 - */ -static int -xmlTextWriterWriteDocCallback(void *context, const xmlChar * str, int len) -{ - xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) context; - int rc; - - if ((rc = xmlParseChunk(ctxt, (const char *) str, len, 0)) != 0) { - xmlWriterErrMsgInt(NULL, XML_ERR_INTERNAL_ERROR, - "xmlTextWriterWriteDocCallback : XML error %d !\n", - rc); - return -1; - } - - return len; -} - -/** - * xmlTextWriterCloseDocCallback: - * @context: the xmlBufferPtr - * - * Close callback for the xmlOutputBuffer with target xmlBuffer - * - * Returns -1, 0, 1 - */ -static int -xmlTextWriterCloseDocCallback(void *context) -{ - xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) context; - int rc; - - if ((rc = xmlParseChunk(ctxt, NULL, 0, 1)) != 0) { - xmlWriterErrMsgInt(NULL, XML_ERR_INTERNAL_ERROR, - "xmlTextWriterWriteDocCallback : XML error %d !\n", - rc); - return -1; - } - - return 0; -} - -/** - * xmlTextWriterVSprintf: - * @format: see printf - * @argptr: pointer to the first member of the variable argument list. - * - * Utility function for formatted output - * - * Returns a new xmlChar buffer with the data or NULL on error. This buffer must be freed. - */ -static xmlChar * -xmlTextWriterVSprintf(const char *format, va_list argptr) -{ - int size; - int count; - xmlChar *buf; - va_list locarg; - - size = BUFSIZ; - buf = (xmlChar *) xmlMalloc(size); - if (buf == NULL) { - xmlWriterErrMsg(NULL, XML_ERR_NO_MEMORY, - "xmlTextWriterVSprintf : out of memory!\n"); - return NULL; - } - - VA_COPY(locarg, argptr); - while (((count = vsnprintf((char *) buf, size, format, locarg)) < 0) - || (count == size - 1) || (count == size) || (count > size)) { - va_end(locarg); - xmlFree(buf); - size += BUFSIZ; - buf = (xmlChar *) xmlMalloc(size); - if (buf == NULL) { - xmlWriterErrMsg(NULL, XML_ERR_NO_MEMORY, - "xmlTextWriterVSprintf : out of memory!\n"); - return NULL; - } - VA_COPY(locarg, argptr); - } - va_end(locarg); - - return buf; -} - -/** - * xmlTextWriterStartDocumentCallback: - * @ctx: the user data (XML parser context) - * - * called at the start of document processing. - */ -static void -xmlTextWriterStartDocumentCallback(void *ctx) -{ - xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; - xmlDocPtr doc; - - if (ctxt->html) { - xmlWriterErrMsg(NULL, XML_ERR_INTERNAL_ERROR, - "libxml2 built without HTML support\n"); - ctxt->errNo = XML_ERR_INTERNAL_ERROR; - ctxt->instate = XML_PARSER_EOF; - ctxt->disableSAX = 1; - return; - } else { - doc = ctxt->myDoc; - if (doc == NULL) - doc = ctxt->myDoc = xmlNewDoc(ctxt->version); - if (doc != NULL) { - if (doc->children == NULL) { - if (ctxt->encoding != NULL) - doc->encoding = xmlStrdup(ctxt->encoding); - else - doc->encoding = NULL; - doc->standalone = ctxt->standalone; - } - } else { - if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL)) - ctxt->sax->error(ctxt->userData, - "SAX.startDocument(): out of memory\n"); - ctxt->errNo = XML_ERR_NO_MEMORY; - ctxt->instate = XML_PARSER_EOF; - ctxt->disableSAX = 1; - return; - } - } - if ((ctxt->myDoc != NULL) && (ctxt->myDoc->URL == NULL) && - (ctxt->input != NULL) && (ctxt->input->filename != NULL)) { - ctxt->myDoc->URL = - xmlCanonicPath((const xmlChar *) ctxt->input->filename); - if (ctxt->myDoc->URL == NULL) - ctxt->myDoc->URL = - xmlStrdup((const xmlChar *) ctxt->input->filename); - } -} - -/** - * xmlTextWriterSetIndent: - * @writer: the xmlTextWriterPtr - * @indent: do indentation? - * - * Set indentation output. indent = 0 do not indentation. indent > 0 do indentation. - * - * Returns -1 on error or 0 otherwise. - */ -int -xmlTextWriterSetIndent(xmlTextWriterPtr writer, int indent) -{ - if ((writer == NULL) || (indent < 0)) - return -1; - - writer->indent = indent; - writer->doindent = 1; - - return 0; -} - -/** - * xmlTextWriterSetIndentString: - * @writer: the xmlTextWriterPtr - * @str: the xmlChar string - * - * Set string indentation. - * - * Returns -1 on error or 0 otherwise. - */ -int -xmlTextWriterSetIndentString(xmlTextWriterPtr writer, const xmlChar * str) -{ - if ((writer == NULL) || (!str)) - return -1; - - if (writer->ichar != NULL) - xmlFree(writer->ichar); - writer->ichar = xmlStrdup(str); - - if (!writer->ichar) - return -1; - else - return 0; -} - -/** - * xmlTextWriterWriteIndent: - * @writer: the xmlTextWriterPtr - * - * Write indent string. - * - * Returns -1 on error or the number of strings written. - */ -static int -xmlTextWriterWriteIndent(xmlTextWriterPtr writer) -{ - int lksize; - int i; - int ret; - - lksize = xmlListSize(writer->nodes); - if (lksize < 1) - return (-1); /* list is empty */ - for (i = 0; i < (lksize - 1); i++) { - ret = xmlOutputBufferWriteString(writer->out, - (const char *) writer->ichar); - if (ret == -1) - return (-1); - } - - return (lksize - 1); -} - -/** - * xmlTextWriterHandleStateDependencies: - * @writer: the xmlTextWriterPtr - * @p: the xmlTextWriterStackEntry - * - * Write state dependent strings. - * - * Returns -1 on error or the number of characters written. - */ -static int -xmlTextWriterHandleStateDependencies(xmlTextWriterPtr writer, - xmlTextWriterStackEntry * p) -{ - int count; - int sum; - char extra[3]; - - if (writer == NULL) - return -1; - - if (p == NULL) - return 0; - - sum = 0; - extra[0] = extra[1] = extra[2] = '\0'; - if (p != 0) { - sum = 0; - switch (p->state) { - case XML_TEXTWRITER_NAME: - /* Output namespace declarations */ - count = xmlTextWriterOutputNSDecl(writer); - if (count < 0) - return -1; - sum += count; - extra[0] = '>'; - p->state = XML_TEXTWRITER_TEXT; - break; - case XML_TEXTWRITER_PI: - extra[0] = ' '; - p->state = XML_TEXTWRITER_PI_TEXT; - break; - case XML_TEXTWRITER_DTD: - extra[0] = ' '; - extra[1] = '['; - p->state = XML_TEXTWRITER_DTD_TEXT; - break; - case XML_TEXTWRITER_DTD_ELEM: - extra[0] = ' '; - p->state = XML_TEXTWRITER_DTD_ELEM_TEXT; - break; - case XML_TEXTWRITER_DTD_ATTL: - extra[0] = ' '; - p->state = XML_TEXTWRITER_DTD_ATTL_TEXT; - break; - case XML_TEXTWRITER_DTD_ENTY: - case XML_TEXTWRITER_DTD_PENT: - extra[0] = ' '; - extra[1] = writer->qchar; - p->state = XML_TEXTWRITER_DTD_ENTY_TEXT; - break; - default: - break; - } - } - - if (*extra != '\0') { - count = xmlOutputBufferWriteString(writer->out, extra); - if (count < 0) - return -1; - sum += count; - } - - return sum; -} - -#define bottom_xmlwriter -#include "elfgcchack.h" -#endif