PHP  
 PHP: Test and Code Coverage Analysis
downloads | QA | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
 

LCOV - code coverage report
Current view: top level - ext/xsl - xsltprocessor.c (source / functions) Hit Total Coverage
Test: PHP Code Coverage Lines: 346 455 76.0 %
Date: 2014-10-16 Functions: 16 18 88.9 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :    +----------------------------------------------------------------------+
       3             :    | PHP Version 5                                                        |
       4             :    +----------------------------------------------------------------------+
       5             :    | Copyright (c) 1997-2014 The PHP Group                                |
       6             :    +----------------------------------------------------------------------+
       7             :    | This source file is subject to version 3.01 of the PHP license,      |
       8             :    | that is bundled with this package in the file LICENSE, and is        |
       9             :    | available through the world-wide-web at the following url:           |
      10             :    | http://www.php.net/license/3_01.txt                                  |
      11             :    | If you did not receive a copy of the PHP license and are unable to   |
      12             :    | obtain it through the world-wide-web, please send a note to          |
      13             :    | license@php.net so we can mail you a copy immediately.               |
      14             :    +----------------------------------------------------------------------+
      15             :    | Authors: Christian Stocker <chregu@php.net>                          |
      16             :    |          Rob Richards <rrichards@php.net>                            |
      17             :    +----------------------------------------------------------------------+
      18             : */
      19             : 
      20             : /* $Id$ */
      21             : 
      22             : #ifdef HAVE_CONFIG_H
      23             : #include "config.h"
      24             : #endif
      25             : 
      26             : #include "php.h"
      27             : #include "php_xsl.h"
      28             : #include "ext/libxml/php_libxml.h"
      29             : 
      30             : /* {{{ arginfo */
      31             : ZEND_BEGIN_ARG_INFO_EX(arginfo_xsl_xsltprocessor_import_stylesheet, 0, 0, 1)
      32             :         ZEND_ARG_INFO(0, doc)
      33             : ZEND_END_ARG_INFO();
      34             : 
      35             : ZEND_BEGIN_ARG_INFO_EX(arginfo_xsl_xsltprocessor_transform_to_doc, 0, 0, 1)
      36             :         ZEND_ARG_INFO(0, doc)
      37             : ZEND_END_ARG_INFO();
      38             : 
      39             : ZEND_BEGIN_ARG_INFO_EX(arginfo_xsl_xsltprocessor_transform_to_uri, 0, 0, 2)
      40             :         ZEND_ARG_INFO(0, doc)
      41             :         ZEND_ARG_INFO(0, uri)
      42             : ZEND_END_ARG_INFO();
      43             : 
      44             : ZEND_BEGIN_ARG_INFO_EX(arginfo_xsl_xsltprocessor_transform_to_xml, 0, 0, 1)
      45             :         ZEND_ARG_INFO(0, doc)
      46             : ZEND_END_ARG_INFO();
      47             : 
      48             : ZEND_BEGIN_ARG_INFO_EX(arginfo_xsl_xsltprocessor_set_parameter, 0, 0, 2)
      49             :         ZEND_ARG_INFO(0, namespace)
      50             :         ZEND_ARG_INFO(0, name)
      51             :         ZEND_ARG_INFO(0, value)
      52             : ZEND_END_ARG_INFO();
      53             : 
      54             : ZEND_BEGIN_ARG_INFO_EX(arginfo_xsl_xsltprocessor_get_parameter, 0, 0, 2)
      55             :         ZEND_ARG_INFO(0, namespace)
      56             :         ZEND_ARG_INFO(0, name)
      57             : ZEND_END_ARG_INFO();
      58             : 
      59             : ZEND_BEGIN_ARG_INFO_EX(arginfo_xsl_xsltprocessor_remove_parameter, 0, 0, 2)
      60             :         ZEND_ARG_INFO(0, namespace)
      61             :         ZEND_ARG_INFO(0, name)
      62             : ZEND_END_ARG_INFO();
      63             : 
      64             : ZEND_BEGIN_ARG_INFO_EX(arginfo_xsl_xsltprocessor_has_exslt_support, 0, 0, 0)
      65             : ZEND_END_ARG_INFO();
      66             : 
      67             : ZEND_BEGIN_ARG_INFO_EX(arginfo_xsl_xsltprocessor_register_php_functions, 0, 0, 0)
      68             :         ZEND_ARG_INFO(0, restrict)
      69             : ZEND_END_ARG_INFO();
      70             : 
      71             : ZEND_BEGIN_ARG_INFO_EX(arginfo_xsl_xsltprocessor_set_profiling, 0, 0, 1)
      72             :         ZEND_ARG_INFO(0, filename)
      73             : ZEND_END_ARG_INFO();
      74             : 
      75             : ZEND_BEGIN_ARG_INFO_EX(arginfo_xsl_xsltprocessor_set_security_prefs, 0, 0, 1)
      76             :         ZEND_ARG_INFO(0, securityPrefs)
      77             : ZEND_END_ARG_INFO();
      78             : 
      79             : ZEND_BEGIN_ARG_INFO_EX(arginfo_xsl_xsltprocessor_get_security_prefs, 0, 0, 0)
      80             : ZEND_END_ARG_INFO();
      81             : /* }}} */
      82             : 
      83             : /*
      84             : * class xsl_xsltprocessor 
      85             : *
      86             : * URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#
      87             : * Since: 
      88             : */
      89             : 
      90             : const zend_function_entry php_xsl_xsltprocessor_class_functions[] = {
      91             :         PHP_FALIAS(importStylesheet, xsl_xsltprocessor_import_stylesheet, arginfo_xsl_xsltprocessor_import_stylesheet)
      92             :         PHP_FALIAS(transformToDoc, xsl_xsltprocessor_transform_to_doc, arginfo_xsl_xsltprocessor_transform_to_doc)
      93             :         PHP_FALIAS(transformToUri, xsl_xsltprocessor_transform_to_uri, arginfo_xsl_xsltprocessor_transform_to_uri)
      94             :         PHP_FALIAS(transformToXml, xsl_xsltprocessor_transform_to_xml, arginfo_xsl_xsltprocessor_transform_to_xml)
      95             :         PHP_FALIAS(setParameter, xsl_xsltprocessor_set_parameter, arginfo_xsl_xsltprocessor_set_parameter)
      96             :         PHP_FALIAS(getParameter, xsl_xsltprocessor_get_parameter, arginfo_xsl_xsltprocessor_get_parameter)
      97             :         PHP_FALIAS(removeParameter, xsl_xsltprocessor_remove_parameter, arginfo_xsl_xsltprocessor_remove_parameter)
      98             :         PHP_FALIAS(hasExsltSupport, xsl_xsltprocessor_has_exslt_support, arginfo_xsl_xsltprocessor_has_exslt_support)
      99             :         PHP_FALIAS(registerPHPFunctions, xsl_xsltprocessor_register_php_functions, arginfo_xsl_xsltprocessor_register_php_functions)
     100             :         PHP_FALIAS(setProfiling, xsl_xsltprocessor_set_profiling, arginfo_xsl_xsltprocessor_set_profiling)
     101             :         PHP_FALIAS(setSecurityPrefs, xsl_xsltprocessor_set_security_prefs, arginfo_xsl_xsltprocessor_set_security_prefs)
     102             :         PHP_FALIAS(getSecurityPrefs, xsl_xsltprocessor_get_security_prefs, arginfo_xsl_xsltprocessor_get_security_prefs)
     103             :         {NULL, NULL, NULL}
     104             : };
     105             : 
     106             : /* {{{ php_xsl_xslt_string_to_xpathexpr()
     107             :    Translates a string to a XPath Expression */
     108           5 : static char *php_xsl_xslt_string_to_xpathexpr(const char *str TSRMLS_DC)
     109             : {
     110           5 :         const xmlChar *string = (const xmlChar *)str;
     111             : 
     112             :         xmlChar *value;
     113             :         int str_len;
     114             :         
     115           5 :         str_len = xmlStrlen(string) + 3;
     116             :         
     117           5 :         if (xmlStrchr(string, '"')) {
     118           2 :                 if (xmlStrchr(string, '\'')) {
     119           2 :                         php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot create XPath expression (string contains both quote and double-quotes)");
     120           2 :                         return NULL;
     121             :                 }
     122           0 :                 value = (xmlChar*) safe_emalloc (str_len, sizeof(xmlChar), 0);
     123           0 :                 snprintf(value, str_len, "'%s'", string);
     124             :         } else {
     125           3 :                 value = (xmlChar*) safe_emalloc (str_len, sizeof(xmlChar), 0);
     126           3 :                 snprintf(value, str_len, "\"%s\"", string);
     127             :         }
     128           3 :         return (char *) value;
     129             : }
     130             : /* }}} */
     131             : 
     132             : /* {{{ php_xsl_xslt_make_params()
     133             :    Translates a PHP array to a libxslt parameters array */
     134          46 : static char **php_xsl_xslt_make_params(HashTable *parht, int xpath_params TSRMLS_DC)
     135             : {
     136             :         
     137             :         int parsize;
     138             :         zval **value;
     139          46 :         char *xpath_expr, *string_key = NULL;
     140             :         ulong num_key;
     141          46 :         char **params = NULL;
     142          46 :         int i = 0;
     143             : 
     144          46 :         parsize = (2 * zend_hash_num_elements(parht) + 1) * sizeof(char *);
     145          46 :         params = (char **)safe_emalloc((2 * zend_hash_num_elements(parht) + 1), sizeof(char *), 0);
     146          46 :         memset((char *)params, 0, parsize);
     147             : 
     148          97 :         for (zend_hash_internal_pointer_reset(parht);
     149          51 :                 zend_hash_get_current_data(parht, (void **)&value) == SUCCESS;
     150           5 :                 zend_hash_move_forward(parht)) {
     151             : 
     152           5 :                 if (zend_hash_get_current_key(parht, &string_key, &num_key, 1) != HASH_KEY_IS_STRING) {
     153           0 :                         php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid argument or parameter array");
     154           0 :                         efree(params);
     155           0 :                         return NULL;
     156             :                 } else {
     157           5 :                         if (Z_TYPE_PP(value) != IS_STRING) {
     158           0 :                                 SEPARATE_ZVAL(value);
     159           0 :                                 convert_to_string(*value);
     160             :                         }
     161             :                         
     162           5 :                         if (!xpath_params) {
     163           5 :                                 xpath_expr = php_xsl_xslt_string_to_xpathexpr(Z_STRVAL_PP(value) TSRMLS_CC);
     164             :                         } else {
     165           0 :                                 xpath_expr = estrndup(Z_STRVAL_PP(value), Z_STRLEN_PP(value));
     166             :                         }
     167           5 :                         if (xpath_expr) {
     168           3 :                                 params[i++] = string_key;
     169           3 :                                 params[i++] = xpath_expr;
     170             :                         } else {
     171           2 :                                 efree(string_key);
     172             :                         }
     173             :                 }
     174             :         }
     175             : 
     176          46 :         params[i++] = NULL;
     177             : 
     178          46 :         return params;
     179             : }
     180             : /* }}} */
     181             : 
     182          27 : static void xsl_ext_function_php(xmlXPathParserContextPtr ctxt, int nargs, int type) /* {{{ */
     183             : {
     184             :         xsltTransformContextPtr tctxt;
     185             :         zval **args;
     186             :         zval *retval;
     187             :         int result, i, ret;
     188          27 :         int error = 0;
     189             :         zend_fcall_info fci;
     190             :         zval handler;
     191             :         xmlXPathObjectPtr obj;
     192             :         char *str;
     193          27 :         char *callable = NULL;
     194             :         xsl_object *intern;
     195             :         
     196             :         TSRMLS_FETCH();
     197             : 
     198          27 :         if (! zend_is_executing(TSRMLS_C)) {
     199           0 :                 xsltGenericError(xsltGenericErrorContext,
     200             :                 "xsltExtFunctionTest: Function called from outside of PHP\n");
     201           0 :                 error = 1;
     202             :         } else {
     203          27 :                 tctxt = xsltXPathGetTransformContext(ctxt);
     204          27 :                 if (tctxt == NULL) {
     205           0 :                         xsltGenericError(xsltGenericErrorContext,
     206             :                         "xsltExtFunctionTest: failed to get the transformation context\n");
     207           0 :                         error = 1;
     208             :                 } else {
     209          27 :                         intern = (xsl_object *) tctxt->_private;
     210          27 :                         if (intern == NULL) {
     211           0 :                                 xsltGenericError(xsltGenericErrorContext,
     212             :                                 "xsltExtFunctionTest: failed to get the internal object\n");
     213           0 :                                 error = 1;
     214             :                         }
     215          27 :                         else if (intern->registerPhpFunctions == 0) {
     216           0 :                                 xsltGenericError(xsltGenericErrorContext,
     217             :                                 "xsltExtFunctionTest: PHP Object did not register PHP functions\n");
     218           0 :                                 error = 1;
     219             :                         }
     220             :                 }
     221             :         }
     222             :         
     223          27 :         if (error == 1) {
     224           0 :                 for (i = nargs - 1; i >= 0; i--) {
     225           0 :                         obj = valuePop(ctxt);
     226           0 :                         xmlXPathFreeObject(obj);
     227             :                 }
     228           0 :                 return;
     229             :         }
     230             :                 
     231          27 :         fci.param_count = nargs - 1;
     232          27 :         if (fci.param_count > 0) {
     233          24 :                 fci.params = safe_emalloc(fci.param_count, sizeof(zval**), 0);
     234          24 :                 args = safe_emalloc(fci.param_count, sizeof(zval *), 0);
     235             :         }
     236             :         /* Reverse order to pop values off ctxt stack */
     237          52 :         for (i = nargs - 2; i >= 0; i--) {
     238          25 :                 obj = valuePop(ctxt);
     239          25 :                 MAKE_STD_ZVAL(args[i]);
     240          25 :                 switch (obj->type) {
     241             :                         case XPATH_STRING:
     242          12 :                                 ZVAL_STRING(args[i],  obj->stringval, 1);
     243          12 :                                 break;
     244             :                         case XPATH_BOOLEAN:
     245           0 :                                 ZVAL_BOOL(args[i],  obj->boolval);
     246           0 :                                 break;
     247             :                         case XPATH_NUMBER:
     248           0 :                                 ZVAL_DOUBLE(args[i], obj->floatval);
     249           0 :                                 break;
     250             :                         case XPATH_NODESET:
     251          13 :                                 if (type == 1) {
     252           1 :                                         str = xmlXPathCastToString(obj);
     253           1 :                                         ZVAL_STRING(args[i], str, 1);
     254           1 :                                         xmlFree(str);
     255          12 :                                 } else if (type == 2) {
     256             :                                         int j;
     257          12 :                                         dom_object *domintern = (dom_object *)intern->doc;
     258          12 :                                         array_init(args[i]);
     259          12 :                                         if (obj->nodesetval && obj->nodesetval->nodeNr > 0) {
     260          24 :                                                 for (j = 0; j < obj->nodesetval->nodeNr; j++) {
     261          12 :                                                         xmlNodePtr node = obj->nodesetval->nodeTab[j];
     262             :                                                         zval *child;
     263          12 :                                                         MAKE_STD_ZVAL(child);
     264             :                                                         /* not sure, if we need this... it's copied from xpath.c */
     265          12 :                                                         if (node->type == XML_NAMESPACE_DECL) {
     266             :                                                                 xmlNsPtr curns;
     267             :                                                                 xmlNodePtr nsparent;
     268             :                                                                 
     269           0 :                                                                 nsparent = node->_private;
     270           0 :                                                                 curns = xmlNewNs(NULL, node->name, NULL);
     271           0 :                                                                 if (node->children) {
     272           0 :                                                                         curns->prefix = xmlStrdup((char *) node->children);
     273             :                                                                 }
     274           0 :                                                                 if (node->children) {
     275           0 :                                                                         node = xmlNewDocNode(node->doc, NULL, (char *) node->children, node->name);
     276             :                                                                 } else {
     277           0 :                                                                         node = xmlNewDocNode(node->doc, NULL, "xmlns", node->name);
     278             :                                                                 }
     279           0 :                                                                 node->type = XML_NAMESPACE_DECL;
     280           0 :                                                                 node->parent = nsparent;
     281           0 :                                                                 node->ns = curns;
     282             :                                                         } else {
     283          12 :                                                                 node = xmlDocCopyNodeList(domintern->document->ptr, node);
     284             :                                                         }
     285             : 
     286          12 :                                                         child = php_dom_create_object(node, &ret, child, domintern TSRMLS_CC);
     287          12 :                                                         add_next_index_zval(args[i], child);
     288             :                                                 }
     289             :                                         }
     290             :                                 }
     291          13 :                                 break;
     292             :                         default:
     293           0 :                                 str = xmlXPathCastToString(obj);
     294           0 :                                 ZVAL_STRING(args[i], str, 1);
     295           0 :                                 xmlFree(str);
     296             :                 }
     297          25 :                 xmlXPathFreeObject(obj);
     298          25 :                 fci.params[i] = &args[i];
     299             :         }
     300             :         
     301          27 :         fci.size = sizeof(fci);
     302          27 :         fci.function_table = EG(function_table);
     303             :         
     304          27 :         obj = valuePop(ctxt);
     305          27 :         if (obj->stringval == NULL) {
     306           1 :                 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Handler name must be a string");
     307           1 :                 xmlXPathFreeObject(obj);
     308           1 :                 valuePush(ctxt, xmlXPathNewString(""));
     309           1 :                 if (fci.param_count > 0) {
     310           2 :                         for (i = 0; i < nargs - 1; i++) {
     311           1 :                                 zval_ptr_dtor(&args[i]);
     312             :                         }
     313           1 :                         efree(args);
     314           1 :                         efree(fci.params);
     315             :                 }
     316           1 :                 return; 
     317             :         }
     318          26 :         INIT_PZVAL(&handler);
     319          26 :         ZVAL_STRING(&handler, obj->stringval, 1);
     320          26 :         xmlXPathFreeObject(obj);
     321             :         
     322          26 :         fci.function_name = &handler;
     323          26 :         fci.symbol_table = NULL;
     324          26 :         fci.object_ptr = NULL;
     325          26 :         fci.retval_ptr_ptr = &retval;
     326          26 :         fci.no_separation = 0;
     327             :         /*fci.function_handler_cache = &function_ptr;*/
     328          26 :         if (!zend_make_callable(&handler, &callable TSRMLS_CC)) {
     329           1 :                 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to call handler %s()", callable);
     330           1 :                 valuePush(ctxt, xmlXPathNewString(""));
     331          26 :         } else if ( intern->registerPhpFunctions == 2 && zend_hash_exists(intern->registered_phpfunctions, callable, strlen(callable) + 1) == 0) { 
     332           2 :                 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Not allowed to call handler '%s()'", callable);
     333             :                 /* Push an empty string, so that we at least have an xslt result... */
     334           2 :                 valuePush(ctxt, xmlXPathNewString(""));
     335             :         } else {
     336          22 :                 result = zend_call_function(&fci, NULL TSRMLS_CC);
     337          22 :                 if (result == FAILURE) {
     338           0 :                         if (Z_TYPE(handler) == IS_STRING) {
     339           0 :                                 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to call handler %s()", Z_STRVAL_P(&handler));
     340           0 :                                 valuePush(ctxt, xmlXPathNewString(""));
     341             :                         }
     342             :                 /* retval is == NULL, when an exception occurred, don't report anything, because PHP itself will handle that */
     343          22 :                 } else if (retval == NULL) {
     344             :                 } else {
     345          14 :                         if (retval->type == IS_OBJECT && instanceof_function( Z_OBJCE_P(retval), dom_node_class_entry TSRMLS_CC)) {
     346             :                                 xmlNode *nodep;
     347             :                                 dom_object *obj;
     348           2 :                                 if (intern->node_list == NULL) {
     349           1 :                                         ALLOC_HASHTABLE(intern->node_list);
     350           1 :                                         zend_hash_init(intern->node_list, 0, NULL, ZVAL_PTR_DTOR, 0);
     351             :                                 }
     352           2 :                                 zval_add_ref(&retval);
     353           2 :                                 zend_hash_next_index_insert(intern->node_list, &retval, sizeof(zval *), NULL);
     354           2 :                                 obj = (dom_object *)zend_object_store_get_object(retval TSRMLS_CC);
     355           2 :                                 nodep = dom_object_get_node(obj);
     356           2 :                                 valuePush(ctxt, xmlXPathNewNodeSet(nodep));
     357          10 :                         } else if (retval->type == IS_BOOL) {
     358           0 :                                 valuePush(ctxt, xmlXPathNewBoolean(retval->value.lval));
     359          10 :                         } else if (retval->type == IS_OBJECT) {
     360           1 :                                 php_error_docref(NULL TSRMLS_CC, E_WARNING, "A PHP Object cannot be converted to a XPath-string");
     361           1 :                                 valuePush(ctxt, xmlXPathNewString(""));
     362             :                         } else {
     363           9 :                                 convert_to_string_ex(&retval);
     364           9 :                                 valuePush(ctxt, xmlXPathNewString( Z_STRVAL_P(retval)));
     365             :                         }
     366          12 :                         zval_ptr_dtor(&retval);
     367             :                 }
     368             :         }
     369          25 :         efree(callable);
     370             :         zval_dtor(&handler);
     371          25 :         if (fci.param_count > 0) {
     372          47 :                 for (i = 0; i < nargs - 1; i++) {
     373          24 :                         zval_ptr_dtor(&args[i]);
     374             :                 }
     375          23 :                 efree(args);
     376          23 :                 efree(fci.params);
     377             :         }
     378             : }
     379             : /* }}} */
     380             : 
     381           1 : void xsl_ext_function_string_php(xmlXPathParserContextPtr ctxt, int nargs) /* {{{ */
     382             : {
     383           1 :         xsl_ext_function_php(ctxt, nargs, 1);
     384           1 : }
     385             : /* }}} */
     386             : 
     387          26 : void xsl_ext_function_object_php(xmlXPathParserContextPtr ctxt, int nargs) /* {{{ */
     388             : {
     389          26 :         xsl_ext_function_php(ctxt, nargs, 2);
     390          25 : }
     391             : /* }}} */
     392             : 
     393             : /* {{{ proto void xsl_xsltprocessor_import_stylesheet(domdocument doc);
     394             : URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#
     395             : Since: 
     396             : */
     397          43 : PHP_FUNCTION(xsl_xsltprocessor_import_stylesheet)
     398             : {
     399          43 :         zval *id, *docp = NULL;
     400          43 :         xmlDoc *doc = NULL, *newdoc = NULL;
     401             :         xsltStylesheetPtr sheetp, oldsheetp;
     402             :         xsl_object *intern;
     403          43 :         int prevSubstValue, prevExtDtdValue, clone_docu = 0;
     404          43 :         xmlNode *nodep = NULL;
     405             :         zend_object_handlers *std_hnd;
     406             :         zval *cloneDocu, *member;
     407             :         
     408          43 :         if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oo", &id, xsl_xsltprocessor_class_entry, &docp) == FAILURE) {
     409           0 :                 RETURN_FALSE;
     410             :         }
     411             : 
     412          43 :         nodep = php_libxml_import_node(docp TSRMLS_CC);
     413             :         
     414          43 :         if (nodep) {
     415          43 :                 doc = nodep->doc;
     416             :         }
     417          43 :         if (doc == NULL) {
     418           0 :                 php_error(E_WARNING, "Invalid Document");
     419           0 :                 RETURN_FALSE;
     420             :         }
     421             : 
     422             :         /* libxslt uses _private, so we must copy the imported 
     423             :         stylesheet document otherwise the node proxies will be a mess */
     424          43 :         newdoc = xmlCopyDoc(doc, 1);
     425          43 :         xmlNodeSetBase((xmlNodePtr) newdoc, (xmlChar *)doc->URL);
     426          43 :         prevSubstValue = xmlSubstituteEntitiesDefault(1);
     427          43 :         prevExtDtdValue = xmlLoadExtDtdDefaultValue;
     428          43 :         xmlLoadExtDtdDefaultValue = XML_DETECT_IDS | XML_COMPLETE_ATTRS;
     429             : 
     430          43 :         sheetp = xsltParseStylesheetDoc(newdoc);
     431          43 :         xmlSubstituteEntitiesDefault(prevSubstValue);
     432          43 :         xmlLoadExtDtdDefaultValue = prevExtDtdValue;
     433             : 
     434          43 :         if (!sheetp) {
     435           0 :                 xmlFreeDoc(newdoc);
     436           0 :                 RETURN_FALSE;
     437             :         }
     438             : 
     439          43 :         intern = (xsl_object *)zend_object_store_get_object(id TSRMLS_CC); 
     440             : 
     441          43 :         std_hnd = zend_get_std_object_handlers();
     442          43 :         MAKE_STD_ZVAL(member);
     443          43 :         ZVAL_STRING(member, "cloneDocument", 0);
     444          43 :         cloneDocu = std_hnd->read_property(id, member, BP_VAR_IS, NULL TSRMLS_CC);
     445          43 :         if (Z_TYPE_P(cloneDocu) != IS_NULL) {
     446           0 :                 convert_to_long(cloneDocu);
     447           0 :                 clone_docu = Z_LVAL_P(cloneDocu);
     448             :         }
     449          43 :         efree(member);
     450          43 :         if (clone_docu == 0) {
     451             :                 /* check if the stylesheet is using xsl:key, if yes, we have to clone the document _always_ before a transformation */
     452          43 :                 nodep = xmlDocGetRootElement(sheetp->doc);
     453          43 :                 if (nodep && (nodep = nodep->children)) {
     454         198 :                         while (nodep) {
     455         113 :                                 if (nodep->type == XML_ELEMENT_NODE && xmlStrEqual(nodep->name, "key") && xmlStrEqual(nodep->ns->href, XSLT_NAMESPACE)) {
     456           1 :                                         intern->hasKeys = 1;
     457           1 :                                         break;
     458             :                                 }
     459         112 :                                 nodep = nodep->next;
     460             :                         }
     461             :                 }
     462             :         } else {
     463           0 :                 intern->hasKeys = clone_docu;
     464             :         }
     465             : 
     466          43 :         if ((oldsheetp = (xsltStylesheetPtr)intern->ptr)) { 
     467             :                 /* free wrapper */
     468           0 :                 if (((xsltStylesheetPtr) intern->ptr)->_private != NULL) {
     469           0 :                         ((xsltStylesheetPtr) intern->ptr)->_private = NULL;   
     470             :                 }
     471           0 :                 xsltFreeStylesheet((xsltStylesheetPtr) intern->ptr);
     472           0 :                 intern->ptr = NULL;
     473             :         }
     474             : 
     475          43 :         php_xsl_set_object(id, sheetp TSRMLS_CC);
     476          43 :         RETVAL_TRUE;
     477             : }
     478             : /* }}} end xsl_xsltprocessor_import_stylesheet */
     479             : 
     480          46 : static xmlDocPtr php_xsl_apply_stylesheet(zval *id, xsl_object *intern, xsltStylesheetPtr style, zval *docp TSRMLS_DC) /* {{{ */
     481             : {
     482          46 :         xmlDocPtr newdocp = NULL;
     483          46 :         xmlDocPtr doc = NULL;
     484          46 :         xmlNodePtr node = NULL;
     485             :         xsltTransformContextPtr ctxt;
     486             :         php_libxml_node_object *object;
     487          46 :         char **params = NULL;
     488             :         int clone;
     489             :         zval *doXInclude, *member;
     490             :         zend_object_handlers *std_hnd;
     491             :         FILE *f;
     492          46 :         int secPrefsError = 0;
     493             :         int secPrefsValue, secPrefsIni;
     494          46 :         xsltSecurityPrefsPtr secPrefs = NULL;
     495             : 
     496          46 :         node = php_libxml_import_node(docp TSRMLS_CC);
     497             :         
     498          46 :         if (node) {
     499          46 :                 doc = node->doc;
     500             :         }
     501          46 :         if (doc == NULL) {
     502           0 :                 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid Document");
     503           0 :                 return NULL;
     504             :         }
     505             : 
     506          46 :         if (style == NULL) {
     507           0 :                 php_error_docref(NULL TSRMLS_CC, E_WARNING, "No stylesheet associated to this object");
     508           0 :                 return NULL;
     509             :         }
     510             :         
     511          46 :         if (intern->profiling) {
     512           0 :                 if (php_check_open_basedir(intern->profiling TSRMLS_CC)) {
     513           0 :                         f = NULL;
     514             :                 } else {
     515           0 :                         f = VCWD_FOPEN(intern->profiling, "w");
     516             :                 }
     517             :         } else {
     518          46 :                 f = NULL;
     519             :         }
     520             :         
     521          46 :         if (intern->parameter) {
     522          46 :                 params = php_xsl_xslt_make_params(intern->parameter, 0 TSRMLS_CC);
     523             :         }
     524             : 
     525          46 :         intern->doc = emalloc(sizeof(php_libxml_node_object));
     526          46 :         memset(intern->doc, 0, sizeof(php_libxml_node_object));
     527             : 
     528          46 :         if (intern->hasKeys == 1) {
     529           1 :                 doc = xmlCopyDoc(doc, 1);
     530             :         } else {
     531          45 :                 object = (php_libxml_node_object *)zend_object_store_get_object(docp TSRMLS_CC);
     532          45 :                 intern->doc->document = object->document;
     533             :         }
     534             : 
     535          46 :         php_libxml_increment_doc_ref(intern->doc, doc TSRMLS_CC);
     536             : 
     537          46 :         ctxt = xsltNewTransformContext(style, doc);
     538          46 :         ctxt->_private = (void *) intern;
     539             : 
     540          46 :         std_hnd = zend_get_std_object_handlers();
     541             : 
     542          46 :         MAKE_STD_ZVAL(member);
     543          46 :         ZVAL_STRING(member, "doXInclude", 0);
     544          46 :         doXInclude = std_hnd->read_property(id, member, BP_VAR_IS, NULL TSRMLS_CC);
     545          46 :         if (Z_TYPE_P(doXInclude) != IS_NULL) {
     546           0 :                 convert_to_long(doXInclude);
     547           0 :                 ctxt->xinclude = Z_LVAL_P(doXInclude);
     548             :         }
     549          46 :         efree(member);
     550             : 
     551          46 :         secPrefsValue = intern->securityPrefs;
     552             :         
     553             :         /* This whole if block can be removed, when we remove the xsl.security_prefs php.ini option in PHP 6+ */
     554          46 :         secPrefsIni= INI_INT("xsl.security_prefs");
     555             :         /* if secPrefsIni has the same value as secPrefsValue, all is fine */
     556          46 :         if (secPrefsIni != secPrefsValue) {
     557           3 :                 if (secPrefsIni != XSL_SECPREF_DEFAULT) {
     558             :                         /* if the ini value is not set to the default, throw an E_DEPRECATED warning */
     559           2 :                         php_error_docref(NULL TSRMLS_CC, E_DEPRECATED, "The xsl.security_prefs php.ini option is deprecated; use XsltProcessor->setSecurityPrefs() instead");
     560           2 :                         if (intern->securityPrefsSet == 0) {
     561             :                                 /* if securityPrefs were not set through the setSecurityPrefs method, take the ini setting */
     562           1 :                                 secPrefsValue = secPrefsIni;
     563             :                         } else {
     564             :                                 /* else throw a notice, that the ini setting was not used */
     565           1 :                                 php_error_docref(NULL TSRMLS_CC, E_NOTICE, "The xsl.security_prefs php.ini was not used, since the  XsltProcessor->setSecurityPrefs() method was used");
     566             :                         }
     567             :                 }
     568             :         }
     569             : 
     570             :         /* if securityPrefs is set to NONE, we don't have to do any checks, but otherwise... */
     571          46 :         if (secPrefsValue != XSL_SECPREF_NONE) {
     572          43 :                 secPrefs = xsltNewSecurityPrefs(); 
     573          43 :                 if (secPrefsValue & XSL_SECPREF_READ_FILE ) { 
     574           0 :                         if (0 != xsltSetSecurityPrefs(secPrefs, XSLT_SECPREF_READ_FILE, xsltSecurityForbid)) { 
     575           0 :                                 secPrefsError = 1;
     576             :                         }
     577             :                 }
     578          43 :                 if (secPrefsValue & XSL_SECPREF_WRITE_FILE ) { 
     579          43 :                         if (0 != xsltSetSecurityPrefs(secPrefs, XSLT_SECPREF_WRITE_FILE, xsltSecurityForbid)) { 
     580           0 :                                 secPrefsError = 1;
     581             :                         }
     582             :                 }
     583          43 :                 if (secPrefsValue & XSL_SECPREF_CREATE_DIRECTORY ) { 
     584          43 :                         if (0 != xsltSetSecurityPrefs(secPrefs, XSLT_SECPREF_CREATE_DIRECTORY, xsltSecurityForbid)) { 
     585           0 :                                 secPrefsError = 1;
     586             :                         }
     587             :                 }
     588          43 :                 if (secPrefsValue & XSL_SECPREF_READ_NETWORK) { 
     589           0 :                         if (0 != xsltSetSecurityPrefs(secPrefs, XSLT_SECPREF_READ_NETWORK, xsltSecurityForbid)) { 
     590           0 :                                 secPrefsError = 1;
     591             :                         }
     592             :                 }
     593          43 :                 if (secPrefsValue & XSL_SECPREF_WRITE_NETWORK) { 
     594          43 :                         if (0 != xsltSetSecurityPrefs(secPrefs, XSLT_SECPREF_WRITE_NETWORK, xsltSecurityForbid)) { 
     595           0 :                                 secPrefsError = 1;
     596             :                         }
     597             :                 }
     598             :         
     599          43 :                 if (0 != xsltSetCtxtSecurityPrefs(secPrefs, ctxt)) { 
     600           0 :                         secPrefsError = 1;
     601             :                 }
     602             :         }
     603             :         
     604          46 :         if (secPrefsError == 1) {
     605           0 :                 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Can't set libxslt security properties, not doing transformation for security reasons");
     606             :         } else {
     607          46 :                 newdocp = xsltApplyStylesheetUser(style, doc, (const char**) params,  NULL, f, ctxt);
     608             :         }
     609          45 :         if (f) {
     610           0 :                 fclose(f);
     611             :         }
     612             :         
     613          45 :         xsltFreeTransformContext(ctxt);
     614          45 :         if (secPrefs) {
     615          42 :                 xsltFreeSecurityPrefs(secPrefs);
     616             :         }
     617             : 
     618          45 :         if (intern->node_list != NULL) {
     619           1 :                 zend_hash_destroy(intern->node_list);
     620           1 :                 FREE_HASHTABLE(intern->node_list);   
     621           1 :                 intern->node_list = NULL;
     622             :         }
     623             : 
     624          45 :         php_libxml_decrement_doc_ref(intern->doc TSRMLS_CC);
     625          45 :         efree(intern->doc);
     626          45 :         intern->doc = NULL;
     627             : 
     628          45 :         if (params) {
     629          45 :                 clone = 0;
     630          96 :                 while(params[clone]) {
     631           6 :                         efree(params[clone++]);
     632             :                 }
     633          45 :                 efree(params);
     634             :         }
     635             : 
     636          45 :         return newdocp;
     637             : 
     638             : }
     639             : /* }}} */
     640             : 
     641             : /* {{{ proto domdocument xsl_xsltprocessor_transform_to_doc(domnode doc);
     642             : URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#
     643             : Since: 
     644             : */
     645          12 : PHP_FUNCTION(xsl_xsltprocessor_transform_to_doc)
     646             : {
     647          12 :         zval *id, *docp = NULL;
     648             :         xmlDoc *newdocp;
     649             :         xsltStylesheetPtr sheetp;
     650          12 :         int ret, ret_class_len=0;
     651          12 :         char *ret_class = NULL;
     652             :         xsl_object *intern;
     653             : 
     654          12 :         id = getThis();
     655          12 :         intern = (xsl_object *)zend_object_store_get_object(id TSRMLS_CC);
     656          12 :         sheetp = (xsltStylesheetPtr) intern->ptr;
     657             : 
     658          12 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o|s!", &docp, &ret_class, &ret_class_len) == FAILURE) {
     659           0 :                 RETURN_FALSE;
     660             :         }
     661             : 
     662          12 :         newdocp = php_xsl_apply_stylesheet(id, intern, sheetp, docp TSRMLS_CC);
     663             : 
     664          11 :         if (newdocp) {
     665          11 :                 if (ret_class) {
     666             :                         int found;
     667             :                         char *curclass_name;
     668             :                         zend_class_entry *curce, **ce;
     669             :                         php_libxml_node_object *interndoc;
     670             : 
     671           0 :                         curce = Z_OBJCE_P(docp);
     672           0 :                         curclass_name = curce->name;
     673           0 :                         while (curce->parent != NULL) {
     674           0 :                                 curce = curce->parent;
     675             :                         }
     676             : 
     677           0 :                         found = zend_lookup_class(ret_class, ret_class_len, &ce TSRMLS_CC);
     678           0 :                         if ((found != SUCCESS) || !instanceof_function(*ce, curce TSRMLS_CC)) {
     679           0 :                                 xmlFreeDoc(newdocp);
     680           0 :                                 php_error_docref(NULL TSRMLS_CC, E_WARNING, 
     681             :                                         "Expecting class compatible with %s, '%s' given", curclass_name, ret_class);
     682           0 :                                 RETURN_FALSE;
     683             :                         }
     684             : 
     685           0 :                         object_init_ex(return_value, *ce);
     686             :                 
     687           0 :                         interndoc = (php_libxml_node_object *)zend_objects_get_address(return_value TSRMLS_CC);
     688           0 :                         php_libxml_increment_doc_ref(interndoc, newdocp TSRMLS_CC);
     689           0 :                         php_libxml_increment_node_ptr(interndoc, (xmlNodePtr)newdocp, (void *)interndoc TSRMLS_CC);
     690             :                 } else {
     691          11 :                         DOM_RET_OBJ((xmlNodePtr) newdocp, &ret, NULL);
     692             :                 }
     693             :         } else {
     694           0 :                 RETURN_FALSE;
     695             :         }
     696             :         
     697             : }
     698             : /* }}} end xsl_xsltprocessor_transform_to_doc */
     699             : 
     700             : /* {{{ proto int xsl_xsltprocessor_transform_to_uri(domdocument doc, string uri);
     701             : */
     702           1 : PHP_FUNCTION(xsl_xsltprocessor_transform_to_uri)
     703             : {
     704           1 :         zval *id, *docp = NULL;
     705             :         xmlDoc *newdocp;
     706             :         xsltStylesheetPtr sheetp;
     707             :         int ret, uri_len;
     708             :         char *uri;
     709             :         xsl_object *intern;
     710             :         
     711           1 :         id = getThis();
     712           1 :         intern = (xsl_object *)zend_object_store_get_object(id TSRMLS_CC);
     713           1 :         sheetp = (xsltStylesheetPtr) intern->ptr;
     714             : 
     715           1 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "op", &docp, &uri, &uri_len) == FAILURE) {
     716           0 :                 RETURN_FALSE;
     717             :         }
     718             : 
     719           1 :         newdocp = php_xsl_apply_stylesheet(id, intern, sheetp, docp TSRMLS_CC);
     720             : 
     721           1 :         ret = -1;
     722           1 :         if (newdocp) {
     723           1 :                 ret = xsltSaveResultToFilename(uri, newdocp, sheetp, 0);
     724           1 :                 xmlFreeDoc(newdocp);
     725             :         }
     726             : 
     727           1 :         RETVAL_LONG(ret);
     728             : }
     729             : /* }}} end xsl_xsltprocessor_transform_to_uri */
     730             : 
     731             : /* {{{ proto string xsl_xsltprocessor_transform_to_xml(domdocument doc);
     732             : */
     733          33 : PHP_FUNCTION(xsl_xsltprocessor_transform_to_xml)
     734             : {
     735          33 :         zval *id, *docp = NULL;
     736             :         xmlDoc *newdocp;
     737             :         xsltStylesheetPtr sheetp;
     738             :         int ret;
     739             :         xmlChar *doc_txt_ptr;
     740             :         int doc_txt_len;
     741             :         xsl_object *intern;
     742             :         
     743          33 :         id = getThis();
     744          33 :         intern = (xsl_object *)zend_object_store_get_object(id TSRMLS_CC);
     745          33 :         sheetp = (xsltStylesheetPtr) intern->ptr;
     746             : 
     747          33 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &docp) == FAILURE) {
     748           0 :                 RETURN_FALSE;
     749             :         }
     750             : 
     751          33 :         newdocp = php_xsl_apply_stylesheet(id, intern, sheetp, docp TSRMLS_CC);
     752             : 
     753          33 :         ret = -1;
     754          33 :         if (newdocp) {
     755          28 :                 ret = xsltSaveResultToString(&doc_txt_ptr, &doc_txt_len, newdocp, sheetp);
     756          28 :                 if (doc_txt_ptr && doc_txt_len) {
     757          21 :                         RETVAL_STRINGL(doc_txt_ptr, doc_txt_len, 1);
     758          21 :                         xmlFree(doc_txt_ptr);
     759             :                 }
     760          28 :                 xmlFreeDoc(newdocp);
     761             :         }
     762             : 
     763          33 :         if (ret < 0) {
     764           5 :                 RETURN_FALSE;
     765             :         }
     766             : }
     767             : /* }}} end xsl_xsltprocessor_transform_to_xml */
     768             : 
     769             : /* {{{ proto bool xsl_xsltprocessor_set_parameter(string namespace, mixed name [, string value]);
     770             : */
     771           7 : PHP_FUNCTION(xsl_xsltprocessor_set_parameter)
     772             : {
     773             :  
     774             :         zval *id;
     775             :         zval *array_value, **entry, *new_string;
     776             :         xsl_object *intern;
     777             :         char *string_key, *name, *value, *namespace;
     778             :         ulong idx;
     779             :         int string_key_len, namespace_len, name_len, value_len;
     780           7 :         DOM_GET_THIS(id);
     781             : 
     782           7 :         if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "sa", &namespace, &namespace_len, &array_value) == SUCCESS) {
     783           2 :                 intern = (xsl_object *)zend_object_store_get_object(id TSRMLS_CC);
     784           2 :                 zend_hash_internal_pointer_reset(Z_ARRVAL_P(array_value));
     785             : 
     786           6 :                 while (zend_hash_get_current_data(Z_ARRVAL_P(array_value), (void **)&entry) == SUCCESS) {
     787           6 :                         SEPARATE_ZVAL(entry);
     788           6 :                         convert_to_string_ex(entry);
     789             :                         
     790           3 :                         if (zend_hash_get_current_key_ex(Z_ARRVAL_P(array_value), &string_key, &string_key_len, &idx, 0, NULL) != HASH_KEY_IS_STRING) {
     791           1 :                                 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter array");
     792           1 :                                 RETURN_FALSE;
     793             :                         }
     794             :                         
     795           2 :                         ALLOC_ZVAL(new_string);
     796           2 :                         Z_ADDREF_PP(entry);
     797           6 :                         COPY_PZVAL_TO_ZVAL(*new_string, *entry);
     798             :                         
     799           2 :                         zend_hash_update(intern->parameter, string_key, string_key_len, &new_string, sizeof(zval*), NULL);
     800           2 :                         zend_hash_move_forward(Z_ARRVAL_P(array_value));
     801             :                 }
     802           1 :                 RETURN_TRUE;
     803             : 
     804           5 :         } else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "sss", &namespace, &namespace_len, &name, &name_len, &value, &value_len) == SUCCESS) {
     805             :                 
     806           5 :                 intern = (xsl_object *)zend_object_store_get_object(id TSRMLS_CC);
     807             :                 
     808           5 :                 MAKE_STD_ZVAL(new_string);
     809           5 :                 ZVAL_STRING(new_string, value, 1);
     810             :                 
     811           5 :                 zend_hash_update(intern->parameter, name, name_len + 1, &new_string, sizeof(zval*), NULL);
     812           5 :                 RETURN_TRUE;
     813             :         } else {
     814           0 :                 WRONG_PARAM_COUNT;
     815             :         }
     816             :         
     817             : }
     818             : /* }}} end xsl_xsltprocessor_set_parameter */
     819             : 
     820             : /* {{{ proto string xsl_xsltprocessor_get_parameter(string namespace, string name);
     821             : */
     822           6 : PHP_FUNCTION(xsl_xsltprocessor_get_parameter)
     823             : {
     824             :         zval *id;
     825           6 :         int name_len = 0, namespace_len = 0;
     826             :         char *name, *namespace;
     827             :         zval **value;
     828             :         xsl_object *intern;
     829             : 
     830           6 :         DOM_GET_THIS(id);
     831             :         
     832           6 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &namespace, &namespace_len, &name, &name_len) == FAILURE) {
     833           3 :                 RETURN_FALSE;
     834             :         }
     835           3 :         intern = (xsl_object *)zend_object_store_get_object(id TSRMLS_CC);
     836           3 :         if ( zend_hash_find(intern->parameter, name, name_len + 1,  (void**) &value) == SUCCESS) {
     837           1 :                 convert_to_string_ex(value);
     838           1 :                 RETVAL_STRING(Z_STRVAL_PP(value),1);
     839             :         } else {
     840           2 :                 RETURN_FALSE;
     841             :         }
     842             : }
     843             : /* }}} end xsl_xsltprocessor_get_parameter */
     844             : 
     845             : /* {{{ proto bool xsl_xsltprocessor_remove_parameter(string namespace, string name);
     846             : */
     847           5 : PHP_FUNCTION(xsl_xsltprocessor_remove_parameter)
     848             : {
     849             :         zval *id;
     850           5 :         int name_len = 0, namespace_len = 0;
     851             :         char *name, *namespace;
     852             :         xsl_object *intern;
     853             : 
     854           5 :         DOM_GET_THIS(id);
     855             :         
     856           5 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &namespace, &namespace_len, &name, &name_len) == FAILURE) {
     857           3 :                 RETURN_FALSE;
     858             :         }
     859           2 :         intern = (xsl_object *)zend_object_store_get_object(id TSRMLS_CC);
     860           2 :         if ( zend_hash_del(intern->parameter, name, name_len + 1) == SUCCESS) {
     861           1 :                 RETURN_TRUE;
     862             :         } else {
     863           1 :                 RETURN_FALSE;
     864             :         }
     865             : }
     866             : /* }}} end xsl_xsltprocessor_remove_parameter */
     867             : 
     868             : /* {{{ proto void xsl_xsltprocessor_register_php_functions([mixed $restrict]);
     869             : */
     870          26 : PHP_FUNCTION(xsl_xsltprocessor_register_php_functions)
     871             : {
     872             :         zval *id;
     873             :         xsl_object *intern;
     874             :         zval *array_value, **entry, *new_string;
     875          26 :         int  name_len = 0;
     876             :         char *name;
     877             : 
     878          26 :         DOM_GET_THIS(id);
     879             :         
     880          26 :         if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "a",  &array_value) == SUCCESS) {
     881          15 :                 intern = (xsl_object *)zend_object_store_get_object(id TSRMLS_CC);
     882          15 :                 zend_hash_internal_pointer_reset(Z_ARRVAL_P(array_value));
     883             : 
     884          45 :                 while (zend_hash_get_current_data(Z_ARRVAL_P(array_value), (void **)&entry) == SUCCESS) {
     885          30 :                         SEPARATE_ZVAL(entry);
     886          15 :                         convert_to_string_ex(entry);
     887             :                         
     888          15 :                         MAKE_STD_ZVAL(new_string);
     889          15 :                         ZVAL_LONG(new_string,1);
     890             :                 
     891          15 :                         zend_hash_update(intern->registered_phpfunctions, Z_STRVAL_PP(entry), Z_STRLEN_PP(entry) + 1, &new_string, sizeof(zval*), NULL);
     892          15 :                         zend_hash_move_forward(Z_ARRVAL_P(array_value));
     893             :                 }
     894          15 :                 intern->registerPhpFunctions = 2;
     895             : 
     896          11 :         } else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "s",  &name, &name_len) == SUCCESS) {
     897           6 :                 intern = (xsl_object *)zend_object_store_get_object(id TSRMLS_CC);
     898             :                 
     899           6 :                 MAKE_STD_ZVAL(new_string);
     900           6 :                 ZVAL_LONG(new_string,1);
     901           6 :                 zend_hash_update(intern->registered_phpfunctions, name, name_len + 1, &new_string, sizeof(zval*), NULL);
     902           6 :                 intern->registerPhpFunctions = 2;
     903             :                 
     904             :         } else {
     905           5 :                 intern = (xsl_object *)zend_object_store_get_object(id TSRMLS_CC);
     906           5 :                 intern->registerPhpFunctions = 1;
     907             :         }
     908             :         
     909             : }
     910             : /* }}} end xsl_xsltprocessor_register_php_functions(); */
     911             : 
     912             : /* {{{ proto bool xsl_xsltprocessor_set_profiling(string filename) */
     913           0 : PHP_FUNCTION(xsl_xsltprocessor_set_profiling)
     914             : {
     915             :         zval *id;
     916             :         xsl_object *intern;
     917           0 :         char *filename = NULL;
     918             :         int filename_len;
     919           0 :         DOM_GET_THIS(id);
     920             : 
     921           0 :         if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "p!", &filename, &filename_len) == SUCCESS) {
     922           0 :                 intern = (xsl_object *)zend_object_store_get_object(id TSRMLS_CC);
     923           0 :                 if (intern->profiling) {
     924           0 :                         efree(intern->profiling);
     925             :                 }
     926           0 :                 if (filename != NULL) {
     927           0 :                         intern->profiling = estrndup(filename,filename_len);
     928             :                 } else {
     929           0 :                         intern->profiling = NULL;
     930             :                 }
     931           0 :                 RETURN_TRUE;
     932             :         } else {
     933           0 :                 WRONG_PARAM_COUNT;
     934             :         }
     935             : }
     936             : /* }}} end xsl_xsltprocessor_set_profiling */
     937             : 
     938             : /* {{{ proto long xsl_xsltprocessor_set_security_prefs(long securityPrefs) */
     939           4 : PHP_FUNCTION(xsl_xsltprocessor_set_security_prefs)
     940             : {
     941             :         zval *id;
     942             :         xsl_object *intern;
     943             :         long securityPrefs, oldSecurityPrefs;
     944             : 
     945           4 :         DOM_GET_THIS(id);
     946           4 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &securityPrefs) == FAILURE) {
     947           0 :                 return;
     948             :         }
     949           4 :         intern = (xsl_object *)zend_object_store_get_object(id TSRMLS_CC);
     950           4 :         oldSecurityPrefs = intern->securityPrefs; 
     951           4 :         intern->securityPrefs = securityPrefs;
     952             :         /* set this to 1 so that we know, it was set through this method. Can be removed, when we remove the ini setting */
     953           4 :         intern->securityPrefsSet = 1;
     954           4 :         RETURN_LONG(oldSecurityPrefs);
     955             : }
     956             : /* }}} end xsl_xsltprocessor_set_security_prefs */
     957             : 
     958             : /* {{{ proto long xsl_xsltprocessor_get_security_prefs() */
     959           0 : PHP_FUNCTION(xsl_xsltprocessor_get_security_prefs)
     960             : {
     961             :         zval *id;
     962             :         xsl_object *intern;
     963             : 
     964           0 :         DOM_GET_THIS(id);
     965           0 :         if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "") == SUCCESS) {
     966           0 :                 intern = (xsl_object *)zend_object_store_get_object(id TSRMLS_CC);
     967           0 :                 RETURN_LONG(intern->securityPrefs);
     968             :         } else {
     969           0 :                 WRONG_PARAM_COUNT;
     970             :         }
     971             : }
     972             : /* }}} end xsl_xsltprocessor_get_security_prefs */
     973             : 
     974             : 
     975             : 
     976             : /* {{{ proto bool xsl_xsltprocessor_has_exslt_support();
     977             : */
     978           1 : PHP_FUNCTION(xsl_xsltprocessor_has_exslt_support)
     979             : {
     980             : #if HAVE_XSL_EXSLT
     981           1 :         RETURN_TRUE;
     982             : #else
     983             :         RETURN_FALSE;
     984             : #endif
     985             : }
     986             : /* }}} end xsl_xsltprocessor_has_exslt_support(); */
     987             : 
     988             : /*
     989             :  * Local variables:
     990             :  * tab-width: 4
     991             :  * c-basic-offset: 4
     992             :  * End:
     993             :  * vim600: sw=4 ts=4 fdm=marker
     994             :  * vim<600: sw=4 ts=4
     995             :  */

Generated by: LCOV version 1.10

Generated at Thu, 16 Oct 2014 05:27:13 +0000 (5 days ago)

Copyright © 2005-2014 The PHP Group
All rights reserved.