diff options
author | Christian Stocker <chregu@php.net> | 2007-10-02 06:31:18 +0000 |
---|---|---|
committer | Christian Stocker <chregu@php.net> | 2007-10-02 06:31:18 +0000 |
commit | 5b0f4647b639b2c653910c8a618dd55465a8be1a (patch) | |
tree | 9d4edf9cf796aa9f347f54a68b9297372fbb346e | |
parent | 32966bb37d83dab58a02e7b7822d261d4af8b3db (diff) | |
download | php-git-5b0f4647b639b2c653910c8a618dd55465a8be1a.tar.gz |
- Added xsl->setProfiling() for profiling stylesheets.
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | ext/xsl/php_xsl.c | 1 | ||||
-rw-r--r-- | ext/xsl/php_xsl.h | 1 | ||||
-rw-r--r-- | ext/xsl/xsl_fe.h | 1 | ||||
-rw-r--r-- | ext/xsl/xsltprocessor.c | 47 |
5 files changed, 49 insertions, 2 deletions
@@ -1,6 +1,7 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? ??? 20??, PHP 5.3.0 +- Added xsl->setProfiling() for profiling stylesheets. (Christian) - Added long-option feature to getopt() and made getopt() available also on win32 systems by adding a common getopt implementation to core. (Jani, David Soria Parra) diff --git a/ext/xsl/php_xsl.c b/ext/xsl/php_xsl.c index 29528565bc..f3165d15f2 100644 --- a/ext/xsl/php_xsl.c +++ b/ext/xsl/php_xsl.c @@ -123,6 +123,7 @@ zend_object_value xsl_objects_new(zend_class_entry *class_type TSRMLS_DC) intern->registered_phpfunctions = NULL; intern->node_list = NULL; intern->doc = NULL; + intern->profiling = NULL; zend_object_std_init(&intern->std, class_type TSRMLS_CC); zend_hash_copy(intern->std.properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *)); diff --git a/ext/xsl/php_xsl.h b/ext/xsl/php_xsl.h index ee1c0c4977..4db6c7f5d9 100644 --- a/ext/xsl/php_xsl.h +++ b/ext/xsl/php_xsl.h @@ -60,6 +60,7 @@ typedef struct _xsl_object { HashTable *registered_phpfunctions; HashTable *node_list; php_libxml_node_object *doc; + char *profiling; } xsl_object; void php_xsl_set_object(zval *wrapper, void *obj TSRMLS_DC); diff --git a/ext/xsl/xsl_fe.h b/ext/xsl/xsl_fe.h index 3153e78e9f..46705a265c 100644 --- a/ext/xsl/xsl_fe.h +++ b/ext/xsl/xsl_fe.h @@ -33,4 +33,5 @@ PHP_FUNCTION(xsl_xsltprocessor_get_parameter); PHP_FUNCTION(xsl_xsltprocessor_remove_parameter); PHP_FUNCTION(xsl_xsltprocessor_has_exslt_support); PHP_FUNCTION(xsl_xsltprocessor_register_php_functions); +PHP_FUNCTION(xsl_xsltprocessor_set_profiling); #endif diff --git a/ext/xsl/xsltprocessor.c b/ext/xsl/xsltprocessor.c index beb38a2ee7..487cfecfe9 100644 --- a/ext/xsl/xsltprocessor.c +++ b/ext/xsl/xsltprocessor.c @@ -44,6 +44,7 @@ const zend_function_entry php_xsl_xsltprocessor_class_functions[] = { PHP_FALIAS(removeParameter, xsl_xsltprocessor_remove_parameter, NULL) PHP_FALIAS(hasExsltSupport, xsl_xsltprocessor_has_exslt_support, NULL) PHP_FALIAS(registerPHPFunctions, xsl_xsltprocessor_register_php_functions, NULL) + PHP_FALIAS(setProfiling, xsl_xsltprocessor_set_profiling, NULL) {NULL, NULL, NULL} }; @@ -424,6 +425,7 @@ static xmlDocPtr php_xsl_apply_stylesheet(zval *id, xsl_object *intern, xsltStyl int clone; zval *doXInclude, *member; zend_object_handlers *std_hnd; + FILE *f; node = php_libxml_import_node(docp TSRMLS_CC); @@ -439,6 +441,17 @@ static xmlDocPtr php_xsl_apply_stylesheet(zval *id, xsl_object *intern, xsltStyl php_error_docref(NULL TSRMLS_CC, E_WARNING, "No stylesheet associated to this object"); return NULL; } + + if (intern->profiling) { + if (php_check_open_basedir(intern->profiling TSRMLS_CC)) { + f = NULL; + } else { + f = VCWD_FOPEN(intern->profiling, "w"); + } + } else { + f = NULL; + } + if (intern->parameter) { params = php_xsl_xslt_make_params(intern->parameter, 0 TSRMLS_CC); } @@ -469,8 +482,10 @@ static xmlDocPtr php_xsl_apply_stylesheet(zval *id, xsl_object *intern, xsltStyl } efree(member); - newdocp = xsltApplyStylesheetUser(style, doc, (const char**) params, NULL, NULL, ctxt); - + newdocp = xsltApplyStylesheetUser(style, doc, (const char**) params, NULL, f, ctxt); + if (f) { + fclose(f); + } xsltFreeTransformContext(ctxt); if (intern->node_list != NULL) { @@ -483,6 +498,9 @@ static xmlDocPtr php_xsl_apply_stylesheet(zval *id, xsl_object *intern, xsltStyl efree(intern->doc); intern->doc = NULL; + if (intern->profiling) { + efree(intern->profiling); + } if (params) { clone = 0; @@ -772,6 +790,31 @@ PHP_FUNCTION(xsl_xsltprocessor_register_php_functions) } /* }}} end xsl_xsltprocessor_register_php_functions(); */ +/* {{{ proto bool xsl_xsltprocessor_set_profiling(string filename) */ +PHP_FUNCTION(xsl_xsltprocessor_set_profiling) +{ + + zval *id; + zval *array_value, **entry, *new_string; + xsl_object *intern; + char *filename; + int filename_len; + DOM_GET_THIS(id); + + if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "s", &filename, &filename_len) == SUCCESS) { + intern = (xsl_object *)zend_object_store_get_object(id TSRMLS_CC); + + intern->profiling = estrndup(filename,filename_len); + + RETURN_TRUE; + + } else { + WRONG_PARAM_COUNT; + } + +} +/* }}} end xsl_xsltprocessor_set_profiling */ + /* {{{ proto bool xsl_xsltprocessor_has_exslt_support(); */ PHP_FUNCTION(xsl_xsltprocessor_has_exslt_support) |