diff --git a/doc/libxml2-api.xml b/doc/libxml2-api.xml index 6e37cc36..68e0b48d 100644 --- a/doc/libxml2-api.xml +++ b/doc/libxml2-api.xml @@ -510,6 +510,10 @@ Daniel Veillard + + + + @@ -665,7 +669,14 @@ + + + + + + + @@ -674,9 +685,12 @@ + + + @@ -4213,6 +4227,14 @@ If the wildcard is complete. + + + + + + + + Both general and parameter entities need to be substituted. @@ -8063,7 +8085,7 @@ crash if you try to modify the tree)'/> - Expresses the URI of the reference in terms relative to the base. Some examples of this operation include: base = "http://site1.com/docs/book1.html" URI input URI returned docs/pic1.gif pic1.gif docs/img/pic1.gif img/pic1.gif img/pic1.gif ../img/pic1.gif http://site1.com/docs/pic1.gif pic1.gif http://site2.com/docs/pic1.gif http://site2.com/docs/pic1.gif base = "docs/book1.html" URI input URI returned docs/pic1.gif pic1.gif docs/img/pic1.gif img/pic1.gif img/pic1.gif ../img/pic1.gif http://site1.com/docs/pic1.gif http://site1.com/docs/pic1.gif Note: if the URI reference is really weird or complicated, it may be worthwhile to first convert it into a "nice" one by calling xmlBuildURI (using 'base') before calling this routine, since this routine (for reasonable efficiency) assumes URI has already been through some validation. Available since 2.13.0. + Expresses the URI of the reference in terms relative to the base. Some examples of this operation include: base = "http://site1.com/docs/book1.html" URI input URI returned http://site1.com/docs/pic1.gif pic1.gif http://site2.com/docs/pic1.gif http://site2.com/docs/pic1.gif base = "docs/book1.html" URI input URI returned docs/pic1.gif pic1.gif docs/img/pic1.gif img/pic1.gif img/pic1.gif ../img/pic1.gif http://site1.com/docs/pic1.gif http://site1.com/docs/pic1.gif Available since 2.13.0. @@ -8582,16 +8604,51 @@ crash if you try to modify the tree)'/> - + + ctxt: parser context + + + + + ctxt: parser context + + + + + ctxt: parser context + + + + Get the last parsing error registered. Get the current options of the parser context. Available since 2.14.0. - + + + ctxt: parser context + + + + + ctxt: parser context + + + + + Get well-formedness and validation status after parsing. Also reports catastrophic errors which are not related to parsing like out-of-memory, I/O or other errors. + + + + + ctxt: parser context + + + Parse an XML document and return the resulting document tree. Takes ownership of the input object. Available since 2.13.0. @@ -8650,7 +8707,7 @@ crash if you try to modify the tree)'/> - + Cleanup the last global error registered. For parsing error this does not change the well-formedness result. @@ -8664,6 +8721,18 @@ crash if you try to modify the tree)'/> + + ctxt: parser context catalogs: catalogs pointer Set the local catalogs. + + + + + + ctxt: parser context dict: dictionary Set the dictionary. This should only be done immediately after creating a parser context. + + + + Register a callback function that will be called on errors and warnings. If handler is NULL, the error handler will be deactivated. This is the recommended way to collect errors from the parser and takes precedence over all other error reporting mechanisms. These are (in order of precedence): - per-context structured handler (xmlCtxtSetErrorHandler) - per-context structured "serror" SAX handler - global structured handler (xmlSetStructuredErrorFunc) - per-context generic "error" and "warning" SAX handlers - global generic handler (xmlSetGenericErrorFunc) - print to stderr Available since 2.13.0. @@ -8683,6 +8752,12 @@ crash if you try to modify the tree)'/> + + ctxt: parser context priv: private application data Set the private application data. + + + + Installs a custom callback to load documents, DTDs or external entities. Available since 2.14.0. @@ -9963,7 +10038,7 @@ crash if you try to modify the tree)'/> - Check whether the character is allowed by the production [84] Letter ::= BaseChar | Ideographic + DEPRECATED: Internal function, don't use. Check whether the character is allowed by the production [84] Letter ::= BaseChar | Ideographic @@ -10950,7 +11025,7 @@ crash if you try to modify the tree)'/> - Find or create a handler matching the encoding. If no default or registered handler could be found, try to create a handler using iconv or ICU if supported. The handler must be closed with xmlCharEncCloseFunc. Available since 2.13.0. + Find or create a handler matching the encoding. If no default or registered handler could be found, try to create a handler using iconv or ICU if supported. The handler must be closed with xmlCharEncCloseFunc. If the encoding is UTF-8, a NULL handler and no error code will be returned. Available since 2.13.0. @@ -12332,7 +12407,7 @@ crash if you try to modify the tree)'/> - called when the end of an element has been detected. Used for HTML and SAX1. + DEPRECATED: Don't call this function directly. called when the end of an element has been detected. Used for HTML and SAX1. @@ -12477,7 +12552,7 @@ crash if you try to modify the tree)'/> - Called when an opening tag has been processed. Used for HTML and SAX1. + DEPRECATED: Don't call this function directly. Called when an opening tag has been processed. Used for HTML and SAX1. @@ -12507,9 +12582,9 @@ crash if you try to modify the tree)'/> defined(LIBXML_SAX1_ENABLED) - DEPRECATED: Use parser option XML_PARSE_SAX1. Set the default version of SAX used globally by the library. By default, during initialization the default is set to 2. Note that it is generally a better coding style to use xmlSAXVersion() to set up the version explicitly for a given parsing context. - - + DEPRECATED: Use parser option XML_PARSE_SAX1. Has no effect. + + defined(LIBXML_VALID_ENABLED) diff --git a/encoding.c b/encoding.c index 73752d04..9629bd53 100644 --- a/encoding.c +++ b/encoding.c @@ -1321,8 +1321,11 @@ static const xmlCharEncodingHandler defaultHandlers[] = { #define NUM_DEFAULT_HANDLERS \ (sizeof(defaultHandlers) / sizeof(defaultHandlers[0])) -static const xmlCharEncodingHandler xmlUTF8Handler = - MAKE_HANDLER("UTF-8", UTF8ToUTF8, UTF8ToUTF8); +static const xmlCharEncodingHandler xmlUTF8Handler = { + (char *) "UTF-8", UTF8ToUTF8, UTF8ToUTF8 + EMPTY_ICONV + EMPTY_UCONV +}; static const xmlCharEncodingHandler *xmlUTF16LEHandler = &defaultHandlers[0]; static const xmlCharEncodingHandler *xmlUTF16BEHandler = &defaultHandlers[1]; diff --git a/gentest.py b/gentest.py index 678a2ec8..fcdf2062 100755 --- a/gentest.py +++ b/gentest.py @@ -146,6 +146,8 @@ skipped_functions = [ # Legacy "xmlCleanupPredefinedEntities", "xmlInitializePredefinedEntities", "xmlSetFeature", "xmlGetFeature", "xmlGetFeaturesList", +# Shouldn't free result +"xmlCtxtGetDict", ] # diff --git a/testapi.c b/testapi.c index 614d6d3c..3181f4ab 100644 --- a/testapi.c +++ b/testapi.c @@ -5299,7 +5299,7 @@ test_xmlSAXDefaultVersion(void) { #ifdef LIBXML_SAX1_ENABLED int mem_base; int ret_val; - int version; /* the version, 1 or 2 */ + int version; /* the version, must be 2 */ int n_version; for (n_version = 0;n_version < gen_nb_int;n_version++) { @@ -11820,6 +11820,70 @@ test_xmlCreatePushParserCtxt(void) { } +static int +test_xmlCtxtGetCatalogs(void) { + int test_ret = 0; + + int mem_base; + void * ret_val; + xmlParserCtxtPtr ctxt; /* */ + int n_ctxt; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0); + + ret_val = xmlCtxtGetCatalogs(ctxt); + desret_void_ptr(ret_val); + call_tests++; + des_xmlParserCtxtPtr(n_ctxt, ctxt, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlCtxtGetCatalogs", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlCtxtGetDeclaredEncoding(void) { + int test_ret = 0; + + int mem_base; + const xmlChar * ret_val; + xmlParserCtxtPtr ctxt; /* */ + int n_ctxt; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0); + + ret_val = xmlCtxtGetDeclaredEncoding(ctxt); + desret_const_xmlChar_ptr(ret_val); + call_tests++; + des_xmlParserCtxtPtr(n_ctxt, ctxt, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlCtxtGetDeclaredEncoding", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + static int test_xmlCtxtGetOptions(void) { int test_ret = 0; @@ -11852,6 +11916,138 @@ test_xmlCtxtGetOptions(void) { } +static int +test_xmlCtxtGetPrivate(void) { + int test_ret = 0; + + int mem_base; + void * ret_val; + xmlParserCtxtPtr ctxt; /* */ + int n_ctxt; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0); + + ret_val = xmlCtxtGetPrivate(ctxt); + desret_void_ptr(ret_val); + call_tests++; + des_xmlParserCtxtPtr(n_ctxt, ctxt, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlCtxtGetPrivate", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlCtxtGetStandalone(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlParserCtxtPtr ctxt; /* */ + int n_ctxt; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0); + + ret_val = xmlCtxtGetStandalone(ctxt); + desret_int(ret_val); + call_tests++; + des_xmlParserCtxtPtr(n_ctxt, ctxt, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlCtxtGetStandalone", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +#define gen_nb_xmlParserCtxt_ptr 1 +#define gen_xmlParserCtxt_ptr(no, nr) NULL +#define des_xmlParserCtxt_ptr(no, val, nr) + +static int +test_xmlCtxtGetStatus(void) { + int test_ret = 0; + + int mem_base; + int ret_val; + xmlParserCtxt * ctxt; /* an XML parser context */ + int n_ctxt; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxt_ptr;n_ctxt++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlParserCtxt_ptr(n_ctxt, 0); + + ret_val = xmlCtxtGetStatus(ctxt); + desret_int(ret_val); + call_tests++; + des_xmlParserCtxt_ptr(n_ctxt, ctxt, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlCtxtGetStatus", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlCtxtGetVersion(void) { + int test_ret = 0; + + int mem_base; + const xmlChar * ret_val; + xmlParserCtxtPtr ctxt; /* */ + int n_ctxt; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0); + + ret_val = xmlCtxtGetVersion(ctxt); + desret_const_xmlChar_ptr(ret_val); + call_tests++; + des_xmlParserCtxtPtr(n_ctxt, ctxt, 0); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlCtxtGetVersion", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf("\n"); + } + } + function_tests++; + + return(test_ret); +} + + static int test_xmlCtxtParseDocument(void) { int test_ret = 0; @@ -12167,6 +12363,80 @@ test_xmlCtxtResetPush(void) { } +static int +test_xmlCtxtSetCatalogs(void) { + int test_ret = 0; + + int mem_base; + xmlParserCtxtPtr ctxt; /* */ + int n_ctxt; + void * catalogs; /* */ + int n_catalogs; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) { + for (n_catalogs = 0;n_catalogs < gen_nb_void_ptr;n_catalogs++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0); + catalogs = gen_void_ptr(n_catalogs, 1); + + xmlCtxtSetCatalogs(ctxt, catalogs); + call_tests++; + des_xmlParserCtxtPtr(n_ctxt, ctxt, 0); + des_void_ptr(n_catalogs, catalogs, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlCtxtSetCatalogs", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_catalogs); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + +static int +test_xmlCtxtSetDict(void) { + int test_ret = 0; + + int mem_base; + xmlParserCtxtPtr ctxt; /* */ + int n_ctxt; + xmlDictPtr dict; /* */ + int n_dict; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) { + for (n_dict = 0;n_dict < gen_nb_xmlDictPtr;n_dict++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0); + dict = gen_xmlDictPtr(n_dict, 1); + + xmlCtxtSetDict(ctxt, dict); + call_tests++; + des_xmlParserCtxtPtr(n_ctxt, ctxt, 0); + des_xmlDictPtr(n_dict, dict, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlCtxtSetDict", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_dict); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + static int test_xmlCtxtSetErrorHandler(void) { int test_ret = 0; @@ -12226,6 +12496,43 @@ test_xmlCtxtSetOptions(void) { } +static int +test_xmlCtxtSetPrivate(void) { + int test_ret = 0; + + int mem_base; + xmlParserCtxtPtr ctxt; /* */ + int n_ctxt; + void * priv; /* */ + int n_priv; + + for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) { + for (n_priv = 0;n_priv < gen_nb_void_ptr;n_priv++) { + mem_base = xmlMemBlocks(); + ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0); + priv = gen_void_ptr(n_priv, 1); + + xmlCtxtSetPrivate(ctxt, priv); + call_tests++; + des_xmlParserCtxtPtr(n_ctxt, ctxt, 0); + des_void_ptr(n_priv, priv, 1); + xmlResetLastError(); + if (mem_base != xmlMemBlocks()) { + printf("Leak of %d blocks found in xmlCtxtSetPrivate", + xmlMemBlocks() - mem_base); + test_ret++; + printf(" %d", n_ctxt); + printf(" %d", n_priv); + printf("\n"); + } + } + } + function_tests++; + + return(test_ret); +} + + static int test_xmlCtxtSetResourceLoader(void) { int test_ret = 0; @@ -14753,23 +15060,32 @@ static int test_parser(void) { int test_ret = 0; - if (quiet == 0) printf("Testing parser : 72 of 84 functions ...\n"); + if (quiet == 0) printf("Testing parser : 81 of 94 functions ...\n"); test_ret += test_xmlByteConsumed(); test_ret += test_xmlCleanupGlobals(); test_ret += test_xmlClearNodeInfoSeq(); test_ret += test_xmlClearParserCtxt(); test_ret += test_xmlCreateDocParserCtxt(); test_ret += test_xmlCreatePushParserCtxt(); + test_ret += test_xmlCtxtGetCatalogs(); + test_ret += test_xmlCtxtGetDeclaredEncoding(); test_ret += test_xmlCtxtGetOptions(); + test_ret += test_xmlCtxtGetPrivate(); + test_ret += test_xmlCtxtGetStandalone(); + test_ret += test_xmlCtxtGetStatus(); + test_ret += test_xmlCtxtGetVersion(); test_ret += test_xmlCtxtParseDocument(); test_ret += test_xmlCtxtReadDoc(); test_ret += test_xmlCtxtReadFile(); test_ret += test_xmlCtxtReadMemory(); test_ret += test_xmlCtxtReset(); test_ret += test_xmlCtxtResetPush(); + test_ret += test_xmlCtxtSetCatalogs(); + test_ret += test_xmlCtxtSetDict(); test_ret += test_xmlCtxtSetErrorHandler(); test_ret += test_xmlCtxtSetMaxAmplification(); test_ret += test_xmlCtxtSetOptions(); + test_ret += test_xmlCtxtSetPrivate(); test_ret += test_xmlCtxtSetResourceLoader(); test_ret += test_xmlCtxtUseOptions(); test_ret += test_xmlGetExternalEntityLoader();