diff options
author | Mark A. Hershberger <mah@debian.(none)> | 2009-03-25 00:34:59 -0400 |
---|---|---|
committer | Mark A. Hershberger <mah@debian.(none)> | 2009-03-25 00:34:59 -0400 |
commit | ce7edc9b3c7370f32fec0bc7a8ec3e29ed9a5f61 (patch) | |
tree | acdb9a8816483652a9db1a47db71df5df43707c5 /ext/libxml | |
parent | 10f5b47dc7c1cf2b9a00991629f43652710322d3 (diff) | |
download | php-ce7edc9b3c7370f32fec0bc7a8ec3e29ed9a5f61.tar.gz |
Imported Upstream version 5.1.1upstream/5.1.1
Diffstat (limited to 'ext/libxml')
-rw-r--r-- | ext/libxml/config.w32 | 3 | ||||
-rw-r--r-- | ext/libxml/config0.m4 | 7 | ||||
-rw-r--r-- | ext/libxml/libxml.c | 388 | ||||
-rw-r--r-- | ext/libxml/php_libxml.h | 16 |
4 files changed, 355 insertions, 59 deletions
diff --git a/ext/libxml/config.w32 b/ext/libxml/config.w32 index f8eb24cb4..963960364 100644 --- a/ext/libxml/config.w32 +++ b/ext/libxml/config.w32 @@ -1,4 +1,4 @@ -// $Id: config.w32,v 1.6.2.3 2004/08/04 19:22:12 fmk Exp $ +// $Id: config.w32,v 1.8 2005/02/25 22:59:26 fmk Exp $ // vim:ft=javascript ARG_WITH("libxml", "LibXML support", "yes"); @@ -10,7 +10,6 @@ if (PHP_LIBXML == "yes") { EXTENSION("libxml", "libxml.c", false /* never shared */); AC_DEFINE("HAVE_LIBXML", 1, "LibXML support"); - ADD_FLAG("CFLAGS", "/D LIBXML_THREAD_ENABLED"); ADD_FLAG("CFLAGS_LIBXML", "/D LIBXML_STATIC "); if (!PHP_LIBXML_SHARED) { ADD_DEF_FILE("ext\\libxml\\php_libxml2.def"); diff --git a/ext/libxml/config0.m4 b/ext/libxml/config0.m4 index 58bd8ec75..b3f3c7944 100644 --- a/ext/libxml/config0.m4 +++ b/ext/libxml/config0.m4 @@ -1,13 +1,13 @@ dnl -dnl $Id: config0.m4,v 1.1 2003/11/12 23:42:38 sniper Exp $ +dnl $Id: config0.m4,v 1.3 2005/05/29 23:16:41 sniper Exp $ dnl PHP_ARG_ENABLE(libxml, whether to enable LIBXML support, -[ --disable-libxml Disable new LIBXML support.], yes) +[ --disable-libxml Disable new LIBXML support], yes) if test -z "$PHP_LIBXML_DIR"; then PHP_ARG_WITH(libxml-dir, libxml2 install dir, - [ --with-libxml-dir[=DIR] libxml2 install prefix.], no, no) + [ --with-libxml-dir[=DIR] libxml2 install prefix], no, no) fi if test "$PHP_LIBXML" != "no"; then @@ -18,6 +18,7 @@ if test "$PHP_LIBXML" != "no"; then PHP_SETUP_LIBXML(LIBXML_SHARED_LIBADD, [ AC_DEFINE(HAVE_LIBXML,1,[ ]) PHP_NEW_EXTENSION(libxml, [libxml.c], $ext_shared) + PHP_INSTALL_HEADERS([ext/libxml/php_libxml.h]) ], [ AC_MSG_ERROR([xml2-config not found. Please check your libxml2 installation.]) ]) diff --git a/ext/libxml/libxml.c b/ext/libxml/libxml.c index d33c67c2e..2d57931a1 100644 --- a/ext/libxml/libxml.c +++ b/ext/libxml/libxml.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2004 The PHP Group | + | Copyright (c) 1997-2005 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.0 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: libxml.c,v 1.18.2.6 2005/01/02 12:09:09 rrichards Exp $ */ +/* $Id: libxml.c,v 1.32.2.5 2005/11/17 21:56:04 rasmus Exp $ */ #define IS_EXT_MODULE @@ -40,6 +40,7 @@ #include <libxml/tree.h> #include <libxml/uri.h> #include <libxml/xmlerror.h> +#include <libxml/xmlsave.h> #ifdef LIBXML_SCHEMAS_ENABLED #include <libxml/relaxng.h> #endif @@ -65,6 +66,8 @@ int libxml_globals_id; PHP_LIBXML_API php_libxml_globals libxml_globals; #endif +zend_class_entry *libxmlerror_class_entry; + /* {{{ dynamically loadable module stuff */ #ifdef COMPILE_DL_LIBXML ZEND_GET_MODULE(libxml) @@ -86,6 +89,10 @@ PHP_MINFO_FUNCTION(libxml); /* {{{ extension definition structures */ function_entry libxml_functions[] = { PHP_FE(libxml_set_streams_context, NULL) + PHP_FE(libxml_use_internal_errors, NULL) + PHP_FE(libxml_get_last_error, NULL) + PHP_FE(libxml_clear_errors, NULL) + PHP_FE(libxml_get_errors, NULL) {NULL, NULL, NULL} }; @@ -235,30 +242,13 @@ static void php_libxml_init_globals(php_libxml_globals *libxml_globals_p TSRMLS_ { LIBXML(stream_context) = NULL; LIBXML(error_buffer).c = NULL; + LIBXML(error_list) = NULL; } #endif /* Channel libxml file io layer through the PHP streams subsystem. * This allows use of ftps:// and https:// urls */ -int php_libxml_streams_IO_match_wrapper(const char *filename) -{ - char *resolved_path; - int retval; - - TSRMLS_FETCH(); - - if (zend_is_executing(TSRMLS_C)) { - resolved_path = xmlURIUnescapeString(filename, 0, NULL); - retval = php_stream_locate_url_wrapper(resolved_path, NULL, 0 TSRMLS_CC) ? 1 : 0; - if (resolved_path) { - xmlFree(resolved_path); - } - return retval; - } - return 0; -} - void *php_libxml_streams_IO_open_wrapper(const char *filename, const char *mode, const int read_only) { php_stream_statbuf ssbuf; @@ -266,9 +256,22 @@ void *php_libxml_streams_IO_open_wrapper(const char *filename, const char *mode, php_stream_wrapper *wrapper = NULL; char *resolved_path, *path_to_open = NULL; void *ret_val = NULL; + int isescaped=0; + xmlURI *uri; TSRMLS_FETCH(); - resolved_path = xmlURIUnescapeString(filename, 0, NULL); + + uri = xmlParseURI((xmlChar *)filename); + if (uri && (uri->scheme == NULL || (xmlStrncmp(uri->scheme, "file", 4) == 0))) { + resolved_path = xmlURIUnescapeString(filename, 0, NULL); + isescaped = 1; + } else { + resolved_path = (char *)filename; + } + + if (uri) { + xmlFreeURI(uri); + } if (resolved_path == NULL) { return NULL; @@ -283,7 +286,9 @@ void *php_libxml_streams_IO_open_wrapper(const char *filename, const char *mode, wrapper = php_stream_locate_url_wrapper(resolved_path, &path_to_open, ENFORCE_SAFE_MODE TSRMLS_CC); if (wrapper && read_only && wrapper->wops->url_stat) { if (wrapper->wops->url_stat(wrapper, path_to_open, PHP_STREAM_URL_STAT_QUIET, &ssbuf, NULL TSRMLS_CC) == -1) { - xmlFree(resolved_path); + if (isescaped) { + xmlFree(resolved_path); + } return NULL; } } @@ -293,7 +298,9 @@ void *php_libxml_streams_IO_open_wrapper(const char *filename, const char *mode, } ret_val = php_stream_open_wrapper_ex(path_to_open, (char *)mode, ENFORCE_SAFE_MODE|REPORT_ERRORS, NULL, context); - xmlFree(resolved_path); + if (isescaped) { + xmlFree(resolved_path); + } return ret_val; } @@ -325,6 +332,117 @@ int php_libxml_streams_IO_close(void *context) return php_stream_close((php_stream*)context); } +xmlParserInputBufferPtr +php_libxml_input_buffer_create_filename(const char *URI, xmlCharEncoding enc) +{ + xmlParserInputBufferPtr ret; + void *context = NULL; + + if (URI == NULL) + return(NULL); + + context = php_libxml_streams_IO_open_read_wrapper(URI); + + if (context == NULL) { + return(NULL); + } + + /* Allocate the Input buffer front-end. */ + ret = xmlAllocParserInputBuffer(enc); + if (ret != NULL) { + ret->context = context; + ret->readcallback = php_libxml_streams_IO_read; + ret->closecallback = php_libxml_streams_IO_close; + } else + php_libxml_streams_IO_close(context); + + return(ret); +} + +xmlOutputBufferPtr +php_libxml_output_buffer_create_filename(const char *URI, + xmlCharEncodingHandlerPtr encoder, + int compression ATTRIBUTE_UNUSED) +{ + xmlOutputBufferPtr ret; + xmlURIPtr puri; + void *context = NULL; + char *unescaped = NULL; + + if (URI == NULL) + return(NULL); + + puri = xmlParseURI(URI); + if (puri != NULL) { + if (puri->scheme != NULL) + unescaped = xmlURIUnescapeString(URI, 0, NULL); + xmlFreeURI(puri); + } + + if (unescaped != NULL) { + context = php_libxml_streams_IO_open_write_wrapper(unescaped); + xmlFree(unescaped); + } + + /* try with a non-escaped URI this may be a strange filename */ + if (context == NULL) { + context = php_libxml_streams_IO_open_write_wrapper(URI); + } + + if (context == NULL) { + return(NULL); + } + + /* Allocate the Output buffer front-end. */ + ret = xmlAllocOutputBuffer(encoder); + if (ret != NULL) { + ret->context = context; + ret->writecallback = php_libxml_streams_IO_write; + ret->closecallback = php_libxml_streams_IO_close; + } + + return(ret); +} + +static int _php_libxml_free_error(xmlErrorPtr error) { + /* This will free the libxml alloc'd memory */ + xmlResetError(error); + return 1; +} + +static void _php_list_set_error_structure(xmlErrorPtr error, const char *msg) +{ + xmlError error_copy; + int ret; + + TSRMLS_FETCH(); + + memset(&error_copy, 0, sizeof(xmlError)); + + if (error) { + ret = xmlCopyError(error, &error_copy); + } else { + error_copy.domain = 0; + error_copy.code = XML_ERR_INTERNAL_ERROR; + error_copy.level = XML_ERR_ERROR; + error_copy.line = 0; + error_copy.node = NULL; + error_copy.int1 = 0; + error_copy.int2 = 0; + error_copy.ctxt = NULL; + error_copy.message = xmlStrdup(msg); + error_copy.file = NULL; + error_copy.str1 = NULL; + error_copy.str2 = NULL; + error_copy.str3 = NULL; + ret = 0; + } + + if (ret == 0) { + zend_llist_add_element(LIBXML(error_list), &error_copy); + } +} + static void php_libxml_ctx_error_level(int level, void *ctx, const char *msg TSRMLS_DC) { xmlParserCtxtPtr parser; @@ -340,6 +458,15 @@ static void php_libxml_ctx_error_level(int level, void *ctx, const char *msg TSR } } +void php_libxml_issue_error(int level, const char *msg TSRMLS_DC) +{ + if (LIBXML(error_list)) { + _php_list_set_error_structure(NULL, msg); + } else { + php_error_docref(NULL TSRMLS_CC, level, "%s", msg); + } +} + static void php_libxml_internal_error_handler(int error_type, void *ctx, const char **msg, va_list ap) { char *buf; @@ -361,15 +488,19 @@ static void php_libxml_internal_error_handler(int error_type, void *ctx, const c efree(buf); if (output == 1) { - switch (error_type) { - case PHP_LIBXML_CTX_ERROR: - php_libxml_ctx_error_level(E_WARNING, ctx, LIBXML(error_buffer).c TSRMLS_CC); - break; - case PHP_LIBXML_CTX_WARNING: - php_libxml_ctx_error_level(E_NOTICE, ctx, LIBXML(error_buffer).c TSRMLS_CC); - break; - default: - php_error(E_WARNING, "%s", LIBXML(error_buffer).c); + if (LIBXML(error_list)) { + _php_list_set_error_structure(NULL, LIBXML(error_buffer).c); + } else { + switch (error_type) { + case PHP_LIBXML_CTX_ERROR: + php_libxml_ctx_error_level(E_WARNING, ctx, LIBXML(error_buffer).c TSRMLS_CC); + break; + case PHP_LIBXML_CTX_WARNING: + php_libxml_ctx_error_level(E_NOTICE, ctx, LIBXML(error_buffer).c TSRMLS_CC); + break; + default: + php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", LIBXML(error_buffer).c); + } } smart_str_free(&LIBXML(error_buffer)); } @@ -391,6 +522,13 @@ void php_libxml_ctx_warning(void *ctx, const char *msg, ...) va_end(args); } +PHP_LIBXML_API void php_libxml_structured_error_handler(void *userData, xmlErrorPtr error) +{ + _php_list_set_error_structure(error, NULL); + + return; +} + PHP_LIBXML_API void php_libxml_error_handler(void *ctx, const char *msg, ...) { va_list args; @@ -405,22 +543,6 @@ PHP_LIBXML_API void php_libxml_initialize() { /* we should be the only one's to ever init!! */ xmlInitParser(); - /* Enable php stream/wrapper support for libxml - we only use php streams, so we do not enable - the default io handlers in libxml. - */ - xmlRegisterInputCallbacks( - php_libxml_streams_IO_match_wrapper, - php_libxml_streams_IO_open_read_wrapper, - php_libxml_streams_IO_read, - php_libxml_streams_IO_close); - - xmlRegisterOutputCallbacks( - php_libxml_streams_IO_match_wrapper, - php_libxml_streams_IO_open_write_wrapper, - php_libxml_streams_IO_write, - php_libxml_streams_IO_close); - zend_hash_init(&php_libxml_exports, 0, NULL, NULL, 1); _php_libxml_initialized = 1; @@ -449,6 +571,8 @@ PHP_LIBXML_API zval *php_libxml_switch_context(zval *context TSRMLS_DC) { PHP_MINIT_FUNCTION(libxml) { + zend_class_entry ce; + php_libxml_initialize(); #ifdef ZTS @@ -456,7 +580,38 @@ PHP_MINIT_FUNCTION(libxml) #else LIBXML(stream_context) = NULL; LIBXML(error_buffer).c = NULL; + LIBXML(error_list) = NULL; +#endif + + REGISTER_LONG_CONSTANT("LIBXML_VERSION", LIBXML_VERSION, CONST_CS | CONST_PERSISTENT); + REGISTER_STRING_CONSTANT("LIBXML_DOTTED_VERSION", LIBXML_DOTTED_VERSION, CONST_CS | CONST_PERSISTENT); + + /* For use with loading xml */ + REGISTER_LONG_CONSTANT("LIBXML_NOENT", XML_PARSE_NOENT, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("LIBXML_DTDLOAD", XML_PARSE_DTDLOAD, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("LIBXML_DTDATTR", XML_PARSE_DTDATTR, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("LIBXML_DTDVALID", XML_PARSE_DTDVALID, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("LIBXML_NOERROR", XML_PARSE_NOERROR, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("LIBXML_NOWARNING", XML_PARSE_NOWARNING, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("LIBXML_NOBLANKS", XML_PARSE_NOBLANKS, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("LIBXML_XINCLUDE", XML_PARSE_XINCLUDE, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("LIBXML_NSCLEAN", XML_PARSE_NSCLEAN, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("LIBXML_NOCDATA", XML_PARSE_NOCDATA, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("LIBXML_NONET", XML_PARSE_NONET, CONST_CS | CONST_PERSISTENT); +#if LIBXML_VERSION >= 20621 + REGISTER_LONG_CONSTANT("LIBXML_COMPACT", XML_PARSE_COMPACT, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("LIBXML_NOXMLDECL", XML_SAVE_NO_DECL, CONST_CS | CONST_PERSISTENT); #endif + REGISTER_LONG_CONSTANT("LIBXML_NOEMPTYTAG", LIBXML_SAVE_NOEMPTYTAG, CONST_CS | CONST_PERSISTENT); + + /* Error levels */ + REGISTER_LONG_CONSTANT("LIBXML_ERR_NONE", XML_ERR_NONE, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("LIBXML_ERR_WARNING", XML_ERR_WARNING, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("LIBXML_ERR_ERROR", XML_ERR_ERROR, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("LIBXML_ERR_FATAL", XML_ERR_FATAL, CONST_CS | CONST_PERSISTENT); + + INIT_CLASS_ENTRY(ce, "LibXMLError", NULL); + libxmlerror_class_entry = zend_register_internal_class(&ce TSRMLS_CC); return SUCCESS; } @@ -466,7 +621,8 @@ PHP_RINIT_FUNCTION(libxml) { /* report errors via handler rather than stderr */ xmlSetGenericErrorFunc(NULL, php_libxml_error_handler); - + xmlParserInputBufferCreateFilenameDefault(php_libxml_input_buffer_create_filename); + xmlOutputBufferCreateFilenameDefault(php_libxml_output_buffer_create_filename); return SUCCESS; } @@ -483,8 +639,18 @@ PHP_RSHUTDOWN_FUNCTION(libxml) { /* reset libxml generic error handling */ xmlSetGenericErrorFunc(NULL, NULL); + xmlSetStructuredErrorFunc(NULL, NULL); + + xmlParserInputBufferCreateFilenameDefault(NULL); + xmlOutputBufferCreateFilenameDefault(NULL); smart_str_free(&LIBXML(error_buffer)); + if (LIBXML(error_list)) { + zend_llist_destroy(LIBXML(error_list)); + efree(LIBXML(error_list)); + LIBXML(error_list) = NULL; + } + return SUCCESS; } @@ -499,7 +665,6 @@ PHP_MINFO_FUNCTION(libxml) } /* }}} */ - /* {{{ proto void libxml_set_streams_context(resource streams_context) Set the streams context for the next libxml document load or write */ PHP_FUNCTION(libxml_set_streams_context) @@ -518,6 +683,129 @@ PHP_FUNCTION(libxml_set_streams_context) } /* }}} */ +/* {{{ proto void libxml_use_internal_errors(boolean use_errors) + Disable libxml errors and allow user to fetch error information as needed */ +PHP_FUNCTION(libxml_use_internal_errors) +{ + xmlStructuredErrorFunc current_handler; + int use_errors=0, retval; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &use_errors) == FAILURE) { + return; + } + + current_handler = xmlStructuredError; + if (current_handler && current_handler == php_libxml_structured_error_handler) { + retval = 1; + } else { + retval = 0; + } + + if (ZEND_NUM_ARGS() == 0) { + RETURN_BOOL(retval); + } + + if (use_errors == 0) { + xmlSetStructuredErrorFunc(NULL, NULL); + if (LIBXML(error_list)) { + zend_llist_destroy(LIBXML(error_list)); + efree(LIBXML(error_list)); + LIBXML(error_list) = NULL; + } + } else { + xmlSetStructuredErrorFunc(NULL, php_libxml_structured_error_handler); + if (LIBXML(error_list) == NULL) { + LIBXML(error_list) = (zend_llist *) emalloc(sizeof(zend_llist)); + zend_llist_init(LIBXML(error_list), sizeof(xmlError), (llist_dtor_func_t) _php_libxml_free_error, 0); + } + } + RETURN_BOOL(retval); +} +/* }}} */ + +/* {{{ proto object libxml_get_last_error() + Retrieve last error from libxml */ +PHP_FUNCTION(libxml_get_last_error) +{ + xmlErrorPtr error; + + error = xmlGetLastError(); + + if (error) { + object_init_ex(return_value, libxmlerror_class_entry); + add_property_long(return_value, "level", error->level); + add_property_long(return_value, "code", error->code); + add_property_long(return_value, "column", error->int2); + if (error->message) { + add_property_string(return_value, "message", error->message, 1); + } else { + add_property_stringl(return_value, "message", "", 0, 1); + } + if (error->file) { + add_property_string(return_value, "file", error->file, 1); + } else { + add_property_stringl(return_value, "file", "", 0, 1); + } + add_property_long(return_value, "line", error->line); + } else { + RETURN_FALSE; + } +} +/* }}} */ + +/* {{{ proto object libxml_get_errors() + Retrieve array of errors */ +PHP_FUNCTION(libxml_get_errors) +{ + + xmlErrorPtr error; + + if (array_init(return_value) == FAILURE) { + RETURN_FALSE; + } + + if (LIBXML(error_list)) { + + error = zend_llist_get_first(LIBXML(error_list)); + + while (error != NULL) { + zval *z_error; + MAKE_STD_ZVAL(z_error); + + object_init_ex(z_error, libxmlerror_class_entry); + add_property_long(z_error, "level", error->level); + add_property_long(z_error, "code", error->code); + add_property_long(z_error, "column", error->int2); + if (error->message) { + add_property_string(z_error, "message", error->message, 1); + } else { + add_property_stringl(z_error, "message", "", 0, 1); + } + if (error->file) { + add_property_string(z_error, "file", error->file, 1); + } else { + add_property_stringl(z_error, "file", "", 0, 1); + } + add_property_long(z_error, "line", error->line); + add_next_index_zval(return_value, z_error); + + error = zend_llist_get_next(LIBXML(error_list)); + } + } +} +/* }}} */ + +/* {{{ proto void libxml_clear_errors() + Clear last error from libxml */ +PHP_FUNCTION(libxml_clear_errors) +{ + xmlResetLastError(); + if (LIBXML(error_list)) { + zend_llist_clean(LIBXML(error_list)); + } +} +/* }}} */ + /* {{{ Common functions shared by extensions */ int php_libxml_xmlCheckUTF8(const unsigned char *s) { diff --git a/ext/libxml/php_libxml.h b/ext/libxml/php_libxml.h index 7bc184d07..5accb2b24 100644 --- a/ext/libxml/php_libxml.h +++ b/ext/libxml/php_libxml.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2004 The PHP Group | + | Copyright (c) 1997-2005 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.0 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_libxml.h,v 1.8.2.4 2005/04/21 11:19:53 sniper Exp $ */ +/* $Id: php_libxml.h,v 1.15.2.1 2005/09/08 10:37:57 rrichards Exp $ */ #ifndef PHP_LIBXML_H #define PHP_LIBXML_H @@ -35,9 +35,12 @@ extern zend_module_entry libxml_module_entry; #include "ext/standard/php_smart_str.h" #include <libxml/tree.h> +#define LIBXML_SAVE_NOEMPTYTAG 1<<2 + typedef struct { zval *stream_context; smart_str error_buffer; + zend_llist *error_list; } php_libxml_globals; typedef struct _php_libxml_ref_obj { @@ -62,11 +65,15 @@ typedef struct _php_libxml_node_object { typedef void * (*php_libxml_export_node) (zval *object TSRMLS_DC); PHP_FUNCTION(libxml_set_streams_context); +PHP_FUNCTION(libxml_use_internal_errors); +PHP_FUNCTION(libxml_get_last_error); +PHP_FUNCTION(libxml_clear_errors); +PHP_FUNCTION(libxml_get_errors); int php_libxml_increment_node_ptr(php_libxml_node_object *object, xmlNodePtr node, void *private_data TSRMLS_DC); int php_libxml_decrement_node_ptr(php_libxml_node_object *object TSRMLS_DC); -int php_libxml_increment_doc_ref(php_libxml_node_object *object, xmlDocPtr docp TSRMLS_DC); -int php_libxml_decrement_doc_ref(php_libxml_node_object *object TSRMLS_DC); +PHP_LIBXML_API int php_libxml_increment_doc_ref(php_libxml_node_object *object, xmlDocPtr docp TSRMLS_DC); +PHP_LIBXML_API int php_libxml_decrement_doc_ref(php_libxml_node_object *object TSRMLS_DC); PHP_LIBXML_API xmlNodePtr php_libxml_import_node(zval *object TSRMLS_DC); PHP_LIBXML_API int php_libxml_register_export(zend_class_entry *ce, php_libxml_export_node export_function); /* When an explicit freeing of node and children is required */ @@ -78,6 +85,7 @@ void php_libxml_ctx_warning(void *ctx, const char *msg, ...); void php_libxml_ctx_error(void *ctx, const char *msg, ...); PHP_LIBXML_API int php_libxml_xmlCheckUTF8(const unsigned char *s); PHP_LIBXML_API zval *php_libxml_switch_context(zval *context TSRMLS_DC); +PHP_LIBXML_API void php_libxml_issue_error(int level, const char *msg TSRMLS_DC); /* Init/shutdown functions*/ PHP_LIBXML_API void php_libxml_initialize(); |