]> granicus.if.org Git - php/commitdiff
@ Added the xslt_set_base function. (Sterling)
authorSterling Hughes <sterling@php.net>
Tue, 16 Jan 2001 12:02:47 +0000 (12:02 +0000)
committerSterling Hughes <sterling@php.net>
Tue, 16 Jan 2001 12:02:47 +0000 (12:02 +0000)
Added the SABLOT_SET_ERROR() macro to set sablotron errors...

ext/sablot/php_sablot.h
ext/sablot/sablot.c

index 6e1d1f3007e899bbf9b857543b51a4e3f765de89..cd9f00f4da2a8be110a0d96213eb0d19e9af45ad 100644 (file)
@@ -56,6 +56,7 @@ PHP_FUNCTION(xslt_set_error_handler);
 #ifdef HAVE_SABLOT_SET_ENCODING
 PHP_FUNCTION(xslt_set_encoding);
 #endif
+PHP_FUNCTION(xslt_set_base);
 PHP_FUNCTION(xslt_fetch_result);
 PHP_FUNCTION(xslt_free);
 
index ead9351ce3913033c4e98c1e1af0074e42d4b150..19ed930473d296af2da60883e706101f783b03be 100644 (file)
@@ -99,6 +99,15 @@ static zval *_php_sablot_resource_zval(long);
 
 #define SABLOT_BASIC_HANDLE SABLOTG(processor)
 
+#define SABLOT_SET_ERROR(handle, error)   \
+       if (error != 0) {                     \
+               if (handle) {                     \
+                       handle->last_errno = error;   \
+               }                                 \
+                                                 \
+               SABLOTG(last_errno) = error;      \
+       }
+
 /**
  * SAX Handler structure, this defines the different functions to be
  * called when Sablotron's internal expat parser reaches the 
@@ -150,6 +159,7 @@ function_entry sablot_functions[] = {
     PHP_FE(xslt_closelog,                 NULL)
     PHP_FE(xslt_set_sax_handler,          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
@@ -865,6 +875,50 @@ PHP_FUNCTION(xslt_set_encoding)
 
 #endif
 
+/* {{{ proto bool xslt_set_base(resource xh, string scheme, string base)
+   Overrides the default base for a resource.  If scheme is non-null, it only affects the uri given by scheme */
+PHP_FUNCTION(xslt_set_base)
+{
+       zval       **xh, **scheme, **base;
+       php_sablot  *handle;
+       int          argc = ZEND_NUM_ARGS(),
+                    ret  = 0;
+       SABLOTLS_FETCH();
+
+       if (argc < 2 || argc > 3 ||
+           zend_get_parameters_ex(argc, &xh, &scheme, &base,) == FAILURE) {
+               WRONG_PARAM_COUNT;
+       }
+       
+       if (argc > 2) {
+               ZEND_FETCH_RESOURCE(handle, php_sablot *, xh, -1, "PHP-Sablotron handle", le_sablot);
+               
+               if (Z_TYPE_PP(scheme) != IS_STRING) {
+                       ret = SablotSetBase(handle->p, Z_STRVAL_PP(base));
+               } else {
+                       ret = SablotSetBaseForScheme((void *) handle->p,
+                                                    Z_STRVAL_PP(scheme),
+                                                    Z_STRVAL_PP(base));
+               }
+       } else {
+               if (Z_TYPE_PP(scheme) != IS_STRING) {
+                       ret = SablotSetBase(SABLOTG(processor), Z_STRVAL_PP(base));
+               } else {
+                       ret = SablotSetBaseForScheme((void *) SABLOTG(processor),
+                                                    Z_STRVAL_PP(scheme),
+                                                    Z_STRVAL_PP(base));
+               }
+       }
+       
+       SABLOT_SET_ERROR(handle, ret);
+       
+       if (ret != 0) {
+               RETURN_FALSE;
+       } else {
+               RETURN_TRUE;
+       }
+}
+/* }}} */
 
 /* }}} */