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 - dom - processinginstruction.c
Test: PHP Code Coverage
Date: 2009-11-23 Instrumented lines: 56
Code covered: 67.9 % Executed lines: 38
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                 :    | Authors: Christian Stocker <chregu@php.net>                          |
      16                 :    |          Rob Richards <rrichards@php.net>                            |
      17                 :    +----------------------------------------------------------------------+
      18                 : */
      19                 : 
      20                 : /* $Id: processinginstruction.c 281094 2009-05-25 14:32:15Z felipe $ */
      21                 : 
      22                 : #ifdef HAVE_CONFIG_H
      23                 : #include "config.h"
      24                 : #endif
      25                 : 
      26                 : #include "php.h"
      27                 : #if HAVE_LIBXML && HAVE_DOM
      28                 : #include "php_dom.h"
      29                 : 
      30                 : /* {{{ arginfo */
      31                 : ZEND_BEGIN_ARG_INFO_EX(arginfo_dom_processinginstruction_construct, 0, 0, 1)
      32                 :         ZEND_ARG_INFO(0, name)
      33                 :         ZEND_ARG_INFO(0, value)
      34                 : ZEND_END_ARG_INFO();
      35                 : /* }}} */
      36                 : 
      37                 : /*
      38                 : * class DOMProcessingInstruction extends DOMNode 
      39                 : *
      40                 : * URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-1004215813
      41                 : * Since: 
      42                 : */
      43                 : 
      44                 : const zend_function_entry php_dom_processinginstruction_class_functions[] = {
      45                 :         PHP_ME(domprocessinginstruction, __construct, arginfo_dom_processinginstruction_construct, ZEND_ACC_PUBLIC)
      46                 :         {NULL, NULL, NULL}
      47                 : };
      48                 : 
      49                 : /* {{{ proto void DOMProcessingInstruction::__construct(string name, [string value]) U */
      50                 : PHP_METHOD(domprocessinginstruction, __construct)
      51               1 : {
      52                 : 
      53                 :         zval *id;
      54               1 :         xmlNodePtr nodep = NULL, oldnode = NULL;
      55                 :         dom_object *intern;
      56               1 :         char *name, *value = NULL;
      57                 :         int name_len, value_len, name_valid;
      58                 :         zend_error_handling error_handling;
      59                 : 
      60               1 :         zend_replace_error_handling(EH_THROW, dom_domexception_class_entry, &error_handling TSRMLS_CC);
      61               1 :         if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os&|s&", &id, dom_processinginstruction_class_entry, &name, &name_len, UG(utf8_conv), &value, &value_len, UG(utf8_conv)) == FAILURE) {
      62               0 :                 zend_restore_error_handling(&error_handling TSRMLS_CC);
      63               0 :                 return;
      64                 :         }
      65               1 :         zend_restore_error_handling(&error_handling TSRMLS_CC);
      66                 : 
      67               1 :         name_valid = xmlValidateName((xmlChar *) name, 0);
      68               1 :         if (name_valid != 0) {
      69               0 :                 php_dom_throw_error(INVALID_CHARACTER_ERR, 1 TSRMLS_CC);
      70               0 :                 RETURN_FALSE;
      71                 :         }
      72                 : 
      73               1 :         nodep = xmlNewPI((xmlChar *) name, (xmlChar *) value);
      74                 : 
      75               1 :         if (!nodep) {
      76               0 :                 php_dom_throw_error(INVALID_STATE_ERR, 1 TSRMLS_CC);
      77               0 :                 RETURN_FALSE;
      78                 :         }
      79                 : 
      80               1 :         intern = (dom_object *)zend_object_store_get_object(id TSRMLS_CC);
      81               1 :         if (intern != NULL) {
      82               1 :                 oldnode = dom_object_get_node(intern);
      83               1 :                 if (oldnode != NULL) {
      84               0 :                         php_libxml_node_free_resource(oldnode  TSRMLS_CC);
      85                 :                 }
      86               1 :                 php_libxml_increment_node_ptr((php_libxml_node_object *)intern, nodep, (void *)intern TSRMLS_CC);
      87                 :         }
      88                 : }
      89                 : /* }}} end DOMProcessingInstruction::__construct */
      90                 : 
      91                 : /* {{{ target   string  
      92                 : readonly=yes 
      93                 : URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-1478689192
      94                 : Since: 
      95                 : */
      96                 : int dom_processinginstruction_target_read(dom_object *obj, zval **retval TSRMLS_DC)
      97               1 : {
      98                 :         xmlNodePtr nodep;
      99                 : 
     100               1 :         nodep = dom_object_get_node(obj);
     101                 : 
     102               1 :         if (nodep == NULL) {
     103               0 :                 php_dom_throw_error(INVALID_STATE_ERR, 0 TSRMLS_CC);
     104               0 :                 return FAILURE;
     105                 :         }
     106                 : 
     107               1 :         ALLOC_ZVAL(*retval);
     108               1 :         ZVAL_XML_STRING(*retval, (char *) (nodep->name), ZSTR_DUPLICATE);
     109                 : 
     110               1 :         return SUCCESS;
     111                 : }
     112                 : 
     113                 : /* }}} */
     114                 : 
     115                 : /* {{{ data     string  
     116                 : readonly=no 
     117                 : URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-837822393
     118                 : Since: 
     119                 : */
     120                 : int dom_processinginstruction_data_read(dom_object *obj, zval **retval TSRMLS_DC)
     121               1 : {
     122                 :         xmlNodePtr nodep;
     123                 :         xmlChar *content;
     124                 : 
     125               1 :         nodep = dom_object_get_node(obj);
     126                 : 
     127               1 :         if (nodep == NULL) {
     128               0 :                 php_dom_throw_error(INVALID_STATE_ERR, 0 TSRMLS_CC);
     129               0 :                 return FAILURE;
     130                 :         }
     131                 : 
     132               1 :         ALLOC_ZVAL(*retval);
     133                 : 
     134                 :         
     135               1 :         if ((content = xmlNodeGetContent(nodep)) != NULL) {
     136               1 :                 ZVAL_XML_STRING(*retval, content, ZSTR_DUPLICATE);
     137               1 :                 xmlFree(content);
     138                 :         } else {
     139               0 :                 ZVAL_EMPTY_UNICODE(*retval);
     140                 :         }
     141                 : 
     142               1 :         return SUCCESS;
     143                 : }
     144                 : 
     145                 : int dom_processinginstruction_data_write(dom_object *obj, zval *newval TSRMLS_DC)
     146               1 : {
     147                 :         zval value_copy;
     148                 :         xmlNode *nodep;
     149                 : 
     150               1 :         nodep = dom_object_get_node(obj);
     151                 : 
     152               1 :         if (nodep == NULL) {
     153               0 :                 php_dom_throw_error(INVALID_STATE_ERR, 0 TSRMLS_CC);
     154               0 :                 return FAILURE;
     155                 :         }
     156                 : 
     157               1 :         if (newval->type != IS_STRING) {
     158               1 :                 if(Z_REFCOUNT_P(newval) > 1) {
     159               0 :                         value_copy = *newval;
     160               0 :                         zval_copy_ctor(&value_copy);
     161               0 :                         newval = &value_copy;
     162                 :                 }
     163               1 :                 convert_to_string_with_converter(newval, UG(utf8_conv));
     164                 :         }
     165                 : 
     166               1 :         xmlNodeSetContentLen(nodep, Z_STRVAL_P(newval), Z_STRLEN_P(newval) + 1);
     167                 : 
     168               1 :         if (newval == &value_copy) {
     169               0 :                 zval_dtor(newval);
     170                 :         }
     171                 : 
     172               1 :         return SUCCESS;
     173                 : }
     174                 : 
     175                 : /* }}} */
     176                 : 
     177                 : #endif
     178                 : 
     179                 : /*
     180                 :  * Local variables:
     181                 :  * tab-width: 4
     182                 :  * c-basic-offset: 4
     183                 :  * End:
     184                 :  * vim600: noet sw=4 ts=4 fdm=marker
     185                 :  * vim<600: noet sw=4 ts=4
     186                 :  */

Generated by: LTP GCOV extension version 1.5

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

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