Skip to content
Snippets Groups Projects
testapi.c 1.34 MiB
Newer Older
  • Learn to ignore specific revisions
  • /*
     * testapi.c: libxml2 API tester program.
     *
     * Automatically generated by gentest.py from libxml2-api.xml
     *
     * See Copyright for the status of this software.
     *
     * daniel@veillard.com
     */
    
    
    /* Disable deprecation warnings */
    #define XML_DEPRECATED
    
    
    #include <stdlib.h> /* for putenv() */
    
    #include <libxml/xmlerror.h>
    
    #include <libxml/relaxng.h>
    
    static int testlibxml2(void);
    
    static int test_module(const char *module);
    
    
    static int generic_errors = 0;
    static int call_tests = 0;
    
    static int function_tests = 0;
    
    Daniel Veillard's avatar
    Daniel Veillard committed
    static xmlChar chartab[1024];
    
    static int inttab[1024];
    static unsigned long longtab[1024];
    
    static xmlDtdPtr api_dtd = NULL;
    
    static xmlNodePtr api_root = NULL;
    static xmlAttrPtr api_attr = NULL;
    
    static xmlNsPtr api_ns = NULL;
    
    static void
    structured_errors(void *userData ATTRIBUTE_UNUSED,
                      xmlErrorPtr error ATTRIBUTE_UNUSED) {
        generic_errors++;
    }
    
    
    static void
    free_api_doc(void) {
        xmlFreeDoc(api_doc);
        api_doc = NULL;
    
        api_dtd = NULL;
    
        api_ns = NULL;
    
    }
    
    static xmlDocPtr
    get_api_doc(void) {
        if (api_doc == NULL) {
    
            api_doc = xmlReadMemory("<!DOCTYPE root [<!ELEMENT root EMPTY>]><root xmlns:h='http://example.com/' h:foo='bar'/>", 88, "root_test", NULL, 0);
    
    	api_root = NULL;
    	api_attr = NULL;
        }
        return(api_doc);
    }
    
    
    static xmlDtdPtr
    get_api_dtd(void) {
        if ((api_dtd == NULL) || (api_dtd->type != XML_DTD_NODE)) {
            get_api_doc();
    	if ((api_doc != NULL) && (api_doc->children != NULL) &&
    	    (api_doc->children->type == XML_DTD_NODE))
    
    	    api_dtd = (xmlDtdPtr) api_doc->children;
    
        }
        return(api_dtd);
    }
    
    
    static xmlNodePtr
    get_api_root(void) {
        if ((api_root == NULL) || (api_root->type != XML_ELEMENT_NODE)) {
            get_api_doc();
    	if ((api_doc != NULL) && (api_doc->children != NULL) &&
    
    	    (api_doc->children->next != NULL) &&
    	    (api_doc->children->next->type == XML_ELEMENT_NODE))
    	    api_root = api_doc->children->next;
    
    static xmlNsPtr
    get_api_ns(void) {
        get_api_root();
        if (api_root != NULL)
            api_ns = api_root->nsDef;
        return(api_ns);
    }
    
    
    #if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XINCLUDE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_HTML_ENABLED)
    
    
        if ((api_root == NULL) || (api_root->type != XML_ELEMENT_NODE)) {
            get_api_root();
        }
    
        if (api_root == NULL)
    
            return(NULL);
        if (api_root->properties != NULL) {
            api_attr = api_root->properties;
            return(api_root->properties);
        }
    
        api_attr = NULL;
    #if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XINCLUDE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_HTML_ENABLED)
    
        snprintf((char *) name, 20, "foo%d", nr++);
        api_attr = xmlSetProp(api_root, name, (const xmlChar *) "bar");
    
        int ret;
        int blocks, mem;
    
    
        /* access to the proxy can slow up regression tests a lot */
    
    Daniel Veillard's avatar
    Daniel Veillard committed
        memset(chartab, 0, sizeof(chartab));
    
        strncpy((char *) chartab, "  chartab\n", 20);
    
    Daniel Veillard's avatar
    Daniel Veillard committed
        memset(inttab, 0, sizeof(inttab));
        memset(longtab, 0, sizeof(longtab));
    
    
    #ifdef LIBXML_SCHEMAS_ENABLED
    
        LIBXML_TEST_VERSION
    
        xmlSetStructuredErrorFunc(NULL, structured_errors);
    
        xmlSetExternalEntityLoader(xmlNoNetExternalEntityLoader);
    
        if (argc >= 2) {
            if (!strcmp(argv[1], "-q")) {
    	    quiet = 1;
    	    if (argc >= 3)
    	        ret = test_module(argv[2]);
    	    else
    		ret = testlibxml2();
            } else {
    	   ret = test_module(argv[1]);
    	}
        } else
    
    
        xmlCleanupParser();
        blocks = xmlMemBlocks();
        mem = xmlMemUsed();
        if ((blocks != 0) || (mem != 0)) {
            printf("testapi leaked %d bytes in %d blocks\n", mem, blocks);
        }
        xmlMemoryDump();
    
        return (ret != 0);
    }
    
    #include <libxml/HTMLparser.h>
    #include <libxml/HTMLtree.h>
    #include <libxml/catalog.h>
    #include <libxml/chvalid.h>
    #include <libxml/dict.h>
    #include <libxml/encoding.h>
    #include <libxml/entities.h>
    #include <libxml/hash.h>
    #include <libxml/list.h>
    #include <libxml/nanoftp.h>
    #include <libxml/nanohttp.h>
    #include <libxml/parser.h>
    
    #include <libxml/parserInternals.h>
    
    #include <libxml/pattern.h>
    #include <libxml/relaxng.h>
    #include <libxml/schemasInternals.h>
    
    #include <libxml/tree.h>
    #include <libxml/uri.h>
    #include <libxml/valid.h>
    #include <libxml/xinclude.h>
    #include <libxml/xmlIO.h>
    #include <libxml/xmlerror.h>
    #include <libxml/xmlreader.h>
    #include <libxml/xmlsave.h>
    #include <libxml/xmlschemas.h>
    #include <libxml/xmlschemastypes.h>
    #include <libxml/xmlstring.h>
    #include <libxml/xmlwriter.h>
    #include <libxml/xpath.h>
    #include <libxml/xpointer.h>
    
      We manually define xmlErrMemory because it's normal declaration
      is "hidden" by #ifdef IN_LIBXML
    */
    void xmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra);
    
    
    /*
     We need some "remote" addresses, but want to avoid getting into
     name resolution delays, so we use these
    */
    #define	REMOTE1GOOD	"http://localhost/"
    
    #define	REMOTE1BAD	"http:http://http"
    
    #define	REMOTE2GOOD	"ftp://localhost/foo"
    
    
    #define gen_nb_void_ptr 2
    
    static void *gen_void_ptr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
    
    static void des_void_ptr(int no ATTRIBUTE_UNUSED, void *val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
    
    #define gen_nb_const_void_ptr 2
    
    static const void *gen_const_void_ptr(int no, int nr ATTRIBUTE_UNUSED) {
        if (no == 0) return((const void *) "immutable string");
        return(NULL);
    }
    static void des_const_void_ptr(int no ATTRIBUTE_UNUSED, const void *val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
    }
    
    static void *gen_userdata(int no, int nr ATTRIBUTE_UNUSED) {
    
        if (no == 0) return((void *) &call_tests);
        if (no == 1) return((void *) -1);
        return(NULL);
    }
    
    static void des_userdata(int no ATTRIBUTE_UNUSED, void *val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
    
    #define gen_nb_int 4
    
    
    static int gen_int(int no, int nr ATTRIBUTE_UNUSED) {
        if (no == 0) return(0);
        if (no == 1) return(1);
    
        if (no == 2) return(-1);
        if (no == 3) return(122);
    
        return(-1);
    }
    
    static void des_int(int no ATTRIBUTE_UNUSED, int val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
    }
    
    
    #define gen_nb_parseroptions 5
    
    static int gen_parseroptions(int no, int nr ATTRIBUTE_UNUSED) {
        if (no == 0) return(XML_PARSE_NOBLANKS | XML_PARSE_RECOVER);
        if (no == 1) return(XML_PARSE_NOENT | XML_PARSE_DTDLOAD | XML_PARSE_DTDATTR | XML_PARSE_DTDVALID | XML_PARSE_NOCDATA);
        if (no == 2) return(XML_PARSE_XINCLUDE | XML_PARSE_NOXINCNODE | XML_PARSE_NSCLEAN);
        if (no == 3) return(XML_PARSE_XINCLUDE | XML_PARSE_NODICT);
        return(XML_PARSE_SAX1);
    }
    
    static void des_parseroptions(int no ATTRIBUTE_UNUSED, int val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
    }
    
    
    #define gen_nb_long 5
    
    
    static long gen_long(int no, int nr ATTRIBUTE_UNUSED) {
        if (no == 0) return(0);
        if (no == 1) return(1);
    
        if (no == 2) return(-1);
        if (no == 3) return(122);
    
        return(-1);
    }
    
    static void des_long(int no ATTRIBUTE_UNUSED, long val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
    }
    
    #define gen_nb_xmlChar 4
    
    static xmlChar gen_xmlChar(int no, int nr ATTRIBUTE_UNUSED) {
        if (no == 0) return('a');
        if (no == 1) return(' ');
    
        if (no == 2) return((xmlChar) '\xf8');
    
        return(0);
    }
    
    static void des_xmlChar(int no ATTRIBUTE_UNUSED, xmlChar val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
    }
    
    
    #define gen_nb_unsigned_int 3
    
    static unsigned int gen_unsigned_int(int no, int nr ATTRIBUTE_UNUSED) {
    
        if (no == 0) return(0);
        if (no == 1) return(1);
        if (no == 2) return(122);
    
    static void des_unsigned_int(int no ATTRIBUTE_UNUSED, unsigned int val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
    
    #ifdef LIBXML_SCHEMAS_ENABLED
    
    
    #define gen_nb_unsigned_long 4
    
    
    static unsigned long gen_unsigned_long(int no, int nr ATTRIBUTE_UNUSED) {
        if (no == 0) return(0);
        if (no == 1) return(1);
        if (no == 2) return(122);
    
    }
    
    static void des_unsigned_long(int no ATTRIBUTE_UNUSED, unsigned long val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
    }
    
    
    #define gen_nb_unsigned_long_ptr 2
    
    static unsigned long *gen_unsigned_long_ptr(int no, int nr) {
        if (no == 0) return(&longtab[nr]);
        return(NULL);
    }
    
    static void des_unsigned_long_ptr(int no ATTRIBUTE_UNUSED, unsigned long *val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
    }
    
    #endif /* LIBXML_SCHEMAS_ENABLED */
    
    #if defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
    
    
    #define gen_nb_double 4
    
    static double gen_double(int no, int nr ATTRIBUTE_UNUSED) {
        if (no == 0) return(0);
        if (no == 1) return(-1.1);
    
        if (no == 2) return(xmlXPathNAN);
    
        return(-1);
    }
    
    static void des_double(int no ATTRIBUTE_UNUSED, double val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
    }
    
    
    #endif /* defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) */
    
    
    #define gen_nb_int_ptr 2
    
    static int *gen_int_ptr(int no, int nr) {
        if (no == 0) return(&inttab[nr]);
        return(NULL);
    }
    
    static void des_int_ptr(int no ATTRIBUTE_UNUSED, int *val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
    }
    
    
    #define gen_nb_const_char_ptr 4
    
    
    static char *gen_const_char_ptr(int no, int nr ATTRIBUTE_UNUSED) {
        if (no == 0) return((char *) "foo");
        if (no == 1) return((char *) "<foo/>");
        if (no == 2) return((char *) "test/ent2");
    
        return(NULL);
    }
    
    static void des_const_char_ptr(int no ATTRIBUTE_UNUSED, const char *val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
    
    #define gen_nb_xmlChar_ptr 2
    
    
    static xmlChar *gen_xmlChar_ptr(int no, int nr ATTRIBUTE_UNUSED) {
    
        if (no == 0) return(&chartab[0]);
    
    static void des_xmlChar_ptr(int no ATTRIBUTE_UNUSED, xmlChar *val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
    
    #define gen_nb_FILE_ptr 2
    
    static FILE *gen_FILE_ptr(int no, int nr ATTRIBUTE_UNUSED) {
        if (no == 0) return(fopen("test.out", "a+"));
        return(NULL);
    }
    static void des_FILE_ptr(int no ATTRIBUTE_UNUSED, FILE *val, int nr ATTRIBUTE_UNUSED) {
        if (val != NULL) fclose(val);
    }
    
    
    #ifdef LIBXML_DEBUG_ENABLED
    
    #define gen_nb_debug_FILE_ptr 2
    static FILE *gen_debug_FILE_ptr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
        return(fopen("test.out", "a+"));
    }
    static void des_debug_FILE_ptr(int no ATTRIBUTE_UNUSED, FILE *val, int nr ATTRIBUTE_UNUSED) {
        if (val != NULL) fclose(val);
    }
    
    #define gen_nb_const_xmlChar_ptr 5
    
    
    static xmlChar *gen_const_xmlChar_ptr(int no, int nr ATTRIBUTE_UNUSED) {
        if (no == 0) return((xmlChar *) "foo");
        if (no == 1) return((xmlChar *) "<foo/>");
    
        if (no == 2) return((xmlChar *) "n" "\xf8" "ne");
    
        if (no == 3) return((xmlChar *) " 2ab ");
    
        return(NULL);
    }
    
    static void des_const_xmlChar_ptr(int no ATTRIBUTE_UNUSED, const xmlChar *val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
    
    }
    
    #define gen_nb_filepath 8
    
    
    static const char *gen_filepath(int no, int nr ATTRIBUTE_UNUSED) {
    
        if (no == 0) return("missing.xml");
        if (no == 1) return("<foo/>");
        if (no == 2) return("test/ent2");
        if (no == 3) return("test/valid/REC-xml-19980210.xml");
    
        if (no == 4) return("test/valid/dtds/xhtml1-strict.dtd");
    
        if (no == 5) return(REMOTE1GOOD);
        if (no == 6) return(REMOTE1BAD);
    
        return(NULL);
    }
    
    static void des_filepath(int no ATTRIBUTE_UNUSED, const char *val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
    
    #define gen_nb_eaten_name 2
    
    static xmlChar *gen_eaten_name(int no, int nr ATTRIBUTE_UNUSED) {
    
        if (no == 0) return(xmlStrdup(BAD_CAST "eaten"));
    
        return(NULL);
    }
    static void des_eaten_name(int no ATTRIBUTE_UNUSED, xmlChar *val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
    }
    
    
    #define gen_nb_fileoutput 6
    
    
    static const char *gen_fileoutput(int no, int nr ATTRIBUTE_UNUSED) {
    
        if (no == 0) return("missing.xml");
    
        if (no == 1) return("<foo/>");
    
        if (no == 2) return(REMOTE2GOOD);
        if (no == 3) return(REMOTE1GOOD);
        if (no == 4) return(REMOTE1BAD);
    
        return(NULL);
    }
    
    static void des_fileoutput(int no ATTRIBUTE_UNUSED, const char *val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
    
    static xmlParserCtxtPtr gen_xmlParserCtxtPtr(int no, int nr ATTRIBUTE_UNUSED) {
    
        if (no == 0) return(xmlNewParserCtxt());
    
        if (no == 1) return(xmlCreateMemoryParserCtxt("<doc/>", 6));
    
        return(NULL);
    }
    
    static void des_xmlParserCtxtPtr(int no ATTRIBUTE_UNUSED, xmlParserCtxtPtr val, int nr ATTRIBUTE_UNUSED) {
    
        if (val != NULL)
            xmlFreeParserCtxt(val);
    }
    
    
    #ifdef LIBXML_SAX1_ENABLED
    
    #define gen_nb_xmlSAXHandlerPtr 2
    static xmlSAXHandlerPtr gen_xmlSAXHandlerPtr(int no, int nr ATTRIBUTE_UNUSED) {
        if (no == 0) return((xmlSAXHandlerPtr) &xmlDefaultSAXHandler);
        return(NULL);
    }
    static void des_xmlSAXHandlerPtr(int no ATTRIBUTE_UNUSED, xmlSAXHandlerPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
    }
    
    static xmlValidCtxtPtr gen_xmlValidCtxtPtr(int no, int nr ATTRIBUTE_UNUSED) {
    
        if (no == 0) return(xmlNewValidCtxt());
    
    static void des_xmlValidCtxtPtr(int no ATTRIBUTE_UNUSED, xmlValidCtxtPtr val, int nr ATTRIBUTE_UNUSED) {
    
    #define gen_nb_xmlParserInputBufferPtr 8
    
    static xmlParserInputBufferPtr gen_xmlParserInputBufferPtr(int no, int nr ATTRIBUTE_UNUSED) {
        if (no == 0) return(xmlParserInputBufferCreateFilename("missing.xml", XML_CHAR_ENCODING_NONE));
        if (no == 1) return(xmlParserInputBufferCreateFilename("<foo/>", XML_CHAR_ENCODING_NONE));
        if (no == 2) return(xmlParserInputBufferCreateFilename("test/ent2", XML_CHAR_ENCODING_NONE));
        if (no == 3) return(xmlParserInputBufferCreateFilename("test/valid/REC-xml-19980210.xml", XML_CHAR_ENCODING_NONE));
        if (no == 4) return(xmlParserInputBufferCreateFilename("test/valid/dtds/xhtml1-strict.dtd", XML_CHAR_ENCODING_NONE));
    
        if (no == 5) return(xmlParserInputBufferCreateFilename(REMOTE1GOOD, XML_CHAR_ENCODING_NONE));
        if (no == 6) return(xmlParserInputBufferCreateFilename(REMOTE1BAD, XML_CHAR_ENCODING_NONE));
    
        return(NULL);
    }
    static void des_xmlParserInputBufferPtr(int no ATTRIBUTE_UNUSED, xmlParserInputBufferPtr val, int nr ATTRIBUTE_UNUSED) {
        xmlFreeParserInputBuffer(val);
    }
    
    
    static xmlDocPtr gen_xmlDocPtr(int no, int nr ATTRIBUTE_UNUSED) {
    
        if (no == 0) return(xmlNewDoc(BAD_CAST "1.0"));
        if (no == 1) return(xmlReadMemory("<foo/>", 6, "test", NULL, 0));
    
        if (no == 2) return(xmlReadMemory("<!DOCTYPE foo []> <foo/>", 24, "test", NULL, 0));
    
        return(NULL);
    }
    
    static void des_xmlDocPtr(int no ATTRIBUTE_UNUSED, xmlDocPtr val, int nr ATTRIBUTE_UNUSED) {
    
        if ((val != NULL) && (val != api_doc) && (val->doc != api_doc))
    
            xmlFreeDoc(val);
    }
    
    
    #define gen_nb_xmlAttrPtr 2
    static xmlAttrPtr gen_xmlAttrPtr(int no, int nr ATTRIBUTE_UNUSED) {
        if (no == 0) return(get_api_attr());
        return(NULL);
    }
    static void des_xmlAttrPtr(int no, xmlAttrPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
        if (no == 0) free_api_doc();
    }
    
    
    #define gen_nb_xmlDictPtr 2
    static xmlDictPtr gen_xmlDictPtr(int no, int nr ATTRIBUTE_UNUSED) {
        if (no == 0) return(xmlDictCreate());
        return(NULL);
    }
    static void des_xmlDictPtr(int no ATTRIBUTE_UNUSED, xmlDictPtr val, int nr ATTRIBUTE_UNUSED) {
        if (val != NULL)
            xmlDictFree(val);
    }
    
    
    static xmlNodePtr gen_xmlNodePtr(int no, int nr ATTRIBUTE_UNUSED) {
    
        if (no == 0) return(xmlNewPI(BAD_CAST "test", NULL));
    
        if (no == 1) return(get_api_root());
    
        return(NULL);
    
    /*     if (no == 2) return((xmlNodePtr) get_api_doc()); */
    
    static void des_xmlNodePtr(int no, xmlNodePtr val, int nr ATTRIBUTE_UNUSED) {
    
        if (no == 1) {
            free_api_doc();
        } else if (val != NULL) {
    
            xmlUnlinkNode(val);
            xmlFreeNode(val);
        }
    }
    
    
    #define gen_nb_xmlDtdPtr 3
    static xmlDtdPtr gen_xmlDtdPtr(int no, int nr ATTRIBUTE_UNUSED) {
    
        if (no == 0)
    
            return(xmlNewDtd(NULL, BAD_CAST "dtd", BAD_CAST"foo", BAD_CAST"bar"));
    
        if (no == 1) return(get_api_dtd());
        return(NULL);
    }
    static void des_xmlDtdPtr(int no, xmlDtdPtr val, int nr ATTRIBUTE_UNUSED) {
        if (no == 1) free_api_doc();
        else if (val != NULL) {
    
            xmlUnlinkNode((xmlNodePtr) val);
            xmlFreeNode((xmlNodePtr) val);
    
        }
    }
    
    #define gen_nb_xmlNsPtr 2
    static xmlNsPtr gen_xmlNsPtr(int no, int nr ATTRIBUTE_UNUSED) {
        if (no == 0) return(get_api_ns());
        return(NULL);
    }
    static void des_xmlNsPtr(int no, xmlNsPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
        if (no == 0) free_api_doc();
    }
    
    
    #define gen_nb_xmlNodePtr_in 3
    
    static xmlNodePtr gen_xmlNodePtr_in(int no, int nr ATTRIBUTE_UNUSED) {
    
        if (no == 0) return(xmlNewPI(BAD_CAST "test", NULL));
        if (no == 0) return(xmlNewText(BAD_CAST "text"));
        return(NULL);
    }
    
    static void des_xmlNodePtr_in(int no ATTRIBUTE_UNUSED, xmlNodePtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
    
    #ifdef LIBXML_WRITER_ENABLED
    
    static xmlTextWriterPtr gen_xmlTextWriterPtr(int no, int nr ATTRIBUTE_UNUSED) {
    
        if (no == 0) return(xmlNewTextWriterFilename("test.out", 0));
        return(NULL);
    }
    
    static void des_xmlTextWriterPtr(int no ATTRIBUTE_UNUSED, xmlTextWriterPtr val, int nr ATTRIBUTE_UNUSED) {
    
        if (val != NULL) xmlFreeTextWriter(val);
    }
    
    #endif
    
    #ifdef LIBXML_READER_ENABLED
    
    static xmlTextReaderPtr gen_xmlTextReaderPtr(int no, int nr ATTRIBUTE_UNUSED) {
    
        if (no == 0) return(xmlNewTextReaderFilename("test/ent2"));
        if (no == 1) return(xmlNewTextReaderFilename("test/valid/REC-xml-19980210.xml"));
        if (no == 2) return(xmlNewTextReaderFilename("test/valid/dtds/xhtml1-strict.dtd"));
        return(NULL);
    }
    
    static void des_xmlTextReaderPtr(int no ATTRIBUTE_UNUSED, xmlTextReaderPtr val, int nr ATTRIBUTE_UNUSED) {
    
        if (val != NULL) xmlFreeTextReader(val);
    }
    
    static const xmlChar *static_buf_content = (xmlChar *)"a static buffer";
    
    static xmlBufferPtr gen_xmlBufferPtr(int no, int nr ATTRIBUTE_UNUSED) {
    
        if (no == 0) return(xmlBufferCreate());
    
        if (no == 1) return(xmlBufferCreateStatic((void *)static_buf_content, 13));
    
    static void des_xmlBufferPtr(int no ATTRIBUTE_UNUSED, xmlBufferPtr val, int nr ATTRIBUTE_UNUSED) {
    
        if (val != NULL) {
            xmlBufferFree(val);
        }
    }
    
    #define gen_nb_xmlListPtr 2
    
    static xmlListPtr gen_xmlListPtr(int no, int nr ATTRIBUTE_UNUSED) {
    
        if (no == 0) return(xmlListCreate(NULL, NULL));
        return(NULL);
    }
    
    static void des_xmlListPtr(int no ATTRIBUTE_UNUSED, xmlListPtr val, int nr ATTRIBUTE_UNUSED) {
    
        if (val != NULL) {
            xmlListDelete(val);
        }
    }
    
    #define gen_nb_xmlHashTablePtr 2
    
    static xmlHashTablePtr gen_xmlHashTablePtr(int no, int nr ATTRIBUTE_UNUSED) {
    
        if (no == 0) return(xmlHashCreate(10));
        return(NULL);
    }
    
    static void des_xmlHashTablePtr(int no ATTRIBUTE_UNUSED, xmlHashTablePtr val, int nr ATTRIBUTE_UNUSED) {
    
        if (val != NULL) {
            xmlHashFree(val, NULL);
        }
    }
    
    #include <libxml/xpathInternals.h>
    
    
    #ifdef LIBXML_XPATH_ENABLED
    
    #define gen_nb_xmlXPathObjectPtr 5
    
    static xmlXPathObjectPtr gen_xmlXPathObjectPtr(int no, int nr ATTRIBUTE_UNUSED) {
    
        if (no == 0) return(xmlXPathNewString(BAD_CAST "string object"));
        if (no == 1) return(xmlXPathNewFloat(1.1));
        if (no == 2) return(xmlXPathNewBoolean(1));
        if (no == 3) return(xmlXPathNewNodeSet(NULL));
        return(NULL);
    }
    
    static void des_xmlXPathObjectPtr(int no ATTRIBUTE_UNUSED, xmlXPathObjectPtr val, int nr ATTRIBUTE_UNUSED) {
    
        if (val != NULL) {
            xmlXPathFreeObject(val);
        }
    }
    
    #endif
    
    #ifdef LIBXML_OUTPUT_ENABLED
    
    #define gen_nb_xmlOutputBufferPtr 2
    static xmlOutputBufferPtr gen_xmlOutputBufferPtr(int no, int nr ATTRIBUTE_UNUSED) {
        if (no == 0) return(xmlOutputBufferCreateFilename("test.out", NULL, 0));
        return(NULL);
    }
    static void des_xmlOutputBufferPtr(int no ATTRIBUTE_UNUSED, xmlOutputBufferPtr val, int nr ATTRIBUTE_UNUSED) {
        if (val != NULL) {
            xmlOutputBufferClose(val);
        }
    }
    
    #endif
    
    #ifdef LIBXML_HTTP_ENABLED
    
    #define gen_nb_xmlNanoHTTPCtxtPtr 1
    
    static void *gen_xmlNanoHTTPCtxtPtr(int no, int nr ATTRIBUTE_UNUSED) {
        if (no == 0) return(xmlNanoHTTPOpen(REMOTE1GOOD, NULL));
        if (no == 1) return(xmlNanoHTTPOpen(REMOTE2GOOD, NULL));
        if (no == 2) return(xmlNanoHTTPOpen(REMOTE1BAD, NULL));
        return(NULL);
    }
    static void des_xmlNanoHTTPCtxtPtr(int no ATTRIBUTE_UNUSED, void *val, int nr ATTRIBUTE_UNUSED) {
        if (val != NULL) {
    	xmlNanoHTTPClose(val);
        }
    
    #define gen_nb_xmlCharEncoding 4
    static xmlCharEncoding gen_xmlCharEncoding(int no, int nr ATTRIBUTE_UNUSED) {
        if (no == 0) return(XML_CHAR_ENCODING_UTF8);
        if (no == 1) return(XML_CHAR_ENCODING_NONE);
    
        if (no == 2) return(XML_CHAR_ENCODING_8859_1);
    
        return(XML_CHAR_ENCODING_ERROR);
    }
    static void des_xmlCharEncoding(int no ATTRIBUTE_UNUSED, xmlCharEncoding val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
    }
    
    
    #if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_EXPR_ENABLED)
    
    #define gen_nb_xmlExpCtxtPtr 1
    static xmlExpCtxtPtr gen_xmlExpCtxtPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
        return(NULL);
    }
    static void des_xmlExpCtxtPtr(int no ATTRIBUTE_UNUSED, xmlExpCtxtPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
    }
    
    #define gen_nb_xmlExpNodePtr 1
    static xmlExpNodePtr gen_xmlExpNodePtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
        return(NULL);
    }
    static void des_xmlExpNodePtr(int no ATTRIBUTE_UNUSED, xmlExpNodePtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
    }
    
    #endif
    
    
    #if defined(LIBXML_SCHEMAS_ENABLED)
    #define gen_nb_xmlSchemaPtr 1
    static xmlSchemaPtr gen_xmlSchemaPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
        return(NULL);
    }
    static void des_xmlSchemaPtr(int no ATTRIBUTE_UNUSED, xmlSchemaPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
    }
    
    #define gen_nb_xmlSchemaValidCtxtPtr 1
    static xmlSchemaValidCtxtPtr gen_xmlSchemaValidCtxtPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
        return(NULL);
    }
    static void des_xmlSchemaValidCtxtPtr(int no ATTRIBUTE_UNUSED, xmlSchemaValidCtxtPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
    }
    
    #endif /* LIBXML_SCHEMAS_ENABLED */
    
    
    #define gen_nb_xmlHashDeallocator 2
    
    static void
    
    test_xmlHashDeallocator(void *payload ATTRIBUTE_UNUSED,
                            const xmlChar *name ATTRIBUTE_UNUSED) {
    
    }
    
    static xmlHashDeallocator gen_xmlHashDeallocator(int no, int nr ATTRIBUTE_UNUSED) {
        if (no == 0) return(test_xmlHashDeallocator);
        return(NULL);
    }
    static void des_xmlHashDeallocator(int no ATTRIBUTE_UNUSED, xmlHashDeallocator val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
    }
    
    
    
    static void desret_int(int val ATTRIBUTE_UNUSED) {
    }
    
    static void desret_xmlChar(xmlChar val ATTRIBUTE_UNUSED) {
    }
    
    static void desret_long(long val ATTRIBUTE_UNUSED) {
    }
    
    static void desret_unsigned_long(unsigned long val ATTRIBUTE_UNUSED) {
    }
    
    #if defined(LIBXML_XPATH_ENABLED)
    
    static void desret_double(double val ATTRIBUTE_UNUSED) {
    }
    
    static void desret_xmlCharEncoding(xmlCharEncoding val ATTRIBUTE_UNUSED) {
    }
    
    static void desret_const_void_ptr(void *val ATTRIBUTE_UNUSED) {
    }
    
    static void desret_void_ptr(void *val ATTRIBUTE_UNUSED) {
    }
    
    static void desret_const_char_ptr(const char *val ATTRIBUTE_UNUSED) {
    }
    
    static void desret_const_xmlChar_ptr(const xmlChar *val ATTRIBUTE_UNUSED) {
    }
    
    static void desret_xmlChar_ptr(xmlChar *val) {
        if (val != NULL)
    	xmlFree(val);
    }
    
    static void desret_xmlDocPtr(xmlDocPtr val) {
    
    static void desret_xmlDictPtr(xmlDictPtr val) {
        xmlDictFree(val);
    }
    
    #ifdef LIBXML_OUTPUT_ENABLED
    
    static void desret_xmlOutputBufferPtr(xmlOutputBufferPtr val) {
        xmlOutputBufferClose(val);
    }
    
    #endif
    #ifdef LIBXML_READER_ENABLED
    
    static void desret_xmlTextReaderPtr(xmlTextReaderPtr val) {
        xmlFreeTextReader(val);
    }
    
    static void desret_xmlNodePtr(xmlNodePtr val) {
    
        if ((val != NULL) && (val != api_root) && (val != (xmlNodePtr) api_doc)) {
    	xmlUnlinkNode(val);
    	xmlFreeNode(val);
        }
    
    static void desret_xmlAttrPtr(xmlAttrPtr val) {
        if (val != NULL) {
    	xmlUnlinkNode((xmlNodePtr) val);
    	xmlFreeNode((xmlNodePtr) val);
        }
    }
    
    static void desret_xmlEntityPtr(xmlEntityPtr val) {
        if (val != NULL) {
    	xmlUnlinkNode((xmlNodePtr) val);
    	xmlFreeNode((xmlNodePtr) val);
        }
    }
    
    static void desret_xmlElementPtr(xmlElementPtr val) {
        if (val != NULL) {
    	xmlUnlinkNode((xmlNodePtr) val);
        }
    }
    static void desret_xmlAttributePtr(xmlAttributePtr val) {
        if (val != NULL) {
    	xmlUnlinkNode((xmlNodePtr) val);
        }
    }
    
    static void desret_xmlNsPtr(xmlNsPtr val ATTRIBUTE_UNUSED) {
    }
    
    static void desret_xmlDtdPtr(xmlDtdPtr val) {
        desret_xmlNodePtr((xmlNodePtr)val);
    }
    
    #ifdef LIBXML_XPATH_ENABLED
    
    static void desret_xmlXPathObjectPtr(xmlXPathObjectPtr val) {
    
        xmlXPathFreeObject(val);
    
    static void desret_xmlNodeSetPtr(xmlNodeSetPtr val) {
        xmlXPathFreeNodeSet(val);
    }
    
    static void desret_xmlParserCtxtPtr(xmlParserCtxtPtr val) {
        xmlFreeParserCtxt(val);
    }
    
    static void desret_xmlParserInputBufferPtr(xmlParserInputBufferPtr val) {
        xmlFreeParserInputBuffer(val);
    }
    
    static void desret_xmlParserInputPtr(xmlParserInputPtr val) {
        xmlFreeInputStream(val);
    }
    
    #ifdef LIBXML_WRITER_ENABLED
    
    static void desret_xmlTextWriterPtr(xmlTextWriterPtr val) {
        xmlFreeTextWriter(val);
    }
    
    static void desret_xmlBufferPtr(xmlBufferPtr val) {
        xmlBufferFree(val);
    }
    
    #ifdef LIBXML_SCHEMAS_ENABLED
    
    static void desret_xmlSchemaParserCtxtPtr(xmlSchemaParserCtxtPtr val) {
        xmlSchemaFreeParserCtxt(val);
    }
    static void desret_xmlSchemaTypePtr(xmlSchemaTypePtr val ATTRIBUTE_UNUSED) {
    }
    static void desret_xmlRelaxNGParserCtxtPtr(xmlRelaxNGParserCtxtPtr val) {
        xmlRelaxNGFreeParserCtxt(val);
    }
    
    #endif
    #ifdef LIBXML_HTML_ENABLED
    
    static void desret_const_htmlEntityDesc_ptr(const htmlEntityDesc * val ATTRIBUTE_UNUSED) {
    
    static void desret_xmlNanoHTTPCtxtPtr(void *val) {
        xmlNanoHTTPClose(val);
    }
    #endif
    
    /* cut and pasted from autogenerated to avoid troubles */
    #define gen_nb_const_xmlChar_ptr_ptr 1
    static xmlChar ** gen_const_xmlChar_ptr_ptr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
        return(NULL);
    }
    static void des_const_xmlChar_ptr_ptr(int no ATTRIBUTE_UNUSED, const xmlChar ** val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
    }
    
    #define gen_nb_unsigned_char_ptr 1
    static unsigned char * gen_unsigned_char_ptr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
        return(NULL);
    }
    static void des_unsigned_char_ptr(int no ATTRIBUTE_UNUSED, unsigned char * val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
    }
    
    #define gen_nb_const_unsigned_char_ptr 1
    static unsigned char * gen_const_unsigned_char_ptr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
        return(NULL);
    }
    static void des_const_unsigned_char_ptr(int no ATTRIBUTE_UNUSED, const unsigned char * val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
    }
    
    #ifdef LIBXML_HTML_ENABLED
    #define gen_nb_const_htmlNodePtr 1
    static htmlNodePtr gen_const_htmlNodePtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
        return(NULL);
    }
    static void des_const_htmlNodePtr(int no ATTRIBUTE_UNUSED, const htmlNodePtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
    }
    #endif
    
    #ifdef LIBXML_HTML_ENABLED
    #define gen_nb_htmlDocPtr 3
    static htmlDocPtr gen_htmlDocPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
        if (no == 0) return(htmlNewDoc(NULL, NULL));
        if (no == 1) return(htmlReadMemory("<html/>", 7, "test", NULL, 0));
        return(NULL);
    }
    static void des_htmlDocPtr(int no ATTRIBUTE_UNUSED, htmlDocPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
        if ((val != NULL) && (val != api_doc) && (val->doc != api_doc))
            xmlFreeDoc(val);
    }
    static void desret_htmlDocPtr(htmlDocPtr val) {
        if ((val != NULL) && (val != api_doc) && (val->doc != api_doc))
            xmlFreeDoc(val);
    }
    #define gen_nb_htmlParserCtxtPtr 3
    static htmlParserCtxtPtr gen_htmlParserCtxtPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
        if (no == 0) return(xmlNewParserCtxt());
        if (no == 1) return(htmlCreateMemoryParserCtxt("<html/>", 7));
        return(NULL);
    }
    static void des_htmlParserCtxtPtr(int no ATTRIBUTE_UNUSED, htmlParserCtxtPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
        if (val != NULL)
            htmlFreeParserCtxt(val);
    }
    static void desret_htmlParserCtxtPtr(htmlParserCtxtPtr val) {
        if (val != NULL)
            htmlFreeParserCtxt(val);
    }
    #endif
    
    #ifdef LIBXML_XPATH_ENABLED
    #define gen_nb_xmlNodeSetPtr 1
    static xmlNodeSetPtr gen_xmlNodeSetPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
        return(NULL);
    }
    static void des_xmlNodeSetPtr(int no ATTRIBUTE_UNUSED, xmlNodeSetPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
    }
    #endif
    
    #ifdef LIBXML_DEBUG_ENABLED
    
    #define gen_nb_xmlShellCtxtPtr 1
    static xmlShellCtxtPtr gen_xmlShellCtxtPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
        return(NULL);
    }
    static void des_xmlShellCtxtPtr(int no ATTRIBUTE_UNUSED, xmlShellCtxtPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
    }
    #endif
    
    
    #ifdef LIBXML_PATTERN_ENABLED
    #define gen_nb_xmlPatternPtr 1
    static xmlPatternPtr gen_xmlPatternPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
        return(NULL);
    }
    static void des_xmlPatternPtr(int no ATTRIBUTE_UNUSED, xmlPatternPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
    }
    #endif
    
    
    #define gen_nb_xmlElementContentPtr 1
    static xmlElementContentPtr gen_xmlElementContentPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
        return(NULL);
    }
    static void des_xmlElementContentPtr(int no ATTRIBUTE_UNUSED, xmlElementContentPtr val, int nr ATTRIBUTE_UNUSED) {
        if (val != NULL)
            xmlFreeElementContent(val);
    }
    static void desret_xmlElementContentPtr(xmlElementContentPtr val) {
        if (val != NULL)
            xmlFreeElementContent(val);
    }
    
    #define gen_nb_xmlParserNodeInfoSeqPtr 1
    static xmlParserNodeInfoSeqPtr gen_xmlParserNodeInfoSeqPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
        return(NULL);
    }
    static void des_xmlParserNodeInfoSeqPtr(int no ATTRIBUTE_UNUSED, xmlParserNodeInfoSeqPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
    }
    
    static void desret_const_xmlParserNodeInfo_ptr(const xmlParserNodeInfo *val ATTRIBUTE_UNUSED) {
    }
    
    
    #if defined(LIBXML_MODULES_ENABLED) || defined(LIBXML_READER_ENABLED) || \
        defined(LIBXML_SCHEMAS_ENABLED)
    
    #define gen_nb_void_ptr_ptr 1
    static void ** gen_void_ptr_ptr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
        return(NULL);
    }
    static void des_void_ptr_ptr(int no ATTRIBUTE_UNUSED, void ** val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
    }
    
    /************************************************************************
     *									*