cleanup patch from Anthony Jones fix the headers to avoid in make scan

* SAX.c: cleanup patch from Anthony Jones
* doc/Makefile.am: fix the headers to avoid in make scan
* parserInternals.c xpath.c include/libxml/*.h: cleanup of the
  includes, * vs Ptr and general cleanup
* parsedecl.py: first version of a script to extract the
  module interfaces, the goal will be to provide .decl or XML
  specification of the interfaces to build wrappers.
Daniel
diff --git a/ChangeLog b/ChangeLog
index b148b3b..6f248eb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+Sun Jan 20 23:03:41 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+	* SAX.c: cleanup patch from Anthony Jones
+	* doc/Makefile.am: fix the headers to avoid in make scan
+	* parserInternals.c xpath.c include/libxml/*.h: cleanup of the
+	  includes, * vs Ptr and general cleanup
+	* parsedecl.py: first version of a script to extract the
+	  module interfaces, the goal will be to provide .decl or XML
+	  specification of the interfaces to build wrappers.
+
 Sun Jan 20 13:38:22 CET 2002 Daniel Veillard <daniel@veillard.com>
 
 	* doc/xmlcatalog_man.xml xmlcatalog.c: Fixed bug #68830, xmlcatalog
diff --git a/DOCBparser.c b/DOCBparser.c
index aec90f0..8b196e9 100644
--- a/DOCBparser.c
+++ b/DOCBparser.c
@@ -847,18 +847,6 @@
 NULL
 };
 
-/*
- * The list of SGML elements which are supposed not to have
- * CDATA content and where a p element will be implied
- *
- * TODO: extend that list by reading the SGML SGML DTD on
- *       implied paragraph
- */
-static char *docbNoContentElements[] = {
-    NULL
-};
-
-
 static const char** docbStartCloseIndex[100];
 static int docbStartCloseIndexinitialized = 0;
 
diff --git a/SAX.c b/SAX.c
index ab02454..fee7739 100644
--- a/SAX.c
+++ b/SAX.c
@@ -1062,14 +1062,14 @@
 		        ((attr->prefix == NULL) &&
 			 (xmlStrEqual(attr->name, BAD_CAST "xmlns"))) ||
 			(ctxt->loadsubset & XML_COMPLETE_ATTRS)) {
-			xmlChar buffer[100];
-			const xmlChar *fulln = attr->name;
+			xmlChar *fulln;
 
 			if (attr->prefix != NULL) {
-			    snprintf((char *) buffer, 99, "%s:%s",
-				     attr->prefix, attr->name);
-			    buffer[99] = 0;
-			    fulln = buffer;
+			    fulln = xmlStrdup(attr->prefix);
+			    fulln = xmlStrcat(fulln, BAD_CAST ":");
+			    fulln = xmlStrcat(fulln, attr->name);
+			} else {
+			    fulln = xmlStrdup(attr->name);
 			}
 
 			/*
@@ -1089,6 +1089,7 @@
 			}
 			if (att == NULL)
 			    attribute(ctxt, fulln, attr->defaultValue);
+			xmlFree(fulln);
 		    }
 		}
 		attr = attr->nexth;
diff --git a/doc/Makefile.am b/doc/Makefile.am
index 95e03d9..4984d61 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -26,7 +26,7 @@
 	  $(bindir)/xsltproc --html $(top_srcdir)/doc/site.xsl $(top_srcdir)/doc/xml.html > index.html ; fi );
 
 scan:
-	gtkdoc-scan --module=libxml --source-dir=$(DOC_SOURCE_DIR) --ignore-headers="acconfig.h config.h xmlwin32version.h win32config.h trio.h strio.h triop.h"
+	gtkdoc-scan --module=libxml --source-dir=$(DOC_SOURCE_DIR) --ignore-headers="acconfig.h config.h xmlwin32version.h win32config.h trio.h triostr.h triop.h config-mac.h XMLTestPrefix2.h  XMLTestPrefix.h triodef.h trionan.h xlink.h"
 
 templates: scan
 	gtkdoc-mktmpl --module=libxml
diff --git a/include/libxml/DOCBparser.h b/include/libxml/DOCBparser.h
index 15195b6..5c4589b 100644
--- a/include/libxml/DOCBparser.h
+++ b/include/libxml/DOCBparser.h
@@ -30,9 +30,9 @@
 /*
  * There is only few public functions.
  */
-int                    docbEncodeEntities(unsigned char* out,
+int                    docbEncodeEntities(unsigned char *out,
                                         int *outlen,
-                                        const unsigned char* in,
+                                        const unsigned char *in,
                                         int *inlen, int quoteChar);
 
 docbDocPtr             docbSAXParseDoc (xmlChar *cur,
diff --git a/include/libxml/HTMLparser.h b/include/libxml/HTMLparser.h
index 5ba0eeb..2e7f009 100644
--- a/include/libxml/HTMLparser.h
+++ b/include/libxml/HTMLparser.h
@@ -58,16 +58,16 @@
 /*
  * There is only few public functions.
  */
-const htmlElemDesc *	htmlTagLookup	(const xmlChar *tag);
-const htmlEntityDesc *	htmlEntityLookup(const xmlChar *name);
-const htmlEntityDesc *	htmlEntityValueLookup(unsigned int value);
+const htmlElemDesc * 	htmlTagLookup	(const xmlChar *tag);
+const htmlEntityDesc * 	htmlEntityLookup(const xmlChar *name);
+const htmlEntityDesc * 	htmlEntityValueLookup(unsigned int value);
 
 int			htmlIsAutoClosed(htmlDocPtr doc,
 					 htmlNodePtr elem);
 int			htmlAutoCloseTag(htmlDocPtr doc,
 					 const xmlChar *name,
 					 htmlNodePtr elem);
-const htmlEntityDesc *	htmlParseEntityRef(htmlParserCtxtPtr ctxt,
+const htmlEntityDesc * 	htmlParseEntityRef(htmlParserCtxtPtr ctxt,
 					 xmlChar **str);
 int			htmlParseCharRef(htmlParserCtxtPtr ctxt);
 void			htmlParseElement(htmlParserCtxtPtr ctxt);
@@ -84,13 +84,13 @@
 					 void *userData);
 htmlDocPtr		htmlParseFile	(const char *filename,
 					 const char *encoding);
-int			UTF8ToHtml	(unsigned char* out,
+int			UTF8ToHtml	(unsigned char *out,
 					 int *outlen,
-					 const unsigned char* in,
+					 const unsigned char *in,
 					 int *inlen);
-int			htmlEncodeEntities(unsigned char* out,
+int			htmlEncodeEntities(unsigned char *out,
 					 int *outlen,
-					 const unsigned char* in,
+					 const unsigned char *in,
 					 int *inlen, int quoteChar);
 int			htmlIsScriptAttribute(const xmlChar *name);
 int			htmlHandleOmittedElem(int val);
diff --git a/include/libxml/HTMLtree.h b/include/libxml/HTMLtree.h
index 1f56775..e17a414 100644
--- a/include/libxml/HTMLtree.h
+++ b/include/libxml/HTMLtree.h
@@ -63,7 +63,7 @@
 int		htmlSetMetaEncoding	(htmlDocPtr doc,
 					 const xmlChar *encoding);
 void		htmlDocDumpMemory	(xmlDocPtr cur,
-					 xmlChar**mem,
+					 xmlChar **mem,
 					 int *size);
 int		htmlDocDump		(FILE *f,
 					 xmlDocPtr cur);
diff --git a/include/libxml/debugXML.h b/include/libxml/debugXML.h
index 32b40ce..f977d77 100644
--- a/include/libxml/debugXML.h
+++ b/include/libxml/debugXML.h
@@ -102,7 +102,8 @@
 			     xmlNodePtr node,
 			     xmlNodePtr node2);
 
-void	xmlShellPrintXPathError	(int errorType, const char* arg);
+void	xmlShellPrintXPathError	(int errorType,
+				 const char *arg);
 void	xmlShellPrintNode	(xmlNodePtr node);
 void	xmlShellPrintXPathResult(xmlXPathObjectPtr list);
 int	xmlShellList		(xmlShellCtxtPtr ctxt,
diff --git a/include/libxml/encoding.h b/include/libxml/encoding.h
index 6fbaf7e..23110f9 100644
--- a/include/libxml/encoding.h
+++ b/include/libxml/encoding.h
@@ -96,8 +96,8 @@
  *     as the return value is positive, else unpredictiable.
  * The value of @outlen after return is the number of octets consumed.
  */
-typedef int (* xmlCharEncodingInputFunc)(unsigned char* out, int *outlen,
-                                         const unsigned char* in, int *inlen);
+typedef int (* xmlCharEncodingInputFunc)(unsigned char *out, int *outlen,
+                                         const unsigned char *in, int *inlen);
 
 
 /**
@@ -118,8 +118,8 @@
  *     as the return value is positive, else unpredictiable.
  * The value of @outlen after return is the number of ocetes consumed.
  */
-typedef int (* xmlCharEncodingOutputFunc)(unsigned char* out, int *outlen,
-                                          const unsigned char* in, int *inlen);
+typedef int (* xmlCharEncodingOutputFunc)(unsigned char *out, int *outlen,
+                                          const unsigned char *in, int *inlen);
 
 
 /*
@@ -161,15 +161,15 @@
 	xmlGetEncodingAlias		(const char *alias);
 void	xmlCleanupEncodingAliases	(void);
 xmlCharEncoding
-	xmlParseCharEncoding		(const char* name);
-const char*
+	xmlParseCharEncoding		(const char *name);
+const char *
 	xmlGetCharEncodingName		(xmlCharEncoding enc);
 
 /*
  * Interfaces directly used by the parsers.
  */
 xmlCharEncoding
-	xmlDetectCharEncoding		(const unsigned char* in,
+	xmlDetectCharEncoding		(const unsigned char *in,
 					 int len);
 
 int	xmlCharEncOutFunc		(xmlCharEncodingHandler *handler,
@@ -187,13 +187,13 @@
 /*
  * Export a few useful functions
  */
-int	UTF8Toisolat1			(unsigned char* out,
+int	UTF8Toisolat1			(unsigned char *out,
 					 int *outlen,
-					 const unsigned char* in,
+					 const unsigned char *in,
 					 int *inlen);
-int	isolat1ToUTF8			(unsigned char* out,
+int	isolat1ToUTF8			(unsigned char *out,
 					 int *outlen,
-					 const unsigned char* in,
+					 const unsigned char *in,
 					 int *inlen);
 /*
  * exports additional "UTF-8 aware" string routines which are
diff --git a/include/libxml/nanoftp.h b/include/libxml/nanoftp.h
index 975f6f4..df45a6e 100644
--- a/include/libxml/nanoftp.h
+++ b/include/libxml/nanoftp.h
@@ -39,7 +39,7 @@
  * Note that only one of year and day:minute are specified
  */
 typedef void (*ftpListCallback) (void *userData,
-	                         const char *filename, const char* attrib,
+	                         const char *filename, const char *attrib,
 	                         const char *owner, const char *group,
 				 unsigned long size, int links, int year,
 				 const char *month, int day, int hour,
@@ -52,7 +52,9 @@
  *
  * A callback for the xmlNanoFTPGet command
  */
-typedef void (*ftpDataCallback) (void *userData, const char *data, int len);
+typedef void (*ftpDataCallback) (void *userData,
+				 const char *data,
+				 int len);
 
 /*
  * Init
diff --git a/include/libxml/parser.h b/include/libxml/parser.h
index 4f863c0..8800fe9 100644
--- a/include/libxml/parser.h
+++ b/include/libxml/parser.h
@@ -502,7 +502,7 @@
 void		xmlFreeParserCtxt	(xmlParserCtxtPtr ctxt);
 void		xmlSetupParserForBuffer	(xmlParserCtxtPtr ctxt,
 					 const xmlChar* buffer,
-					 const char* filename);
+					 const char *filename);
 xmlParserCtxtPtr xmlCreateDocParserCtxt	(xmlChar *cur);
 
 /*
@@ -550,14 +550,14 @@
  * Node infos
  */
 const xmlParserNodeInfo*
-		xmlParserFindNodeInfo	(const xmlParserCtxt* ctxt,
-                                               const xmlNode* node);
+		xmlParserFindNodeInfo	(const xmlParserCtxtPtr ctxt,
+				         const xmlNodePtr node);
 void		xmlInitNodeInfoSeq	(xmlParserNodeInfoSeqPtr seq);
 void		xmlClearNodeInfoSeq	(xmlParserNodeInfoSeqPtr seq);
-unsigned long xmlParserFindNodeInfoIndex(const xmlParserNodeInfoSeq* seq,
-                                         const xmlNode* node);
+unsigned long xmlParserFindNodeInfoIndex(const xmlParserNodeInfoSeqPtr seq,
+                                         const xmlNodePtr node);
 void		xmlParserAddNodeInfo	(xmlParserCtxtPtr ctxt,
-					 const xmlParserNodeInfo* info);
+					 const xmlParserNodeInfoPtr info);
 
 /*
  * External entities handling actually implemented in xmlIO
diff --git a/include/libxml/tree.h b/include/libxml/tree.h
index fd6065b..6eda9ec 100644
--- a/include/libxml/tree.h
+++ b/include/libxml/tree.h
@@ -787,11 +787,11 @@
  * Saving
  */
 void		xmlDocDumpFormatMemory	(xmlDocPtr cur,
-					 xmlChar**mem,
+					 xmlChar **mem,
 					 int *size,
 					 int format);
 void		xmlDocDumpMemory	(xmlDocPtr cur,
-					 xmlChar**mem,
+					 xmlChar **mem,
 					 int *size);
 void		xmlDocDumpMemoryEnc	(xmlDocPtr out_doc,
 					 xmlChar **doc_txt_ptr,
diff --git a/include/libxml/xpathInternals.h b/include/libxml/xpathInternals.h
index ccbf53f..5ffa441 100644
--- a/include/libxml/xpathInternals.h
+++ b/include/libxml/xpathInternals.h
@@ -335,8 +335,7 @@
 /*
  * Function Lookup forwarding
  */
-typedef xmlXPathFunction
-	(*xmlXPathFuncLookupFunc)	(void *ctxt,
+typedef xmlXPathFunction xmlXPathFuncLookupFunc	(void *ctxt,
 					 const xmlChar *name,
 					 const xmlChar *ns_uri);
 
@@ -448,7 +447,7 @@
 xmlXPathObjectPtr xmlXPathNewString		(const xmlChar *val);
 xmlXPathObjectPtr xmlXPathNewCString		(const char *val);
 xmlXPathObjectPtr xmlXPathWrapString		(xmlChar *val);
-xmlXPathObjectPtr xmlXPathWrapCString		(char *val);
+xmlXPathObjectPtr xmlXPathWrapCString		(char * val);
 xmlXPathObjectPtr xmlXPathNewFloat		(double val);
 xmlXPathObjectPtr xmlXPathNewBoolean		(int val);
 xmlXPathObjectPtr xmlXPathNewNodeSet		(xmlNodePtr val);
diff --git a/parsedecl.py b/parsedecl.py
new file mode 100755
index 0000000..c97e51a
--- /dev/null
+++ b/parsedecl.py
@@ -0,0 +1,185 @@
+#!/usr/bin/python -u
+#
+# tries to parse the output of gtk-doc declaration files and make
+# something usable from them
+#
+
+import sys
+import string
+
+input = open('doc/libxml-decl.txt')
+macros = []
+structs = []
+typedefs = []
+enums = {}
+functions = {}
+private_functions = {}
+types = {}
+
+def extractTypes(raw, function):
+    global types
+
+    tokens = string.split(raw)
+    type = ''
+    for token in tokens:
+	if type != '':
+	    type = type + ' ' + token
+	else:
+	    type = token
+    if types.has_key(type):
+        types[type].append(function)
+    else:
+        types[type] = [function]
+    return type
+
+def parseMacro():
+    global input
+    global macros
+
+    line = input.readline()[:-1]
+    while line != "</MACRO>":
+        if line[0:6] == "<NAME>" and line[-7:] == "</NAME>":
+	    name = line[6:-7]
+	line = input.readline()[:-1]
+
+    macros.append(name)
+
+def parseStruct():
+    global input
+    global structs
+
+    line = input.readline()[:-1]
+    while line != "</STRUCT>":
+        if line[0:6] == "<NAME>" and line[-7:] == "</NAME>":
+	    name = line[6:-7]
+	line = input.readline()[:-1]
+
+    structs.append(name)
+
+def parseTypedef():
+    global input
+    global typedefs
+
+    line = input.readline()[:-1]
+    while line != "</TYPEDEF>":
+        if line[0:6] == "<NAME>" and line[-7:] == "</NAME>":
+	    name = line[6:-7]
+	line = input.readline()[:-1]
+
+    typedefs.append(name)
+
+def parseEnum():
+    global input
+    global enums
+
+    line = input.readline()[:-1]
+    consts = []
+    while line != "</ENUM>":
+        if line[0:6] == "<NAME>" and line[-7:] == "</NAME>":
+	    name = line[6:-7]
+	elif string.find(line, 'enum') >= 0:
+	    pass
+	elif string.find(line, '{') >= 0:
+	    pass
+	elif string.find(line, '}') >= 0:
+	    pass
+	elif string.find(line, ';') >= 0:
+	    pass
+	else:
+	    comment = string.find(line, '/*')
+	    if comment >= 0:
+	        line = line[0:comment]
+	    decls = string.split(line, ",")
+	    for decl in decls:
+		val = string.split(decl, "=")[0]
+		tokens = string.split(val)
+		if len(tokens) >= 1:
+		    token = tokens[0]
+		    if string.find(string.letters, token[0]) >= 0:
+			consts.append(token)
+	line = input.readline()[:-1]
+        
+    enums[name] = consts
+
+def parseStaticFunction():
+    global input
+    global private_functions
+
+    line = input.readline()[:-1]
+    type = None
+    signature = None
+    while line != "</USER_FUNCTION>":
+        if line[0:6] == "<NAME>" and line[-7:] == "</NAME>":
+	    name = line[6:-7]
+        elif line[0:9] == "<RETURNS>" and line[-10:] == "</RETURNS>":
+	    type = extractTypes(line[9:-10], name)
+	else:
+	    signature = line
+	line = input.readline()[:-1]
+
+    args = string.split(signature, ",")
+    sig = []
+    for arg in args:
+        l = string.split(arg)
+	sig.append(extractTypes(l[0], name))
+
+    private_functions[name] = (type , sig)
+
+def parseFunction():
+    global input
+    global functions
+
+    line = input.readline()[:-1]
+    type = None
+    signature = None
+    while line != "</FUNCTION>":
+        if line[0:6] == "<NAME>" and line[-7:] == "</NAME>":
+	    name = line[6:-7]
+        elif line[0:9] == "<RETURNS>" and line[-10:] == "</RETURNS>":
+	    type = extractTypes(line[9:-10], name)
+	else:
+	    signature = line
+	line = input.readline()[:-1]
+
+    args = string.split(signature, ",")
+    sig = []
+    for arg in args:
+        l = string.split(arg)
+	sig.append(extractTypes(l[0], name))
+
+    functions[name] = (type , sig)
+
+while 1:
+    line = input.readline()
+    if not line:
+        break
+    line = line[:-1]
+    if line == "<MACRO>":
+        parseMacro()
+    elif line == "<ENUM>":
+        parseEnum()
+    elif line == "<FUNCTION>":
+        parseFunction()
+    elif line == "<STRUCT>":
+        parseStruct()
+    elif line == "<TYPEDEF>":
+        parseTypedef()
+    elif line == "<USER_FUNCTION>":
+        parseStaticFunction()
+    elif len(line) >= 1 and line[0] == "<":
+        print "unhandled %s" % (line)
+
+print "Parsed: %d macros. %d structs, %d typedefs, %d enums" % (
+          len(macros), len(structs), len(typedefs), len(enums))
+c = 0
+for enum in enums.keys():
+    consts = enums[enum]
+    c = c + len(consts)
+print "        %d constants, %d functions and %d private functions" % (
+          c, len(functions.keys()), len(private_functions.keys()))
+print "The functions uses %d different types" % (len(types.keys()))
+for type in types.keys():
+    if string.find(type, '*') >= 0 or (type[0:3] != 'xml' and
+       type[0:4] != 'html' and type[0:4] != 'docb'):
+#        print "  %s : %s" % (type, types[type])
+        print "  %s" % (type)
diff --git a/parserInternals.c b/parserInternals.c
index 4af5d71..031f3c1 100644
--- a/parserInternals.c
+++ b/parserInternals.c
@@ -2378,8 +2378,8 @@
  * 
  * Returns an xmlParserNodeInfo block pointer or NULL
  */
-const xmlParserNodeInfo* xmlParserFindNodeInfo(const xmlParserCtxt* ctx,
-                                               const xmlNode* node)
+const xmlParserNodeInfo* xmlParserFindNodeInfo(const xmlParserCtxtPtr ctx,
+                                               const xmlNodePtr node)
 {
   unsigned long pos;
 
@@ -2433,8 +2433,8 @@
  *
  * Returns a long indicating the position of the record
  */
-unsigned long xmlParserFindNodeInfoIndex(const xmlParserNodeInfoSeq* seq,
-                                         const xmlNode* node)
+unsigned long xmlParserFindNodeInfoIndex(const xmlParserNodeInfoSeqPtr seq,
+                                         const xmlNodePtr node)
 {
   unsigned long upper, lower, middle;
   int found = 0;
@@ -2470,13 +2470,14 @@
  */
 void
 xmlParserAddNodeInfo(xmlParserCtxtPtr ctxt, 
-                     const xmlParserNodeInfo* info)
+                     const xmlParserNodeInfoPtr info)
 {
   unsigned long pos;
   static unsigned int block_size = 5;
 
   /* Find pos and check to see if node is already in the sequence */
-  pos = xmlParserFindNodeInfoIndex(&ctxt->node_seq, info->node);
+  pos = xmlParserFindNodeInfoIndex(&ctxt->node_seq, (const xmlNodePtr)
+	                           info->node);
   if ( pos < ctxt->node_seq.length
        && ctxt->node_seq.buffer[pos].node == info->node ) {
     ctxt->node_seq.buffer[pos] = *info;
diff --git a/xpath.c b/xpath.c
index 8e3adb6..9b07ce6 100644
--- a/xpath.c
+++ b/xpath.c
@@ -2291,9 +2291,10 @@
 
     if (ctxt->funcLookupFunc != NULL) {
 	xmlXPathFunction ret;
+	xmlXPathFuncLookupFunc *f;
 
-	ret = ((xmlXPathFuncLookupFunc) ctxt->funcLookupFunc)
-	    (ctxt->funcLookupData, name, NULL);
+	f = (xmlXPathFuncLookupFunc *) ctxt->funcLookupFunc;
+	ret = f(ctxt->funcLookupData, name, NULL);
 	if (ret != NULL)
 	    return(ret);
     }
@@ -2321,9 +2322,10 @@
 
     if (ctxt->funcLookupFunc != NULL) {
 	xmlXPathFunction ret;
+	xmlXPathFuncLookupFunc *f;
 
-	ret = ((xmlXPathFuncLookupFunc) ctxt->funcLookupFunc)
-	    (ctxt->funcLookupData, name, ns_uri);
+	f = (xmlXPathFuncLookupFunc *) ctxt->funcLookupFunc;
+	ret = f(ctxt->funcLookupData, name, ns_uri);
 	if (ret != NULL)
 	    return(ret);
     }