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/dom - processinginstruction.c (source / functions) Hit Total Coverage
Test: PHP Code Coverage Lines: 0 43 0.0 %
Date: 2019-05-06 Functions: 0 4 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :    +----------------------------------------------------------------------+
       3             :    | PHP Version 7                                                        |
       4             :    +----------------------------------------------------------------------+
       5             :    | Copyright (c) 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             : #ifdef HAVE_CONFIG_H
      21             : #include "config.h"
      22             : #endif
      23             : 
      24             : #include "php.h"
      25             : #if HAVE_LIBXML && HAVE_DOM
      26             : #include "php_dom.h"
      27             : 
      28             : 
      29             : /* {{{ arginfo */
      30             : ZEND_BEGIN_ARG_INFO_EX(arginfo_dom_processinginstruction_construct, 0, 0, 1)
      31             :         ZEND_ARG_INFO(0, name)
      32             :         ZEND_ARG_INFO(0, value)
      33             : ZEND_END_ARG_INFO();
      34             : /* }}} */
      35             : 
      36             : /*
      37             : * class DOMProcessingInstruction extends DOMNode
      38             : *
      39             : * URL: https://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-1004215813
      40             : * Since:
      41             : */
      42             : 
      43             : const zend_function_entry php_dom_processinginstruction_class_functions[] = {
      44             :         PHP_ME(domprocessinginstruction, __construct, arginfo_dom_processinginstruction_construct, ZEND_ACC_PUBLIC)
      45             :         PHP_FE_END
      46             : };
      47             : 
      48             : /* {{{ proto DOMProcessingInstruction::__construct(string name, [string value]); */
      49           0 : PHP_METHOD(domprocessinginstruction, __construct)
      50             : {
      51           0 :         xmlNodePtr nodep = NULL, oldnode = NULL;
      52             :         dom_object *intern;
      53           0 :         char *name, *value = NULL;
      54             :         size_t name_len, value_len;
      55             :         int name_valid;
      56             : 
      57           0 :         if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|s", &name, &name_len, &value, &value_len) == FAILURE) {
      58           0 :                 return;
      59             :         }
      60             : 
      61           0 :         name_valid = xmlValidateName((xmlChar *) name, 0);
      62           0 :         if (name_valid != 0) {
      63           0 :                 php_dom_throw_error(INVALID_CHARACTER_ERR, 1);
      64           0 :                 RETURN_FALSE;
      65             :         }
      66             : 
      67           0 :         nodep = xmlNewPI((xmlChar *) name, (xmlChar *) value);
      68             : 
      69           0 :         if (!nodep) {
      70           0 :                 php_dom_throw_error(INVALID_STATE_ERR, 1);
      71           0 :                 RETURN_FALSE;
      72             :         }
      73             : 
      74           0 :         intern = Z_DOMOBJ_P(ZEND_THIS);
      75           0 :         oldnode = dom_object_get_node(intern);
      76           0 :         if (oldnode != NULL) {
      77           0 :                 php_libxml_node_free_resource(oldnode );
      78             :         }
      79           0 :         php_libxml_increment_node_ptr((php_libxml_node_object *)intern, nodep, (void *)intern);
      80             : }
      81             : /* }}} end DOMProcessingInstruction::__construct */
      82             : 
      83             : /* {{{ target   string
      84             : readonly=yes
      85             : URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-1478689192
      86             : Since:
      87             : */
      88           0 : int dom_processinginstruction_target_read(dom_object *obj, zval *retval)
      89             : {
      90           0 :         xmlNodePtr nodep = dom_object_get_node(obj);
      91             : 
      92           0 :         if (nodep == NULL) {
      93           0 :                 php_dom_throw_error(INVALID_STATE_ERR, 0);
      94           0 :                 return FAILURE;
      95             :         }
      96             : 
      97           0 :         ZVAL_STRING(retval, (char *) (nodep->name));
      98             : 
      99           0 :         return SUCCESS;
     100             : }
     101             : 
     102             : /* }}} */
     103             : 
     104             : /* {{{ data     string
     105             : readonly=no
     106             : URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-837822393
     107             : Since:
     108             : */
     109           0 : int dom_processinginstruction_data_read(dom_object *obj, zval *retval)
     110             : {
     111             :         xmlNodePtr nodep;
     112             :         xmlChar *content;
     113             : 
     114           0 :         nodep = dom_object_get_node(obj);
     115             : 
     116           0 :         if (nodep == NULL) {
     117           0 :                 php_dom_throw_error(INVALID_STATE_ERR, 0);
     118           0 :                 return FAILURE;
     119             :         }
     120             : 
     121           0 :         if ((content = xmlNodeGetContent(nodep)) != NULL) {
     122           0 :                 ZVAL_STRING(retval, (char *) content);
     123           0 :                 xmlFree(content);
     124             :         } else {
     125           0 :                 ZVAL_EMPTY_STRING(retval);
     126             :         }
     127             : 
     128           0 :         return SUCCESS;
     129             : }
     130             : 
     131           0 : int dom_processinginstruction_data_write(dom_object *obj, zval *newval)
     132             : {
     133           0 :         xmlNode *nodep = dom_object_get_node(obj);
     134             :         zend_string *str;
     135             : 
     136           0 :         if (nodep == NULL) {
     137           0 :                 php_dom_throw_error(INVALID_STATE_ERR, 0);
     138           0 :                 return FAILURE;
     139             :         }
     140             : 
     141           0 :         str = zval_get_string(newval);
     142             : 
     143           0 :         xmlNodeSetContentLen(nodep, (xmlChar *) ZSTR_VAL(str), ZSTR_LEN(str) + 1);
     144             : 
     145             :         zend_string_release_ex(str, 0);
     146           0 :         return SUCCESS;
     147             : }
     148             : 
     149             : /* }}} */
     150             : 
     151             : #endif

Generated by: LCOV version 1.10

Generated at Mon, 06 May 2019 17:58:13 +0000 (998 days ago)

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