shane Sun Oct 19 17:48:47 2003 EDT Added files: /php-src/ext/libxml CREDITS config.m4 libxml.c php_libxml.h
Modified files: /php-src/win32 php4dllts.dsp /php-src/main internal_functions_win32.c Log: Add libxml extension for common code that is needed to be shared between various xml extensions. currently the only implemented support is the addition of the streams support for libxml. One new function, libxml_set_streams_context, which allows a streams context to bet set prior to loading or writing documents. This works transparently with any extension that uses libxml. All ini settings that effect streams will also now effect the loading and writing of xml documents. TODO: linux support, not sure if config.m4 will work right.
Index: php-src/win32/php4dllts.dsp diff -u php-src/win32/php4dllts.dsp:1.134 php-src/win32/php4dllts.dsp:1.135 --- php-src/win32/php4dllts.dsp:1.134 Fri Oct 17 16:52:18 2003 +++ php-src/win32/php4dllts.dsp Sun Oct 19 17:48:44 2003 @@ -1847,10 +1847,6 @@ # End Source File # Begin Source File -SOURCE=..\ext\standard\php_http.h -# End Source File -# Begin Source File - SOURCE=..\ext\standard\info.h # End Source File # Begin Source File @@ -1891,6 +1887,10 @@ # End Source File # Begin Source File +SOURCE=..\ext\standard\php_http.h +# End Source File +# Begin Source File + SOURCE=..\ext\standard\php_lcg.h # End Source File # Begin Source File @@ -2000,6 +2000,26 @@ # Begin Source File SOURCE=..\ext\sqlite\sqlite.c +# End Source File +# End Group +# End Group +# Begin Group "LIBXML" + +# PROP Default_Filter "" +# Begin Group "Header Files No. 10" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=..\ext\libxml\php_libxml.h +# End Source File +# End Group +# Begin Group "Source Files No. 9" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=..\ext\libxml\libxml.c # End Source File # End Group # End Group Index: php-src/main/internal_functions_win32.c diff -u php-src/main/internal_functions_win32.c:1.81 php-src/main/internal_functions_win32.c:1.82 --- php-src/main/internal_functions_win32.c:1.81 Mon Aug 25 22:50:39 2003 +++ php-src/main/internal_functions_win32.c Sun Oct 19 17:48:45 2003 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: internal_functions_win32.c,v 1.81 2003/08/26 02:50:39 sniper Exp $ */ +/* $Id: internal_functions_win32.c,v 1.82 2003/10/19 21:48:45 shane Exp $ */ /* {{{ includes */ @@ -81,6 +81,7 @@ #include "ext/zlib/php_zlib.h" #endif #if HAVE_LIBXML +#include "ext/libxml/php_libxml.h" #if HAVE_DOM #include "ext/dom/php_dom.h" #endif @@ -136,6 +137,7 @@ ,phpext_zlib_ptr #endif #if HAVE_LIBXML + ,phpext_libxml_ptr #if HAVE_DOM ,phpext_dom_ptr #endif Index: php-src/ext/libxml/config.m4 +++ php-src/ext/libxml/config.m4 dnl dnl $Id: config.m4,v 1.1 2003/10/19 21:48:46 shane Exp $ dnl PHP_ARG_ENABLE(libxml, whether to enable LIBXML support, [ --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) fi 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_SUBST(LIBXML_SHARED_LIBADD) ], [ AC_MSG_ERROR([xml2-config not found. Please check your libxml2 installation.]) ]) fi Index: php-src/ext/libxml/libxml.c +++ php-src/ext/libxml/libxml.c /* +----------------------------------------------------------------------+ | PHP Version 4 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2003 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 | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_0.txt. | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | [EMAIL PROTECTED] so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: Shane Caraveo <[EMAIL PROTECTED]> | | Wez Furlong <[EMAIL PROTECTED]> | +----------------------------------------------------------------------+ */ /* $Id: libxml.c,v 1.1 2003/10/19 21:48:46 shane Exp $ */ #define IS_EXT_MODULE #ifdef HAVE_CONFIG_H #include "config.h" #endif #include "php.h" #define PHP_XML_INTERNAL #include "zend_variables.h" #include "ext/standard/php_string.h" #include "ext/standard/info.h" #if HAVE_LIBXML #include <libxml/parser.h> #include <libxml/parserInternals.h> #include <libxml/tree.h> #include <libxml/uri.h> #include <libxml/xmlerror.h> #include "php_libxml.h" #ifdef ZTS int libxml_globals_id; #else PHP_LIBXML_API php_libxml_globals libxml_globals; #endif /* {{{ dynamically loadable module stuff */ #ifdef COMPILE_DL_LIBXML ZEND_GET_MODULE(libxml) # ifdef PHP_WIN32 # include "zend_arg_defs.c" # endif #endif /* COMPILE_DL_LIBXML */ /* }}} */ /* {{{ function prototypes */ PHP_MINIT_FUNCTION(libxml); PHP_RINIT_FUNCTION(libxml); PHP_MSHUTDOWN_FUNCTION(libxml); PHP_RSHUTDOWN_FUNCTION(libxml); PHP_MINFO_FUNCTION(libxml); /* }}} */ /* {{{ extension definition structures */ function_entry libxml_functions[] = { PHP_FE(libxml_set_streams_context, NULL) {NULL, NULL, NULL} }; zend_module_entry libxml_module_entry = { STANDARD_MODULE_HEADER, "libxml", /* extension name */ libxml_functions, /* extension function list */ PHP_MINIT(libxml), /* extension-wide startup function */ PHP_MSHUTDOWN(libxml), /* extension-wide shutdown function */ PHP_RINIT(libxml), /* per-request startup function */ PHP_RSHUTDOWN(libxml), /* per-request shutdown function */ PHP_MINFO(libxml), /* information function */ NO_VERSION_YET, STANDARD_MODULE_PROPERTIES }; /* }}} */ /* {{{ startup, shutdown and info functions */ #ifdef ZTS static void php_libxml_init_globals(php_libxml_globals *libxml_globals_p TSRMLS_DC) { LIBXML(stream_context) = 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) { TSRMLS_FETCH(); return php_stream_locate_url_wrapper(filename, NULL, STREAM_LOCATE_WRAPPERS_ONLY TSRMLS_CC) ? 1 : 0; } void *php_libxml_streams_IO_open_wrapper(const char *filename) { php_stream_context *context = NULL; TSRMLS_FETCH(); if (LIBXML(stream_context)) { context = zend_fetch_resource(&LIBXML(stream_context) TSRMLS_CC, -1, "Stream-Context", NULL, 1, php_le_stream_context()); return php_stream_open_wrapper_ex((char *)filename, "rb", ENFORCE_SAFE_MODE|REPORT_ERRORS, NULL, context); } return php_stream_open_wrapper((char *)filename, "rb", ENFORCE_SAFE_MODE|REPORT_ERRORS, NULL); } int php_libxml_streams_IO_read(void *context, char *buffer, int len) { TSRMLS_FETCH(); return php_stream_read((php_stream*)context, buffer, len); } int php_libxml_streams_IO_write(void *context, const char *buffer, int len) { TSRMLS_FETCH(); return php_stream_write((php_stream*)context, buffer, len); } int php_libxml_streams_IO_close(void *context) { TSRMLS_FETCH(); return php_stream_close((php_stream*)context); } PHP_MINIT_FUNCTION(libxml) { /* Enable php stream/wrapper support for libxml we only use php streams, so we disable the libxml builtin io support. */ xmlCleanupInputCallbacks(); xmlRegisterInputCallbacks( php_libxml_streams_IO_match_wrapper, php_libxml_streams_IO_open_wrapper, php_libxml_streams_IO_read, php_libxml_streams_IO_close); xmlCleanupOutputCallbacks(); xmlRegisterOutputCallbacks( php_libxml_streams_IO_match_wrapper, php_libxml_streams_IO_open_wrapper, php_libxml_streams_IO_write, php_libxml_streams_IO_close); #ifdef ZTS ts_allocate_id(&libxml_globals_id, sizeof(php_libxml_globals), (ts_allocate_ctor) php_libxml_init_globals, NULL); #else LIBXML(stream_context) = NULL; #endif return SUCCESS; } PHP_RINIT_FUNCTION(libxml) { return SUCCESS; } PHP_MSHUTDOWN_FUNCTION(libxml) { return SUCCESS; } PHP_RSHUTDOWN_FUNCTION(libxml) { return SUCCESS; } PHP_MINFO_FUNCTION(libxml) { php_info_print_table_start(); php_info_print_table_row(2, "libXML support", "active"); php_info_print_table_row(2, "libXML Version", LIBXML_DOTTED_VERSION); php_info_print_table_row(2, "libXML streams", "enabled"); php_info_print_table_end(); } /* }}} */ /* {{{ 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) { zval *arg; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &arg) == FAILURE) { return; } LIBXML(stream_context) = arg; } /* }}} */ #endif /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * End: * vim600: sw=4 ts=4 fdm=marker * vim<600: sw=4 ts=4 */ Index: php-src/ext/libxml/php_libxml.h +++ php-src/ext/libxml/php_libxml.h /* +----------------------------------------------------------------------+ | PHP Version 4 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2003 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 | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_0.txt. | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | [EMAIL PROTECTED] so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: Shane Caraveo <[EMAIL PROTECTED]> | | Wez Furlong <[EMAIL PROTECTED]> | +----------------------------------------------------------------------+ */ /* $Id: php_libxml.h,v 1.1 2003/10/19 21:48:46 shane Exp $ */ #ifndef PHP_LIBXML_H #define PHP_LIBXML_H #ifdef HAVE_LIBXML extern zend_module_entry libxml_module_entry; #define libxml_module_ptr &libxml_module_entry #else #define libxml_module_ptr NULL #endif #ifdef HAVE_LIBXML #ifdef PHP_WIN32 #define PHP_LIBXML_API __declspec(dllexport) #else #define PHP_LIBXML_API #endif typedef struct { zval *stream_context; } php_libxml_globals; PHP_FUNCTION(libxml_set_streams_context); #endif /* HAVE_LIBXML */ #define phpext_libxml_ptr libxml_module_ptr #ifdef ZTS #define LIBXML(v) TSRMG(libxml_globals_id, php_libxml_globals *, v) #else #define LIBXML(v) (libxml_globals.v) #endif #endif /* PHP_LIBXML_H */ /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * End: */
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php