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: 85 107 79.4 %
Date: 2015-08-25 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-2015 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             :         STANDARD_MODULE_HEADER_EX, NULL,
      51             :         xsl_deps,
      52             :         "xsl",
      53             :         xsl_functions,
      54             :         PHP_MINIT(xsl),
      55             :         PHP_MSHUTDOWN(xsl),
      56             :         NULL,
      57             :         NULL,
      58             :         PHP_MINFO(xsl),
      59             :         PHP_XSL_VERSION,
      60             :         STANDARD_MODULE_PROPERTIES
      61             : };
      62             : /* }}} */
      63             : 
      64             : #ifdef COMPILE_DL_XSL
      65             : ZEND_GET_MODULE(xsl)
      66             : #endif
      67             : 
      68             : /* {{{ xsl_objects_free_storage */
      69          67 : void xsl_objects_free_storage(zend_object *object)
      70             : {
      71          67 :         xsl_object *intern = php_xsl_fetch_object(object);
      72             : 
      73          67 :         zend_object_std_dtor(&intern->std);
      74             : 
      75          67 :         zend_hash_destroy(intern->parameter);
      76          67 :         FREE_HASHTABLE(intern->parameter);
      77             : 
      78          67 :         zend_hash_destroy(intern->registered_phpfunctions);
      79          67 :         FREE_HASHTABLE(intern->registered_phpfunctions);
      80             : 
      81          67 :         if (intern->node_list) {
      82           0 :                 zend_hash_destroy(intern->node_list);
      83           0 :                 FREE_HASHTABLE(intern->node_list);
      84             :         }
      85             : 
      86          67 :         if (intern->doc) {
      87           1 :                 php_libxml_decrement_doc_ref(intern->doc);
      88           1 :                 efree(intern->doc);
      89             :         }
      90             : 
      91          67 :         if (intern->ptr) {
      92             :                 /* free wrapper */
      93          61 :                 if (((xsltStylesheetPtr) intern->ptr)->_private != NULL) {
      94          61 :                         ((xsltStylesheetPtr) intern->ptr)->_private = NULL;
      95             :                 }
      96             : 
      97          61 :                 xsltFreeStylesheet((xsltStylesheetPtr) intern->ptr);
      98          61 :                 intern->ptr = NULL;
      99             :         }
     100          67 :         if (intern->profiling) {
     101           0 :                 efree(intern->profiling);
     102             :         }
     103          67 : }
     104             : /* }}} */
     105             : 
     106             : /* {{{ xsl_objects_new */
     107          67 : zend_object *xsl_objects_new(zend_class_entry *class_type)
     108             : {
     109             :         xsl_object *intern;
     110             : 
     111          67 :         intern = ecalloc(1, sizeof(xsl_object) + zend_object_properties_size(class_type));
     112          67 :         intern->securityPrefs = XSL_SECPREF_DEFAULT;
     113             : 
     114          67 :         zend_object_std_init(&intern->std, class_type);
     115          67 :         object_properties_init(&intern->std, class_type);
     116          67 :         ALLOC_HASHTABLE(intern->parameter);
     117          67 :         zend_hash_init(intern->parameter, 0, NULL, ZVAL_PTR_DTOR, 0);
     118          67 :         ALLOC_HASHTABLE(intern->registered_phpfunctions);
     119          67 :         zend_hash_init(intern->registered_phpfunctions, 0, NULL, ZVAL_PTR_DTOR, 0);
     120             : 
     121          67 :         intern->std.handlers = &xsl_object_handlers;
     122          67 :         return &intern->std;
     123             : }
     124             : /* }}} */
     125             : 
     126             : /* {{{ PHP_MINIT_FUNCTION
     127             :  */
     128       21285 : PHP_MINIT_FUNCTION(xsl)
     129             : {
     130             : 
     131             :         zend_class_entry ce;
     132             : 
     133       21285 :         memcpy(&xsl_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
     134       21285 :         xsl_object_handlers.offset = XtOffsetOf(xsl_object, std);
     135       21285 :         xsl_object_handlers.clone_obj = NULL;
     136       21285 :         xsl_object_handlers.free_obj = xsl_objects_free_storage;
     137             : 
     138       21285 :         REGISTER_XSL_CLASS(ce, "XSLTProcessor", NULL, php_xsl_xsltprocessor_class_functions, xsl_xsltprocessor_class_entry);
     139             : #if HAVE_XSL_EXSLT
     140       21285 :         exsltRegisterAll();
     141             : #endif
     142             : 
     143       21285 :         xsltRegisterExtModuleFunction ((const xmlChar *) "functionString",
     144             :                                    (const xmlChar *) "http://php.net/xsl",
     145             :                                    xsl_ext_function_string_php);
     146       21285 :         xsltRegisterExtModuleFunction ((const xmlChar *) "function",
     147             :                                    (const xmlChar *) "http://php.net/xsl",
     148             :                                    xsl_ext_function_object_php);
     149       21285 :         xsltSetGenericErrorFunc(NULL, php_libxml_error_handler);
     150             : 
     151       21285 :         REGISTER_LONG_CONSTANT("XSL_CLONE_AUTO",      0,     CONST_CS | CONST_PERSISTENT);
     152       21285 :         REGISTER_LONG_CONSTANT("XSL_CLONE_NEVER",    -1,     CONST_CS | CONST_PERSISTENT);
     153       21285 :         REGISTER_LONG_CONSTANT("XSL_CLONE_ALWAYS",    1,     CONST_CS | CONST_PERSISTENT);
     154             : 
     155       21285 :         REGISTER_LONG_CONSTANT("XSL_SECPREF_NONE",             XSL_SECPREF_NONE,             CONST_CS | CONST_PERSISTENT);
     156       21285 :         REGISTER_LONG_CONSTANT("XSL_SECPREF_READ_FILE",        XSL_SECPREF_READ_FILE,        CONST_CS | CONST_PERSISTENT);
     157       21285 :         REGISTER_LONG_CONSTANT("XSL_SECPREF_WRITE_FILE",       XSL_SECPREF_WRITE_FILE,       CONST_CS | CONST_PERSISTENT);
     158       21285 :         REGISTER_LONG_CONSTANT("XSL_SECPREF_CREATE_DIRECTORY", XSL_SECPREF_CREATE_DIRECTORY, CONST_CS | CONST_PERSISTENT);
     159       21285 :         REGISTER_LONG_CONSTANT("XSL_SECPREF_READ_NETWORK",     XSL_SECPREF_READ_NETWORK,     CONST_CS | CONST_PERSISTENT);
     160       21285 :         REGISTER_LONG_CONSTANT("XSL_SECPREF_WRITE_NETWORK",    XSL_SECPREF_WRITE_NETWORK,    CONST_CS | CONST_PERSISTENT);
     161       21285 :         REGISTER_LONG_CONSTANT("XSL_SECPREF_DEFAULT",          XSL_SECPREF_DEFAULT,          CONST_CS | CONST_PERSISTENT);
     162             : 
     163       21285 :         REGISTER_LONG_CONSTANT("LIBXSLT_VERSION",           LIBXSLT_VERSION,            CONST_CS | CONST_PERSISTENT);
     164       21285 :         REGISTER_STRING_CONSTANT("LIBXSLT_DOTTED_VERSION",  LIBXSLT_DOTTED_VERSION,     CONST_CS | CONST_PERSISTENT);
     165             : 
     166             : #if HAVE_XSL_EXSLT
     167       21285 :         REGISTER_LONG_CONSTANT("LIBEXSLT_VERSION",           LIBEXSLT_VERSION,            CONST_CS | CONST_PERSISTENT);
     168       21285 :         REGISTER_STRING_CONSTANT("LIBEXSLT_DOTTED_VERSION",  LIBEXSLT_DOTTED_VERSION,     CONST_CS | CONST_PERSISTENT);
     169             : #endif
     170             : 
     171       21285 :         return SUCCESS;
     172             : }
     173             : /* }}} */
     174             : 
     175             : /* {{{ xsl_object_get_data */
     176           0 : zval *xsl_object_get_data(void *obj)
     177             : {
     178             :         zval *dom_wrapper;
     179           0 :         dom_wrapper = ((xsltStylesheetPtr) obj)->_private;
     180           0 :         return dom_wrapper;
     181             : }
     182             : /* }}} */
     183             : 
     184             : /* {{{ xsl_object_set_data */
     185          61 : static void xsl_object_set_data(void *obj, zval *wrapper)
     186             : {
     187          61 :         ((xsltStylesheetPtr) obj)->_private = wrapper;
     188          61 : }
     189             : /* }}} */
     190             : 
     191             : /* {{{ php_xsl_set_object */
     192          61 : void php_xsl_set_object(zval *wrapper, void *obj)
     193             : {
     194             :         xsl_object *object;
     195             : 
     196          61 :         object = Z_XSL_P(wrapper);
     197          61 :         object->ptr = obj;
     198          61 :         xsl_object_set_data(obj, wrapper);
     199          61 : }
     200             : /* }}} */
     201             : 
     202             : /* {{{ php_xsl_create_object */
     203           0 : void php_xsl_create_object(xsltStylesheetPtr obj, zval *wrapper_in, zval *return_value )
     204             : {
     205             :         zval *wrapper;
     206             :         zend_class_entry *ce;
     207             : 
     208           0 :         if (!obj) {
     209           0 :                 wrapper = wrapper_in;
     210           0 :                 ZVAL_NULL(wrapper);
     211           0 :                 return;
     212             :         }
     213             : 
     214           0 :         if ((wrapper = xsl_object_get_data((void *) obj))) {
     215           0 :                 ZVAL_COPY(wrapper, wrapper_in);
     216           0 :                 return;
     217             :         }
     218             : 
     219           0 :         if (!wrapper_in) {
     220           0 :                 wrapper = return_value;
     221             :         } else {
     222           0 :                 wrapper = wrapper_in;
     223             :         }
     224             : 
     225             : 
     226           0 :         ce = xsl_xsltprocessor_class_entry;
     227             : 
     228           0 :         if (!wrapper_in) {
     229           0 :                 object_init_ex(wrapper, ce);
     230             :         }
     231           0 :         php_xsl_set_object(wrapper, (void *) obj);
     232             : 
     233           0 :         return;
     234             : }
     235             : /* }}} */
     236             : 
     237             : /* {{{ PHP_MSHUTDOWN_FUNCTION
     238             :  */
     239       21321 : PHP_MSHUTDOWN_FUNCTION(xsl)
     240             : {
     241       21321 :         xsltUnregisterExtModuleFunction ((const xmlChar *) "functionString",
     242             :                                    (const xmlChar *) "http://php.net/xsl");
     243       21321 :         xsltUnregisterExtModuleFunction ((const xmlChar *) "function",
     244             :                                    (const xmlChar *) "http://php.net/xsl");
     245       21321 :         xsltSetGenericErrorFunc(NULL, NULL);
     246       21321 :         xsltCleanupGlobals();
     247             : 
     248       21321 :         return SUCCESS;
     249             : }
     250             : /* }}} */
     251             : 
     252             : /* {{{ PHP_MINFO_FUNCTION
     253             :  */
     254         142 : PHP_MINFO_FUNCTION(xsl)
     255             : {
     256         142 :         php_info_print_table_start();
     257             :         {
     258             :                 char buffer[128];
     259             :                 int major, minor, subminor;
     260             : 
     261         142 :                 php_info_print_table_row(2, "XSL", "enabled");
     262         142 :                 major = xsltLibxsltVersion/10000;
     263         142 :                 minor = (xsltLibxsltVersion - major * 10000) / 100;
     264         142 :                 subminor = (xsltLibxsltVersion - major * 10000 - minor * 100);
     265         142 :                 snprintf(buffer, 128, "%d.%d.%d", major, minor, subminor);
     266         142 :                 php_info_print_table_row(2, "libxslt Version", buffer);
     267         142 :                 major = xsltLibxmlVersion/10000;
     268         142 :                 minor = (xsltLibxmlVersion - major * 10000) / 100;
     269         142 :                 subminor = (xsltLibxmlVersion - major * 10000 - minor * 100);
     270         142 :                 snprintf(buffer, 128, "%d.%d.%d", major, minor, subminor);
     271         142 :                 php_info_print_table_row(2, "libxslt compiled against libxml Version", buffer);
     272             :         }
     273             : #if HAVE_XSL_EXSLT
     274         142 :         php_info_print_table_row(2, "EXSLT", "enabled");
     275         142 :         php_info_print_table_row(2, "libexslt Version", LIBEXSLT_DOTTED_VERSION);
     276             : #endif
     277         142 :         php_info_print_table_end();
     278         142 : }
     279             : /* }}} */
     280             : 
     281             : /*
     282             :  * Local variables:
     283             :  * tab-width: 4
     284             :  * c-basic-offset: 4
     285             :  * End:
     286             :  * vim600: noet sw=4 ts=4 fdm=marker
     287             :  * vim<600: noet sw=4 ts=4
     288             :  */

Generated by: LCOV version 1.10

Generated at Tue, 25 Aug 2015 07:24:30 +0000 (3 days ago)

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