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 - php_xsl.c (source / functions) Hit Total Coverage
Test: PHP Code Coverage Lines: 87 109 79.8 %
Date: 2014-10-22 Functions: 7 9 77.8 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :   +----------------------------------------------------------------------+
       3             :   | PHP Version 7                                                        |
       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             :   | Author: Christian Stocker <chregu@php.net>                           |
      16             :   +----------------------------------------------------------------------+
      17             : */
      18             : 
      19             : /* $Id$ */
      20             : 
      21             : #ifdef HAVE_CONFIG_H
      22             : #include "config.h"
      23             : #endif
      24             : 
      25             : #include "php.h"
      26             : #include "php_ini.h"
      27             : #include "ext/standard/info.h"
      28             : #include "php_xsl.h"
      29             : 
      30             : zend_class_entry *xsl_xsltprocessor_class_entry;
      31             : static zend_object_handlers xsl_object_handlers;
      32             : 
      33             : /* {{{ xsl_functions[]
      34             :  *
      35             :  * Every user visible function must have an entry in xsl_functions[].
      36             :  */
      37             : const zend_function_entry xsl_functions[] = {
      38             :         PHP_FE_END
      39             : };
      40             : /* }}} */
      41             : 
      42             : static const zend_module_dep xsl_deps[] = {
      43             :         ZEND_MOD_REQUIRED("libxml")
      44             :         ZEND_MOD_END
      45             : };
      46             : 
      47             : /* {{{ xsl_module_entry
      48             :  */
      49             : zend_module_entry xsl_module_entry = {
      50             : #if ZEND_MODULE_API_NO >= 20050617
      51             :         STANDARD_MODULE_HEADER_EX, NULL,
      52             :         xsl_deps,
      53             : #elif ZEND_MODULE_API_NO >= 20010901
      54             :         STANDARD_MODULE_HEADER,
      55             : #endif
      56             :         "xsl",
      57             :         xsl_functions,
      58             :         PHP_MINIT(xsl),
      59             :         PHP_MSHUTDOWN(xsl),
      60             :         NULL,
      61             :         NULL,
      62             :         PHP_MINFO(xsl),
      63             : #if ZEND_MODULE_API_NO >= 20010901
      64             :         "0.1", /* Replace with version number for your extension */
      65             : #endif
      66             :         STANDARD_MODULE_PROPERTIES
      67             : };
      68             : /* }}} */
      69             : 
      70             : #ifdef COMPILE_DL_XSL
      71             : ZEND_GET_MODULE(xsl)
      72             : #endif
      73             : 
      74             : /* {{{ xsl_objects_free_storage */
      75          47 : void xsl_objects_free_storage(zend_object *object TSRMLS_DC)
      76             : {
      77          47 :         xsl_object *intern = php_xsl_fetch_object(object);
      78             : 
      79          47 :         zend_object_std_dtor(&intern->std TSRMLS_CC);
      80             : 
      81          47 :         zend_hash_destroy(intern->parameter);
      82          47 :         FREE_HASHTABLE(intern->parameter);
      83             :         
      84          47 :         zend_hash_destroy(intern->registered_phpfunctions);
      85          47 :         FREE_HASHTABLE(intern->registered_phpfunctions);
      86             :         
      87          47 :         if (intern->node_list) {
      88           0 :                 zend_hash_destroy(intern->node_list);
      89           0 :                 FREE_HASHTABLE(intern->node_list);
      90             :         }
      91             : 
      92          47 :         if (intern->doc) {
      93           1 :                 php_libxml_decrement_doc_ref(intern->doc TSRMLS_CC);
      94           1 :                 efree(intern->doc);
      95             :         }
      96             : 
      97          47 :         if (intern->ptr) {
      98             :                 /* free wrapper */
      99          43 :                 if (((xsltStylesheetPtr) intern->ptr)->_private != NULL) {
     100          43 :                         ((xsltStylesheetPtr) intern->ptr)->_private = NULL;   
     101             :                 }
     102             : 
     103          43 :                 xsltFreeStylesheet((xsltStylesheetPtr) intern->ptr);
     104          43 :                 intern->ptr = NULL;
     105             :         }
     106          47 :         if (intern->profiling) {
     107           0 :                 efree(intern->profiling);
     108             :         }
     109          47 : }
     110             : /* }}} */
     111             : 
     112             : /* {{{ xsl_objects_new */
     113          47 : zend_object *xsl_objects_new(zend_class_entry *class_type TSRMLS_DC)
     114             : {
     115             :         xsl_object *intern;
     116             : 
     117          47 :         intern = ecalloc(1, sizeof(xsl_object) + sizeof(zval) * (class_type->default_properties_count - 1));
     118          47 :         intern->securityPrefs = XSL_SECPREF_DEFAULT;
     119             : 
     120          47 :         zend_object_std_init(&intern->std, class_type TSRMLS_CC);
     121          47 :         object_properties_init(&intern->std, class_type);
     122          47 :         ALLOC_HASHTABLE(intern->parameter);
     123          47 :         zend_hash_init(intern->parameter, 0, NULL, ZVAL_PTR_DTOR, 0);
     124          47 :         ALLOC_HASHTABLE(intern->registered_phpfunctions);
     125          47 :         zend_hash_init(intern->registered_phpfunctions, 0, NULL, ZVAL_PTR_DTOR, 0);
     126             : 
     127          47 :         intern->std.handlers = &xsl_object_handlers;
     128          47 :         return &intern->std;
     129             : }
     130             : /* }}} */
     131             : 
     132             : PHP_INI_BEGIN()
     133             : /* Default is not allowing any write operations. 
     134             :    XSL_SECPREF_CREATE_DIRECTORY | XSL_SECPREF_WRITE_NETWORK | XSL_SECPREF_WRITE_FILE == 44 
     135             : */
     136             : PHP_INI_ENTRY("xsl.security_prefs", "44", PHP_INI_ALL, NULL)
     137             : PHP_INI_END()
     138             : 
     139             : /* {{{ PHP_MINIT_FUNCTION
     140             :  */
     141       20423 : PHP_MINIT_FUNCTION(xsl)
     142             : {
     143             :         
     144             :         zend_class_entry ce;
     145             :         
     146       20423 :         memcpy(&xsl_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
     147       20423 :         xsl_object_handlers.offset = XtOffsetOf(xsl_object, std);
     148       20423 :         xsl_object_handlers.clone_obj = NULL;
     149       20423 :         xsl_object_handlers.free_obj = xsl_objects_free_storage;
     150             : 
     151       20423 :         REGISTER_XSL_CLASS(ce, "XSLTProcessor", NULL, php_xsl_xsltprocessor_class_functions, xsl_xsltprocessor_class_entry);
     152             : #if HAVE_XSL_EXSLT
     153       20423 :         exsltRegisterAll();
     154             : #endif
     155             :  
     156       20423 :         xsltRegisterExtModuleFunction ((const xmlChar *) "functionString",
     157             :                                    (const xmlChar *) "http://php.net/xsl",
     158             :                                    xsl_ext_function_string_php);
     159       20423 :         xsltRegisterExtModuleFunction ((const xmlChar *) "function",
     160             :                                    (const xmlChar *) "http://php.net/xsl",
     161             :                                    xsl_ext_function_object_php);
     162       20423 :         xsltSetGenericErrorFunc(NULL, php_libxml_error_handler);
     163             : 
     164       20423 :         REGISTER_LONG_CONSTANT("XSL_CLONE_AUTO",      0,     CONST_CS | CONST_PERSISTENT);
     165       20423 :         REGISTER_LONG_CONSTANT("XSL_CLONE_NEVER",    -1,     CONST_CS | CONST_PERSISTENT);
     166       20423 :         REGISTER_LONG_CONSTANT("XSL_CLONE_ALWAYS",    1,     CONST_CS | CONST_PERSISTENT);
     167             : 
     168       20423 :         REGISTER_LONG_CONSTANT("XSL_SECPREF_NONE",             XSL_SECPREF_NONE,             CONST_CS | CONST_PERSISTENT);
     169       20423 :         REGISTER_LONG_CONSTANT("XSL_SECPREF_READ_FILE",        XSL_SECPREF_READ_FILE,        CONST_CS | CONST_PERSISTENT);
     170       20423 :         REGISTER_LONG_CONSTANT("XSL_SECPREF_WRITE_FILE",       XSL_SECPREF_WRITE_FILE,       CONST_CS | CONST_PERSISTENT);
     171       20423 :         REGISTER_LONG_CONSTANT("XSL_SECPREF_CREATE_DIRECTORY", XSL_SECPREF_CREATE_DIRECTORY, CONST_CS | CONST_PERSISTENT);
     172       20423 :         REGISTER_LONG_CONSTANT("XSL_SECPREF_READ_NETWORK",     XSL_SECPREF_READ_NETWORK,     CONST_CS | CONST_PERSISTENT);
     173       20423 :         REGISTER_LONG_CONSTANT("XSL_SECPREF_WRITE_NETWORK",    XSL_SECPREF_WRITE_NETWORK,    CONST_CS | CONST_PERSISTENT);
     174       20423 :         REGISTER_LONG_CONSTANT("XSL_SECPREF_DEFAULT",          XSL_SECPREF_DEFAULT,          CONST_CS | CONST_PERSISTENT);
     175             : 
     176       20423 :         REGISTER_LONG_CONSTANT("LIBXSLT_VERSION",           LIBXSLT_VERSION,            CONST_CS | CONST_PERSISTENT);
     177       20423 :         REGISTER_STRING_CONSTANT("LIBXSLT_DOTTED_VERSION",  LIBXSLT_DOTTED_VERSION,     CONST_CS | CONST_PERSISTENT);
     178             : 
     179             : #if HAVE_XSL_EXSLT
     180       20423 :         REGISTER_LONG_CONSTANT("LIBEXSLT_VERSION",           LIBEXSLT_VERSION,            CONST_CS | CONST_PERSISTENT);
     181       20423 :         REGISTER_STRING_CONSTANT("LIBEXSLT_DOTTED_VERSION",  LIBEXSLT_DOTTED_VERSION,     CONST_CS | CONST_PERSISTENT);
     182             : #endif
     183             : 
     184       20423 :     REGISTER_INI_ENTRIES();
     185             : 
     186       20423 :         return SUCCESS;
     187             : }
     188             : /* }}} */
     189             : 
     190             : /* {{{ xsl_object_get_data */
     191           0 : zval *xsl_object_get_data(void *obj)
     192             : {
     193             :         zval *dom_wrapper;
     194           0 :         dom_wrapper = ((xsltStylesheetPtr) obj)->_private;
     195           0 :         return dom_wrapper;
     196             : }
     197             : /* }}} */
     198             : 
     199             : /* {{{ xsl_object_set_data */
     200          43 : static void xsl_object_set_data(void *obj, zval *wrapper TSRMLS_DC)
     201             : {
     202          43 :         ((xsltStylesheetPtr) obj)->_private = wrapper;
     203          43 : }
     204             : /* }}} */
     205             : 
     206             : /* {{{ php_xsl_set_object */
     207          43 : void php_xsl_set_object(zval *wrapper, void *obj TSRMLS_DC)
     208             : {
     209             :         xsl_object *object;
     210             : 
     211          43 :         object = Z_XSL_P(wrapper);
     212          43 :         object->ptr = obj;
     213          43 :         xsl_object_set_data(obj, wrapper TSRMLS_CC);
     214          43 : }
     215             : /* }}} */
     216             : 
     217             : /* {{{ php_xsl_create_object */
     218           0 : void php_xsl_create_object(xsltStylesheetPtr obj, zval *wrapper_in, zval *return_value  TSRMLS_DC)
     219             : {
     220             :         zval *wrapper;
     221             :         zend_class_entry *ce;
     222             : 
     223           0 :         if (!obj) {
     224           0 :                 wrapper = wrapper_in;
     225           0 :                 ZVAL_NULL(wrapper);
     226           0 :                 return;
     227             :         }
     228             : 
     229           0 :         if ((wrapper = xsl_object_get_data((void *) obj))) {
     230           0 :                 ZVAL_COPY(wrapper, wrapper_in);
     231           0 :                 return;
     232             :         }
     233             : 
     234           0 :         if (!wrapper_in) {
     235           0 :                 wrapper = return_value;
     236             :         } else {
     237           0 :                 wrapper = wrapper_in;
     238             :         }
     239             : 
     240             :         
     241           0 :         ce = xsl_xsltprocessor_class_entry;
     242             : 
     243           0 :         if (!wrapper_in) {
     244           0 :                 object_init_ex(wrapper, ce);
     245             :         }
     246           0 :         php_xsl_set_object(wrapper, (void *) obj TSRMLS_CC);
     247             : 
     248           0 :         return;
     249             : }
     250             : /* }}} */
     251             : 
     252             : /* {{{ PHP_MSHUTDOWN_FUNCTION
     253             :  */
     254       20457 : PHP_MSHUTDOWN_FUNCTION(xsl)
     255             : {
     256       20457 :         xsltUnregisterExtModuleFunction ((const xmlChar *) "functionString",
     257             :                                    (const xmlChar *) "http://php.net/xsl");
     258       20457 :         xsltUnregisterExtModuleFunction ((const xmlChar *) "function",
     259             :                                    (const xmlChar *) "http://php.net/xsl");
     260       20457 :         xsltSetGenericErrorFunc(NULL, NULL);
     261       20457 :         xsltCleanupGlobals();
     262             : 
     263       20457 :         UNREGISTER_INI_ENTRIES();
     264             : 
     265       20457 :         return SUCCESS;
     266             : }
     267             : /* }}} */
     268             : 
     269             : /* {{{ PHP_MINFO_FUNCTION
     270             :  */
     271         143 : PHP_MINFO_FUNCTION(xsl)
     272             : {
     273         143 :         php_info_print_table_start();
     274             :         {
     275             :                 char buffer[128];
     276             :                 int major, minor, subminor;
     277             : 
     278         143 :                 php_info_print_table_row(2, "XSL", "enabled");
     279         143 :                 major = xsltLibxsltVersion/10000;
     280         143 :                 minor = (xsltLibxsltVersion - major * 10000) / 100;
     281         143 :                 subminor = (xsltLibxsltVersion - major * 10000 - minor * 100);
     282         143 :                 snprintf(buffer, 128, "%d.%d.%d", major, minor, subminor);
     283         143 :                 php_info_print_table_row(2, "libxslt Version", buffer);
     284         143 :                 major = xsltLibxmlVersion/10000;
     285         143 :                 minor = (xsltLibxmlVersion - major * 10000) / 100;
     286         143 :                 subminor = (xsltLibxmlVersion - major * 10000 - minor * 100);
     287         143 :                 snprintf(buffer, 128, "%d.%d.%d", major, minor, subminor);
     288         143 :                 php_info_print_table_row(2, "libxslt compiled against libxml Version", buffer);
     289             :         }
     290             : #if HAVE_XSL_EXSLT
     291         143 :         php_info_print_table_row(2, "EXSLT", "enabled");
     292         143 :         php_info_print_table_row(2, "libexslt Version", LIBEXSLT_DOTTED_VERSION);
     293             : #endif
     294         143 :         php_info_print_table_end();
     295         143 : }
     296             : /* }}} */
     297             : 
     298             : /*
     299             :  * Local variables:
     300             :  * tab-width: 4
     301             :  * c-basic-offset: 4
     302             :  * End:
     303             :  * vim600: noet sw=4 ts=4 fdm=marker
     304             :  * vim<600: noet sw=4 ts=4
     305             :  */

Generated by: LCOV version 1.10

Generated at Wed, 22 Oct 2014 07:25:01 +0000 (5 hours ago)

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