diff options
author | Sascha Schumann <sas@php.net> | 2003-06-24 13:56:57 +0000 |
---|---|---|
committer | Sascha Schumann <sas@php.net> | 2003-06-24 13:56:57 +0000 |
commit | e1a9dd289afc0a056865dff95fc356444af6744c (patch) | |
tree | 081db0cd69edb1cd04ccdb84d9fe4d3e174dd97d /ext/xslt | |
parent | 6b5b6079da8af0e3b7d3bba2f26854ac8d05885d (diff) | |
download | php-git-e1a9dd289afc0a056865dff95fc356444af6744c.tar.gz |
Empty HEAD of domxml, hyperwave, xslt
Diffstat (limited to 'ext/xslt')
30 files changed, 0 insertions, 3589 deletions
diff --git a/ext/xslt/README.XSLT-BACKENDS b/ext/xslt/README.XSLT-BACKENDS deleted file mode 100644 index b779c952ef..0000000000 --- a/ext/xslt/README.XSLT-BACKENDS +++ /dev/null @@ -1,285 +0,0 @@ -+------------------------------------------------------------------------------+ -| CREATING XSLT BACKENDS | -+------------------------------------------------------------------------------+ - - Author(s): Sterling Hughes <sterling@php.net> - - Introduction - ------------------------------------------------------------------------------- - Truth be told, at this point in time there are about a zillion and two - different XSLT libraries, each with their own unique merits and faults. If you - provide a Sablotron extension, people will clamor for a Xalan extension, if you - provide a Xalan extension people will clamor for a libxslt extension. - - In order to be as user friendly as possible, we try and provide the most - options to the user. At the same time we must try to keep a level of - consistency, so the user does not need to remember 15 different syntaxes, etc. - for each XSLT extension, and when switching from XSLT backends, no changes in - the PHP code should be necessary (akin to the concept of a database independent - api, but with XSLT libraries). - - At the same time, you'll also notice that in some cases extensions seem to - duplicate each others functionality. All extensions need code for calling - user-defined handlers, omitting debug messages, etc. In the interests of - laziness, we must also try to make these as minimal as possible. - - Therefore, I've created a processor independent api for XSLT, aka, the XSLT - extension (but doesn't "A processor independent API for XSLT" sound cooler?). - It defines a set of functions which every XSLT backend must provide, as well - as a syntax which those functions must adhere to. Furthermore, the underlying - code, provides a "library" if you will, of code that is relevant to all XSLT - extensions. - - The API - ------------------------------------------------------------------------------- - Every extension must define the following functions: - - - xslt_create() - - xslt_set_scheme_handlers() - - xslt_set_sax_handlers() - - xslt_set_error_handler() - - xslt_set_log() - - xslt_set_object() - - xslt_process() - - xslt_error() - - xslt_errno() - - xslt_free() - - These functions are common or implementable with every single XSLT library that - I've come across so far (at least every C library) and should there for be - defined by the extension. - - - resource xslt_create(void) - - The XSLT create function allocates a new XSLT processor and returns a resource - pointer to the XSLT processor. It also handles any initialization that the - processor requires. - - - void xslt_set_scheme_handlers(resource processor, array handlers) - - Registers the scheme handlers for the document (aka XPath handlers), given a - XSLT processor resource (allocated by xslt_create()) and an array in the - following format: - - array( - "get_all" => function, - "open" => function, - "get" => function, - "put" => function, - "close" => function - ) - - Where function is either a function name or an array in the following format: - - array(&$obj, "method") - - Note: You do not need to handle the array(&$obj, "method") syntax by yourself - as this is handled in the call_xslt_function() library function (and - more specifically, Zend's call_user_function_ex() function. - Note: The given array does not need to contain all of the different scheme - handler elements (although it can), but it only needs to conform to - the "handler" => "function" format described above. - - Each of the individual scheme handler functions called are in the formats - below: - - string get_all(resource processor, string scheme, string rest) - resource open(resource processor, string scheme, string rest) - int get(resource processor, resource fp, string &data) - int put(resource processor, resource fp, string data) - void close(resource processor, resource fp) - - - void xslt_set_sax_handlers(resource processor, array handlers) - - Registers the SAX handlers for the document, given a XSLT processor resource - (allocated by xslt_create()) and an array in the following format: - - array( - "document" => array(document_start_function, - document_end_function), - "element" => array(element_start_function, - element_end_function), - "namespace" => array(namespace_start_function, - namespace_end_function), - "comment" => function, - "pi" => function, - "character" => function - ) - - Where the functions follow the syntax described for the scheme handler - functions. - - Each of the individual SAX handler functions are in the format below: - - void start_doc(resource processor) - void end_doc(resource processor) - void start_element(resource processor, string name, array attributes) - void end_element(resource processor, string name) - void start_namespace(resource processor, string prefix, string uri) - void end_namespace(resource processor, string prefix) - void comment(resource processor, string contents) - void pi(resource processor, string target, string contents) - void characters(resource processor, string contents) - - - void xslt_set_error_handler(resource processor, function error_handler) - - This function sets the user defined error handler to be called when a - processing or any other type of error occurs. It is given a XSLT - processor resource (allocated by xslt_create()) and an error function of - the same syntax described for the scheme handler function. - - The user defined error handler as the following syntax: - - void error(resource processor, int level, int error, array info) - - - void xslt_set_log(resource processor, string logname) - - Sets the XSLT log to record log information (processor messages, not errors). - Its given a XSLT processor (allocated by xslt_create()) and a string containing - the name of the log file. If the string is "php://stderr" then the logging - should go to standard error (stderr). Also the default place to send log - messages is standard error (if no log file is set). - - - mixed xslt_process(resource processor, - string xml, - string xsl[, - string result[, - array arguments[, - array parameters]]]) - - This function performs the magic, it takes the user's data, performs the - transformation and depending on the context either saves the result to a file - or returns the data to the user. - - To understand the way the xslt_process() function works, you must first - understand the concept of "argument buffers". Argument buffers are equivalent - to the concept of symlinks on a Unix system, take the following example: - - <?php - - /** - * $xml contains the contents of an XML file and $xsl contains - * the contents of an XSLT stylesheet - */ - $args = array("/_xml" => $xml, - "/_xsl" => $xsl); - - $xh = xslt_create(); - $data = xslt_process($xh, "arg:/_xml", "arg:/_xsl", NULL, $args); - xslt_free($xh); - - print( "The results of the transformation were\n" ); - print( "<br>\n<hr>\n<br>" ); - print( $data ); - print( "<br>\n<hr>\n<br>" ); - ?> - - See what was done? The argument buffer was declared ($args) and the different - arguments were defined. Then when the xslt_process() function was called - instead of giving the XML filename and XSLT filename we instead gave - "arguments", which correspond to the XML and XSLT data in the argument buffers. - - This concept is a bit foreign to some people, however, I find it the best way - to handle processing xsl data. If you're still having trouble with this, try - playing around with the sablotron backend a bit, you should be able to catch on - pretty quickly. - - In order to use argument buffers, the XSLT extension provides a couple of easy - to use API functions, you can use them as follows: - - { - zval **arguments_zp; - char **arguments_cp; - xslt_args *arguments; - char *types[] = { "file", "data" }; - - /* Fetch the arguments from the user into a zval ** */ - - /* Translate the zval array into a character array */ - xslt_make_array(&arguments_cp, arguments_zp); - - /* Translate the character array into an xslt_arg * structure */ - arguments = xslt_parse_arguments(arguments_cp); - - /* Print out the resulting xslt_arg * structure */ - php_printf("XML type: %s\n", types[arguments->xml.type]); - php_printf("XML data: %s\n", arguments->xml.ptr); - PUTS("\n"); - php_printf("XSLT type: %s\n", types[arguments->xsl.type]); - php_printf("XSLT data: %s\n", arguments->xsl.ptr); - PUTS("\n"); - php_printf("Result type: %s\n", types[arguments->result.type]); - php_printf("Result data: %s\n", arguments->result.ptr); - PUTS("\n"); - } - - You can also test the "type" field by using the XSLT_IS_FILE and XSLT_IS_DATA - constants. - - Anyway back to the syntax of the xslt_process() function. The first argument - to the xslt_process() function is a resource pointer to the XSLT processor to - be used. The second argument is either an "argument buffer" pointing to the - XML data or the name of a file containing the XML data. The third argument is - either an argument buffer pointing to the XSLT data or a file containing the - XSLT data. The fourth argument is optional, it either contains the name of the - file to place the results of the transformation into, NULL or "arg:/_result", - in the latter 2 cases, the results of the transformation will be returned. The - fifth optional argument is the "argument buffer" itself, it is an associative - PHP array of "argument_name" => "value" pairs, or NULL, if no arguments are to - be passed. The final optional argument is a set of parameters to pass to the - XSLT stylesheet. The parameter argument is an associative array of - "parameter_name" => "value" pairs. - - - string xslt_error(resource processor) - - The xslt_error() function returns the last error that occured, given a XSLT - processor resource (allocated by xslt_create()). - - - int xslt_errno(resource processor) - - The xslt_errno() function returns the last error number that occured given a - XSLT processor resource (allocated by xslt_create()). - - - void xslt_free(resource processor) - - The xslt_free() function free's the given XSLT processor resource (allocated - by xslt_create()). - - - Config.m4 - ------------------------------------------------------------------------------- - - The XSLT extension's "magic" really occurs in the config.m4 file. Here you - must add a couple of things in order for your backend to be enabled. Its a bit - too complex to describe (but easy to implement and understand). Take a look at - config.m4 (which is well commented) to see what is necessary. - - - Makefile.in - ------------------------------------------------------------------------------- - - Simply add the source files for your backend to the LTLIBRARY_SOURCES variable - and you're all set with this file. - - - Conclusion - ------------------------------------------------------------------------------- - - Nobody's perfect, I'm sure I've made some mistakes while thinking this whole - thing through and I would be glad to hear from any of you who think I'm a - colossal moron and think you have a better way to do it. Please e-mail at - sterling@php.net, this extension will only get better with feedback. - - With that said, the concepts here may take a little bit of time to sink in, I - know I've written a whole lot. My suggestion to you, if you're planning on - writing an XSLT backend is simply to go off and implement, taking the api - section as a guide and making sure you match that api as closely as possible. diff --git a/ext/xslt/TODO b/ext/xslt/TODO deleted file mode 100644 index cf85d7c264..0000000000 --- a/ext/xslt/TODO +++ /dev/null @@ -1,31 +0,0 @@ -To Do List - -This informal list is the working list for the php sablotron extension. It is -maintained and used by the people on sab-php@gingerall.cz. See -http://www.gingerall.org/charlie/ga/xml/m_ml.xml for more information. - -The numbering of the items on the list does not imply priority. Rather it is -simply a means for efficient communication on the mailing lists. - -$Id$ - -Short Term -========== -1. Add streams support for file paths in 4th and 5th arg of xslt_process -2. Use zend_parse_parameters and related API's -3. SDOM_* stuff which does xpath queries. - - Melvyn - - -Long Term -========= -1. Documentation of the wide variety of functions now available. - - Roy Huggins -2. remove TSRMLS_FETCH() and expand user_data parameter to forward the -actual tsrmls value. - - suggested by Marcus Boerger - -3. Evaluate OO functions, ZE2 - - All -4. Prolly an API rewrite, for php5 - - All diff --git a/ext/xslt/config.m4 b/ext/xslt/config.m4 deleted file mode 100644 index e29e244093..0000000000 --- a/ext/xslt/config.m4 +++ /dev/null @@ -1,164 +0,0 @@ -dnl -dnl $Id$ -dnl -dnl +------------------------------------------------------------------------------+ -dnl | This is where the magic of the extension reallly is. Depending on what | -dnl | backend the user chooses, this script performs the magic | -dnl +------------------------------------------------------------------------------+ - -PHP_ARG_ENABLE(xslt, whether to enable xslt support, -[ --enable-xslt Enable xslt support.]) - -PHP_ARG_WITH(xslt-sablot, for XSLT Sablotron backend, -[ --with-xslt-sablot=DIR XSLT: Enable the sablotron backend.], no, no) - -PHP_ARG_WITH(expat-dir, for libexpat dir for Sablotron XSL support, -[ --with-expat-dir=DIR XSLT: libexpat dir for Sablotron.], no, no) - -PHP_ARG_WITH(iconv-dir, for iconv dir for Sablotron XSL support, -[ --with-iconv-dir=DIR XSLT: iconv dir for Sablotron.], no, no) - -PHP_ARG_WITH(sablot-js, for JavaScript for Sablotron XSL support, -[ --with-sablot-js=DIR XSLT: enable JavaScript support for Sablotron.], no, no) - - -if test "$PHP_XSLT" != "no"; then - - PHP_NEW_EXTENSION(xslt, xslt.c sablot.c, $ext_shared) - PHP_SUBST(XSLT_SHARED_LIBADD) - - if test "$PHP_XSLT_SABLOT" != "no"; then - XSLT_CHECK_DIR=$PHP_XSLT_SABLOT - XSLT_TEST_FILE=/include/sablot.h - XSLT_BACKEND_NAME=Sablotron - XSLT_LIBNAME=sablot - fi - - if test -z "$XSLT_BACKEND_NAME"; then - AC_MSG_ERROR([No backend specified for XSLT extension.]) - fi - - condition="$XSLT_CHECK_DIR$XSLT_TEST_FILE" - - if test -r $condition; then - XSLT_DIR=$XSLT_CHECK_DIR - else - AC_MSG_CHECKING(for $XSLT_BACKEND_NAME libraries in the default path) - for i in /usr /usr/local; do - condition="$i$XSLT_TEST_FILE" - if test -r $condition; then - XSLT_DIR=$i - fi - done - AC_MSG_RESULT(found in $XSLT_DIR) - fi - - if test -z "$XSLT_DIR"; then - AC_MSG_ERROR([not found. Please re-install the $XSLT_BACKEND_NAME distribution.]) - fi - - if test "$PHP_XSLT_SABLOT" != "no"; then - AC_MSG_CHECKING([for sablot-config]) - if test -x $XSLT_DIR/bin/sablot-config ; then - AC_MSG_RESULT(found) - AC_DEFINE(HAVE_SABLOT_CONFIG, 1, [Whether the Sablotron config file is found]) - dnl Use this script to register this information in phpinfo() - SABINF_CFLAGS=`$XSLT_DIR/bin/sablot-config --cflags` - SABINF_LIBS=`$XSLT_DIR/bin/sablot-config --libs` - SABINF_PREFIX=`$XSLT_DIR/bin/sablot-config --prefix` - SABINF_ALL="\"Cflags: $SABINF_CFLAGS\nLibs: $SABINF_LIBS\nPrefix: $SABINF_PREFIX\"" - PHP_DEFINE(SAB_INFO, "$SABINF_ALL") - else - AC_MSG_RESULT(not found) - fi - AC_MSG_CHECKING([for Sablotron version]) - old_CPPFLAGS=$CPPFLAGS - CPPFLAGS="$CPPFLAGS -I$XSLT_DIR/include" - AC_TRY_RUN([ -#include <stdlib.h> -#include <sablot.h> - -int main () -{ - double version; - version = atof(SAB_VERSION); - - if (version >= 0.96) { - exit(0); - } - exit(255); -} - ],[ - AC_MSG_RESULT([>= 0.96]) - ],[ - AC_MSG_ERROR([Sablotron version 0.96 or greater required.]) - ]) - CPPFLAGS=$old_CPPFLAGS - - found_expat=no - for i in $PHP_EXPAT_DIR $XSLT_DIR /usr/local /usr; do - if test -f $i/lib/libexpat.a -o -f $i/lib/libexpat.$SHLIB_SUFFIX_NAME; then - AC_DEFINE(HAVE_LIBEXPAT2, 1, [ ]) - PHP_ADD_INCLUDE($i/include) - PHP_ADD_LIBRARY_WITH_PATH(expat, $i/lib, XSLT_SHARED_LIBADD) - found_expat=yes - break - fi - done - - if test "$found_expat" = "no"; then - AC_MSG_ERROR([expat not found. To build sablotron you need the expat library.]) - fi - - if test "$PHP_ICONV_DIR" != "no"; then - PHP_ICONV=$PHP_ICONV_DIR - fi - - if test "$PHP_ICONV" = "no"; then - PHP_ICONV=yes - fi - - PHP_SETUP_ICONV(XSLT_SHARED_LIBADD, [], [ - AC_MSG_ERROR([iconv not found. To build sablotron you need the iconv library.]) - ]) - - if test "$PHP_SABLOT_JS" != "no"; then - for i in /usr/local /usr $PHP_SABLOT_JS; do - if test -f $i/lib/libjs.a -o -f $i/lib/libjs.$SHLIB_SUFFIX_NAME; then - PHP_SABLOT_JS_DIR=$i - fi - done - - PHP_CHECK_LIBRARY(js, JS_GetRuntime, - [ - PHP_ADD_LIBRARY_WITH_PATH(js, $PHP_SABLOT_JS_DIR/lib, XSLT_SHARED_LIBADD) - ], [ - AC_MSG_ERROR([libjs not found. Please check config.log for more information.]) - ], [ - -L$PHP_SABLOT_JS_DIR/lib - ]) - fi - - PHP_CHECK_LIBRARY(sablot, SablotSetEncoding, - [ - AC_DEFINE(HAVE_SABLOT_SET_ENCODING, 1, [ ]) - ], [], [ - -L$XSLT_DIR/lib - ]) - - dnl SablotSetOptions implemented in Sablotron CVS > 2002/10/31 - PHP_CHECK_LIBRARY(sablot, SablotGetOptions, - [ - AC_DEFINE(HAVE_SABLOT_GET_OPTIONS, 1, [Whether Sablotron supports SablotGetOptions]) - ], [], [ - -L$XSLT_DIR/lib - ]) - - AC_DEFINE(HAVE_SABLOT_BACKEND, 1, [ ]) - fi - - PHP_ADD_INCLUDE($XSLT_DIR/include) - PHP_ADD_LIBRARY_WITH_PATH($XSLT_LIBNAME, $XSLT_DIR/lib, XSLT_SHARED_LIBADD) - - AC_DEFINE(HAVE_XSLT, 1, [ ]) -fi diff --git a/ext/xslt/php_sablot.h b/ext/xslt/php_sablot.h deleted file mode 100644 index 64b5f88ac2..0000000000 --- a/ext/xslt/php_sablot.h +++ /dev/null @@ -1,142 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | 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 | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: Sterling Hughes <sterling@php.net> | - +----------------------------------------------------------------------+ - */ - -#ifndef PHP_XSLT_H -#define PHP_XSLT_H - -#include "php.h" - -#if HAVE_SABLOT_BACKEND - -#include "php_xslt.h" - -#include <sablot.h> - -extern zend_module_entry xslt_module_entry; -#define phpext_xslt_ptr &xslt_module_entry - -#ifdef PHP_WIN32 -#define PHP_XSLT_API __declspec(dllexport) -#else -#define PHP_XSLT_API -#endif - -#define XSLT_SCHEME(handle) ((handle)->handlers->scheme) -#define XSLT_SAX(handle) ((handle)->handlers->sax) -#define XSLT_ERROR(handle) ((handle)->handlers->error) - -#define XSLT_PROCESSOR(handle) ((handle)->processor.ptr) -#define XSLT_SITUATION(handle) ((handle)->processor.sit) - -#define XSLT_ERRNO(handle) ((handle)->err->no) -#define XSLT_ERRSTR(handle) ((handle)->err->str) -#define XSLT_LOG(handle) ((handle)->err->log) -#define XSLT_BASE_ISSET(handle) ((handle)->base_isset) - -#define XSLT_FUNCH_FREE(__var) if (__var) zval_ptr_dtor(&(__var)); -#define XSLT_REG_ERRMSG(msg, handle) if (XSLT_ERRSTR(handle)) efree(XSLT_ERRSTR(handle)); \ - XSLT_ERRSTR(handle) = estrdup(msg); -#define XSLT_NO_INFO "No information available." - -PHP_MINIT_FUNCTION(xslt); -PHP_MINFO_FUNCTION(xslt); - -PHP_FUNCTION(xslt_create); -PHP_FUNCTION(xslt_set_sax_handlers); -PHP_FUNCTION(xslt_set_scheme_handlers); -PHP_FUNCTION(xslt_set_error_handler); -PHP_FUNCTION(xslt_set_base); -PHP_FUNCTION(xslt_set_encoding); -PHP_FUNCTION(xslt_set_log); -PHP_FUNCTION(xslt_process); -PHP_FUNCTION(xslt_error); -PHP_FUNCTION(xslt_errno); -PHP_FUNCTION(xslt_free); -PHP_FUNCTION(xslt_set_object); -PHP_FUNCTION(xslt_setopt); -#ifdef HAVE_SABLOT_GET_OPTIONS -PHP_FUNCTION(xslt_getopt); -#endif -PHP_FUNCTION(xslt_backend_version); -PHP_FUNCTION(xslt_backend_name); -PHP_FUNCTION(xslt_backend_info); - -struct scheme_handlers { - zval *sh_get_all; - zval *sh_open; - zval *sh_get; - zval *sh_put; - zval *sh_close; -}; - -struct sax_handlers { - zval *doc_start; - zval *element_start; - zval *element_end; - zval *namespace_start; - zval *namespace_end; - zval *comment; - zval *pi; - zval *characters; - zval *doc_end; -}; - -struct xslt_handlers { - struct scheme_handlers scheme; - struct sax_handlers sax; - zval *error; -}; - -struct xslt_processor { - SablotHandle ptr; - SablotSituation sit; - long idx; -}; - -struct xslt_log { - char *path; - int fd; - int do_log; -}; - -struct xslt_error { - struct xslt_log log; - char *str; - int no; -}; - -typedef struct { - struct xslt_handlers *handlers; - struct xslt_processor processor; - struct xslt_error *err; - zval *object; - unsigned short base_isset; -} php_xslt; - -#else -#define phpext_xslt_ptr NULL -#endif - -#endif - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - */ diff --git a/ext/xslt/php_xslt.h b/ext/xslt/php_xslt.h deleted file mode 100644 index d5369b350c..0000000000 --- a/ext/xslt/php_xslt.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | 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 | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: Sterling Hughes <sterling@php.net> | - +----------------------------------------------------------------------+ - */ - -#ifndef _PHP_XSLT_H -#define _PHP_XSLT_H - -#include "php.h" -#include "ext/standard/php_filestat.h" - -#ifdef HAVE_XSLT - -#define XSLT_OBJ(__func) (&(__func)->obj) -#define XSLT_FUNC(__func) ((__func)->func) - -#define XSLT_IS_FILE 0 -#define XSLT_IS_DATA 1 - -struct xslt_function { - zval *obj; - zval *func; -}; - -struct _xslt_argument { - char *ptr; - int type; -}; - -typedef struct { - struct _xslt_argument xml; - struct _xslt_argument xsl; - struct _xslt_argument result; -} xslt_args; - -extern xslt_args *xslt_parse_arguments(char *, char *, char *, char **); -extern void xslt_free_arguments(xslt_args *); - -extern void xslt_assign_handler(struct xslt_function **, zval **); -extern void xslt_free_handler(struct xslt_function *); -extern void xslt_call_function(char *, zval *, zval *, int, zval **, zval **); - -extern void xslt_debug(char *, char *, ...); - -extern void xslt_make_array(zval **zarr, char ***carr); -extern void xslt_free_array(char **arr); - -#endif - -#endif diff --git a/ext/xslt/sablot.c b/ext/xslt/sablot.c deleted file mode 100644 index a55d2c49aa..0000000000 --- a/ext/xslt/sablot.c +++ /dev/null @@ -1,1821 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | 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 | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Authors: Sterling Hughes <sterling@php.net> | - | David Viner <dviner@php.net> | - | Lenar Lohmus <flex@php.net> | - | Melvyn Sopacua <msopacua@php.net> | - +----------------------------------------------------------------------+ - */ - -/* $Id$ */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "php.h" -#include "php_xslt.h" -#include "php_sablot.h" -#include "ext/standard/info.h" - -#if HAVE_SABLOT_BACKEND - -#ifdef HAVE_SABLOT_CONFIG -#include "php_sab_info.h" -#endif -#include <sablot.h> - -#include <string.h> -#include <stdarg.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> - -/* functions relating to handlers */ -static void register_sax_handler_pair(zval **, zval **, zval ** TSRMLS_DC); - -/* Free processor */ -static void free_processor(zend_rsrc_list_entry *rsrc TSRMLS_DC); - -/* Scheme handler functions */ -static int scheme_getall(void *, SablotHandle, const char *, const char *, char **, int *); -static int scheme_freememory(void *, SablotHandle, char *); -static int scheme_open(void *, SablotHandle, const char *, const char *, int *); -static int scheme_get(void *, SablotHandle, int, char *, int *); -static int scheme_put(void *, SablotHandle, int, const char *, int *); -static int scheme_close(void *, SablotHandle, int); - -/* Sax handler functions */ -static SAX_RETURN sax_startdoc(void *, SablotHandle); -static SAX_RETURN sax_startelement(void *, SablotHandle, const char *, const char **); -static SAX_RETURN sax_endelement(void *, SablotHandle, const char *); -static SAX_RETURN sax_startnamespace(void *, SablotHandle, const char *, const char *); -static SAX_RETURN sax_endnamespace(void *, SablotHandle, const char *); -static SAX_RETURN sax_comment(void *, SablotHandle, const char *); -static SAX_RETURN sax_pi(void *, SablotHandle, const char *, const char *); -static SAX_RETURN sax_characters(void *, SablotHandle, const char *, int); -static SAX_RETURN sax_enddoc(void *, SablotHandle); - -/* Error handlers */ -static MH_ERROR error_makecode(void *, SablotHandle, int, unsigned short, unsigned short); -static MH_ERROR error_log(void *, SablotHandle, MH_ERROR, MH_LEVEL, char **); -static MH_ERROR error_print(void *, SablotHandle, MH_ERROR, MH_LEVEL, char **); - -/* Resource related */ -#define le_xslt_name "XSLT Processor" -static int le_xslt; - -/* {{{ xslt_functions[] - */ -static unsigned char second_args_force_ref[] = { 2, BYREF_NONE, BYREF_FORCE }; - -function_entry xslt_functions[] = { - PHP_FE(xslt_create, NULL) - PHP_FE(xslt_set_sax_handlers, NULL) - PHP_FE(xslt_set_scheme_handlers, NULL) - PHP_FE(xslt_set_error_handler, NULL) - PHP_FE(xslt_set_base, NULL) -#ifdef HAVE_SABLOT_SET_ENCODING - PHP_FE(xslt_set_encoding, NULL) -#endif - PHP_FE(xslt_set_log, NULL) - PHP_FE(xslt_process, NULL) - PHP_FE(xslt_error, NULL) - PHP_FE(xslt_errno, NULL) - PHP_FE(xslt_free, NULL) - PHP_FE(xslt_set_object, second_args_force_ref) - PHP_FE(xslt_setopt, NULL) -#ifdef HAVE_SABLOT_GET_OPTIONS - PHP_FE(xslt_getopt, NULL) -#endif - PHP_FE(xslt_backend_version, NULL) - PHP_FE(xslt_backend_name, NULL) - PHP_FE(xslt_backend_info, NULL) - {NULL, NULL, NULL} -}; -/* }}} */ - -/* {{{ xslt_module_entry - */ -zend_module_entry xslt_module_entry = { - STANDARD_MODULE_HEADER, - "xslt", - xslt_functions, - PHP_MINIT(xslt), - NULL, - NULL, - NULL, - PHP_MINFO(xslt), - NO_VERSION_YET, - STANDARD_MODULE_PROPERTIES -}; -/* }}} */ - -#ifdef COMPILE_DL_XSLT -ZEND_GET_MODULE(xslt) -#endif - -/* {{{ handler structs - A structure containing the sax handlers, automatically - registered whether the user defines them or not */ -static SAXHandler sax_handlers = -{ - sax_startdoc, - sax_startelement, - sax_endelement, - sax_startnamespace, - sax_endnamespace, - sax_comment, - sax_pi, - sax_characters, - sax_enddoc -}; - -/* Error handlers, automatically registered */ -static MessageHandler message_handler = { - error_makecode, - error_log, - error_print -}; - -/* Scheme handlers automatically registered */ -static SchemeHandler scheme_handler = { - scheme_getall, - scheme_freememory, - scheme_open, - scheme_get, - scheme_put, - scheme_close -}; -/* }}} */ - -/* {{{ PHP_MINIT_FUNCTION - */ -PHP_MINIT_FUNCTION(xslt) -{ - le_xslt = zend_register_list_destructors_ex(free_processor, NULL, le_xslt_name, module_number); - - /* Generic options, which can apply to 'all' xslt processors */ - REGISTER_LONG_CONSTANT("XSLT_OPT_SILENT", SAB_NO_ERROR_REPORTING, CONST_CS | CONST_PERSISTENT); - - /* Error constants, which are useful in userspace. */ - REGISTER_LONG_CONSTANT("XSLT_ERR_UNSUPPORTED_SCHEME", SH_ERR_UNSUPPORTED_SCHEME, CONST_CS | CONST_PERSISTENT); - /* Sablotron specific options */ - REGISTER_LONG_CONSTANT("XSLT_SABOPT_PARSE_PUBLIC_ENTITIES", SAB_PARSE_PUBLIC_ENTITIES, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XSLT_SABOPT_DISABLE_ADDING_META", SAB_DISABLE_ADDING_META, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XSLT_SABOPT_DISABLE_STRIPPING", SAB_DISABLE_STRIPPING, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XSLT_SABOPT_IGNORE_DOC_NOT_FOUND", SAB_IGNORE_DOC_NOT_FOUND, CONST_CS | CONST_PERSISTENT); -/* hack: implemented at the same time, so should work. - Otherwise we need to check the enum type of SablotFlag in <sablot.h> */ -#ifdef HAVE_SABLOT_GET_OPTIONS - REGISTER_LONG_CONSTANT("XSLT_SABOPT_FILES_TO_HANDLER", SAB_FILES_TO_HANDLER, CONST_CS | CONST_PERSISTENT); -#endif - - return SUCCESS; -} -/* }}} */ - -/* {{{ PHP_MINFO_FUNCTION - */ -PHP_MINFO_FUNCTION(xslt) -{ - php_info_print_table_start(); - php_info_print_table_row(2, "XSLT support", "enabled"); - php_info_print_table_row(2, "Backend", "Sablotron"); -#ifdef SAB_VERSION - php_info_print_table_row(2, "Sablotron Version", SAB_VERSION); -#endif -#ifdef HAVE_SABLOT_CONFIG - php_info_print_table_row(2, "Sablotron Information", SAB_INFO); -#endif - php_info_print_table_end(); -} -/* }}} */ - -/* {{{ proto resource xslt_create(void) - Create a new XSLT processor */ -PHP_FUNCTION(xslt_create) -{ - php_xslt *handle; /* The php -> sablotron handle */ - SablotHandle processor; /* The sablotron processor */ - SablotSituation sit; /* The sablotron Situation handle */ - int error; /* The error container */ - - /* Allocate the php-sablotron handle */ - handle = ecalloc(1, sizeof(php_xslt)); - handle->handlers = ecalloc(1, sizeof(struct xslt_handlers)); - handle->err = ecalloc(1, sizeof(struct xslt_error)); - handle->object = NULL; - handle->base_isset = 0; - - XSLT_LOG(handle).path = NULL; - - /* Allocate the actual processor itself, via sablotron */ - SablotCreateSituation(&sit); - error = SablotCreateProcessorForSituation(sit, &processor); - if (error) { - XSLT_ERRNO(handle) = error; - RETURN_FALSE; - } - - /* Save the processor and set the default handlers */ - XSLT_PROCESSOR(handle) = processor; - XSLT_SITUATION(handle) = sit; - SablotRegHandler(XSLT_PROCESSOR(handle), HLR_SAX, (void *) &sax_handlers, (void *) handle); - SablotRegHandler(XSLT_PROCESSOR(handle), HLR_MESSAGE, (void *) &message_handler, (void *) handle); - SablotRegHandler(XSLT_PROCESSOR(handle), HLR_SCHEME, (void *) &scheme_handler, (void *) handle); - - /* Register the processor as a resource and return it to the user */ - ZEND_REGISTER_RESOURCE(return_value, handle, le_xslt); - - /* The resource index, save it for later use */ - handle->processor.idx = Z_LVAL_P(return_value); -} -/* }}} */ - -/* {{{ proto void xslt_set_sax_handlers(resource processor, array handlers) - Set the SAX handlers to be called when the XML document gets processed */ -PHP_FUNCTION(xslt_set_sax_handlers) -{ - zval **processor_p, /* Resource pointer to the php->sablotron handle */ - **sax_handlers_p, /* Pointer to the sax handlers php array */ - **handler; /* Individual handler, or handler pair */ - HashTable *sax_handlers; /* PHP array of sax handlers */ - php_xslt *handle; /* Pointer to a php_xslt handle */ - char *string_key; /* String key for the hash */ - ulong num_key; /* (unused) hash's numerical key */ - int key_type; /* The type of the current hash key */ - - if (ZEND_NUM_ARGS() != 2 || - zend_get_parameters_ex(2, &processor_p, &sax_handlers_p) == FAILURE) { - WRONG_PARAM_COUNT; - } - ZEND_FETCH_RESOURCE(handle, php_xslt *, processor_p, -1, le_xslt_name, le_xslt); - - /* Convert the sax_handlers_p zval ** to a hash table we can process */ - sax_handlers = HASH_OF(*sax_handlers_p); - if (!sax_handlers) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Expecting an array as the second argument"); - return; - } - - /* Loop through the HashTable containing the SAX handlers */ - for (zend_hash_internal_pointer_reset(sax_handlers); - zend_hash_get_current_data(sax_handlers, (void **) &handler) == SUCCESS; - zend_hash_move_forward(sax_handlers)) { - - key_type = zend_hash_get_current_key(sax_handlers, &string_key, &num_key, 0); - if (key_type == HASH_KEY_IS_LONG) { - convert_to_string_ex(handler); - php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Skipping numerical index %d (with value %s)", - num_key, Z_STRVAL_PP(handler)); - continue; - } - - /* Document handlers (document start, document end) */ - if (strcasecmp(string_key, "document") == 0) { - SEPARATE_ZVAL(handler); - register_sax_handler_pair(&XSLT_SAX(handle).doc_start, - &XSLT_SAX(handle).doc_end, - handler TSRMLS_CC); - } - /* Element handlers, start of an element, and end of an element */ - else if (strcasecmp(string_key, "element") == 0) { - SEPARATE_ZVAL(handler); - register_sax_handler_pair(&XSLT_SAX(handle).element_start, - &XSLT_SAX(handle).element_end, - handler TSRMLS_CC); - } - /* Namespace handlers, start of a namespace, end of a namespace */ - else if (strcasecmp(string_key, "namespace") == 0) { - SEPARATE_ZVAL(handler); - register_sax_handler_pair(&XSLT_SAX(handle).namespace_start, - &XSLT_SAX(handle).namespace_end, - handler TSRMLS_CC); - } - /* Comment handlers, called when a comment is reached */ - else if (strcasecmp(string_key, "comment") == 0) { - XSLT_SAX(handle).comment = *handler; - zval_add_ref(&XSLT_SAX(handle).comment); - } - /* Processing instructions handler called when processing instructions - (<? ?>) */ - else if (strcasecmp(string_key, "pi") == 0) { - XSLT_SAX(handle).pi = *handler; - zval_add_ref(&XSLT_SAX(handle).pi); - } - /* Character handler, called when data is found */ - else if (strcasecmp(string_key, "character") == 0) { - XSLT_SAX(handle).characters = *handler; - zval_add_ref(&XSLT_SAX(handle).characters); - } - /* Invalid handler name, tsk, tsk, tsk :) */ - else { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid option: %s", string_key); - } - } -} -/* }}} */ - -/* {{{ proto void xslt_set_scheme_handlers(resource processor, array handlers) - Set the scheme handlers for the XSLT processor */ -PHP_FUNCTION(xslt_set_scheme_handlers) -{ - zval **processor_p, /* Resource pointer to the php->sablotron handle */ - **scheme_handlers_p, /* Pointer to the scheme handler array */ - **handler; /* Individual scheme handler */ - zval **assign_handle; /* The handler to assign to */ - HashTable *scheme_handlers; /* Scheme handler array */ - php_xslt *handle; /* php->sablotron handle */ - char *string_key; /* Hash key (string) */ - ulong num_key; /* (unused) Hash key (number) */ - int key_type; /* The type of the current key */ - - if (ZEND_NUM_ARGS() != 2 || - zend_get_parameters_ex(2, &processor_p, &scheme_handlers_p) == FAILURE) { - WRONG_PARAM_COUNT; - } - ZEND_FETCH_RESOURCE(handle, php_xslt *, processor_p, -1, le_xslt_name, le_xslt); - - scheme_handlers = HASH_OF(*scheme_handlers_p); - if (!scheme_handlers) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "2nd argument must be an array"); - return; - } - - /* Loop through the scheme handlers array, setting the given - scheme handlers */ - for (zend_hash_internal_pointer_reset(scheme_handlers); - zend_hash_get_current_data(scheme_handlers, (void **) &handler) == SUCCESS; - zend_hash_move_forward(scheme_handlers)) { - - key_type = zend_hash_get_current_key(scheme_handlers, &string_key, &num_key, 0); - if (key_type == HASH_KEY_IS_LONG) { - php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Numerical key %d (with value %s) being ignored", - num_key, Z_STRVAL_PP(handler)); - continue; - } - - /* Open the URI and return the whole string */ - if (strcasecmp(string_key, "get_all") == 0) { - assign_handle = &XSLT_SCHEME(handle).sh_get_all; - } - /* Open the URI and return a handle */ - else if (strcasecmp(string_key, "open") == 0) { - assign_handle = &XSLT_SCHEME(handle).sh_open; - } - /* Retrieve data from the URI */ - else if (strcasecmp(string_key, "get") == 0) { - assign_handle = &XSLT_SCHEME(handle).sh_get; - } - /* Save data to the URI */ - else if (strcasecmp(string_key, "put") == 0) { - assign_handle = &XSLT_SCHEME(handle).sh_put; - } - /* Close the URI */ - else if (strcasecmp(string_key, "close") == 0) { - assign_handle = &XSLT_SCHEME(handle).sh_close; - } - /* Invalid handler name */ - else { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "invalid option '%s', skipping", string_key); - continue; - } - - *assign_handle = *handler; - zval_add_ref(assign_handle); - } -} -/* }}} */ - -/* {{{ proto void xslt_set_error_handler(resource processor, mixed error_func) - Set the error handler, to be called when an XSLT error happens */ -PHP_FUNCTION(xslt_set_error_handler) -{ - zval **processor_p, /* Resource Pointer to a PHP-XSLT processor */ - **error_func; /* Name of the user defined error function */ - php_xslt *handle; /* A PHP-XSLT processor */ - - if (ZEND_NUM_ARGS() != 2 || - zend_get_parameters_ex(2, &processor_p, &error_func) == FAILURE) { - WRONG_PARAM_COUNT; - } - ZEND_FETCH_RESOURCE(handle, php_xslt *, processor_p, -1, le_xslt_name, le_xslt); - - XSLT_ERROR(handle) = *error_func; - zval_add_ref(&XSLT_ERROR(handle)); -} -/* }}} */ - -/* {{{ proto void xslt_set_base(resource processor, string base) - Sets the base URI for all XSLT transformations */ -PHP_FUNCTION(xslt_set_base) -{ - zval **processor_p, /* Resource Pointer to a PHP-XSLT processor */ - **base; /* The base URI for the transformation */ - php_xslt *handle; /* A PHP-XSLT processor */ - - if (ZEND_NUM_ARGS() != 2 || - zend_get_parameters_ex(2, &processor_p, &base) == FAILURE) { - WRONG_PARAM_COUNT; - } - ZEND_FETCH_RESOURCE(handle, php_xslt *, processor_p, -1, le_xslt_name, le_xslt); - convert_to_string_ex(base); - - /* Set the base */ - SablotSetBase(XSLT_PROCESSOR(handle), Z_STRVAL_PP(base)); - XSLT_BASE_ISSET(handle) = 1; -} -/* }}} */ - -/* {{{ proto void xslt_set_encoding(resource processor, string encoding) - Set the output encoding for the current stylesheet */ -PHP_FUNCTION(xslt_set_encoding) -{ -/* The user has to explicitly compile sablotron with sablotron - encoding functions in order for SablotSetEncoding to be - enabled. config.m4 automatically checks for this... */ - -#ifdef HAVE_SABLOT_SET_ENCODING - zval **processor_p, /* Resource Pointer to a PHP-XSLT processor */ - **encoding; /* The encoding to use for the output */ - php_xslt *handle; /* A PHP-XSLT processor */ - - if (ZEND_NUM_ARGS() != 2 || - zend_get_parameters_ex(2, &processor_p, &encoding) == FAILURE) { - WRONG_PARAM_COUNT; - } - ZEND_FETCH_RESOURCE(handle, php_xslt *, processor_p, -1, le_xslt_name, le_xslt); - convert_to_string_ex(encoding); - - /* Set the encoding */ - SablotSetEncoding(XSLT_PROCESSOR(handle), Z_STRVAL_PP(encoding)); -#endif - -} -/* }}} */ - -/* {{{ proto void xslt_set_log(resource processor, string logfile) - Set the log file to write the errors to (defaults to stderr) */ -PHP_FUNCTION(xslt_set_log) -{ - zval **processor_p, /* Resource pointer to a PHP-XSLT processor */ - **logfile; /* Path to the logfile */ - php_xslt *handle; /* A PHP-XSLT processor */ - int argc = ZEND_NUM_ARGS(); /* Argument count */ - - if (argc < 1 || argc > 2 || - zend_get_parameters_ex(argc, &processor_p, &logfile) == FAILURE) { - WRONG_PARAM_COUNT; - } - ZEND_FETCH_RESOURCE(handle, php_xslt *, processor_p, -1, le_xslt_name, le_xslt); - - if (Z_TYPE_PP(logfile) == IS_LONG || Z_TYPE_PP(logfile) == IS_BOOL || Z_TYPE_PP(logfile) == IS_DOUBLE) { - XSLT_LOG(handle).do_log = Z_LVAL_PP(logfile); - RETURN_NULL(); - } - else { - convert_to_string_ex(logfile); - } - - /* If the log file already exists, free it */ - if (XSLT_LOG(handle).path) { - efree(XSLT_LOG(handle).path); - } - - /* Copy the path */ - XSLT_LOG(handle).path = estrndup(Z_STRVAL_PP(logfile), - Z_STRLEN_PP(logfile)); -} -/* }}} */ - -/* {{{ proto string xslt_process(resource processor, string xml, string xslt[, mixed result[, array args[, array params]]]) - Perform the xslt transformation */ -PHP_FUNCTION(xslt_process) -{ - zval **processor_p, /* Resource Pointer to a PHP-XSLT processor */ - **xml_p, /* A zval pointer to the XML data */ - **xslt_p, /* A zval pointer to the XSLT data */ - **result_p, /* A zval pointer to the transformation results */ - **params_p, /* A zval pointer to the XSLT parameters array */ - **args_p; /* A zval pointer to the XSLT arguments array */ - php_xslt *handle; /* A PHP-XSLT processor */ - char **params = NULL; /* A Sablotron parameter array (derived from the zval parameter array) */ - char **args = NULL; /* A Sablotron argument array (derived from the zval argument array) */ - char *xslt; /* The XSLT stylesheet or argument buffer (pointer to xslt_p) */ - char *xml; /* The XML stylesheet or argument buffer (pointer to xml_p) */ - char *result; /* The result file or argument buffer */ - int argc = ZEND_NUM_ARGS(); /* The number of arguments given */ - int error; /* Our error container */ - int i; /* iterator for Situation */ - - if (argc < 3 || argc > 6 || - zend_get_parameters_ex(argc, &processor_p, &xml_p, &xslt_p, &result_p, &args_p, ¶ms_p) == FAILURE) { - WRONG_PARAM_COUNT; - } - - ZEND_FETCH_RESOURCE(handle, php_xslt *, processor_p, -1, le_xslt_name, le_xslt); - convert_to_string_ex(xml_p); - convert_to_string_ex(xslt_p); - - xml = Z_STRVAL_PP(xml_p); - xslt = Z_STRVAL_PP(xslt_p); - - /* Well, no result file was given or result buffer, that means (guess what?) - we're returning the result yipp di doo! */ - if (argc < 4 || Z_TYPE_PP(result_p) == IS_NULL) { - result = "arg:/_result"; - } - /* The result buffer to place the data into, either a file or an argument buffer, etc. */ - else { - convert_to_string_ex(result_p); - result = Z_STRVAL_PP(result_p); - } - - /* Translate a PHP array into a Sablotron array */ - if (argc > 4) { - xslt_make_array(args_p, &args); - /* Can return NULL */ - if (args) { - TSRMLS_FETCH(); - i=0; - while (args[i]) { - /* We can safely add args[i+1] since xslt_make_array sets args[i] to NULL if - a key on the array is missing. */ - /* For now, we don't care about the error. So don't store it. */ - SablotAddArgBuffer(XSLT_SITUATION(handle), XSLT_PROCESSOR(handle), args[i], args[i+1]); - i += 2; - } - - /* Since we have args passed, we need to set the base uri, so pull in executor - globals and set the base, using the current filename, specifcally for the - 'arg' scheme */ - if(XSLT_BASE_ISSET(handle) == 0) - { - char *baseuri; - spprintf(&baseuri, 0, "file://%s", zend_get_executed_filename(TSRMLS_C)); - SablotSetBaseForScheme(XSLT_PROCESSOR(handle), "arg", baseuri); - - if(baseuri) - efree(baseuri); - } - } - } - - if (argc > 5) { - xslt_make_array(params_p, ¶ms); - /* Can return NULL */ - if (params) { - i=0; - while (params[i]) { - SablotAddParam(XSLT_SITUATION(handle), XSLT_PROCESSOR(handle), params[i], params[i+1]); - i += 2; - } - } - } - - /* Perform transformation */ - error = SablotRunProcessorGen(XSLT_SITUATION(handle), XSLT_PROCESSOR(handle), xslt, xml, result); - if (error) { - XSLT_ERRNO(handle) = error; - - if (params) xslt_free_array(params); - if (args) xslt_free_array(args); - - RETURN_FALSE; - } - - /* If the result buffer is specified, then we return the results of the XSLT - transformation */ - if (!strcmp(result, "arg:/_result")) { - char *trans_result; - - /* Fetch the result buffer into trans_result */ - error = SablotGetResultArg(handle->processor.ptr, "arg:/_result", &trans_result); - if (error) { - /* Save the error number */ - XSLT_ERRNO(handle) = error; - - /* Cleanup */ - if (params) xslt_free_array(params); - if (args) xslt_free_array(args); - - RETURN_FALSE; - } - - RETVAL_STRING(trans_result, 1); - SablotFree(trans_result); - } - else { - RETVAL_TRUE; - } - - /* Cleanup */ - if (params) xslt_free_array(params); - if (args) xslt_free_array(args); -} -/* }}} */ - -/* {{{ proto int xslt_errno(resource processor) - Error number */ -PHP_FUNCTION(xslt_errno) -{ - zval **processor_p; /* Resource pointer to a PHP-XSLT processor */ - php_xslt *handle; /* A PHP-XSLT processor */ - - if (ZEND_NUM_ARGS() != 1 || - zend_get_parameters_ex(1, &processor_p) == FAILURE) { - WRONG_PARAM_COUNT; - } - ZEND_FETCH_RESOURCE(handle, php_xslt *, processor_p, -1, le_xslt_name, le_xslt); - - RETURN_LONG(XSLT_ERRNO(handle)); -} -/* }}} */ - -/* {{{ proto string xslt_error(resource processor) - Error string */ -PHP_FUNCTION(xslt_error) -{ - zval **processor_p; /* Resource pointer to a PHP-XSLT processor */ - php_xslt *handle; /* A PHP-XSLT processor */ - - if (ZEND_NUM_ARGS() != 1 || - zend_get_parameters_ex(1, &processor_p) == FAILURE) { - WRONG_PARAM_COUNT; - } - ZEND_FETCH_RESOURCE(handle, php_xslt *, processor_p, -1, le_xslt_name, le_xslt); - - if (XSLT_ERRSTR(handle)) { - RETURN_STRING(XSLT_ERRSTR(handle), 1); - } else { - RETURN_FALSE; - } -} -/* }}} */ - -/* {{{ proto void xslt_free(resource processor) - Free the xslt processor up */ -PHP_FUNCTION(xslt_free) -{ - zval **processor_p; /* Resource pointer to a php-xslt processor */ - php_xslt *handle; /* A PHP-XSLT processor */ - - if (ZEND_NUM_ARGS() != 1 || - zend_get_parameters_ex(1, &processor_p) == FAILURE) { - WRONG_PARAM_COUNT; - } - ZEND_FETCH_RESOURCE(handle, php_xslt *, processor_p, -1, le_xslt_name, le_xslt); - - /* Remove the entry from the list */ - zend_list_delete(Z_LVAL_PP(processor_p)); -} -/* }}} */ - -/* {{{ proto int xslt_set_object(resource parser, object obj) - sets the object in which to resolve callback functions */ -PHP_FUNCTION(xslt_set_object) -{ - zval *processor_p; /* Resource pointer to a PHP-XSLT processor */ - zval *myobj; /* The object that will handle the callback */ - php_xslt *handle; /* A PHP-XSLT processor */ - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zo", &processor_p, &myobj) == FAILURE) - return; - - ZEND_FETCH_RESOURCE(handle, php_xslt *, &processor_p, -1, le_xslt_name, le_xslt); - - handle->object = myobj; - - RETURN_TRUE; -} -/* }}} */ - -/* {{{ proto int xslt_setopt(resource processor, int newmask) - Set options on a given xsl processor */ -PHP_FUNCTION(xslt_setopt) -{ - zval **processor_p; /* Resource pointer to a PHP-XSLT processor */ - zval **zbitmask; /* A bitmask created by through processor specific constants */ - php_xslt *handle; /* A PHP-XSLT processor */ - int error; /* Error return codes */ - int newmask; /* New mask */ -#ifdef HAVE_SABLOT_GET_OPTIONS - int prevmask; /* Previous mask */ -#endif - - if (ZEND_NUM_ARGS() != 2 || - zend_get_parameters_ex(2, &processor_p, &zbitmask) == FAILURE) { - WRONG_PARAM_COUNT; - } - - ZEND_FETCH_RESOURCE(handle, php_xslt *, processor_p, -1, le_xslt_name, le_xslt); - convert_to_long_ex(zbitmask); - - newmask = Z_LVAL_PP(zbitmask); - if (newmask < 0) { - php_error_docref("function.xslt-setopt" TSRMLS_CC, E_WARNING, "Invalid bitmask: %i", newmask); - RETURN_FALSE; - } - -#ifdef HAVE_SABLOT_GET_OPTIONS - prevmask = SablotGetOptions(XSLT_SITUATION(handle)); -#endif - error = SablotSetOptions(XSLT_SITUATION(handle), newmask); - if (error) { - /* FIXME: Need to analyze the return code to give a more verbose error description */ - php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Failed to set options"); - } - -#ifdef HAVE_SABLOT_GET_OPTIONS - RETURN_LONG(prevmask); -#else - RETURN_TRUE; -#endif -} - -/* }}} */ - -#ifdef HAVE_SABLOT_GET_OPTIONS -/* {{{ proto int xslt_getopt(resource processor) - Get options on a given xsl processor */ -PHP_FUNCTION(xslt_getopt) -{ - zval **processor_p; /* Resource pointer to a PHP-XSLT processor */ - php_xslt *handle; /* A PHP-XSLT processor */ - - if (ZEND_NUM_ARGS() != 1 || - zend_get_parameters_ex(1, &processor_p) == FAILURE) { - WRONG_PARAM_COUNT; - } - - ZEND_FETCH_RESOURCE(handle, php_xslt *, processor_p, -1, le_xslt_name, le_xslt); - - RETURN_LONG(SablotGetOptions(XSLT_SITUATION(handle))); -} - -/* }}} */ -#endif - -/* {{{ proto string xslt_backend_version() - Returns the version number of Sablotron (if available) */ -PHP_FUNCTION(xslt_backend_version) -{ -#ifdef SAB_VERSION - RETURN_STRING(SAB_VERSION,1); -#else - RETURN_FALSE; -#endif -} -/* }}} */ - -/* {{{ proto string xslt_backend_name() - Returns the name of the Backend (here "Sablotron")*/ -PHP_FUNCTION(xslt_backend_name) -{ - RETURN_STRING("Sablotron",1); -} -/* }}} */ - -/* {{{ proto string xslt_backend_info() - Returns the information on the compilation settings of the backend */ -PHP_FUNCTION(xslt_backend_info) -{ -#ifdef HAVE_SABLOT_CONFIG - RETURN_STRING(SAB_INFO, strlen(SAB_INFO)); -#else - RETURN_STRING(XSLT_NO_INFO, strlen(XSLT_NO_INFO)); -#endif -} -/* }}} */ -/* {{{ free_processor() - Free an XSLT processor */ -static void free_processor(zend_rsrc_list_entry *rsrc TSRMLS_DC) -{ - php_xslt *handle = (php_xslt *) rsrc->ptr; /* A PHP-XSLT processor */ - - /* Free the processor */ - if (XSLT_PROCESSOR(handle)) { - SablotUnregHandler(XSLT_PROCESSOR(handle), HLR_MESSAGE, NULL, NULL); - SablotUnregHandler(XSLT_PROCESSOR(handle), HLR_SAX, NULL, NULL); - SablotUnregHandler(XSLT_PROCESSOR(handle), HLR_SCHEME, NULL, NULL); - SablotDestroyProcessor(XSLT_PROCESSOR(handle)); - SablotDestroySituation(XSLT_SITUATION(handle)); - } - - /* Free Scheme handlers */ - XSLT_FUNCH_FREE(XSLT_SCHEME(handle).sh_get_all); - XSLT_FUNCH_FREE(XSLT_SCHEME(handle).sh_open); - XSLT_FUNCH_FREE(XSLT_SCHEME(handle).sh_get); - XSLT_FUNCH_FREE(XSLT_SCHEME(handle).sh_put); - XSLT_FUNCH_FREE(XSLT_SCHEME(handle).sh_close); - /* Free SAX handlers */ - XSLT_FUNCH_FREE(XSLT_SAX(handle).doc_start); - XSLT_FUNCH_FREE(XSLT_SAX(handle).element_start); - XSLT_FUNCH_FREE(XSLT_SAX(handle).element_end); - XSLT_FUNCH_FREE(XSLT_SAX(handle).namespace_start); - XSLT_FUNCH_FREE(XSLT_SAX(handle).namespace_end); - XSLT_FUNCH_FREE(XSLT_SAX(handle).comment); - XSLT_FUNCH_FREE(XSLT_SAX(handle).pi); - XSLT_FUNCH_FREE(XSLT_SAX(handle).characters); - XSLT_FUNCH_FREE(XSLT_SAX(handle).doc_end); - /* Free error handler */ - XSLT_FUNCH_FREE(XSLT_ERROR(handle)); - - /* Free error message, if any */ - if (XSLT_ERRSTR(handle)) { - efree(XSLT_ERRSTR(handle)); - } - - /* Close log file */ - if (XSLT_LOG(handle).fd) { - close(XSLT_LOG(handle).fd); - } - - /* Free log file path */ - if (XSLT_LOG(handle).path) { - efree(XSLT_LOG(handle).path); - } - - /* Free up the handle */ - efree(handle->handlers); - efree(handle->err); - efree(handle); -} -/* }}} */ - -/* {{{ register_sax_handler_pair() - Register a pair of sax handlers */ -static void register_sax_handler_pair(zval **handler1, zval **handler2, zval **handler TSRMLS_DC) -{ - zval **current; /* The current handler we're grabbing */ - - /* Grab and assign handler 1 */ - if (zend_hash_index_find(Z_ARRVAL_PP(handler), 0, (void **) ¤t) == SUCCESS) { - *handler1 = *current; - zval_add_ref(handler1); - } - else { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Wrong format of arguments"); - return; - } - - /* Grab and assign handler 2 */ - if (zend_hash_index_find(Z_ARRVAL_PP(handler), 1, (void **) ¤t) == SUCCESS) { - *handler2 = *current; - zval_add_ref(handler2); - } - else { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Wrong format of arguments"); - return; - } -} -/* }}} */ - -/* {{{ scheme_getall() - The getall scheme handler */ -static int scheme_getall(void *user_data, SablotHandle proc, const char *scheme, const char *rest, char **buffer, int *byte_count) -{ - zval *argv[3]; /* Arguments to the scheme getall function */ - zval *retval; /* Return value from the scheme getall function */ - int result; - php_xslt *handle = (php_xslt *) user_data; /* A PHP-XSLT processor */ - TSRMLS_FETCH(); - - /* If the scheme handler get all function doesn't - exist, exit out */ - if (!XSLT_SCHEME(handle).sh_get_all) { - return 0; - } - - /* Allocate and initialize */ - MAKE_STD_ZVAL(argv[0]); - MAKE_STD_ZVAL(argv[1]); - MAKE_STD_ZVAL(argv[2]); - - /* Argument 1: XSLT processor (resource) - Argument 2: Scheme (string) - Argument 3: Rest (string) - */ - ZVAL_RESOURCE(argv[0], handle->processor.idx); - zend_list_addref(handle->processor.idx); - ZVAL_STRING(argv[1], (char *) scheme, 1); - ZVAL_STRING(argv[2], (char *) rest, 1); - - xslt_call_function("scheme get all", XSLT_SCHEME(handle).sh_get_all, handle->object, - 3, argv, &retval); - - if (!retval) { - /* return failure */ - return 1; - } - - if ((Z_TYPE_P(retval) == IS_BOOL && Z_LVAL_P(retval) == 0) || (Z_TYPE_P(retval) == IS_NULL)) { - result = 1; - } else { - /* Convert the return value to string if needed */ - if (Z_TYPE_P(retval) != IS_STRING) - convert_to_string_ex(&retval); - - /* Save the return value in the buffer (copying it) */ - *buffer = estrndup(Z_STRVAL_P(retval), Z_STRLEN_P(retval)); - *byte_count = Z_STRLEN_P(retval); - result = 0; - } - - /* Free return value */ - zval_ptr_dtor(&retval); - - return result; -} -/* }}} */ - -/* {{{ scheme_handler_is_registered() - Check to see if the scheme handler is registered with the user */ -static int scheme_handler_is_registered(php_xslt *handle) -{ - /* If one of the functions is exists, then scheme - handlers are registered */ - if (XSLT_SCHEME(handle).sh_get_all || - XSLT_SCHEME(handle).sh_open || - XSLT_SCHEME(handle).sh_get || - XSLT_SCHEME(handle).sh_put || - XSLT_SCHEME(handle).sh_close) - return 1; - /* otherwise, no cigar */ - else - return 0; -} -/* }}} */ - -/* {{{ scheme_freememory() - Called when sablotron needs to free memory related to scheme handling */ -static int scheme_freememory(void *user_data, SablotHandle proc, char *buffer) -{ - /* If we don't have any scheme handler's registered, then emalloc() wasn't - used, and if emalloc() wasn't then efree shouldn't be used */ - if (!scheme_handler_is_registered((php_xslt *) user_data)) { - return 0; - } - - /* Free the memory using efree() and remove it from the register */ - efree(buffer); - - return 0; -} -/* }}} */ - -/* {{{ scheme_open() - Called when the URI needs to be opened */ -static int scheme_open(void *user_data, SablotHandle proc, const char *scheme, const char *rest, int *fd) -{ - zval *argv[3]; /* Arguments to the scheme open function */ - zval *retval; /* The return value from the scheme open function */ - php_xslt *handle = (php_xslt *) user_data; /* A PHP-XSLT processor */ - TSRMLS_FETCH(); - - /* If no open handler exists, let's exit */ - if (!XSLT_SCHEME(handle).sh_open) { - return 0; - } - - /* Allocate and initialize arguments */ - MAKE_STD_ZVAL(argv[0]); - MAKE_STD_ZVAL(argv[1]); - MAKE_STD_ZVAL(argv[2]); - - /* Argument 1: XSLT Processor (resource) - Argument 2: Scheme (string) - Argument 3: Rest (string) - */ - ZVAL_RESOURCE(argv[0], handle->processor.idx); - zend_list_addref(handle->processor.idx); - ZVAL_STRING(argv[1], (char *) scheme, 1); - ZVAL_STRING(argv[2], (char *) rest, 1); - - /* Call the function */ - xslt_call_function("scheme open", XSLT_SCHEME(handle).sh_open, handle->object, - 3, argv, &retval); - - if (!retval) { - /* return failure */ - return 1; - } - - /* Return value is a resource pointer to an open file */ - *fd = Z_LVAL_P(retval); - - /* Free it all up */ - zval_ptr_dtor(&retval); - - if (!*fd) { - /* return failure - unsupported scheme */ - return SH_ERR_UNSUPPORTED_SCHEME; - } - - /* return success */ - return 0; -} -/* }}} */ - -/* {{{ scheme_get() - Called when data needs to be fetched from the URI */ -static int scheme_get(void *user_data, SablotHandle proc, int fd, char *buffer, int *byte_count) -{ - zval *argv[3]; /* Arguments to the scheme get function */ - zval *retval; /* Return value from the scheme get function */ - php_xslt *handle = (php_xslt *) user_data; /* A PHP-XSLT processor */ - TSRMLS_FETCH(); - - /* If no get handler exists, let's exit */ - if (!XSLT_SCHEME(handle).sh_get) { - return 0; - } - - /* Allocate and initialize arguments */ - MAKE_STD_ZVAL(argv[0]); - MAKE_STD_ZVAL(argv[1]); - MAKE_STD_ZVAL(argv[2]); - - /* Argument 1: XSLT Processor (resource) - Argument 2: File Pointer (resource) - Argument 3: Data (string) - */ - ZVAL_RESOURCE(argv[0], handle->processor.idx); - zend_list_addref(handle->processor.idx); - ZVAL_RESOURCE(argv[1], fd); - zend_list_addref(fd); - ZVAL_STRINGL(argv[2], buffer, *byte_count, 0); - - /* Call the function */ - xslt_call_function("scheme get", XSLT_SCHEME(handle).sh_get, handle->object, - 3, argv, &retval); - - if (!retval) { - /* return failure */ - return 1; - } - - /* Returns the number of bytes read */ - *byte_count = Z_LVAL_P(retval); - - /* Free things up */ - zval_ptr_dtor(&retval); - - /* return success */ - return 0; -} -/* }}} */ - -/* {{{ scheme_put() - Called when data needs to be written */ -static int scheme_put(void *user_data, SablotHandle proc, int fd, const char *buffer, int *byte_count) -{ - zval *argv[3]; /* Arguments to the scheme put function */ - zval *retval; /* Return value from the scheme put function */ - php_xslt *handle = (php_xslt *) user_data; /* A PHP-XSLT processor */ - TSRMLS_FETCH(); - - /* If no put handler exists, let's exit */ - if (!XSLT_SCHEME(handle).sh_put) { - return 0; - } - - /* Allocate and initialize arguments */ - MAKE_STD_ZVAL(argv[0]); - MAKE_STD_ZVAL(argv[1]); - MAKE_STD_ZVAL(argv[2]); - - /* Argument 1: XSLT processor (resource) - Argument 2: File pointer (resource) - Argument 3: Data (string) - */ - ZVAL_RESOURCE(argv[0], handle->processor.idx); - zend_list_addref(handle->processor.idx); - ZVAL_RESOURCE(argv[1], fd); - zend_list_addref(fd); - ZVAL_STRINGL(argv[2], (char *) buffer, *byte_count, 1); - - /* Call the scheme put function already */ - xslt_call_function("scheme put", XSLT_SCHEME(handle).sh_put, handle->object, - 3, argv, &retval); - - if (!retval) { - /* return failure */ - return 1; - } - - /* The return value is the number of bytes written */ - *byte_count = Z_LVAL_P(retval); - - /* Free everything up */ - zval_ptr_dtor(&retval); - - /* Return success */ - return 0; -} -/* }}} */ - -/* {{{ scheme_close() - Called when its time to close the fd */ -static int scheme_close(void *user_data, SablotHandle proc, int fd) -{ - zval *argv[2]; /* Arguments to the scheme close function*/ - zval *retval; /* Return value from the scheme close function */ - php_xslt *handle = (php_xslt *) user_data; /* A PHP-XSLT processor */ - TSRMLS_FETCH(); - - /* if no close handler exists, exit */ - if (!XSLT_SCHEME(handle).sh_close) { - return 0; - } - - /* Allocate and initialize arguments */ - MAKE_STD_ZVAL(argv[0]); - MAKE_STD_ZVAL(argv[1]); - - /* Argument 1: XSLT processor (resource) - Argument 2: File pointer (resource) - */ - ZVAL_RESOURCE(argv[0], handle->processor.idx); - zend_list_addref(handle->processor.idx); - ZVAL_RESOURCE(argv[1], fd); - zend_list_addref(fd); - - /* Call the scheme handler close function */ - xslt_call_function("scheme close", XSLT_SCHEME(handle).sh_close, handle->object, - 2, argv, &retval); - - if (!retval) { - /* return failure */ - return 1; - } - - /* Free everything up */ - zval_ptr_dtor(&retval); - - /* Return success */ - return 0; -} -/* }}} */ - -/* {{{ sax_startdoc() - Called when the document starts to be processed */ -static SAX_RETURN sax_startdoc(void *ctx, SablotHandle processor) -{ - zval *argv[1]; /* Arguments to the sax start doc function */ - zval *retval; /* Return value from sax start doc function */ - php_xslt *handle = (php_xslt *) ctx; /* A PHP-XSLT processor */ - TSRMLS_FETCH(); - - /* if no document start function exists, exit */ - if (!XSLT_SAX(handle).doc_start) { - return; - } - - /* Allocate and initialize arguments */ - MAKE_STD_ZVAL(argv[0]); - - /* Argument 1: XSLT processor (resource) */ - ZVAL_RESOURCE(argv[0], handle->processor.idx); - zend_list_addref(handle->processor.idx); - - /* Call the Sax start doc function */ - xslt_call_function("sax start doc", XSLT_SAX(handle).doc_start, handle->object, - 1, argv, &retval); - - /* Cleanup */ - if (retval) - zval_ptr_dtor(&retval); -} -/* }}} */ - -/* {{{ sax_startelement() - Called when an element is begun to be processed */ -static SAX_RETURN sax_startelement(void *ctx, SablotHandle processor, - const char *name, - const char **attr) -{ - zval *argv[3]; /* Arguments to the sax start element function */ - zval *retval; /* Return value from the sax start element function */ - php_xslt *handle = (php_xslt *) ctx; /* A PHP-XSLT processor */ - char **p; /* Pointer to attributes */ - TSRMLS_FETCH(); - - /* If no element start function is found, exit */ - if (!XSLT_SAX(handle).element_start) { - return; - } - - /* Allocate and initialize arguments */ - MAKE_STD_ZVAL(argv[0]); - MAKE_STD_ZVAL(argv[1]); - MAKE_STD_ZVAL(argv[2]); - array_init(argv[2]); - - /* Argument 1: XSLT processor (resource) - Argument 2: Element name (string) - Argument 3: Element attributes (array) - */ - ZVAL_RESOURCE(argv[0], handle->processor.idx); - zend_list_addref(handle->processor.idx); - ZVAL_STRING(argv[1], (char *) name, 1); - - /* loop through the attributes array, copying it onto our - php array */ - p = (char **) attr; - while (p && *p) { - add_assoc_string(argv[2], *p, *(p + 1), 1); - p += 2; - } - - /* Call the sax element start function */ - xslt_call_function("sax start element", XSLT_SAX(handle).element_start, handle->object, - 3, argv, &retval); - - /* Cleanup */ - if (retval) - zval_ptr_dtor(&retval); -} -/* }}} */ - -/* {{{ xslt_sax_endelement() - Called when an ending XML element is encountered */ -static SAX_RETURN sax_endelement(void *ctx, SablotHandle processor, const char *name) -{ - zval *argv[2]; /* Arguments to the sax end element function */ - zval *retval; /* Return value from the sax end element function */ - php_xslt *handle = (php_xslt *) ctx; /* A PHP-XSLT processor */ - TSRMLS_FETCH(); - - /* If no element end function exists, exit */ - if (!XSLT_SAX(handle).element_end) { - return; - } - - /* Allocate and initialize arguments */ - MAKE_STD_ZVAL(argv[0]); - MAKE_STD_ZVAL(argv[1]); - - /* Argument 1: XSLT processor (resource) - Argument 2: Element name (string) - */ - ZVAL_RESOURCE(argv[0], handle->processor.idx); - zend_list_addref(handle->processor.idx); - ZVAL_STRING(argv[1], (char *) name, 1); - - /* Call the sax end element function */ - xslt_call_function("sax end element", XSLT_SAX(handle).element_end, handle->object, - 2, argv, &retval); - - /* Cleanup */ - if (retval) - zval_ptr_dtor(&retval); -} -/* }}} */ - -/* {{{ sax_startnamespace() - Called at the beginning of the parsing of a new namespace */ -static SAX_RETURN sax_startnamespace(void *ctx, SablotHandle processor, - const char *prefix, - const char *uri) -{ - zval *argv[3]; /* Arguments to the sax start namespace function */ - zval *retval; /* Return value from the sax start namespace function */ - php_xslt *handle = (php_xslt *) ctx; /* A PHP-XSLT processor */ - TSRMLS_FETCH(); - - /* if no namespace start function exists, exit */ - if (!XSLT_SAX(handle).namespace_start) { - return; - } - - /* Allocate and initialize arguments */ - MAKE_STD_ZVAL(argv[0]); - MAKE_STD_ZVAL(argv[1]); - MAKE_STD_ZVAL(argv[2]); - - /* Argument 1: XSLT processor (resource) - Argument 2: Prefix (string) - Argument 3: URI (string) - */ - ZVAL_RESOURCE(argv[0], handle->processor.idx); - zend_list_addref(handle->processor.idx); - ZVAL_STRING(argv[1], (char *) prefix, 1); - ZVAL_STRING(argv[2], (char *) uri, 1); - - /* Call the sax start namespace function */ - xslt_call_function("sax start namespace", XSLT_SAX(handle).namespace_start, handle->object, - 3, argv, &retval); - - /* Cleanup */ - if (retval) - zval_ptr_dtor(&retval); -} -/* }}} */ - -/* {{{ sax_endnamespace() - Called when a new namespace is finished being parsed */ -static SAX_RETURN sax_endnamespace(void *ctx, SablotHandle processor, const char *prefix) -{ - zval *argv[2]; /* Arguments to the sax end namespace function */ - zval *retval; /* Return value from the sax end namespace function */ - php_xslt *handle = (php_xslt *) ctx; /* A PHP-XSLT processor */ - TSRMLS_FETCH(); - - /* If no namespace end function exists, exit */ - if (!XSLT_SAX(handle).namespace_end) { - return; - } - - /* Allocate and initialize arguments */ - MAKE_STD_ZVAL(argv[0]); - MAKE_STD_ZVAL(argv[1]); - - /* Argument 1: XSLT processor (resource) - Argument 2: Prefix (string) - */ - ZVAL_RESOURCE(argv[0], handle->processor.idx); - zend_list_addref(handle->processor.idx); - ZVAL_STRING(argv[1], (char *) prefix, 1); - - /* Call the sax end namespace function */ - xslt_call_function("sax end namespace", XSLT_SAX(handle).namespace_end, handle->object, - 2, argv, &retval); - - /* Cleanup */ - if (retval) - zval_ptr_dtor(&retval); -} -/* }}} */ - -/* {{{ sax_comment() - Called when a comment is found */ -static SAX_RETURN sax_comment(void *ctx, SablotHandle processor, const char *contents) -{ - zval *argv[2]; /* Arguments to the sax comment function */ - zval *retval; /* Return value from the sax comment function */ - php_xslt *handle = (php_xslt *) ctx; /* A PHP-XSLT processor */ - TSRMLS_FETCH(); - - /* if no comment function exists, exit */ - if (!XSLT_SAX(handle).comment) { - return; - } - - /* Allocate and initialize arguments */ - MAKE_STD_ZVAL(argv[0]); - MAKE_STD_ZVAL(argv[1]); - - /* Argument 1: XSLT processor (resource) - Argument 2: Comment contents (string) - */ - ZVAL_RESOURCE(argv[0], handle->processor.idx); - zend_list_addref(handle->processor.idx); - ZVAL_STRING(argv[1], (char *) contents, 1); - - /* Call the sax comment function */ - xslt_call_function("sax comment", XSLT_SAX(handle).comment, handle->object, - 2, argv, &retval); - - /* Cleanup */ - if (retval) - zval_ptr_dtor(&retval); -} -/* }}} */ - -/* {{{ sax_pi() - Called when processing instructions are found */ -static SAX_RETURN sax_pi(void *ctx, SablotHandle processor, - const char *target, - const char *contents) -{ - zval *argv[3]; /* Arguments to the sax processing instruction function */ - zval *retval; /* Return value from the sax processing instruction function */ - php_xslt *handle = (php_xslt *) ctx; /* A PHP-XSLT processor */ - TSRMLS_FETCH(); - - /* If no processing instructions function exists, exit */ - if (!XSLT_SAX(handle).pi) { - return; - } - - /* Allocate and initialize arguments */ - MAKE_STD_ZVAL(argv[0]); - MAKE_STD_ZVAL(argv[1]); - MAKE_STD_ZVAL(argv[2]); - - /* Argument 1: XSLT processor (resource) - Argument 2: Target of the pi (string) - Argument 3: Contents of the pi (string) - */ - ZVAL_RESOURCE(argv[0], handle->processor.idx); - zend_list_addref(handle->processor.idx); - ZVAL_STRING(argv[1], (char *) target, 1); - ZVAL_STRING(argv[2], (char *) contents, 1); - - /* Call processing instructions function */ - xslt_call_function("sax processing instructions", XSLT_SAX(handle).pi, handle->object, - 3, argv, &retval); - - /* Cleanup */ - if (retval) - zval_ptr_dtor(&retval); -} -/* }}} */ - -/* {{{ sax_characters() - Called when characters are come upon */ -static SAX_RETURN sax_characters(void *ctx, SablotHandle processor, - const char *contents, - int length) -{ - zval *argv[2]; /* Arguments to the sax characters function */ - zval *retval; /* Return value to the sax characters function */ - php_xslt *handle = (php_xslt *) ctx; /* A PHP-XSLT processor */ - TSRMLS_FETCH(); - - /* If no characters function exists, exit */ - if (!XSLT_SAX(handle).characters) { - return; - } - - /* Allocate and initialize arguments */ - MAKE_STD_ZVAL(argv[0]); - MAKE_STD_ZVAL(argv[1]); - - /* Argument 1: XSLT processor (resource) - Argument 2: Contents (string) - */ - ZVAL_RESOURCE(argv[0], handle->processor.idx); - zend_list_addref(handle->processor.idx); - ZVAL_STRINGL(argv[1], (char *) contents, length, 1); - - /* Call characters function */ - xslt_call_function("sax characters", XSLT_SAX(handle).characters, handle->object, - 2, argv, &retval); - - /* Cleanup */ - if (retval) - zval_ptr_dtor(&retval); -} -/* }}} */ - -/* {{{ sax_enddoc() - Called when the document is finished being parsed */ -static SAX_RETURN sax_enddoc(void *ctx, SablotHandle processor) -{ - zval *argv[1]; /* Arguments to the end document function */ - zval *retval; /* Return value from the end document function */ - php_xslt *handle = (php_xslt *) ctx; /* A PHP-XSLT processor */ - TSRMLS_FETCH(); - - /* If no end document function exists, exit */ - if (!XSLT_SAX(handle).doc_end) { - return; - } - - /* Allocate and initialize arguments */ - MAKE_STD_ZVAL(argv[0]); - - /* Argument 1: XSLT Processor (resource) - */ - ZVAL_RESOURCE(argv[0], handle->processor.idx); - zend_list_addref(handle->processor.idx); - - /* Call the function */ - xslt_call_function("sax end doc", XSLT_SAX(handle).doc_end, handle->object, - 1, argv, &retval); - - /* Cleanup */ - if (retval) - zval_ptr_dtor(&retval); -} -/* }}} */ - -/* {{{ error_makecode() - Make the error code */ -static MH_ERROR error_makecode(void *user_data, SablotHandle proc, int severity, unsigned short facility, unsigned short code) -{ - return 0; -} -/* }}} */ - -/* {{{ error_log() - Called when its time to log data */ -static MH_ERROR error_log(void *user_data, SablotHandle proc, MH_ERROR code, MH_LEVEL level, char **fields) -{ - php_xslt *handle = (php_xslt *) user_data; /* A PHP-XSLT processor */ - char *errmsg = NULL; /* Error message*/ - char *errtype = NULL; /* Error type */ - char *errline = NULL; /* Error line */ - char *msgbuf = NULL; /* Message buffer */ - char msgformat[] = "Sablotron Message on line %s, level %s: %s\n"; /* Message format */ - int error = 0; /* Error container */ - TSRMLS_FETCH(); - - if (!XSLT_LOG(handle).do_log) - return 0; - - /* Parse the error array */ - /* Loop through the error array */ - if (fields) { - while (*fields) { - char *key; /* Key to for the message */ - char *val; /* The message itself */ - char *ptr; /* Pointer to the location of the ':' (separator) */ - int pos; /* Position of the ':' (separator) */ - int len; /* Length of the string */ - - len = strlen(*fields); - - /* Grab the separator's position */ - ptr = strchr(*fields, ':'); - if (!ptr) { - continue; - } - pos = ptr - *fields; - - /* Allocate the key and value and copy the data onto them */ - key = emalloc(pos + 1); - val = emalloc((len - pos) + 1); - - strlcpy(key, *fields, pos + 1); - strlcpy(val, *fields + pos + 1, len - pos); - - /* Check to see whether or not we want to save the data */ - if (!strcmp(key, "msg")) { - errmsg = estrndup(val, len - pos); - } - else if (!strcmp(key, "type")) { - errtype = estrndup(val, len - pos); - } - else if (!strcmp(key, "line")) { - errline = estrndup(val, len - pos); - } - /* Haven't seen this yet, but turning it on during dev, to see - what we can encounter -- MRS - else { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Got key %s with val %s", key, val); - } - */ - - /* Cleanup */ - if (key) efree(key); - if (val) efree(val); - - /* Next key:value pair please :) */ - fields++; - } - } - - /* If no error line is given, then place none in the - file */ - if (!errline) { - errline = estrndup("none", sizeof("none") - 1); - } - - /* Default type is a log handle */ - if (!errtype) { - errtype = estrndup("log", sizeof("log") - 1); - } - - /* No error message, no cry */ - if (!errmsg) { - errmsg = estrndup("unknown error", sizeof("unknown error") - 1); - } - - /* Allocate the message buf and copy the data into it */ - msgbuf = emalloc((sizeof(msgformat) - 6) + - strlen(errmsg) + - strlen(errline) + - strlen(errtype) + 1); - sprintf(msgbuf, msgformat, errline, errtype, errmsg); - - /* If the error is serious enough, copy it to our error buffer - which will show up when someone calls the xslt_error() function */ - if (level == MH_LEVEL_WARN || - level == MH_LEVEL_ERROR || - level == MH_LEVEL_CRITICAL) { - XSLT_REG_ERRMSG(errmsg, handle); - } - - /* If we haven't allocated and opened the file yet */ - if (!XSLT_LOG(handle).fd) { - /* Lets open up a file */ - if (XSLT_LOG(handle).path && strcmp(XSLT_LOG(handle).path, "php://stderr")) { - /* open for append */ - XSLT_LOG(handle).fd = open(XSLT_LOG(handle).path, - O_WRONLY|O_CREAT|O_APPEND, - S_IRUSR|S_IRGRP|S_IROTH|S_IWUSR); - if (XSLT_LOG(handle).fd == -1) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot open log file, %s [%d]: %s", - XSLT_LOG(handle).path, errno, strerror(errno)); - XSLT_LOG(handle).fd = 0; - } - } - /* Default is stderr, or if the user provided "php://stderr" that's the - stream */ - else { - XSLT_LOG(handle).fd = 2; - } - } - - /* Write the error to the file */ - error = write(XSLT_LOG(handle).fd, msgbuf, strlen(msgbuf)); - if (error == -1) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot write data to log file, %s, with fd, %d [%d]: %s", - (XSLT_LOG(handle).path ? XSLT_LOG(handle).path : "stderr"), - XSLT_LOG(handle).fd, - errno, - strerror(errno)); - return 0; - } - - /* Cleanup */ - if (msgbuf) efree(msgbuf); - if (errtype) efree(errtype); - if (errline) efree(errline); - if (errmsg) efree(errmsg); - - return 0; -} -/* }}} */ - -/* {{{ error_print() - Print out an error message or call the error handler */ -static MH_ERROR error_print(void *user_data, SablotHandle proc, MH_ERROR code, MH_LEVEL level, char **fields) -{ - php_xslt *handle = (php_xslt *) user_data; /* A PHP-XSLT processor */ - TSRMLS_FETCH(); - - if (XSLT_ERROR(handle)) { - zval *argv[4]; /* Arguments to the error function */ - zval *retval; /* Return value from the error function */ - - /* Allocate and initialize */ - MAKE_STD_ZVAL(argv[0]); - MAKE_STD_ZVAL(argv[1]); - MAKE_STD_ZVAL(argv[2]); - MAKE_STD_ZVAL(argv[3]); - array_init(argv[3]); - - /* Argument 1: XSLT Processor (resource) - Argument 2: Error level (long) - Argument 3: Error code (long) - Argument 4: Error messages (array) - */ - ZVAL_RESOURCE(argv[0], handle->processor.idx); - zend_list_addref(handle->processor.idx); - ZVAL_LONG(argv[1], level); - ZVAL_LONG(argv[2], code); - - if (fields) { - while (*fields) { - char *key; /* Key to for the message */ - char *val; /* The message itself */ - char *ptr; /* Pointer to the location of the ':' (separator) */ - int pos; /* Position of the ':' (separator) */ - int len; /* Length of the string */ - - len = strlen(*fields); - - /* Grab the separator's position */ - ptr = strchr(*fields, ':'); - if (!ptr) { - continue; - } - pos = ptr - *fields; - - /* Allocate the key and value and copy the data onto them */ - key = emalloc(pos + 1); - val = emalloc((len - pos) + 1); - - strlcpy(key, *fields, pos + 1); - strlcpy(val, *fields + pos + 1, len - pos); - - /* Add it */ - add_assoc_stringl_ex(argv[3], key, pos + 1, val, len - pos - 1, 1); - - /* Cleanup */ - efree(key); - efree(val); - - /* Next field please */ - fields++; - } - } - - /* Call the function */ - xslt_call_function("error handler", XSLT_ERROR(handle), handle->object, - 4, argv, &retval); - - /* Free up */ - if (retval) - zval_ptr_dtor(&retval); - } - else { - char *errmsg = NULL; /* Error message */ - char *errline = NULL; /* Error line */ - char *msgbuf = NULL; /* Message buffer */ - char msgformat[] = "Sablotron error on line %s: %s"; /* Message format */ - - /* If the error is not serious, exit out */ - if (code == MH_LEVEL_WARN || - code == MH_LEVEL_ERROR || - code == MH_LEVEL_CRITICAL) { - return 0; - } - - /* Loop through and extract the error message and the - error line */ - if (fields) { - while (fields && *fields) { - char *key; /* Key to for the message */ - char *val; /* The message itself */ - char *ptr; /* Pointer to the location of the ':' (separator) */ - int pos; /* Position of the ':' (separator) */ - int len; /* Length of the string */ - - len = strlen(*fields); - - /* Grab the separator's position */ - ptr = strchr(*fields, ':'); - if (!ptr) { - continue; - } - pos = ptr - *fields; - - /* Allocate the key and value and copy the data onto them */ - key = emalloc(pos + 1); - val = emalloc((len - pos) + 1); - - strlcpy(key, *fields, pos + 1); - strlcpy(val, *fields + pos + 1, len - pos); - - /* Check to see whether or not we want to save the data */ - if (!strcmp(key, "msg")) { - errmsg = estrndup(val, len - pos); - } - else if (!strcmp(key, "line")) { - errline = estrndup(val, len - pos); - } - - /* Cleanup */ - if (key) efree(key); - if (val) efree(val); - - /* Next key:value pair please :) */ - fields++; - } - } - - if (!errline) { - errline = estrndup("none", sizeof("none") - 1); - } - - if (!errmsg) { - errmsg = estrndup("unkown error", sizeof("unkown error") - 1); - } - - /* Allocate the message buffer and copy the data onto it */ - msgbuf = emalloc((sizeof(msgformat) - 4) + strlen(errmsg) + strlen(errline) + 1); - sprintf(msgbuf, msgformat, errline, errmsg); - - XSLT_REG_ERRMSG(errmsg, handle); - - /* Output a warning */ - php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", msgbuf); - - /* Cleanup */ - efree(msgbuf); - efree(errmsg); - efree(errline); - } - - return(0); -} -/* }}} */ - -#endif - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: noet sw=4 ts=4 fdm=marker - * vim<600: noet sw=4 ts=4 - */ diff --git a/ext/xslt/tests/args.xsl b/ext/xslt/tests/args.xsl deleted file mode 100755 index 4ff140c777..0000000000 --- a/ext/xslt/tests/args.xsl +++ /dev/null @@ -1,10 +0,0 @@ -<?xml version="1.0" encoding="ISO-8859-1"?> -<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> - <xsl:output encoding="ISO-8859-1" method="text" omit-xml-declaration="yes" /> - <xsl:template match="/qa"> - <xsl:apply-templates select="test" /> - </xsl:template> - <xsl:template match="test[@type = 'simple']"> - <xsl:value-of select="." /> - </xsl:template> -</xsl:stylesheet> diff --git a/ext/xslt/tests/bug17791.phpt b/ext/xslt/tests/bug17791.phpt deleted file mode 100644 index 0a9446e1b0..0000000000 --- a/ext/xslt/tests/bug17791.phpt +++ /dev/null @@ -1,15 +0,0 @@ ---TEST-- -Pass long string to 'file' argument, bug #17791 ---SKIPIF-- -<?php include("skipif.inc"); ?> ---FILE-- -<?php -$xmlstring = str_repeat('x', 512); -$xslstring = 'x'; -$xh = xslt_create(); -$result = @xslt_process($xh, $xmlstring, $xslstring); -@xslt_free($xh); -echo("OK"); -?> ---EXPECT-- -OK diff --git a/ext/xslt/tests/bug17931.phpt b/ext/xslt/tests/bug17931.phpt deleted file mode 100644 index a85dd0674e..0000000000 --- a/ext/xslt/tests/bug17931.phpt +++ /dev/null @@ -1,32 +0,0 @@ ---TEST-- -Pass object for xslt_error_handler, bug #17931 ---SKIPIF-- -<?php include("skipif.inc"); ?> ---FILE-- -<?php -class xsl { - - function xsl() { - $this->_parser = xslt_create(); - } - - function set_error() { - xslt_set_error_handler($this->_parser, array($this, 'xslt_trap_error')); - echo "OK"; - } - - function xslt_trap_error($parser, $errorno, $level, $fields) { - return TRUE; - } - function clean() { - xslt_free($this->_parser); - } -} - -$x = new xsl; -// work-around for possible '$this does not exist' bug in constructor -$x->set_error(); -$x->clean(); -?> ---EXPECT-- -OK diff --git a/ext/xslt/tests/bug20177.phpt b/ext/xslt/tests/bug20177.phpt deleted file mode 100644 index 3c1695b351..0000000000 --- a/ext/xslt/tests/bug20177.phpt +++ /dev/null @@ -1,34 +0,0 @@ ---TEST-- -Relative and absolute arg handling ---SKIPIF-- -<?php -include("skipif.inc"); -if(!function_exists('utf8_encode')) { - die("skip function utf8_encode() not available"); -} -?> ---INI-- -magic_quotes_runtime=0 ---FILE-- -<?php -error_reporting(E_ALL); -$xslfile = dirname(__FILE__) . '/args.xsl'; -$xslsheet = @implode('', @file($xslfile)); -$xmldata = '<?xml version="1.0" encoding="ISO-8859-1"?>'; -$xmldata .= '<!DOCTYPE qa SYSTEM "qa.dtd">' . "\n"; -$xmldata .=' -<qa> - <test type="simple">Test has passed</test> - <test type="complex" /> -</qa>'; - -$xh = xslt_create(); -$result = xslt_process($xh, 'arg:/_xml', $xslfile, NULL, array('/_xml' => $xmldata)); -print "$result\n"; -$result = xslt_process($xh, 'arg:/_xml', 'arg:/_xsl', NULL, array('/_xml' => $xmldata, '/_xsl' => $xslsheet)); -print "$result\n"; -xslt_free($xh); -?> ---EXPECT-- -Test has passed -Test has passed diff --git a/ext/xslt/tests/bug20518.phpt b/ext/xslt/tests/bug20518.phpt deleted file mode 100644 index bf0a8f9f8d..0000000000 --- a/ext/xslt/tests/bug20518.phpt +++ /dev/null @@ -1,33 +0,0 @@ ---TEST-- -Don't override xslt_set_base (bug #20518) ---SKIPIF-- -<?php // vim600: syn=php ts=4 sw=4 -include("skipif.inc"); -mkdir(dirname(__FILE__) . '/tmp', 0777) or die("skip Cannot create working directory"); -?> ---INI-- -magic_quotes_runtime=0 ---FILE-- -<?php -error_reporting(E_ALL); -copy(dirname(__FILE__) . '/qa.dtd', dirname(__FILE__) . '/tmp/qa.dtd'); -$xslfile = dirname(__FILE__) . '/args.xsl'; -$xslsheet = @implode('', @file($xslfile)); -$xmldata = '<?xml version="1.0" encoding="ISO-8859-1"?>'; -$xmldata .= '<!DOCTYPE qa SYSTEM "qa.dtd">' . "\n"; -$xmldata .=' -<qa> - <test type="simple">Test has passed</test> - <test type="complex" /> -</qa>'; - -$xh = xslt_create(); -xslt_set_base($xh, 'file://' . dirname(__FILE__) . '/tmp/'); -$result = xslt_process($xh, 'arg:/_xml', 'arg:/_xsl', NULL, array('/_xml' => $xmldata, '/_xsl' => $xslsheet)); -print "$result\n"; -xslt_free($xh); -unlink(dirname(__FILE__) . '/tmp/qa.dtd'); -rmdir(dirname(__FILE__) . '/tmp'); -?> ---EXPECT-- -Test has passed diff --git a/ext/xslt/tests/param.xsl b/ext/xslt/tests/param.xsl deleted file mode 100644 index 64b78fafe7..0000000000 --- a/ext/xslt/tests/param.xsl +++ /dev/null @@ -1,15 +0,0 @@ -<?xml version="1.0" encoding="ISO-8859-1"?> -<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> - <xsl:output method="text" omit-xml-declaration="yes" encoding="ISO-8859-1" /> - <xsl:param name="insertion">Test failed</xsl:param> - <xsl:template match="/qa"> - <xsl:apply-templates select="test" /> - </xsl:template> - <xsl:template match="test"> - <xsl:choose> - <xsl:when test="@type != 'simple'"> - <xsl:value-of select="$insertion" /> - </xsl:when> - </xsl:choose> - </xsl:template> -</xsl:stylesheet> diff --git a/ext/xslt/tests/public.xml b/ext/xslt/tests/public.xml deleted file mode 100755 index d5de9a8bd5..0000000000 --- a/ext/xslt/tests/public.xml +++ /dev/null @@ -1,5 +0,0 @@ -<?xml version="1.0" encoding="ISO-8859-1"?>
-<!DOCTYPE qa PUBLIC "-//PHP-QA//PHP Quality Assurance DTD //EN" "qa.dtd">
-<qa>
- <test type="simple">PHP QA®</test>
-</qa>
diff --git a/ext/xslt/tests/qa.dtd b/ext/xslt/tests/qa.dtd deleted file mode 100755 index 8b807ead44..0000000000 --- a/ext/xslt/tests/qa.dtd +++ /dev/null @@ -1,7 +0,0 @@ -<?xml version="1.0" encoding="ISO-8859-1"?> -<!ELEMENT qa (test+)> -<!ELEMENT test (#PCDATA)> -<!ATTLIST test - type CDATA #IMPLIED -> -<!ENTITY reg "®"> diff --git a/ext/xslt/tests/skipif.inc b/ext/xslt/tests/skipif.inc deleted file mode 100644 index 7cffae6c66..0000000000 --- a/ext/xslt/tests/skipif.inc +++ /dev/null @@ -1,5 +0,0 @@ -<?php -if(!extension_loaded("xslt")) { - die("skip xslt extension not available"); -} -?> diff --git a/ext/xslt/tests/test.xml b/ext/xslt/tests/test.xml deleted file mode 100644 index f7c69d4c4a..0000000000 --- a/ext/xslt/tests/test.xml +++ /dev/null @@ -1,5 +0,0 @@ -<?xml version="1.0" encoding="ISO-8859-1"?> -<qa> - <test type="simple">Test has passed</test> - <test type="complex" /> -</qa> diff --git a/ext/xslt/tests/xslt-001.phpt b/ext/xslt/tests/xslt-001.phpt deleted file mode 100644 index eeb1c6d769..0000000000 --- a/ext/xslt/tests/xslt-001.phpt +++ /dev/null @@ -1,21 +0,0 @@ ---TEST-- -Memoryleak in error printing ---SKIPIF-- -<?php include("skipif.inc"); ?> ---INI-- -error_reporting=2047 -display_errors=0 -track_errors=1 ---FILE-- -<?php -$xmlfile = 'ext/xslt/tests/non-existent.xml'; -$xslfile = 'ext/xslt/tests/non-existent.xsl'; - -$xh = xslt_create(); -$result = xslt_process($xh, $xmlfile, $xslfile, NULL); -xslt_free($xh); - -echo $php_errormsg."\n"; -?> ---EXPECTF-- -Sablotron error on line none: cannot open file '%s/ext/xslt/tests/non-existent.xsl' diff --git a/ext/xslt/tests/xslt.phpt b/ext/xslt/tests/xslt.phpt deleted file mode 100644 index 3270c3f20e..0000000000 --- a/ext/xslt/tests/xslt.phpt +++ /dev/null @@ -1,12 +0,0 @@ ---TEST-- -Check for xslt presence ---SKIPIF-- -<?php if (!extension_loaded("xslt")) print "skip"; ?> ---POST-- ---GET-- ---FILE-- -<?php -echo "xslt extension is available"; -?> ---EXPECT-- -xslt extension is available
\ No newline at end of file diff --git a/ext/xslt/tests/xslt_backend_info.phpt b/ext/xslt/tests/xslt_backend_info.phpt deleted file mode 100644 index 1fd849c48f..0000000000 --- a/ext/xslt/tests/xslt_backend_info.phpt +++ /dev/null @@ -1,49 +0,0 @@ ---TEST-- -xslt_backend_info: examples for detection of backend features ---SKIPIF-- -<?php // vim600: noet sw=4 ts=4 syn=php ai si tw=78 -include("skipif.inc"); -if(!function_exists('xslt_backend_info')) { - die("skip\n"); -} -// Yeah-right-but-still -if(xslt_backend_name() != "Sablotron") { - die("skip This test currently only supports Sablotron"); -} -if("No information available." == xslt_backend_info()) { - die("skip Information could not be detected."); -} -?> ---FILE-- -<?php -/* - * Test xslt_backend_info: basically this test is provided as a how-to for - * x-platform packages, which rely on certain features which may or may - * not be available depending on what has been linked into the backend. - */ - -$tmp = explode("\n", xslt_backend_info()); -$info = array(); -foreach($tmp AS $line) { - list($key, $value) = explode(": ", $line, 2); - $info[strtolower($key)] = $value; -} - -if(FALSE === strstr($info['libs'], " -lexpat")) { - die("You're configuration is missing expat, which conflicts with sanity."); -} - -if(FALSE === strstr($info['libs'], " -liconv")) { - echo("You don't have iconv support\n"); -} else { - echo("You have iconv support\n"); -} -if(FALSE === strstr($info['libs'], " -ljs")) { - echo("You don't have JavaScript support\n"); -} else { - echo("You have JavaScript support\n"); -} -?> ---EXPECTREGEX-- -You (don't )?have iconv support -You (don't )?have JavaScript support diff --git a/ext/xslt/tests/xslt_getopt.phpt b/ext/xslt/tests/xslt_getopt.phpt deleted file mode 100644 index a00a875fac..0000000000 --- a/ext/xslt/tests/xslt_getopt.phpt +++ /dev/null @@ -1,37 +0,0 @@ ---TEST-- -xslt_getopt function ---SKIPIF-- -<?php -include("skipif.inc"); -if(!function_exists('xslt_getopt')) { - die("skip\n"); -} -?> ---FILE-- -<?php -error_reporting(E_ALL); - -$xh = xslt_create(); -xslt_setopt($xh, XSLT_SABOPT_PARSE_PUBLIC_ENTITIES); -if(xslt_getopt($xh) == XSLT_SABOPT_PARSE_PUBLIC_ENTITIES) - print("OK\n"); -else - var_dump(xslt_getopt($xh)); - -xslt_setopt($xh, XSLT_SABOPT_PARSE_PUBLIC_ENTITIES | XSLT_SABOPT_DISABLE_ADDING_META); -if(xslt_getopt($xh) == XSLT_SABOPT_PARSE_PUBLIC_ENTITIES | XSLT_SABOPT_DISABLE_ADDING_META) - print("OK\n"); -else - var_dump(xslt_getopt($xh)); - -xslt_setopt($xh, xslt_getopt($xh) | XSLT_OPT_SILENT); -if(xslt_getopt($xh) == XSLT_SABOPT_PARSE_PUBLIC_ENTITIES | XSLT_SABOPT_DISABLE_ADDING_META | XSLT_OPT_SILENT) - print("OK\n"); -else - var_dump(xslt_getopt($xh)); -xslt_free($xh); -?> ---EXPECT-- -OK -OK -OK diff --git a/ext/xslt/tests/xslt_process-001.phpt b/ext/xslt/tests/xslt_process-001.phpt deleted file mode 100644 index 15f9cae262..0000000000 --- a/ext/xslt/tests/xslt_process-001.phpt +++ /dev/null @@ -1,62 +0,0 @@ ---TEST-- -Various ways to provide xml and xslt arguments and params ---SKIPIF-- -<?php -include("skipif.inc"); -if(!function_exists('utf8_encode')) { - die("skip function utf8_encode() not available"); -} -?> ---INI-- -magic_quotes_runtime=0 ---FILE-- -<?php -error_reporting(E_ALL); -$xmlfile = 'ext/xslt/tests/test.xml'; -$xslfile = 'ext/xslt/tests/args.xsl'; -$xmldata = @implode('', @file($xmlfile)); -$xslsheet = @implode('', @file($xslfile)); - -$xh = xslt_create(); -$result = xslt_process($xh, $xmlfile, $xslfile); -print "$result\n"; -$result = xslt_process($xh, 'arg:/_xml', $xslfile, NULL, array('/_xml' => $xmldata)); -print "$result\n"; -$result = xslt_process($xh, $xmlfile, 'arg:/_xsl', NULL, array('/_xsl' => $xslsheet)); -print "$result\n"; -$result = xslt_process($xh, 'arg:/_xml', 'arg:/_xsl', NULL, array('/_xml' => $xmldata, '/_xsl' => $xslsheet)); -print "$result\n"; - -// The same, with params -$xslfile = 'ext/xslt/tests/param.xsl'; -$xslsheet = implode('', file($xslfile)); -$params = array("Test has passed", "PHP QA®"); - -foreach($params AS $val) -{ - $val = utf8_encode($val); - $result = xslt_process($xh, $xmlfile, $xslfile, NULL, NULL, array('insertion' => $val)); - print "$result\n"; - $result = xslt_process($xh, 'arg:/_xml', $xslfile, NULL, array('/_xml' => $xmldata), array('insertion' => $val)); - print "$result\n"; - $result = xslt_process($xh, $xmlfile, 'arg:/_xsl', NULL, array('/_xsl' => $xslsheet), array('insertion' => $val)); - print "$result\n"; - $result = xslt_process($xh, 'arg:/_xml', 'arg:/_xsl', NULL, array('/_xml' => $xmldata, '/_xsl' => $xslsheet), array('insertion' => $val)); - print "$result\n"; -} - -xslt_free($xh); -?> ---EXPECT-- -Test has passed -Test has passed -Test has passed -Test has passed -Test has passed -Test has passed -Test has passed -Test has passed -PHP QA® -PHP QA® -PHP QA® -PHP QA® diff --git a/ext/xslt/tests/xslt_process-002.phpt b/ext/xslt/tests/xslt_process-002.phpt deleted file mode 100644 index 7c6f14fa45..0000000000 --- a/ext/xslt/tests/xslt_process-002.phpt +++ /dev/null @@ -1,74 +0,0 @@ ---TEST-- -Crash xslt_process with reused handler (this test may take a while) ---SKIPIF-- -<?php -include("skipif.inc"); -if(!function_exists('utf8_encode')) { - die("skip\n"); -} -?> ---FILE-- -<?php -error_reporting(E_ALL); -$xmlfile = 'ext/xslt/tests/test.xml'; -$xslfile = 'ext/xslt/tests/param.xsl'; -$xmldata = @implode('', @file($xmlfile)); -$xslsheet = @implode('', @file($xslfile)); - -/* - * Tested on a Cyrix 200MMX/128MB took 2 secs. Should be a reasonable margin. - * - * It's not meant as an actual speed test, but if it's slower than this, - * there must be something significantly off in the php/sablot/expat trio. - * Emulation OS's come to mind... - */ -$want_time = 6; - -function make_param() -{ - $ret_val = ''; - $numchars = mt_rand(2,16); - $illegal = array(0,256,512); - for($i=0;$i<$numchars;$i++) - { - $char=0; - while(in_array($char, $illegal)) - { - $char .= mt_rand(32, 512); - } - $ret_val .= chr($char); - } - - return utf8_encode($ret_val); -} - -function decode($string) -{ - $ret_val = ''; - for($i=0; $i<strlen($string);$i++) - { - $ret_val .= ord(substr($string,$i,1)) . " "; - } - return $ret_val; -} - - -$xh = xslt_create(); - -$t1 = time(); -for ($i=0; $i<50; $i++) -{ - $val = make_param(); - $result = xslt_process($xh, $xmlfile, $xslfile, NULL, NULL, array('insertion' => $val)); - if(!$result or $result != utf8_decode($val)) - print "Failed $i / ".utf8_decode($val).": $result\n\tDecode: " . decode(utf8_decode($val)) . "\n" ; -} -print "OK\n"; -xslt_free($xh); -$t2 = time(); -$op_time = $t2 - $t1; -if($op_time > $want_time) - print "This test took more than $want_time seconds. Either you have a very slow / busy machine, or there's something very wrong with the speed. Your time: $op_time"; -?> ---EXPECT-- -OK diff --git a/ext/xslt/tests/xslt_set_object.phpt b/ext/xslt/tests/xslt_set_object.phpt deleted file mode 100644 index fdc0291a4d..0000000000 --- a/ext/xslt/tests/xslt_set_object.phpt +++ /dev/null @@ -1,89 +0,0 @@ ---TEST-- -xslt_set_object function ---SKIPIF-- -<?php -include("skipif.inc"); -if(!function_exists('xslt_set_object')) { - die("skip function xslt_set_object() not available"); -} -?> ---INI-- -magic_quotes_runtime=0 ---FILE-- -<?php -error_reporting(E_ALL); -class XSLTTester -{ - var $_success = false; - var $_success2 = false; - - function XSLTTester() - {} - - // this function will register this object as the - // callback object. - function test1($xmlfile,$xslfile) - { - $xh = xslt_create(); - xslt_set_object($xh,$this); - $handlers = array('get_all'=> 'handle_getall'); - xslt_set_scheme_handlers($xh,$handlers); - $res = xslt_process($xh,$xmlfile,$xslfile); - xslt_free($xh); - return 1; - } - - // this function will pass this object as in set_scheme_handler - function test2($xmlfile,$xslfile) - { - $xh = xslt_create(); - $handlers = array('get_all'=> array(&$this,'handle_getall2')); - xslt_set_scheme_handlers($xh,$handlers); - $res = xslt_process($xh,$xmlfile,$xslfile); - xslt_free($xh); - return 1; - } - function handle_getall($xh,$scheme,$rest) - { - $this->_success = true; - $rest = substr($rest,2); - return implode('', file('ext/xslt/tests/'.$rest)); - } - function handle_getall2($xh,$scheme,$rest) - { - $this->_success2 = true; - $rest = substr($rest,2); - return implode('', file('ext/xslt/tests/'.$rest)); - } - function testSucceeded() - { - return $this->_success; - } - function test2Succeeded() - { - return $this->_success2; - } -} - -$xmlfile = 'ext/xslt/tests/test.xml'; -$xslfile = 'ext/xslt/tests/xslt_set_object.xsl'; - -$testobj = new XSLTTester(); -$testobj->test1($xmlfile,$xslfile); - -$testobj->test2($xmlfile,$xslfile); - -if ($testobj->testSucceeded()) - print "OK\n"; -else - print "FAILED\n"; - -if ($testobj->test2Succeeded()) - print "OK\n"; -else - print "FAILED\n"; - -?> ---EXPECT-- -OK -OK diff --git a/ext/xslt/tests/xslt_set_object.xsl b/ext/xslt/tests/xslt_set_object.xsl deleted file mode 100644 index 9618f42e21..0000000000 --- a/ext/xslt/tests/xslt_set_object.xsl +++ /dev/null @@ -1,3 +0,0 @@ -<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> -<xsl:import href="http://param.xsl" /> -</xsl:stylesheet> diff --git a/ext/xslt/tests/xslt_set_scheme_handlers-001.phpt b/ext/xslt/tests/xslt_set_scheme_handlers-001.phpt deleted file mode 100644 index c8b7b236f2..0000000000 --- a/ext/xslt/tests/xslt_set_scheme_handlers-001.phpt +++ /dev/null @@ -1,20 +0,0 @@ ---TEST-- -Set a non-existing scheme handler ---SKIPIF-- -<?php include("skipif.inc"); ?> ---FILE-- -<?php -function bar() -{ - return 1; -} -$xh = xslt_create(); -$xmlstring = '<foo><barred /></foo>'; -$xslstring = '<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/TR/1999/XSL/Transform"><xsl:for-each select="/"><xsl:value-of select="document(\'bogus://foo\')" /></xsl:for-each></xsl:stylesheet>'; -xslt_set_scheme_handlers($xh, array('get_all' => 'foo')); -$result = xslt_process($xh, 'arg:/_xml', 'arg:/_xsl', NULL, array('/_xml' => $xmlstring, '/_xsl' => $xslstring)); -xslt_free($xh); -echo("OK"); -?> ---EXPECT-- -OK diff --git a/ext/xslt/tests/xslt_set_scheme_handlers-002.phpt b/ext/xslt/tests/xslt_set_scheme_handlers-002.phpt deleted file mode 100644 index 3658b378a1..0000000000 --- a/ext/xslt/tests/xslt_set_scheme_handlers-002.phpt +++ /dev/null @@ -1,57 +0,0 @@ ---TEST-- -Override Sablotron file handler ---SKIPIF-- -<?php -include("skipif.inc"); -if(!defined("XSLT_SABOPT_FILES_TO_HANDLER")) { - die("skip Sab CVS > 20021031 needed"); -} -?> ---INI-- -magic_quotes_runtime=0 ---FILE-- -<?php -function handle_files_all($xh, $proto, $rest_uri) -{ - $error = "Cannot resolve $proto:$rest_uri on handle $xh"; - - if($proto != 'file') - return $error; - - $rest_uri = substr($rest_uri, 2); // strip protocol separators // - if(substr($rest_uri, 0, 1) == '/') - { - return (file_exists($rest_uri)) ? implode('', file($rest_uri)) : $error; - } - else - { - $f = dirname(__FILE__) . '/' . $rest_uri; - return (file_exists($f)) ? implode('', file($f)) : $error; - } -} - -$xh = xslt_create(); -xslt_setopt($xh, XSLT_SABOPT_FILES_TO_HANDLER); -$xmlstring='<?xml version="1.0" encoding="ISO-8859-1"?> -<!DOCTYPE qa SYSTEM "file://qa.dtd"> -<qa> - <test type="simple">PHP QA</test> -</qa>'; -$xslstring='<?xml version="1.0" encoding="ISO-8859-1"?> -<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> - <xsl:output method="text" omit-xml-declaration="yes" encoding="ISO-8859-1" /> - <xsl:param name="insertion">Test failed</xsl:param> - <xsl:template match="/qa"> - <xsl:apply-templates select="test" /> - </xsl:template> - <xsl:template match="test"> - <xsl:value-of select="concat(@type, \': \', .)" /> - </xsl:template> -</xsl:stylesheet>'; -xslt_set_scheme_handlers($xh, array('get_all' => 'handle_files_all')); -$result = xslt_process($xh, 'arg:/_xml', 'arg:/_xsl', NULL, array('/_xml' => $xmlstring, '/_xsl' => $xslstring)); -echo $result; -xslt_free($xh); -?> ---EXPECT-- -simple: PHP QA diff --git a/ext/xslt/tests/xslt_set_scheme_handlers-003.phpt b/ext/xslt/tests/xslt_set_scheme_handlers-003.phpt deleted file mode 100644 index c5bca5c0b6..0000000000 --- a/ext/xslt/tests/xslt_set_scheme_handlers-003.phpt +++ /dev/null @@ -1,47 +0,0 @@ ---TEST-- -Core dump when returning FALSE in a handler ---SKIPIF-- -<?php -include("skipif.inc"); -if(!defined("XSLT_SABOPT_FILES_TO_HANDLER")) { - die("skip Sablotron CVS > 20021031 needed"); -} -?> ---INI-- -magic_quotes_runtime=0 ---FILE-- -<?php -function handle_files_all($xh, $proto, $rest_uri) -{ - return FALSE; -} - -$xh = xslt_create(); -xslt_setopt($xh, XSLT_SABOPT_FILES_TO_HANDLER); -$xmlstring='<?xml version="1.0" encoding="ISO-8859-1"?> -<!DOCTYPE qa SYSTEM "file://qa.dtd"> -<qa> - <test type="simple">PHP QA</test> -</qa>'; -$xslstring='<?xml version="1.0" encoding="ISO-8859-1"?> -<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> - <xsl:output method="text" omit-xml-declaration="yes" encoding="ISO-8859-1" /> - <xsl:param name="insertion">Test failed</xsl:param> - <xsl:template match="/qa"> - <xsl:apply-templates select="test" /> - </xsl:template> - <xsl:template match="test"> - <xsl:value-of select="concat(@type, \': \', .)" /> - </xsl:template> -</xsl:stylesheet>'; -xslt_set_scheme_handlers($xh, array('get_all' => 'handle_files_all')); -/* This is intended to be silent! - * The result is known to be invalid, but if it doesn't core dump, the test - * has succeeded. */ -$result = @xslt_process($xh, 'arg:/_xml', 'arg:/_xsl', NULL, array('/_xml' => $xmlstring, '/_xsl' => $xslstring)); -echo "OK"; -xslt_free($xh); -?> ---EXPECT-- -OK - diff --git a/ext/xslt/tests/xslt_setopt.phpt b/ext/xslt/tests/xslt_setopt.phpt deleted file mode 100644 index ce45c46e1c..0000000000 --- a/ext/xslt/tests/xslt_setopt.phpt +++ /dev/null @@ -1,60 +0,0 @@ ---TEST-- -xslt_setopt function and public entities ---SKIPIF-- -<?php -include("skipif.inc"); -if(!function_exists('xslt_setopt')) { - die("skip function xslt_setopt() is not available\n"); -} -?> ---INI-- -magic_quotes_runtime=0 ---FILE-- -<?php -error_reporting(E_ALL); -$xmlfile = dirname(__FILE__).'/public.xml'; -$xslfile = dirname(__FILE__).'/args.xsl'; - -$xh = xslt_create(); -// Tell Sablotron to process public entities -xslt_setopt($xh, XSLT_SABOPT_PARSE_PUBLIC_ENTITIES); - -$result = xslt_process($xh, $xmlfile, $xslfile); -print "$result\n"; - -$xslstring = implode('', file($xslfile)); -$xslstring = str_replace('method="text"', 'method="html"', $xslstring); -$xslstring = str_replace('<xsl:value-of select="." />', '<html><head><title>foo</title></head><body><p><xsl:value-of select="." /></p></body></html>', $xslstring); -// DEBUG: print $xslstring; - -xslt_setopt($xh, XSLT_SABOPT_PARSE_PUBLIC_ENTITIES | XSLT_SABOPT_DISABLE_ADDING_META); -var_dump(xslt_process($xh, $xmlfile, 'arg:/_xsl', NULL, array('/_xsl' => $xslstring))); - - -xslt_setopt($xh, XSLT_SABOPT_PARSE_PUBLIC_ENTITIES); -var_dump(xslt_process($xh, $xmlfile, 'arg:/_xsl', NULL, array('/_xsl' => $xslstring))); -// DEBUG: print "$result_meta\n"; - -xslt_free($xh); -?> ---EXPECT-- -PHP QA® -string(95) "<html> - <head> - <title>foo</title> - </head> - <body> - <p>PHP QA®</p> - </body> -</html> -" -string(172) "<html> - <head> - <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> - <title>foo</title> - </head> - <body> - <p>PHP QA®</p> - </body> -</html> -" diff --git a/ext/xslt/xslt.c b/ext/xslt/xslt.c deleted file mode 100644 index d92e3a25bf..0000000000 --- a/ext/xslt/xslt.c +++ /dev/null @@ -1,276 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | 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 | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: Sterling Hughes <sterling@php.net> | - +----------------------------------------------------------------------+ - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "php.h" -#include "php_xslt.h" - -#if HAVE_XSLT - -#include <stdio.h> -#include <string.h> -#include <stdarg.h> - -#define XSLT_DEBUG 0 - -/* {{{ xslt_debug() - Output a debug message if debugging is enabled */ -extern void xslt_debug(char *function_name, char *format, ...) -{ -#if DEBUG - va_list argv; - char buffer[1024]; - - va_start(argv, format); - vsnprintf(buffer, sizeof(buffer) - 1, format, argv); - va_end(argv); - - buffer[sizeof(buffer) - 1] = '\0'; - - php_printf("<b>XSLT Debug</b>: %s: %s<br />\n", - function_name, buffer); -#endif -} -/* }}} */ - -/* {{{ find_xslt_argument() - Find and return an xslt argument from the argument buffer */ -static char *_find_xslt_argument(const char **argv, const char *key) -{ - char **ptr; /* Pointer to the passed char ** array */ - char *return_value = NULL; /* Value to return from the function */ - - if (! argv) - return NULL; - - /* Loop through the array searching for the value */ - ptr = (char **) argv; - while (*ptr) { - /* If we have a match, save the value and exit out */ - if (! strcmp(*ptr, key)) { - return_value = estrdup(*ptr); - break; - } - - ++ptr; - } - - return return_value; -} -/* }}} */ - -/* {{{ xslt_make_array() - Make an XSLT array (char **) from a zval array (HashTable *) */ -extern void xslt_make_array(zval **zarr, char ***carr) -{ - zval **current; - HashTable *arr; - int idx = 0; - TSRMLS_FETCH(); - - /* Skip a warning, when 'NULL' is provided as argument */ - if ( Z_TYPE_PP(zarr) == IS_NULL) - return; - - arr = HASH_OF(*zarr); - if (! arr) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid argument or parameter array"); - return; - } - - *carr = emalloc(((zend_hash_num_elements(arr) * 2) + 1) * sizeof(char *)); - - for (zend_hash_internal_pointer_reset(arr); - zend_hash_get_current_data(arr, (void **) ¤t) == SUCCESS; - zend_hash_move_forward(arr)) { - char *string_key = NULL; - ulong num_key; - int type; - - SEPARATE_ZVAL(current); - convert_to_string_ex(current); - - type = zend_hash_get_current_key(arr, &string_key, &num_key, 0); - if (type == HASH_KEY_IS_LONG) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid key value for argument or parameter array"); - /* Make the next index NULL, so it signals the end of the array - this will protect against invalid arrays, like: - array('foo'=>'bar', 'foobarred', 'oops') */ - (*carr)[idx] = NULL; - return; - } - - (*carr)[idx++] = estrdup(string_key); - (*carr)[idx++] = estrndup(Z_STRVAL_PP(current), Z_STRLEN_PP(current)); - } - - (*carr)[idx] = NULL; -} -/* }}} */ - -/* {{{ xslt_free_array() - Free an xslt array built by xslt_make_array() */ -extern void xslt_free_array(char **arr) -{ - char **ptr = arr; - - while (*ptr != NULL) { - efree(*ptr); - ptr++; - } - - efree(arr); -} -/* }}} */ - -/* {{{ xslt_parse_arguments() - Parse an XSLT argument buffer */ -extern xslt_args *xslt_parse_arguments(char *xml, - char *xsl, - char *result, - char **argv) -{ - xslt_args *return_value; /* The value to return from the function */ - - return_value = emalloc(sizeof(xslt_args)); - - /* The xml argument */ - if (! strncasecmp(xml, "arg:", 4)) { - char *key = xml + 5; - - return_value->xml.type = XSLT_IS_DATA; - return_value->xml.ptr = _find_xslt_argument((const char **) argv, - (const char *) key); - } - else { - return_value->xml.type = XSLT_IS_FILE; - return_value->xml.ptr = estrdup(xml); - } - - /* The xslt arguments */ - if (! strncasecmp(xsl, "arg:", 4)) { - char *key = xsl + 5; - - return_value->xsl.type = XSLT_IS_DATA; - return_value->xsl.ptr = _find_xslt_argument((const char **) argv, - (const char *) key); - } - else { - return_value->xsl.type = XSLT_IS_FILE; - return_value->xsl.ptr = estrdup(xsl); - } - - /* The result argument */ - if (! strncasecmp(result, "arg:", 4)) { - char *key = result + 5; - - return_value->result.type = XSLT_IS_DATA; - return_value->result.ptr = _find_xslt_argument((const char **) argv, - (const char *) key); - } - else { - return_value->result.type = XSLT_IS_FILE; - return_value->result.ptr = estrdup(result); - } - - return return_value; -} -/* }}} */ - -/* {{{ free_xslt_arguments() - Free's an XSLT argument list returned from parse_xslt_arguments() */ -extern void xslt_free_arguments(xslt_args *to_free) -{ - if (to_free->xml.ptr) { - efree(to_free->xml.ptr); - } - - if (to_free->xsl.ptr) { - efree(to_free->xsl.ptr); - } - - if (to_free->result.ptr) { - efree(to_free->result.ptr); - } - - efree(to_free); -} -/* }}} */ - -/* {{{ call_xslt_function() - Call an XSLT handler */ -extern void xslt_call_function(char *name, - zval *function, - zval *object, - int argc, - zval **user_args, - zval **retval) -{ - zval ***argv; /* Argument container, maps around for call_user_function_ex() */ - int error; /* Error container */ - int idx; /* Idx, when looping through and free'ing the arguments */ - TSRMLS_FETCH(); /* For TS mode, fetch the executor globals */ - - argv = emalloc(argc * sizeof(zval **)); - for (idx = 0; idx < argc; idx++) { - argv[idx] = &user_args[idx]; - } - - - /* Call the function (with object when appropriate)*/ - if (object == NULL) - { - error = call_user_function_ex(EG(function_table), - NULL, function, - retval, argc, argv, 0, NULL TSRMLS_CC); - } - else - { - error = call_user_function_ex(EG(function_table), - &object, function, - retval, argc, argv, 0, NULL TSRMLS_CC); - } - - if (error == FAILURE) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot call the %s handler: %s", - name, Z_STRVAL_P(function)); - } - - /* Cleanup arguments */ - for (idx = 0; idx < argc; idx++) { - /* Decrease refcount and free if refcount is <= 0 */ - zval_ptr_dtor(argv[idx]); - } - - efree(argv); -} -/* }}} */ - -#endif - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: noet sw=4 ts=4 fdm=marker - * vim<600: noet sw=4 ts=4 - */ diff --git a/ext/xslt/xslt.dsp b/ext/xslt/xslt.dsp deleted file mode 100644 index 80ef1d6976..0000000000 --- a/ext/xslt/xslt.dsp +++ /dev/null @@ -1,115 +0,0 @@ -# Microsoft Developer Studio Project File - Name="xslt" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
-
-CFG=xslt - Win32 Debug_TS
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "xslt.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "xslt.mak" CFG="xslt - Win32 Debug_TS"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "xslt - Win32 Release_TS" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "xslt - Win32 Debug_TS" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-MTL=midl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "xslt - Win32 Release_TS"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release_TS"
-# PROP BASE Intermediate_Dir "Release_TS"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release_TS"
-# PROP Intermediate_Dir "Release_TS"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "XSLT_EXPORTS" /YX /FD /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\main" /I "..\.." /I "..\..\Zend" /I "..\..\TSRM" /I "..\..\win32" /I "C:\Program Files\Sablot-0.96\include" /D "COMPILE_DL_XSLT" /D ZEND_DEBUG=0 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D ZTS=1 /D "ZEND_WIN32" /D "PHP_WIN32" /D HAVE_XSLT=1 /D "HAVE_SABLOT_BACKEND" /D "HAVE_SABLOT_SET_ENCODING" /YX /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x407 /d "NDEBUG"
-# ADD RSC /l 0x407 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
-# ADD LINK32 kernel32.lib php4ts.lib sablot.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"..\..\Release_TS/php_xslt.dll" /libpath:"..\..\Release_TS" /libpath:"..\..\Release_TS_Inline" /libpath:"C:\Program Files\Sablot-0.96\lib"
-
-!ELSEIF "$(CFG)" == "xslt - Win32 Debug_TS"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug_TS"
-# PROP BASE Intermediate_Dir "Debug_TS"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug_TS"
-# PROP Intermediate_Dir "Debug_TS"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "XSLT_EXPORTS" /YX /FD /GZ /c
-# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\TSRM" /D ZEND_DEBUG=1 /D COMPILE_DL_XSLT=1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D ZTS=1 /D "ZEND_WIN32" /D "PHP_WIN32" /D HAVE_XSLT=1 /D "HAVE_SABLOT_BACKEND" /D "HAVE_SABLOT_SET_ENCODING" /YX /FD /GZ /c
-# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x407 /d "_DEBUG"
-# ADD RSC /l 0x407 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 kernel32.lib php4ts_debug.lib sablot.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"..\..\Debug_TS/php_xslt.dll" /pdbtype:sept /libpath:"..\..\Debug_TS"
-
-!ENDIF
-
-# Begin Target
-
-# Name "xslt - Win32 Release_TS"
-# Name "xslt - Win32 Debug_TS"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=.\sablot.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\xslt.c
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl"
-# Begin Source File
-
-SOURCE=.\php_sablot.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\php_xslt.h
-# End Source File
-# End Group
-# End Target
-# End Project
|