msopacua Thu Oct 31 16:21:00 2002 EDT
Modified files:
/php4/ext/xslt config.m4 php_sablot.h sablot.c
Log:
- Add constant XSLT_SABOPT_FILES_TO_HANDLER overriding the default
behavior of Sablotron to handle files itself, even if a scheme-handler
is registered.
- Implement xslt_getopt
- Modify behavior of xslt_setopt, so that it returns the previous value.
# All these need Sab CVS version > 2002/10/31
Index: php4/ext/xslt/config.m4
diff -u php4/ext/xslt/config.m4:1.28 php4/ext/xslt/config.m4:1.29
--- php4/ext/xslt/config.m4:1.28 Mon Sep 9 14:17:11 2002
+++ php4/ext/xslt/config.m4 Thu Oct 31 16:21:00 2002
@@ -1,5 +1,5 @@
dnl
-dnl $Id: config.m4,v 1.28 2002/09/09 18:17:11 sniper Exp $
+dnl $Id: config.m4,v 1.29 2002/10/31 21:21:00 msopacua Exp $
dnl
dnl +------------------------------------------------------------------------------+
dnl | This is where the magic of the extension reallly is. Depending on what |
@@ -131,6 +131,12 @@
AC_DEFINE(HAVE_SABLOT_SET_ENCODING, 1, [ ])
], [], [
-L$XSLT_DIR/lib
+ ])
+
+ dnl SablotSetOptions implemented in Sablotron CVS > 2002/10/31
+ AC_CHECK_LIB(sablot, SablotGetOptions,
+ [
+ AC_DEFINE(HAVE_SABLOT_GET_OPTIONS, 1, [Whether Sablotron supports
+SablotGetOptions])
])
AC_DEFINE(HAVE_SABLOT_BACKEND, 1, [ ])
Index: php4/ext/xslt/php_sablot.h
diff -u php4/ext/xslt/php_sablot.h:1.15 php4/ext/xslt/php_sablot.h:1.16
--- php4/ext/xslt/php_sablot.h:1.15 Fri Oct 25 15:23:13 2002
+++ php4/ext/xslt/php_sablot.h Thu Oct 31 16:21:00 2002
@@ -67,6 +67,9 @@
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);
Index: php4/ext/xslt/sablot.c
diff -u php4/ext/xslt/sablot.c:1.60 php4/ext/xslt/sablot.c:1.61
--- php4/ext/xslt/sablot.c:1.60 Wed Oct 30 09:15:15 2002
+++ php4/ext/xslt/sablot.c Thu Oct 31 16:21:00 2002
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: sablot.c,v 1.60 2002/10/30 14:15:15 helly Exp $ */
+/* $Id: sablot.c,v 1.61 2002/10/31 21:21:00 msopacua Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -91,6 +91,9 @@
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)
{NULL, NULL, NULL}
@@ -167,6 +170,9 @@
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);
+#ifdef SAB_FILES_TO_HANDLER
+ REGISTER_LONG_CONSTANT("XSLT_SABOPT_FILES_TO_HANDLER", SAB_FILES_TO_HANDLER,
+CONST_CS | CONST_PERSISTENT);
+#endif
return SUCCESS;
}
@@ -669,7 +675,7 @@
}
/* }}} */
-/* {{{ proto int xslt_setopt(resource processor, int bitmask)
+/* {{{ proto int xslt_setopt(resource processor, int newmask)
Set options on a given xsl processor */
PHP_FUNCTION(xslt_setopt)
{
@@ -677,7 +683,10 @@
zval **zbitmask; /* A bitmask created by through processor specific
constants */
php_xslt *handle; /* A PHP-XSLT processor */
int error; /* Error return codes */
- int bitmask;
+ 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) {
@@ -687,35 +696,50 @@
ZEND_FETCH_RESOURCE(handle, php_xslt *, processor_p, -1, le_xslt_name,
le_xslt);
convert_to_long_ex(zbitmask);
- bitmask = Z_LVAL_PP(zbitmask);
- if (bitmask < 0) {
- php_error_docref("function.xslt-setopt" TSRMLS_CC, E_WARNING, "Invalid
bitmask: %i", bitmask);
+ newmask = Z_LVAL_PP(zbitmask);
+ if (newmask < 0) {
+ php_error_docref("function.xslt-setopt" TSRMLS_CC, E_WARNING, "Invalid
+bitmask: %i", newmask);
RETURN_FALSE;
}
- error = SablotSetOptions(XSLT_SITUATION(handle), bitmask);
+#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");
}
- /* FIXME:
- now returning TRUE/FALSE, but should return the previous bitmask, so
users can
- temporarily set a certain option and restore the old value.
- However - there's no API function in Sablotron to retrieve the current
option set.
- If that becomes available, the second argument should become optional,
and if not
- specified the function should return the current value.
- This would allow for:
- <?php
- $current_settings = xslt_setopt($xh);
- // Add public entity support, retaining any options set at present
- xslt_setopt($xh, $current_settings & XSLT_SAB_PARSE_PUBLIC_ENTITIES);
- ?>
- */
+#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 void xslt_backend_version()
Returns the version number of Sablotron (if available) */
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php