[libxml2] 560524 – xmlTextReaderLocalName description



commit aacc2a2466f2d616c85e59fc0d0644b5b8aa4e28
Author: Daniel Veillard <veillard redhat com>
Date:   Tue Aug 11 18:31:42 2009 +0200

    560524 â?? xmlTextReaderLocalName description
    
    * xmlreader.c: document all functions returning xmlChar * that they
      need to free the result, and some space/tabs cleanups

 xmlreader.c |  718 ++++++++++++++++++++++++++++++++---------------------------
 1 files changed, 390 insertions(+), 328 deletions(-)
---
diff --git a/xmlreader.c b/xmlreader.c
index d42b1a0..eda32f3 100644
--- a/xmlreader.c
+++ b/xmlreader.c
@@ -1,7 +1,7 @@
 /*
  * xmlreader.c: implements the xmlTextReader streaming node API
  *
- * NOTE: 
+ * NOTE:
  *   XmlTextReader.Normalization Property won't be supported, since
  *     it makes the parser non compliant to the XML recommendation
  *
@@ -73,7 +73,7 @@
  *
  * macro to flag unimplemented blocks
  */
-#define TODO 								\
+#define TODO								\
     xmlGenericError(xmlGenericErrorContext,				\
 	    "Unimplemented block at %s:%d\n",				\
             __FILE__, __LINE__);
@@ -128,8 +128,8 @@ struct _xmlTextReader {
     endElementNsSAX2Func	endElementNs;  /* idem */
     charactersSAXFunc		characters;
     cdataBlockSAXFunc		cdataBlock;
-    unsigned int 		base;	/* base of the segment in the input */
-    unsigned int 		cur;	/* current position in the input */
+    unsigned int		base;	/* base of the segment in the input */
+    unsigned int		cur;	/* current position in the input */
     xmlNodePtr			node;	/* current node */
     xmlNodePtr			curnode;/* current attribute node */
     int				depth;  /* depth of the current node */
@@ -207,7 +207,7 @@ static int xmlTextReaderNextTree(xmlTextReaderPtr reader);
  * current scope
  */
 #define DICT_FREE(str)						\
-	if ((str) && ((!dict) || 				\
+	if ((str) && ((!dict) ||				\
 	    (xmlDictOwns(dict, (const xmlChar *)(str)) == 0)))	\
 	    xmlFree((char *)(str));
 
@@ -252,7 +252,7 @@ xmlTextReaderRemoveID(xmlDocPtr doc, xmlAttrPtr attr) {
     if (doc == NULL) return(-1);
     if (attr == NULL) return(-1);
     table = (xmlIDTablePtr) doc->ids;
-    if (table == NULL) 
+    if (table == NULL)
         return(-1);
 
     ID = xmlNodeListGetString(doc, attr->children, 1);
@@ -842,7 +842,7 @@ xmlTextReaderPushData(xmlTextReaderPtr reader) {
 		    break;
 		}
 
-	    } else 
+	    } else
 		break;
 	}
 	/*
@@ -891,7 +891,7 @@ xmlTextReaderPushData(xmlTextReaderPtr reader) {
 	if (reader->state != XML_TEXTREADER_DONE) {
 	    s = inbuf->use - reader->cur;
 	    val = xmlParseChunk(reader->ctxt,
-		    (const char *) &inbuf->content[reader->cur], 
+		    (const char *) &inbuf->content[reader->cur],
 		    s, 1);
 	    reader->cur = inbuf->use;
 	    reader->state  = XML_TEXTREADER_DONE;
@@ -1031,7 +1031,7 @@ xmlTextReaderValidatePop(xmlTextReaderPtr reader) {
 	int ret;
 
 	if (reader->rngFullNode != NULL) {
-	    if (node == reader->rngFullNode) 
+	    if (node == reader->rngFullNode)
 	        reader->rngFullNode = NULL;
 	    return;
 	}
@@ -1066,7 +1066,7 @@ xmlTextReaderValidateEntity(xmlTextReaderPtr reader) {
 	     */
 	    if ((node->children == NULL) && (ctxt->sax != NULL) &&
 		(ctxt->sax->getEntity != NULL)) {
-		node->children = (xmlNodePtr) 
+		node->children = (xmlNodePtr)
 		    ctxt->sax->getEntity(ctxt, node->name);
 	    }
 
@@ -1256,7 +1256,7 @@ xmlTextReaderRead(xmlTextReaderPtr reader) {
     xmlTextReaderState oldstate = XML_TEXTREADER_START;
     xmlNodePtr oldnode = NULL;
 
-   
+
     if (reader == NULL)
 	return(-1);
     reader->curnode = NULL;
@@ -1489,7 +1489,7 @@ node_found:
 	 (xmlStrEqual(reader->node->ns->href, XINCLUDE_OLD_NS)))) {
 	if (reader->xincctxt == NULL) {
 	    reader->xincctxt = xmlXIncludeNewContext(reader->ctxt->myDoc);
-	    xmlXIncludeSetFlags(reader->xincctxt, 
+	    xmlXIncludeSetFlags(reader->xincctxt,
 	                        reader->parserFlags & (~XML_PARSE_NOXINCNODE));
 	}
 	/*
@@ -1502,7 +1502,7 @@ node_found:
     if ((reader->node != NULL) && (reader->node->type == XML_XINCLUDE_START)) {
         reader->in_xinclude++;
 	goto get_next_node;
-    } 
+    }
     if ((reader->node != NULL) && (reader->node->type == XML_XINCLUDE_END)) {
         reader->in_xinclude--;
 	goto get_next_node;
@@ -1520,7 +1520,7 @@ node_found:
 	 */
 	if ((reader->node->children == NULL) && (reader->ctxt->sax != NULL) &&
 	    (reader->ctxt->sax->getEntity != NULL)) {
-	    reader->node->children = (xmlNodePtr) 
+	    reader->node->children = (xmlNodePtr)
 		reader->ctxt->sax->getEntity(reader->ctxt, reader->node->name);
 	}
 
@@ -1548,7 +1548,7 @@ node_found:
     if ((reader->validate) && (reader->node != NULL)) {
 	xmlNodePtr node = reader->node;
 
-	if ((node->type == XML_ELEMENT_NODE) && 
+	if ((node->type == XML_ELEMENT_NODE) &&
             ((reader->state != XML_TEXTREADER_END) &&
 	     (reader->state != XML_TEXTREADER_BACKTRACK))) {
 	    xmlTextReaderValidatePush(reader);
@@ -1573,7 +1573,7 @@ node_found:
 #endif /* LIBXML_PATTERN_ENABLED */
 #ifdef LIBXML_SCHEMAS_ENABLED
     if ((reader->validate == XML_TEXTREADER_VALIDATE_XSD) &&
-        (reader->xsdValidErrors == 0) && 
+        (reader->xsdValidErrors == 0) &&
 	(reader->xsdValidCtxt != NULL)) {
 	reader->xsdValidErrors = !xmlSchemaIsValid(reader->xsdValidCtxt);
     }
@@ -1664,7 +1664,7 @@ xmlTextReaderNext(xmlTextReaderPtr reader) {
  * 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 
+ *         is neither an element nor attribute, or has no child nodes. The
  *         string must be deallocated by the caller.
  */
 xmlChar *
@@ -1710,7 +1710,7 @@ xmlTextReaderReadInnerXml(xmlTextReaderPtr reader ATTRIBUTE_UNUSED)
  * 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 
+ *         is neither an element nor attribute, or has no child nodes. The
  *         string must be deallocated by the caller.
  */
 xmlChar *
@@ -2106,7 +2106,7 @@ xmlNewTextReader(xmlParserInputBufferPtr input, const char *URI) {
 	ret->base = 0;
 	ret->cur = 0;
     }
-    
+
     if (ret->ctxt == NULL) {
         xmlGenericError(xmlGenericErrorContext,
 		"xmlNewTextReader : malloc failed\n");
@@ -2308,7 +2308,7 @@ xmlTextReaderGetAttributeNo(xmlTextReaderPtr reader, int no) {
     if (reader->curnode != NULL)
 	return(NULL);
     /* TODO: handle the xmlDecl */
-    if (reader->node->type != XML_ELEMENT_NODE) 
+    if (reader->node->type != XML_ELEMENT_NODE)
 	return(NULL);
 
     ns = reader->node->nsDef;
@@ -2438,7 +2438,7 @@ xmlTextReaderGetAttributeNs(xmlTextReaderPtr reader, const xmlChar *localName,
 		}
 		ns = reader->node->nsDef;
 		while (ns != NULL) {
-			if ((prefix == NULL && ns->prefix == NULL) || 
+			if ((prefix == NULL && ns->prefix == NULL) ||
 				((ns->prefix != NULL) && (xmlStrEqual(ns->prefix, localName)))) {
 				return xmlStrdup(ns->href);
 			}
@@ -2550,7 +2550,7 @@ xmlTextReaderMoveToAttributeNo(xmlTextReaderPtr reader, int no) {
     if (reader->node == NULL)
 	return(-1);
     /* TODO: handle the xmlDecl */
-    if (reader->node->type != XML_ELEMENT_NODE) 
+    if (reader->node->type != XML_ELEMENT_NODE)
 	return(-1);
 
     reader->curnode = NULL;
@@ -2637,7 +2637,7 @@ xmlTextReaderMoveToAttribute(xmlTextReaderPtr reader, const xmlChar *name) {
 	}
 	return(0);
     }
-    
+
     /*
      * Namespace default decl
      */
@@ -2714,7 +2714,7 @@ xmlTextReaderMoveToAttributeNs(xmlTextReaderPtr reader,
 		}
 		ns = reader->node->nsDef;
 		while (ns != NULL) {
-			if ((prefix == NULL && ns->prefix == NULL) || 
+			if ((prefix == NULL && ns->prefix == NULL) ||
 				((ns->prefix != NULL) && (xmlStrEqual(ns->prefix, localName)))) {
 				reader->curnode = (xmlNodePtr) ns;
 				return(1);
@@ -2860,7 +2860,7 @@ xmlTextReaderReadAttributeValue(xmlTextReaderPtr reader) {
 	xmlNsPtr ns = (xmlNsPtr) reader->curnode;
 
 	if (reader->faketext == NULL) {
-	    reader->faketext = xmlNewDocText(reader->node->doc, 
+	    reader->faketext = xmlNewDocText(reader->node->doc,
 		                             ns->href);
 	} else {
             if ((reader->faketext->content != NULL) &&
@@ -2898,7 +2898,7 @@ xmlTextReaderConstEncoding(xmlTextReaderPtr reader) {
 	doc = reader->ctxt->myDoc;
     if (doc == NULL)
 	return(NULL);
-    
+
     if (doc->encoding == NULL)
 	return(NULL);
     else
@@ -2930,7 +2930,7 @@ xmlTextReaderAttributeCount(xmlTextReaderPtr reader) {
 	return(-1);
     if (reader->node == NULL)
 	return(0);
-    
+
     if (reader->curnode != NULL)
 	node = reader->curnode;
     else
@@ -2968,7 +2968,7 @@ xmlTextReaderAttributeCount(xmlTextReaderPtr reader) {
 int
 xmlTextReaderNodeType(xmlTextReaderPtr reader) {
     xmlNodePtr node;
-    
+
     if (reader == NULL)
 	return(-1);
     if (reader->node == NULL)
@@ -3064,7 +3064,8 @@ xmlTextReaderIsEmptyElement(xmlTextReaderPtr reader) {
  *
  * The local name of the node.
  *
- * Returns the local name or NULL if not available
+ * Returns the local name or NULL if not available,
+ *   if non NULL it need to be freed by the caller.
  */
 xmlChar *
 xmlTextReaderLocalName(xmlTextReaderPtr reader) {
@@ -3125,7 +3126,8 @@ xmlTextReaderConstLocalName(xmlTextReaderPtr reader) {
  *
  * The qualified name of the node, equal to Prefix :LocalName.
  *
- * Returns the local name or NULL if not available
+ * Returns the local name or NULL if not available,
+ *   if non NULL it need to be freed by the caller.
  */
 xmlChar *
 xmlTextReaderName(xmlTextReaderPtr reader) {
@@ -3144,7 +3146,7 @@ xmlTextReaderName(xmlTextReaderPtr reader) {
 	    if ((node->ns == NULL) ||
 		(node->ns->prefix == NULL))
 		return(xmlStrdup(node->name));
-	    
+
 	    ret = xmlStrdup(node->ns->prefix);
 	    ret = xmlStrcat(ret, BAD_CAST ":");
 	    ret = xmlStrcat(ret, node->name);
@@ -3268,7 +3270,8 @@ xmlTextReaderConstName(xmlTextReaderPtr reader) {
  *
  * A shorthand reference to the namespace associated with the node.
  *
- * Returns the prefix or NULL if not available
+ * Returns the prefix or NULL if not available,
+ *    if non NULL it need to be freed by the caller.
  */
 xmlChar *
 xmlTextReaderPrefix(xmlTextReaderPtr reader) {
@@ -3331,7 +3334,8 @@ xmlTextReaderConstPrefix(xmlTextReaderPtr reader) {
  *
  * The URI defining the namespace associated with the node.
  *
- * Returns the namespace URI or NULL if not available
+ * Returns the namespace URI or NULL if not available,
+ *    if non NULL it need to be freed by the caller.
  */
 xmlChar *
 xmlTextReaderNamespaceUri(xmlTextReaderPtr reader) {
@@ -3386,7 +3390,8 @@ xmlTextReaderConstNamespaceUri(xmlTextReaderPtr reader) {
  *
  * The base URI of the node.
  *
- * Returns the base URI or NULL if not available
+ * Returns the base URI or NULL if not available,
+ *    if non NULL it need to be freed by the caller.
  */
 xmlChar *
 xmlTextReaderBaseUri(xmlTextReaderPtr reader) {
@@ -3644,7 +3649,8 @@ xmlTextReaderQuoteChar(xmlTextReaderPtr reader) {
  *
  * The xml:lang scope within which the node resides.
  *
- * Returns the xml:lang value or NULL if none exists.
+ * Returns the xml:lang value or NULL if none exists.,
+ *    if non NULL it need to be freed by the caller.
  */
 xmlChar *
 xmlTextReaderXmlLang(xmlTextReaderPtr reader) {
@@ -3869,7 +3875,7 @@ xmlNodePtr
 xmlTextReaderCurrentNode(xmlTextReaderPtr reader) {
     if (reader == NULL)
 	return(NULL);
-    
+
     if (reader->curnode != NULL)
 	return(reader->curnode);
     return(reader->node);
@@ -3891,7 +3897,7 @@ xmlTextReaderPreserve(xmlTextReaderPtr reader) {
 
     if (reader == NULL)
 	return(NULL);
-    
+
     if (reader->curnode != NULL)
         cur = reader->curnode;
     else
@@ -3904,7 +3910,7 @@ xmlTextReaderPreserve(xmlTextReaderPtr reader) {
 	cur->extra |= NODE_IS_SPRESERVED;
     }
     reader->preserves++;
-        
+
     parent = cur->parent;;
     while (parent != NULL) {
         if (parent->type == XML_ELEMENT_NODE)
@@ -3920,7 +3926,7 @@ xmlTextReaderPreserve(xmlTextReaderPtr reader) {
  * @reader:  the xmlTextReaderPtr used
  * @pattern:  an XPath subset pattern
  * @namespaces: the prefix definitions, array of [URI, prefix] or NULL
- * 
+ *
  * This tells the XML Reader to preserve all nodes matched by the
  * pattern. The caller must also use xmlTextReaderCurrentDoc() to
  * keep an handle on the resulting document once parsing has finished
@@ -3935,7 +3941,7 @@ xmlTextReaderPreservePattern(xmlTextReaderPtr reader, const xmlChar *pattern,
 
     if ((reader == NULL) || (pattern == NULL))
 	return(-1);
-    
+
     comp = xmlPatterncompile(pattern, reader->dict, 0, namespaces);
     if (comp == NULL)
         return(-1);
@@ -3972,7 +3978,7 @@ xmlTextReaderPreservePattern(xmlTextReaderPtr reader, const xmlChar *pattern,
  * @reader:  the xmlTextReaderPtr used
  *
  * Hacking interface allowing to get the xmlDocPtr correponding to the
- * current document being accessed by the xmlTextReader. 
+ * current document being accessed by the xmlTextReader.
  * NOTE: as a result of this call, the reader will not destroy the
  *       associated XML document and calling xmlFreeDoc() on the result
  *       is needed once the reader parsing has finished.
@@ -3987,72 +3993,80 @@ xmlTextReaderCurrentDoc(xmlTextReaderPtr reader) {
         return(reader->doc);
     if ((reader->ctxt == NULL) || (reader->ctxt->myDoc == NULL))
 	return(NULL);
-    
+
     reader->preserve = 1;
     return(reader->ctxt->myDoc);
 }
 
 #ifdef LIBXML_SCHEMAS_ENABLED
+static char *xmlTextReaderBuildMessage(const char *msg, va_list ap);
 
-static char *
-xmlTextReaderBuildMessage(const char *msg, va_list ap);
-
-static void XMLCDECL 
+static void XMLCDECL
 xmlTextReaderValidityError(void *ctxt, const char *msg, ...);
 
-static void XMLCDECL 
+static void XMLCDECL
 xmlTextReaderValidityWarning(void *ctxt, const char *msg, ...);
 
-static void XMLCDECL xmlTextReaderValidityErrorRelay(void *ctx, const char *msg, ...)
+static void XMLCDECL
+xmlTextReaderValidityErrorRelay(void *ctx, const char *msg, ...)
 {
-	xmlTextReaderPtr reader = (xmlTextReaderPtr) ctx;
-	char * str;
-	va_list ap;
-
-	va_start(ap,msg);
-	str = xmlTextReaderBuildMessage(msg,ap);
-	if (!reader->errorFunc) {
-		xmlTextReaderValidityError(ctx, "%s", str);
-	} else {
-		reader->errorFunc(reader->errorFuncArg, str, XML_PARSER_SEVERITY_VALIDITY_ERROR, NULL /* locator */);
-	}
-	if (str != NULL)
-		xmlFree(str);
-	va_end(ap);
+    xmlTextReaderPtr reader = (xmlTextReaderPtr) ctx;
+
+    char *str;
+
+    va_list ap;
+
+    va_start(ap, msg);
+    str = xmlTextReaderBuildMessage(msg, ap);
+    if (!reader->errorFunc) {
+        xmlTextReaderValidityError(ctx, "%s", str);
+    } else {
+        reader->errorFunc(reader->errorFuncArg, str,
+                          XML_PARSER_SEVERITY_VALIDITY_ERROR,
+                          NULL /* locator */ );
+    }
+    if (str != NULL)
+        xmlFree(str);
+    va_end(ap);
 }
 
-static void XMLCDECL xmlTextReaderValidityWarningRelay(void *ctx, const char *msg, ...)
+static void XMLCDECL
+xmlTextReaderValidityWarningRelay(void *ctx, const char *msg, ...)
 {
-	xmlTextReaderPtr reader = (xmlTextReaderPtr) ctx;
-	char * str;
-	va_list ap;
-
-	va_start(ap,msg);
-	str = xmlTextReaderBuildMessage(msg,ap);
-	if (!reader->errorFunc) {
-		xmlTextReaderValidityWarning(ctx, "%s", str);
-	} else {
-		reader->errorFunc(reader->errorFuncArg, str, XML_PARSER_SEVERITY_VALIDITY_WARNING, NULL /* locator */);
-	}
-	if (str != NULL)
-		xmlFree(str);
-	va_end(ap);
+    xmlTextReaderPtr reader = (xmlTextReaderPtr) ctx;
+
+    char *str;
+
+    va_list ap;
+
+    va_start(ap, msg);
+    str = xmlTextReaderBuildMessage(msg, ap);
+    if (!reader->errorFunc) {
+        xmlTextReaderValidityWarning(ctx, "%s", str);
+    } else {
+        reader->errorFunc(reader->errorFuncArg, str,
+                          XML_PARSER_SEVERITY_VALIDITY_WARNING,
+                          NULL /* locator */ );
+    }
+    if (str != NULL)
+        xmlFree(str);
+    va_end(ap);
 }
 
-static void 
-xmlTextReaderStructuredError(void *ctxt, xmlErrorPtr error);
+static void
+  xmlTextReaderStructuredError(void *ctxt, xmlErrorPtr error);
 
-static void xmlTextReaderValidityStructuredRelay(void * userData, xmlErrorPtr error)
+static void
+xmlTextReaderValidityStructuredRelay(void *userData, xmlErrorPtr error)
 {
-	xmlTextReaderPtr reader = (xmlTextReaderPtr) userData;
+    xmlTextReaderPtr reader = (xmlTextReaderPtr) userData;
 
-	if (reader->sErrorFunc) {
-		reader->sErrorFunc(reader->errorFuncArg, error);
-	} else {
-		xmlTextReaderStructuredError(reader, error);
-	}
+    if (reader->sErrorFunc) {
+        reader->sErrorFunc(reader->errorFuncArg, error);
+    } else {
+        xmlTextReaderStructuredError(reader, error);
+    }
 }
-
 /**
  * xmlTextReaderRelaxNGSetSchema:
  * @reader:  the xmlTextReaderPtr used
@@ -4102,7 +4116,7 @@ xmlTextReaderRelaxNGSetSchema(xmlTextReaderPtr reader, xmlRelaxNGPtr schema) {
 			reader);
     }
 	if (reader->sErrorFunc != NULL) {
-		xmlRelaxNGSetValidStructuredErrors(reader->rngValidCtxt, 
+		xmlRelaxNGSetValidStructuredErrors(reader->rngValidCtxt,
 			xmlTextReaderValidityStructuredRelay,
 			reader);
     }
@@ -4138,15 +4152,15 @@ xmlTextReaderSetSchema(xmlTextReaderPtr reader, xmlSchemaPtr schema) {
         if (reader->xsdValidCtxt != NULL) {
 	    if (! reader->xsdPreserveCtxt)
 		xmlSchemaFreeValidCtxt(reader->xsdValidCtxt);
-	    reader->xsdValidCtxt = NULL;	    
+	    reader->xsdValidCtxt = NULL;
         }
 	reader->xsdPreserveCtxt = 0;
         if (reader->xsdSchemas != NULL) {
 	    xmlSchemaFree(reader->xsdSchemas);
 	    reader->xsdSchemas = NULL;
-	}	
+	}
 	return(0);
-    }    
+    }
     if (reader->mode != XML_TEXTREADER_MODE_INITIAL)
 	return(-1);
     if (reader->xsdPlug != NULL) {
@@ -4155,7 +4169,7 @@ xmlTextReaderSetSchema(xmlTextReaderPtr reader, xmlSchemaPtr schema) {
     }
     if (reader->xsdValidCtxt != NULL) {
 	if (! reader->xsdPreserveCtxt)
-	    xmlSchemaFreeValidCtxt(reader->xsdValidCtxt);	
+	    xmlSchemaFreeValidCtxt(reader->xsdValidCtxt);
 	reader->xsdValidCtxt = NULL;
     }
     reader->xsdPreserveCtxt = 0;
@@ -4213,7 +4227,7 @@ xmlTextReaderRelaxNGValidate(xmlTextReaderPtr reader, const char *rng) {
 
     if (reader == NULL)
         return(-1);
-    
+
     if (rng == NULL) {
         if (reader->rngValidCtxt != NULL) {
 	    xmlRelaxNGFreeValidCtxt(reader->rngValidCtxt);
@@ -4243,7 +4257,7 @@ xmlTextReaderRelaxNGValidate(xmlTextReaderPtr reader, const char *rng) {
 			 reader);
     }
     if (reader->sErrorFunc != NULL) {
-	xmlRelaxNGSetValidStructuredErrors(reader->rngValidCtxt, 
+	xmlRelaxNGSetValidStructuredErrors(reader->rngValidCtxt,
 			xmlTextReaderValidityStructuredRelay,
 			reader);
     }
@@ -4264,7 +4278,7 @@ xmlTextReaderRelaxNGValidate(xmlTextReaderPtr reader, const char *rng) {
 			 reader);
     }
 	if (reader->sErrorFunc != NULL) {
-		xmlRelaxNGSetValidStructuredErrors(reader->rngValidCtxt, 
+		xmlRelaxNGSetValidStructuredErrors(reader->rngValidCtxt,
 			xmlTextReaderValidityStructuredRelay,
 			reader);
     }
@@ -4293,7 +4307,7 @@ xmlTextReaderSchemaValidateInternal(xmlTextReaderPtr reader,
 				    const char *xsd,
 				    xmlSchemaValidCtxtPtr ctxt,
 				    int options ATTRIBUTE_UNUSED)
-{    
+{
     if (reader == NULL)
         return(-1);
 
@@ -4304,7 +4318,7 @@ xmlTextReaderSchemaValidateInternal(xmlTextReaderPtr reader,
 	((reader->mode != XML_TEXTREADER_MODE_INITIAL) ||
         (reader->ctxt == NULL)))
 	return(-1);
-        
+
     /* Cleanup previous validation stuff. */
     if (reader->xsdPlug != NULL) {
 	xmlSchemaSAXUnplug(reader->xsdPlug);
@@ -4312,20 +4326,20 @@ xmlTextReaderSchemaValidateInternal(xmlTextReaderPtr reader,
     }
     if (reader->xsdValidCtxt != NULL) {
 	if (! reader->xsdPreserveCtxt)
-	    xmlSchemaFreeValidCtxt(reader->xsdValidCtxt);	
+	    xmlSchemaFreeValidCtxt(reader->xsdValidCtxt);
 	reader->xsdValidCtxt = NULL;
     }
     reader->xsdPreserveCtxt = 0;
     if (reader->xsdSchemas != NULL) {
 	xmlSchemaFree(reader->xsdSchemas);
 	reader->xsdSchemas = NULL;
-    }    
+    }
 
     if ((xsd == NULL) && (ctxt == NULL)) {
 	/* We just want to deactivate the validation, so get out. */
 	return(0);
-    }    
-    
+    }
+
     if (xsd != NULL) {
 	xmlSchemaParserCtxtPtr pctxt;
 	/* Parse the schema and create validation environment. */
@@ -4357,13 +4371,13 @@ xmlTextReaderSchemaValidateInternal(xmlTextReaderPtr reader,
 	    return(-1);
 	}
     } else {
-	/* Use the given validation context. */	
+	/* Use the given validation context. */
 	reader->xsdValidCtxt = ctxt;
 	reader->xsdPreserveCtxt = 1;
 	reader->xsdPlug = xmlSchemaSAXPlug(reader->xsdValidCtxt,
 	    &(reader->ctxt->sax),
 	    &(reader->ctxt->userData));
-	if (reader->xsdPlug == NULL) {	    
+	if (reader->xsdPlug == NULL) {
 	    reader->xsdValidCtxt = NULL;
 	    reader->xsdPreserveCtxt = 0;
 	    return(-1);
@@ -4382,7 +4396,7 @@ xmlTextReaderSchemaValidateInternal(xmlTextReaderPtr reader,
 			 reader);
     }
 	if (reader->sErrorFunc != NULL) {
-		xmlSchemaSetValidStructuredErrors(reader->xsdValidCtxt, 
+		xmlSchemaSetValidStructuredErrors(reader->xsdValidCtxt,
 			xmlTextReaderValidityStructuredRelay,
 			reader);
     }
@@ -4453,7 +4467,7 @@ xmlTextReaderIsNamespaceDecl(xmlTextReaderPtr reader) {
 	node = reader->curnode;
     else
 	node = reader->node;
-    
+
     if (XML_NAMESPACE_DECL == node->type)
 	return(1);
     else
@@ -4477,10 +4491,10 @@ xmlTextReaderConstXmlVersion(xmlTextReaderPtr reader) {
     if (reader->doc != NULL)
         doc = reader->doc;
     else if (reader->ctxt != NULL)
-	doc = reader->ctxt->myDoc; 
+	doc = reader->ctxt->myDoc;
     if (doc == NULL)
 	return(NULL);
-    
+
     if (doc->version == NULL)
 	return(NULL);
     else
@@ -4533,20 +4547,20 @@ xmlTextReaderBuildMessage(const char *msg, va_list ap) {
         va_end(aq);
         if (chars < 0) {
 	    xmlGenericError(xmlGenericErrorContext, "vsnprintf failed !\n");
-	    if (str) 
-	    	xmlFree(str);
-	    return NULL;  
+	    if (str)
+		xmlFree(str);
+	    return NULL;
 	}
 	if ((chars < size) || (size == MAX_ERR_MSG_SIZE))
             break;
         if (chars < MAX_ERR_MSG_SIZE)
-        	size = chars + 1;
+	size = chars + 1;
 	else
 		size = MAX_ERR_MSG_SIZE;
         if ((larger = (char *) xmlRealloc(str, size)) == NULL) {
 	    xmlGenericError(xmlGenericErrorContext, "xmlRealloc failed !\n");
 	    if (str)
-            	xmlFree(str);
+                xmlFree(str);
             return NULL;
         }
         str = larger;
@@ -4582,7 +4596,7 @@ xmlTextReaderLocatorLineNumber(xmlTextReaderLocatorPtr locator) {
 	    input = ctx->inputTab[ctx->inputNr - 2];
 	if (input != NULL) {
 	    ret = input->line;
-	} 
+	}
 	else {
 	    ret = -1;
 	}
@@ -4597,7 +4611,8 @@ xmlTextReaderLocatorLineNumber(xmlTextReaderLocatorPtr locator) {
  *
  * Obtain the base URI for the given locator.
  *
- * Returns the base URI or NULL in case of error.
+ * Returns the base URI or NULL in case of error,
+ *    if non NULL it need to be freed by the caller.
  */
 xmlChar *
 xmlTextReaderLocatorBaseURI(xmlTextReaderLocatorPtr locator) {
@@ -4618,7 +4633,7 @@ xmlTextReaderLocatorBaseURI(xmlTextReaderLocatorPtr locator) {
 	    input = ctx->inputTab[ctx->inputNr - 2];
 	if (input != NULL) {
 	    ret = xmlStrdup(BAD_CAST input->filename);
-	} 
+	}
 	else {
 	    ret = NULL;
 	}
@@ -4628,87 +4643,95 @@ xmlTextReaderLocatorBaseURI(xmlTextReaderLocatorPtr locator) {
 }
 
 static void
-xmlTextReaderGenericError(void *ctxt, xmlParserSeverities severity, char *str) {
-    xmlParserCtxtPtr ctx = (xmlParserCtxtPtr)ctxt;
-    xmlTextReaderPtr reader = (xmlTextReaderPtr)ctx->_private;
+xmlTextReaderGenericError(void *ctxt, xmlParserSeverities severity,
+                          char *str)
+{
+    xmlParserCtxtPtr ctx = (xmlParserCtxtPtr) ctxt;
+
+    xmlTextReaderPtr reader = (xmlTextReaderPtr) ctx->_private;
 
     if (str != NULL) {
-      if (reader->errorFunc)
-	reader->errorFunc(reader->errorFuncArg,
-			  str,
-			  severity,
-			  (xmlTextReaderLocatorPtr)ctx);
-	xmlFree(str);
+        if (reader->errorFunc)
+            reader->errorFunc(reader->errorFuncArg, str, severity,
+                              (xmlTextReaderLocatorPtr) ctx);
+        xmlFree(str);
     }
 }
 
-static void 
-xmlTextReaderStructuredError(void *ctxt, xmlErrorPtr error) {
-  xmlParserCtxtPtr ctx = (xmlParserCtxtPtr) ctxt;
-  xmlTextReaderPtr reader = (xmlTextReaderPtr) ctx->_private;
+static void
+xmlTextReaderStructuredError(void *ctxt, xmlErrorPtr error)
+{
+    xmlParserCtxtPtr ctx = (xmlParserCtxtPtr) ctxt;
 
-  if (error && reader->sErrorFunc) {
-	reader->sErrorFunc(reader->errorFuncArg,
-			   (xmlErrorPtr) error);
-  }
+    xmlTextReaderPtr reader = (xmlTextReaderPtr) ctx->_private;
+
+    if (error && reader->sErrorFunc) {
+        reader->sErrorFunc(reader->errorFuncArg, (xmlErrorPtr) error);
+    }
 }
 
-static void XMLCDECL 
-xmlTextReaderError(void *ctxt, const char *msg, ...) {
+static void XMLCDECL
+xmlTextReaderError(void *ctxt, const char *msg, ...)
+{
     va_list ap;
 
-    va_start(ap,msg);
+    va_start(ap, msg);
     xmlTextReaderGenericError(ctxt,
                               XML_PARSER_SEVERITY_ERROR,
-	                      xmlTextReaderBuildMessage(msg,ap));
+                              xmlTextReaderBuildMessage(msg, ap));
     va_end(ap);
 
 }
 
-static void XMLCDECL 
-xmlTextReaderWarning(void *ctxt, const char *msg, ...) {
+static void XMLCDECL
+xmlTextReaderWarning(void *ctxt, const char *msg, ...)
+{
     va_list ap;
 
-    va_start(ap,msg);
+    va_start(ap, msg);
     xmlTextReaderGenericError(ctxt,
                               XML_PARSER_SEVERITY_WARNING,
-	                      xmlTextReaderBuildMessage(msg,ap));
+                              xmlTextReaderBuildMessage(msg, ap));
     va_end(ap);
 }
 
-static void XMLCDECL 
-xmlTextReaderValidityError(void *ctxt, const char *msg, ...) {
+static void XMLCDECL
+xmlTextReaderValidityError(void *ctxt, const char *msg, ...)
+{
     va_list ap;
+
     int len = xmlStrlen((const xmlChar *) msg);
 
     if ((len > 1) && (msg[len - 2] != ':')) {
-	/* 
-	 * some callbacks only report locator information: 
-	 * skip them (mimicking behaviour in error.c) 
-	 */
-	va_start(ap,msg);
-	xmlTextReaderGenericError(ctxt,
-				  XML_PARSER_SEVERITY_VALIDITY_ERROR,
-				  xmlTextReaderBuildMessage(msg,ap));
-	va_end(ap);
+        /*
+         * some callbacks only report locator information:
+         * skip them (mimicking behaviour in error.c)
+         */
+        va_start(ap, msg);
+        xmlTextReaderGenericError(ctxt,
+                                  XML_PARSER_SEVERITY_VALIDITY_ERROR,
+                                  xmlTextReaderBuildMessage(msg, ap));
+        va_end(ap);
     }
 }
 
-static void XMLCDECL 
-xmlTextReaderValidityWarning(void *ctxt, const char *msg, ...) {
+static void XMLCDECL
+xmlTextReaderValidityWarning(void *ctxt, const char *msg, ...)
+{
     va_list ap;
+
     int len = xmlStrlen((const xmlChar *) msg);
 
     if ((len != 0) && (msg[len - 1] != ':')) {
-	/* 
-	 * some callbacks only report locator information: 
-	 * skip them (mimicking behaviour in error.c) 
-	 */
-	va_start(ap,msg);
-	xmlTextReaderGenericError(ctxt,
-				  XML_PARSER_SEVERITY_VALIDITY_WARNING,
-				  xmlTextReaderBuildMessage(msg,ap));
-	va_end(ap);
+        /*
+         * some callbacks only report locator information:
+         * skip them (mimicking behaviour in error.c)
+         */
+        va_start(ap, msg);
+        xmlTextReaderGenericError(ctxt,
+                                  XML_PARSER_SEVERITY_VALIDITY_WARNING,
+                                  xmlTextReaderBuildMessage(msg, ap));
+        va_end(ap);
     }
 }
 
@@ -4723,53 +4746,58 @@ xmlTextReaderValidityWarning(void *ctxt, const char *msg, ...) {
  * If @f is NULL, the default error and warning handlers are restored.
  */
 void
-xmlTextReaderSetErrorHandler(xmlTextReaderPtr reader, 
-			     xmlTextReaderErrorFunc f, 
-			     void *arg) {
+xmlTextReaderSetErrorHandler(xmlTextReaderPtr reader,
+                             xmlTextReaderErrorFunc f, void *arg)
+{
     if (f != NULL) {
-	reader->ctxt->sax->error = xmlTextReaderError;
-	reader->ctxt->sax->serror = NULL;
-	reader->ctxt->vctxt.error = xmlTextReaderValidityError;
-	reader->ctxt->sax->warning = xmlTextReaderWarning;
-	reader->ctxt->vctxt.warning = xmlTextReaderValidityWarning;
-	reader->errorFunc = f;
-	reader->sErrorFunc = NULL;
-	reader->errorFuncArg = arg;
+        reader->ctxt->sax->error = xmlTextReaderError;
+        reader->ctxt->sax->serror = NULL;
+        reader->ctxt->vctxt.error = xmlTextReaderValidityError;
+        reader->ctxt->sax->warning = xmlTextReaderWarning;
+        reader->ctxt->vctxt.warning = xmlTextReaderValidityWarning;
+        reader->errorFunc = f;
+        reader->sErrorFunc = NULL;
+        reader->errorFuncArg = arg;
 #ifdef LIBXML_SCHEMAS_ENABLED
-		if (reader->rngValidCtxt) {
-			xmlRelaxNGSetValidErrors(reader->rngValidCtxt,
-				 xmlTextReaderValidityErrorRelay,
-				 xmlTextReaderValidityWarningRelay,
-				 reader);
-			xmlRelaxNGSetValidStructuredErrors(reader->rngValidCtxt, NULL, reader);
-		}
-		if (reader->xsdValidCtxt) {
-			xmlSchemaSetValidErrors(reader->xsdValidCtxt,
-				 xmlTextReaderValidityErrorRelay,
-				 xmlTextReaderValidityWarningRelay,
-				 reader);
-			xmlSchemaSetValidStructuredErrors(reader->xsdValidCtxt, NULL, reader);
-		}
+        if (reader->rngValidCtxt) {
+            xmlRelaxNGSetValidErrors(reader->rngValidCtxt,
+                                     xmlTextReaderValidityErrorRelay,
+                                     xmlTextReaderValidityWarningRelay,
+                                     reader);
+            xmlRelaxNGSetValidStructuredErrors(reader->rngValidCtxt, NULL,
+                                               reader);
+        }
+        if (reader->xsdValidCtxt) {
+            xmlSchemaSetValidErrors(reader->xsdValidCtxt,
+                                    xmlTextReaderValidityErrorRelay,
+                                    xmlTextReaderValidityWarningRelay,
+                                    reader);
+            xmlSchemaSetValidStructuredErrors(reader->xsdValidCtxt, NULL,
+                                              reader);
+        }
 #endif
-    }
-    else {
-	/* restore defaults */
-	reader->ctxt->sax->error = xmlParserError;
-	reader->ctxt->vctxt.error = xmlParserValidityError;
-	reader->ctxt->sax->warning = xmlParserWarning;
-	reader->ctxt->vctxt.warning = xmlParserValidityWarning;
-	reader->errorFunc = NULL;
-	reader->sErrorFunc = NULL;
-	reader->errorFuncArg = NULL;
+    } else {
+        /* restore defaults */
+        reader->ctxt->sax->error = xmlParserError;
+        reader->ctxt->vctxt.error = xmlParserValidityError;
+        reader->ctxt->sax->warning = xmlParserWarning;
+        reader->ctxt->vctxt.warning = xmlParserValidityWarning;
+        reader->errorFunc = NULL;
+        reader->sErrorFunc = NULL;
+        reader->errorFuncArg = NULL;
 #ifdef LIBXML_SCHEMAS_ENABLED
-		if (reader->rngValidCtxt) {
-			xmlRelaxNGSetValidErrors(reader->rngValidCtxt, NULL, NULL, reader);
-			xmlRelaxNGSetValidStructuredErrors(reader->rngValidCtxt, NULL, reader);
-		}
-		if (reader->xsdValidCtxt) {
-			xmlSchemaSetValidErrors(reader->xsdValidCtxt, NULL, NULL, reader);
-			xmlSchemaSetValidStructuredErrors(reader->xsdValidCtxt, NULL, reader);
-		}
+        if (reader->rngValidCtxt) {
+            xmlRelaxNGSetValidErrors(reader->rngValidCtxt, NULL, NULL,
+                                     reader);
+            xmlRelaxNGSetValidStructuredErrors(reader->rngValidCtxt, NULL,
+                                               reader);
+        }
+        if (reader->xsdValidCtxt) {
+            xmlSchemaSetValidErrors(reader->xsdValidCtxt, NULL, NULL,
+                                    reader);
+            xmlSchemaSetValidStructuredErrors(reader->xsdValidCtxt, NULL,
+                                              reader);
+        }
 #endif
     }
 }
@@ -4785,54 +4813,59 @@ xmlTextReaderSetErrorHandler(xmlTextReaderPtr reader,
  * If @f is NULL, the default error and warning handlers are restored.
  */
 void
-xmlTextReaderSetStructuredErrorHandler(xmlTextReaderPtr reader, 
-					 xmlStructuredErrorFunc f, 
-					 void *arg) {
-  if (f != NULL) {
-	reader->ctxt->sax->error = NULL;
-	reader->ctxt->sax->serror = xmlTextReaderStructuredError;
-	reader->ctxt->vctxt.error = xmlTextReaderValidityError;
-	reader->ctxt->sax->warning = xmlTextReaderWarning;
-	reader->ctxt->vctxt.warning = xmlTextReaderValidityWarning;
-	reader->sErrorFunc = f;
-	reader->errorFunc = NULL;
-	reader->errorFuncArg = arg;
+xmlTextReaderSetStructuredErrorHandler(xmlTextReaderPtr reader,
+                                       xmlStructuredErrorFunc f, void *arg)
+{
+    if (f != NULL) {
+        reader->ctxt->sax->error = NULL;
+        reader->ctxt->sax->serror = xmlTextReaderStructuredError;
+        reader->ctxt->vctxt.error = xmlTextReaderValidityError;
+        reader->ctxt->sax->warning = xmlTextReaderWarning;
+        reader->ctxt->vctxt.warning = xmlTextReaderValidityWarning;
+        reader->sErrorFunc = f;
+        reader->errorFunc = NULL;
+        reader->errorFuncArg = arg;
 #ifdef LIBXML_SCHEMAS_ENABLED
-		if (reader->rngValidCtxt) {
-			xmlRelaxNGSetValidErrors(reader->rngValidCtxt, NULL, NULL, reader);
-			xmlRelaxNGSetValidStructuredErrors(reader->rngValidCtxt,
-				xmlTextReaderValidityStructuredRelay,
-				reader);
-		}
-		if (reader->xsdValidCtxt) {
-			xmlSchemaSetValidErrors(reader->xsdValidCtxt, NULL, NULL, reader);
-			xmlSchemaSetValidStructuredErrors(reader->xsdValidCtxt, 
-				xmlTextReaderValidityStructuredRelay,
-				reader);
-		}
+        if (reader->rngValidCtxt) {
+            xmlRelaxNGSetValidErrors(reader->rngValidCtxt, NULL, NULL,
+                                     reader);
+            xmlRelaxNGSetValidStructuredErrors(reader->rngValidCtxt,
+                                        xmlTextReaderValidityStructuredRelay,
+                                               reader);
+        }
+        if (reader->xsdValidCtxt) {
+            xmlSchemaSetValidErrors(reader->xsdValidCtxt, NULL, NULL,
+                                    reader);
+            xmlSchemaSetValidStructuredErrors(reader->xsdValidCtxt,
+                                       xmlTextReaderValidityStructuredRelay,
+                                              reader);
+        }
 #endif
-  }
-  else {
-	/* restore defaults */
-	reader->ctxt->sax->error = xmlParserError;
-	reader->ctxt->sax->serror = NULL;
-	reader->ctxt->vctxt.error = xmlParserValidityError;
-	reader->ctxt->sax->warning = xmlParserWarning;
-	reader->ctxt->vctxt.warning = xmlParserValidityWarning;
-	reader->errorFunc = NULL;
-	reader->sErrorFunc = NULL;
-	reader->errorFuncArg = NULL;
+    } else {
+        /* restore defaults */
+        reader->ctxt->sax->error = xmlParserError;
+        reader->ctxt->sax->serror = NULL;
+        reader->ctxt->vctxt.error = xmlParserValidityError;
+        reader->ctxt->sax->warning = xmlParserWarning;
+        reader->ctxt->vctxt.warning = xmlParserValidityWarning;
+        reader->errorFunc = NULL;
+        reader->sErrorFunc = NULL;
+        reader->errorFuncArg = NULL;
 #ifdef LIBXML_SCHEMAS_ENABLED
-		if (reader->rngValidCtxt) {
-			xmlRelaxNGSetValidErrors(reader->rngValidCtxt, NULL, NULL, reader);
-			xmlRelaxNGSetValidStructuredErrors(reader->rngValidCtxt, NULL, reader);
-		}
-		if (reader->xsdValidCtxt) {
-			xmlSchemaSetValidErrors(reader->xsdValidCtxt, NULL, NULL, reader);
-			xmlSchemaSetValidStructuredErrors(reader->xsdValidCtxt, NULL, reader);
-		}
+        if (reader->rngValidCtxt) {
+            xmlRelaxNGSetValidErrors(reader->rngValidCtxt, NULL, NULL,
+                                     reader);
+            xmlRelaxNGSetValidStructuredErrors(reader->rngValidCtxt, NULL,
+                                               reader);
+        }
+        if (reader->xsdValidCtxt) {
+            xmlSchemaSetValidErrors(reader->xsdValidCtxt, NULL, NULL,
+                                    reader);
+            xmlSchemaSetValidStructuredErrors(reader->xsdValidCtxt, NULL,
+                                              reader);
+        }
 #endif
-  }
+    }
 }
 
 /**
@@ -4844,17 +4877,19 @@ xmlTextReaderSetStructuredErrorHandler(xmlTextReaderPtr reader,
  * Returns the flag value 1 if valid, 0 if no, and -1 in case of error
  */
 int
-xmlTextReaderIsValid(xmlTextReaderPtr reader) {
-    if (reader == NULL) return(-1);
+xmlTextReaderIsValid(xmlTextReaderPtr reader)
+{
+    if (reader == NULL)
+        return (-1);
 #ifdef LIBXML_SCHEMAS_ENABLED
     if (reader->validate == XML_TEXTREADER_VALIDATE_RNG)
-        return(reader->rngValidErrors == 0);
+        return (reader->rngValidErrors == 0);
     if (reader->validate == XML_TEXTREADER_VALIDATE_XSD)
-        return(reader->xsdValidErrors == 0);
+        return (reader->xsdValidErrors == 0);
 #endif
     if ((reader->ctxt != NULL) && (reader->ctxt->validate == 1))
-	return(reader->ctxt->valid);
-    return(0);
+        return (reader->ctxt->valid);
+    return (0);
 }
 
 /**
@@ -4866,14 +4901,14 @@ xmlTextReaderIsValid(xmlTextReaderPtr reader) {
  * Retrieve the error callback function and user argument.
  */
 void
-xmlTextReaderGetErrorHandler(xmlTextReaderPtr reader, 
-			     xmlTextReaderErrorFunc *f, 
-			     void **arg) {
-    if (f != NULL) *f = reader->errorFunc;
-    if (arg != NULL) *arg = reader->errorFuncArg;
+xmlTextReaderGetErrorHandler(xmlTextReaderPtr reader,
+                             xmlTextReaderErrorFunc * f, void **arg)
+{
+    if (f != NULL)
+        *f = reader->errorFunc;
+    if (arg != NULL)
+        *arg = reader->errorFuncArg;
 }
-
-
 /************************************************************************
  *									*
  *	New set (2.6.0) of simpler and more flexible APIs		*
@@ -4890,7 +4925,7 @@ xmlTextReaderGetErrorHandler(xmlTextReaderPtr reader,
  * @options:  a combination of xmlParserOption
  *
  * Setup an XML reader with new options
- * 
+ *
  * Returns 0 in case of success and -1 in case of error.
  */
 int
@@ -5003,8 +5038,8 @@ xmlTextReaderSetup(xmlTextReaderPtr reader,
 	    inputStream->buf = buf;
 	    inputStream->base = inputStream->buf->buffer->content;
 	    inputStream->cur = inputStream->buf->buffer->content;
-	    inputStream->end = 
-		&inputStream->buf->buffer->content[inputStream->buf->buffer->use];
+	    inputStream->end =
+            &inputStream->buf->buffer->content[inputStream->buf->buffer->use];
 
 	    inputPush(reader->ctxt, inputStream);
 	    reader->cur = 0;
@@ -5105,14 +5140,14 @@ xmlTextReaderByteConsumed(xmlTextReaderPtr reader) {
         return(-1);
     return(xmlByteConsumed(reader->ctxt));
 }
- 
+
 
 /**
  * xmlReaderWalker:
  * @doc:  a preparsed document
  *
  * Create an xmltextReader for a preparsed document.
- * 
+ *
  * Returns the new reader or NULL in case of error.
  */
 xmlTextReaderPtr
@@ -5153,7 +5188,7 @@ xmlReaderWalker(xmlDocPtr doc)
  *
  * Create an xmltextReader for an XML in-memory document.
  * The parsing flags @options are a combination of xmlParserOption.
- * 
+ *
  * Returns the new reader or NULL in case of error.
  */
 xmlTextReaderPtr
@@ -5178,7 +5213,7 @@ xmlReaderForDoc(const xmlChar * cur, const char *URL, const char *encoding,
  *
  * parse an XML file from the filesystem or the network.
  * The parsing flags @options are a combination of xmlParserOption.
- * 
+ *
  * Returns the new reader or NULL in case of error.
  */
 xmlTextReaderPtr
@@ -5203,7 +5238,7 @@ xmlReaderForFile(const char *filename, const char *encoding, int options)
  *
  * Create an xmltextReader for an XML in-memory document.
  * The parsing flags @options are a combination of xmlParserOption.
- * 
+ *
  * Returns the new reader or NULL in case of error.
  */
 xmlTextReaderPtr
@@ -5239,7 +5274,7 @@ xmlReaderForMemory(const char *buffer, int size, const char *URL,
  * The parsing flags @options are a combination of xmlParserOption.
  * NOTE that the file descriptor will not be closed when the
  *      reader is closed or reset.
- * 
+ *
  * Returns the new reader or NULL in case of error.
  */
 xmlTextReaderPtr
@@ -5276,7 +5311,7 @@ xmlReaderForFd(int fd, const char *URL, const char *encoding, int options)
  *
  * Create an xmltextReader for an XML document from I/O functions and source.
  * The parsing flags @options are a combination of xmlParserOption.
- * 
+ *
  * Returns the new reader or NULL in case of error.
  */
 xmlTextReaderPtr
@@ -5311,7 +5346,7 @@ xmlReaderForIO(xmlInputReadCallback ioread, xmlInputCloseCallback ioclose,
  *
  * Setup an xmltextReader to parse a preparsed XML document.
  * This reuses the existing @reader xmlTextReader.
- * 
+ *
  * Returns 0 in case of success and -1 in case of error
  */
 int
@@ -5359,7 +5394,7 @@ xmlReaderNewWalker(xmlTextReaderPtr reader, xmlDocPtr doc)
  * Setup an xmltextReader to parse an XML in-memory document.
  * The parsing flags @options are a combination of xmlParserOption.
  * This reuses the existing @reader xmlTextReader.
- * 
+ *
  * Returns 0 in case of success and -1 in case of error
  */
 int
@@ -5389,7 +5424,7 @@ xmlReaderNewDoc(xmlTextReaderPtr reader, const xmlChar * cur,
  * parse an XML file from the filesystem or the network.
  * The parsing flags @options are a combination of xmlParserOption.
  * This reuses the existing @reader xmlTextReader.
- * 
+ *
  * Returns 0 in case of success and -1 in case of error
  */
 int
@@ -5423,7 +5458,7 @@ xmlReaderNewFile(xmlTextReaderPtr reader, const char *filename,
  * Setup an xmltextReader to parse an XML in-memory document.
  * The parsing flags @options are a combination of xmlParserOption.
  * This reuses the existing @reader xmlTextReader.
- * 
+ *
  * Returns 0 in case of success and -1 in case of error
  */
 int
@@ -5458,7 +5493,7 @@ xmlReaderNewMemory(xmlTextReaderPtr reader, const char *buffer, int size,
  *      reader is closed or reset.
  * The parsing flags @options are a combination of xmlParserOption.
  * This reuses the existing @reader xmlTextReader.
- * 
+ *
  * Returns 0 in case of success and -1 in case of error
  */
 int
@@ -5493,7 +5528,7 @@ xmlReaderNewFd(xmlTextReaderPtr reader, int fd,
  * and source.
  * The parsing flags @options are a combination of xmlParserOption.
  * This reuses the existing @reader xmlTextReader.
- * 
+ *
  * Returns 0 in case of success and -1 in case of error
  */
 int
@@ -5520,6 +5555,7 @@ xmlReaderNewIO(xmlTextReaderPtr reader, xmlInputReadCallback ioread,
  *									*
  ************************************************************************/
 #ifdef NOT_USED_YET
+
 /**
  * xmlBase64Decode:
  * @in:  the input buffer
@@ -5535,22 +5571,34 @@ xmlReaderNewIO(xmlTextReaderPtr reader, xmlInputReadCallback ioread,
  */
 static int
 xmlBase64Decode(const unsigned char *in, unsigned long *inlen,
-	        unsigned char *to, unsigned long *tolen) {
-    unsigned long incur;		/* current index in in[] */
-    unsigned long inblk;		/* last block index in in[] */
-    unsigned long outcur;		/* current index in out[] */
-    unsigned long inmax;		/* size of in[] */
-    unsigned long outmax;		/* size of out[] */
-    unsigned char cur;			/* the current value read from in[] */
-    unsigned char intmp[4], outtmp[4];	/* temporary buffers for the convert */
-    int nbintmp;			/* number of byte in intmp[] */
-    int is_ignore;			/* cur should be ignored */
-    int is_end = 0;			/* the end of the base64 was found */
+                unsigned char *to, unsigned long *tolen)
+{
+    unsigned long incur;        /* current index in in[] */
+
+    unsigned long inblk;        /* last block index in in[] */
+
+    unsigned long outcur;       /* current index in out[] */
+
+    unsigned long inmax;        /* size of in[] */
+
+    unsigned long outmax;       /* size of out[] */
+
+    unsigned char cur;          /* the current value read from in[] */
+
+    unsigned char intmp[4], outtmp[4];  /* temporary buffers for the convert */
+
+    int nbintmp;                /* number of byte in intmp[] */
+
+    int is_ignore;              /* cur should be ignored */
+
+    int is_end = 0;             /* the end of the base64 was found */
+
     int retval = 1;
+
     int i;
 
     if ((in == NULL) || (inlen == NULL) || (to == NULL) || (tolen == NULL))
-	return(-1);
+        return (-1);
 
     incur = 0;
     inblk = 0;
@@ -5576,16 +5624,17 @@ xmlBase64Decode(const unsigned char *in, unsigned long *inlen,
             cur = 63;
         else if (cur == '.')
             cur = 0;
-        else if (cur == '=') /*no op , end of the base64 stream */
+        else if (cur == '=')    /*no op , end of the base64 stream */
             is_end = 1;
         else {
             is_ignore = 1;
-	    if (nbintmp == 0)
-		inblk = incur;
-	}
+            if (nbintmp == 0)
+                inblk = incur;
+        }
 
         if (!is_ignore) {
             int nbouttmp = 3;
+
             int is_break = 0;
 
             if (is_end) {
@@ -5599,30 +5648,30 @@ xmlBase64Decode(const unsigned char *in, unsigned long *inlen,
                 is_break = 1;
             }
             intmp[nbintmp++] = cur;
-	    /*
-	     * if intmp is full, push the 4byte sequence as a 3 byte
-	     * sequence out
-	     */
+            /*
+             * if intmp is full, push the 4byte sequence as a 3 byte
+             * sequence out
+             */
             if (nbintmp == 4) {
                 nbintmp = 0;
                 outtmp[0] = (intmp[0] << 2) | ((intmp[1] & 0x30) >> 4);
                 outtmp[1] =
                     ((intmp[1] & 0x0F) << 4) | ((intmp[2] & 0x3C) >> 2);
                 outtmp[2] = ((intmp[2] & 0x03) << 6) | (intmp[3] & 0x3F);
-		if (outcur + 3 >= outmax) {
-		    retval = 2;
-		    break;
-		}
+                if (outcur + 3 >= outmax) {
+                    retval = 2;
+                    break;
+                }
 
                 for (i = 0; i < nbouttmp; i++)
-		    to[outcur++] = outtmp[i];
-		inblk = incur;
+                    to[outcur++] = outtmp[i];
+                inblk = incur;
             }
 
             if (is_break) {
-		retval = 0;
+                retval = 0;
                 break;
-	    }
+            }
         }
     }
 
@@ -5635,14 +5684,23 @@ xmlBase64Decode(const unsigned char *in, unsigned long *inlen,
  * Test routine for the xmlBase64Decode function
  */
 #if 0
-int main(int argc, char **argv) {
+int
+main(int argc, char **argv)
+{
     char *input = "  VW4 gcGV0        \n      aXQgdGVzdCAuCg== ";
+
     char output[100];
+
     char output2[100];
+
     char output3[100];
+
     unsigned long inlen = strlen(input);
+
     unsigned long outlen = 100;
+
     int ret;
+
     unsigned long cons, tmp, tmp2, prod;
 
     /*
@@ -5651,25 +5709,28 @@ int main(int argc, char **argv) {
     ret = xmlBase64Decode(input, &inlen, output, &outlen);
 
     output[outlen] = 0;
-    printf("ret: %d, inlen: %ld , outlen: %ld, output: '%s'\n", ret, inlen, outlen, output);
-    
+    printf("ret: %d, inlen: %ld , outlen: %ld, output: '%s'\n", ret, inlen,
+           outlen, output)indent: Standard input:179: Error:Unmatched #endif
+;
+
     /*
      * output chunking
      */
     cons = 0;
     prod = 0;
     while (cons < inlen) {
-	tmp = 5;
-	tmp2 = inlen - cons;
+        tmp = 5;
+        tmp2 = inlen - cons;
 
-	printf("%ld %ld\n", cons, prod);
-	ret = xmlBase64Decode(&input[cons], &tmp2, &output2[prod], &tmp);
-	cons += tmp2;
-	prod += tmp;
-	printf("%ld %ld\n", cons, prod);
+        printf("%ld %ld\n", cons, prod);
+        ret = xmlBase64Decode(&input[cons], &tmp2, &output2[prod], &tmp);
+        cons += tmp2;
+        prod += tmp;
+        printf("%ld %ld\n", cons, prod);
     }
     output2[outlen] = 0;
-    printf("ret: %d, cons: %ld , prod: %ld, output: '%s'\n", ret, cons, prod, output2);
+    printf("ret: %d, cons: %ld , prod: %ld, output: '%s'\n", ret, cons,
+           prod, output2);
 
     /*
      * input chunking
@@ -5677,20 +5738,21 @@ int main(int argc, char **argv) {
     cons = 0;
     prod = 0;
     while (cons < inlen) {
-	tmp = 100 - prod;
-	tmp2 = inlen - cons;
-	if (tmp2 > 5)
-	    tmp2 = 5;
+        tmp = 100 - prod;
+        tmp2 = inlen - cons;
+        if (tmp2 > 5)
+            tmp2 = 5;
 
-	printf("%ld %ld\n", cons, prod);
-	ret = xmlBase64Decode(&input[cons], &tmp2, &output3[prod], &tmp);
-	cons += tmp2;
-	prod += tmp;
-	printf("%ld %ld\n", cons, prod);
+        printf("%ld %ld\n", cons, prod);
+        ret = xmlBase64Decode(&input[cons], &tmp2, &output3[prod], &tmp);
+        cons += tmp2;
+        prod += tmp;
+        printf("%ld %ld\n", cons, prod);
     }
     output3[outlen] = 0;
-    printf("ret: %d, cons: %ld , prod: %ld, output: '%s'\n", ret, cons, prod, output3);
-    return(0);
+    printf("ret: %d, cons: %ld , prod: %ld, output: '%s'\n", ret, cons,
+           prod, output3);
+    return (0);
 
 }
 #endif



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]