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

LTP GCOV extension - code coverage report
Current view: directory - xsl - php_xsl.c
Test: PHP Code Coverage
Date: 2009-11-23 Instrumented lines: 117
Code covered: 77.8 % Executed lines: 91
Legend: not executed executed

       1                 : /*
       2                 :   +----------------------------------------------------------------------+
       3                 :   | PHP Version 6                                                        |
       4                 :   +----------------------------------------------------------------------+
       5                 :   | Copyright (c) 1997-2009 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: php_xsl.c 276986 2009-03-10 23:40:06Z helly $ */
      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                 :         {NULL, NULL, NULL}  /* Must be the last line in xsl_functions[] */
      39                 : };
      40                 : /* }}} */
      41                 : 
      42                 : static const zend_module_dep xsl_deps[] = {
      43                 :         ZEND_MOD_REQUIRED("libxml")
      44                 :         {NULL, NULL, NULL}
      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                 :         PHP_RINIT(xsl),         /* Replace with NULL if there's nothing to do at request start */
      61                 :         PHP_RSHUTDOWN(xsl),     /* Replace with NULL if there's nothing to do at request end */
      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                 : void xsl_objects_free_storage(void *object TSRMLS_DC)
      76              26 : {
      77              26 :         xsl_object *intern = (xsl_object *)object;
      78                 : 
      79              26 :         zend_object_std_dtor(&intern->std TSRMLS_CC);
      80                 : 
      81              26 :         zend_hash_destroy(intern->parameter);
      82              26 :         FREE_HASHTABLE(intern->parameter);
      83                 :         
      84              26 :         zend_hash_destroy(intern->registered_phpfunctions);
      85              26 :         FREE_HASHTABLE(intern->registered_phpfunctions);
      86                 :         
      87              26 :         if (intern->node_list) {
      88               0 :                 zend_hash_destroy(intern->node_list);
      89               0 :                 FREE_HASHTABLE(intern->node_list);
      90                 :         }
      91                 : 
      92              26 :         if (intern->doc) {
      93               1 :                 php_libxml_decrement_doc_ref(intern->doc TSRMLS_CC);
      94               1 :                 efree(intern->doc);
      95                 :         }
      96                 : 
      97              26 :         if (intern->ptr) {
      98                 :                 /* free wrapper */
      99              22 :                 if (((xsltStylesheetPtr) intern->ptr)->_private != NULL) {
     100              22 :                         ((xsltStylesheetPtr) intern->ptr)->_private = NULL;   
     101                 :                 }
     102                 : 
     103              22 :                 xsltFreeStylesheet((xsltStylesheetPtr) intern->ptr);
     104              22 :                 intern->ptr = NULL;
     105                 :         }
     106              26 :         if (intern->profiling) {
     107               0 :                 efree(intern->profiling);
     108                 :         }
     109              26 :         efree(object);
     110              26 : }
     111                 : /* }}} */
     112                 : 
     113                 : /* {{{ xsl_objects_new */
     114                 : zend_object_value xsl_objects_new(zend_class_entry *class_type TSRMLS_DC)
     115              26 : {
     116                 :         zend_object_value retval;
     117                 :         xsl_object *intern;
     118                 :         zval *tmp;
     119                 : 
     120              26 :         intern = emalloc(sizeof(xsl_object));
     121              26 :         intern->ptr = NULL;
     122              26 :         intern->prop_handler = NULL;
     123              26 :         intern->parameter = NULL;
     124              26 :         intern->hasKeys = 0;
     125              26 :         intern->registerPhpFunctions = 0;
     126              26 :         intern->registered_phpfunctions = NULL;
     127              26 :         intern->node_list = NULL;
     128              26 :         intern->doc = NULL;
     129              26 :         intern->profiling = NULL;
     130                 : 
     131              26 :         zend_object_std_init(&intern->std, class_type TSRMLS_CC);
     132              26 :         zend_hash_copy(intern->std.properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
     133              26 :         ALLOC_HASHTABLE(intern->parameter);
     134              26 :         zend_hash_init(intern->parameter, 0, NULL, ZVAL_PTR_DTOR, 0);
     135              26 :         ALLOC_HASHTABLE(intern->registered_phpfunctions);
     136              26 :         zend_u_hash_init(intern->registered_phpfunctions, 0, NULL, ZVAL_PTR_DTOR, 0, UG(unicode));
     137              26 :         retval.handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t)zend_objects_destroy_object, (zend_objects_free_object_storage_t) xsl_objects_free_storage, NULL TSRMLS_CC);
     138              26 :         intern->handle = retval.handle;
     139              26 :         retval.handlers = &xsl_object_handlers;
     140              26 :         return retval;
     141                 : }
     142                 : /* }}} */
     143                 : 
     144                 : /* {{{ PHP_MINIT_FUNCTION
     145                 :  */
     146                 : PHP_MINIT_FUNCTION(xsl)
     147           17007 : {
     148                 :         
     149                 :         zend_class_entry ce;
     150                 :         
     151           17007 :         memcpy(&xsl_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
     152           17007 :         xsl_object_handlers.clone_obj = NULL;
     153                 : 
     154           17007 :         REGISTER_XSL_CLASS(ce, "XSLTProcessor", NULL, php_xsl_xsltprocessor_class_functions, xsl_xsltprocessor_class_entry);
     155                 : #if HAVE_XSL_EXSLT
     156           17007 :         exsltRegisterAll();
     157                 : #endif
     158                 :  
     159           17007 :         xsltRegisterExtModuleFunction ((const xmlChar *) "functionString",
     160                 :                                    (const xmlChar *) "http://php.net/xsl",
     161                 :                                    xsl_ext_function_string_php);
     162           17007 :         xsltRegisterExtModuleFunction ((const xmlChar *) "function",
     163                 :                                    (const xmlChar *) "http://php.net/xsl",
     164                 :                                    xsl_ext_function_object_php);
     165                 : 
     166           17007 :         REGISTER_LONG_CONSTANT("XSL_CLONE_AUTO",      0,     CONST_CS | CONST_PERSISTENT);
     167           17007 :         REGISTER_LONG_CONSTANT("XSL_CLONE_NEVER",    -1,     CONST_CS | CONST_PERSISTENT);
     168           17007 :         REGISTER_LONG_CONSTANT("XSL_CLONE_ALWAYS",    1,     CONST_CS | CONST_PERSISTENT);
     169           17007 :         REGISTER_LONG_CONSTANT("LIBXSLT_VERSION",           LIBXSLT_VERSION,            CONST_CS | CONST_PERSISTENT);
     170           17007 :         REGISTER_STRING_CONSTANT("LIBXSLT_DOTTED_VERSION",  LIBXSLT_DOTTED_VERSION,     CONST_CS | CONST_PERSISTENT);
     171                 : 
     172                 : #if HAVE_XSL_EXSLT
     173           17007 :         REGISTER_LONG_CONSTANT("LIBEXSLT_VERSION",           LIBEXSLT_VERSION,            CONST_CS | CONST_PERSISTENT);
     174           17007 :         REGISTER_STRING_CONSTANT("LIBEXSLT_DOTTED_VERSION",  LIBEXSLT_DOTTED_VERSION,     CONST_CS | CONST_PERSISTENT);
     175                 : #endif
     176           17007 :         return SUCCESS;
     177                 : }
     178                 : /* }}} */
     179                 : 
     180                 : /* {{{ xsl_object_get_data */
     181                 : zval *xsl_object_get_data(void *obj)
     182               0 : {
     183                 :         zval *dom_wrapper;
     184               0 :         dom_wrapper = ((xsltStylesheetPtr) obj)->_private;
     185               0 :         return dom_wrapper;
     186                 : }
     187                 : /* }}} */
     188                 : 
     189                 : /* {{{ xsl_object_set_data */
     190                 : static void xsl_object_set_data(void *obj, zval *wrapper TSRMLS_DC)
     191              22 : {
     192              22 :         ((xsltStylesheetPtr) obj)->_private = wrapper;
     193              22 : }
     194                 : /* }}} */
     195                 : 
     196                 : /* {{{ php_xsl_set_object */
     197                 : void php_xsl_set_object(zval *wrapper, void *obj TSRMLS_DC)
     198              22 : {
     199                 :         xsl_object *object;
     200                 : 
     201              22 :         object = (xsl_object *)zend_objects_get_address(wrapper TSRMLS_CC);
     202              22 :         object->ptr = obj;
     203              22 :         xsl_object_set_data(obj, wrapper TSRMLS_CC);
     204              22 : }
     205                 : /* }}} */
     206                 : 
     207                 : /* {{{ php_xsl_create_object */
     208                 : zval *php_xsl_create_object(xsltStylesheetPtr obj, int *found, zval *wrapper_in, zval *return_value  TSRMLS_DC)
     209               0 : {
     210                 :         zval *wrapper;
     211                 :         zend_class_entry *ce;
     212                 : 
     213               0 :         *found = 0;
     214                 : 
     215               0 :         if (!obj) {
     216               0 :                 if(!wrapper_in) {
     217               0 :                         ALLOC_ZVAL(wrapper);
     218                 :                 } else {
     219               0 :                         wrapper = wrapper_in;
     220                 :                 }
     221               0 :                 ZVAL_NULL(wrapper);
     222               0 :                 return wrapper;
     223                 :         }
     224                 : 
     225               0 :         if ((wrapper = (zval *) xsl_object_get_data((void *) obj))) {
     226               0 :                 zval_add_ref(&wrapper);
     227               0 :                 *found = 1;
     228               0 :                 return wrapper;
     229                 :         }
     230                 : 
     231               0 :         if(!wrapper_in) {
     232               0 :                 wrapper = return_value;
     233                 :         } else {
     234               0 :                 wrapper = wrapper_in;
     235                 :         }
     236                 : 
     237                 :         
     238               0 :         ce = xsl_xsltprocessor_class_entry;
     239                 : 
     240               0 :         if(!wrapper_in) {
     241               0 :                 object_init_ex(wrapper, ce);
     242                 :         }
     243               0 :         php_xsl_set_object(wrapper, (void *) obj TSRMLS_CC);
     244               0 :         return (wrapper);
     245                 : }
     246                 : /* }}} */
     247                 : 
     248                 : /* {{{ PHP_MSHUTDOWN_FUNCTION
     249                 :  */
     250                 : PHP_MSHUTDOWN_FUNCTION(xsl)
     251           17039 : {
     252           17039 :         xsltUnregisterExtModuleFunction ((const xmlChar *) "functionString",
     253                 :                                    (const xmlChar *) "http://php.net/xsl");
     254           17039 :         xsltUnregisterExtModuleFunction ((const xmlChar *) "function",
     255                 :                                    (const xmlChar *) "http://php.net/xsl");
     256                 : 
     257           17039 :         xsltCleanupGlobals();
     258                 : 
     259           17039 :         return SUCCESS;
     260                 : }
     261                 : /* }}} */
     262                 : 
     263                 : /* {{{ PHP_RINIT_FUNCTION
     264                 :  */
     265                 : PHP_RINIT_FUNCTION(xsl)
     266           16993 : {
     267           16993 :         xsltSetGenericErrorFunc(NULL, php_libxml_error_handler);
     268           16993 :         return SUCCESS;
     269                 : }
     270                 : /* }}} */
     271                 : 
     272                 : /* {{{ PHP_RSHUTDOWN_FUNCTION
     273                 :  */
     274                 : PHP_RSHUTDOWN_FUNCTION(xsl)
     275           17025 : {
     276           17025 :         xsltSetGenericErrorFunc(NULL, NULL);
     277           17025 :         return SUCCESS;
     278                 : }
     279                 : /* }}} */
     280                 : 
     281                 : /* {{{ PHP_MINFO_FUNCTION
     282                 :  */
     283                 : PHP_MINFO_FUNCTION(xsl)
     284              43 : {
     285              43 :         php_info_print_table_start();
     286                 :         {
     287                 :                 char buffer[128];
     288                 :                 int major, minor, subminor;
     289                 : 
     290              43 :                 php_info_print_table_row(2, "XSL", "enabled");
     291              43 :                 major = xsltLibxsltVersion/10000;
     292              43 :                 minor = (xsltLibxsltVersion - major * 10000) / 100;
     293              43 :                 subminor = (xsltLibxsltVersion - major * 10000 - minor * 100);
     294              43 :                 snprintf(buffer, 128, "%d.%d.%d", major, minor, subminor);
     295              43 :                 php_info_print_table_row(2, "libxslt Version", buffer);
     296              43 :                 major = xsltLibxmlVersion/10000;
     297              43 :                 minor = (xsltLibxmlVersion - major * 10000) / 100;
     298              43 :                 subminor = (xsltLibxmlVersion - major * 10000 - minor * 100);
     299              43 :                 snprintf(buffer, 128, "%d.%d.%d", major, minor, subminor);
     300              43 :                 php_info_print_table_row(2, "libxslt compiled against libxml Version", buffer);
     301                 :         }
     302                 : #if HAVE_XSL_EXSLT
     303              43 :         php_info_print_table_row(2, "EXSLT", "enabled");
     304              43 :         php_info_print_table_row(2, "libexslt Version", LIBEXSLT_DOTTED_VERSION);
     305                 : #endif
     306              43 :         php_info_print_table_end();
     307              43 : }
     308                 : /* }}} */
     309                 : 
     310                 : /*
     311                 :  * Local variables:
     312                 :  * tab-width: 4
     313                 :  * c-basic-offset: 4
     314                 :  * End:
     315                 :  * vim600: noet sw=4 ts=4 fdm=marker
     316                 :  * vim<600: noet sw=4 ts=4
     317                 :  */

Generated by: LTP GCOV extension version 1.5

Generated at Mon, 23 Nov 2009 17:39:44 +0000 (35 hours ago)

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