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 - documenttype.c (source / functions) Hit Total Coverage
Test: PHP Code Coverage Lines: 66 66 100.0 %
Date: 2019-05-06 Functions: 6 6 100.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             : * class DOMDocumentType extends DOMNode
      30             : *
      31             : * URL: https://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-412266927
      32             : * Since:
      33             : */
      34             : 
      35             : const zend_function_entry php_dom_documenttype_class_functions[] = {
      36             :         PHP_FE_END
      37             : };
      38             : 
      39             : /* {{{ name     string
      40             : readonly=yes
      41             : URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-1844763134
      42             : Since:
      43             : */
      44           2 : int dom_documenttype_name_read(dom_object *obj, zval *retval)
      45             : {
      46           2 :         xmlDtdPtr dtdptr = (xmlDtdPtr) dom_object_get_node(obj);
      47             : 
      48           2 :         if (dtdptr == NULL) {
      49           1 :                 php_dom_throw_error(INVALID_STATE_ERR, 0);
      50           1 :                 return FAILURE;
      51             :         }
      52             : 
      53           2 :         ZVAL_STRING(retval, (char *) (dtdptr->name));
      54             : 
      55           1 :         return SUCCESS;
      56             : }
      57             : 
      58             : /* }}} */
      59             : 
      60             : /* {{{ entities DOMNamedNodeMap
      61             : readonly=yes
      62             : URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-1788794630
      63             : Since:
      64             : */
      65           3 : int dom_documenttype_entities_read(dom_object *obj, zval *retval)
      66             : {
      67           3 :         xmlDtdPtr doctypep = (xmlDtdPtr) dom_object_get_node(obj);
      68             :         xmlHashTable *entityht;
      69             :         dom_object *intern;
      70             : 
      71           3 :         if (doctypep == NULL) {
      72           1 :                 php_dom_throw_error(INVALID_STATE_ERR, 0);
      73           1 :                 return FAILURE;
      74             :         }
      75             : 
      76           2 :         php_dom_create_interator(retval, DOM_NAMEDNODEMAP);
      77             : 
      78           2 :         entityht = (xmlHashTable *) doctypep->entities;
      79             : 
      80           2 :         intern = Z_DOMOBJ_P(retval);
      81           2 :         dom_namednode_iter(obj, XML_ENTITY_NODE, intern, entityht, NULL, NULL);
      82             : 
      83           2 :         return SUCCESS;
      84             : }
      85             : 
      86             : /* }}} */
      87             : 
      88             : /* {{{ notations        DOMNamedNodeMap
      89             : readonly=yes
      90             : URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-D46829EF
      91             : Since:
      92             : */
      93           3 : int dom_documenttype_notations_read(dom_object *obj, zval *retval)
      94             : {
      95           3 :         xmlDtdPtr doctypep = (xmlDtdPtr) dom_object_get_node(obj);
      96             :         xmlHashTable *notationht;
      97             :         dom_object *intern;
      98             : 
      99           3 :         if (doctypep == NULL) {
     100           1 :                 php_dom_throw_error(INVALID_STATE_ERR, 0);
     101           1 :                 return FAILURE;
     102             :         }
     103             : 
     104           2 :         php_dom_create_interator(retval, DOM_NAMEDNODEMAP);
     105             : 
     106           2 :         notationht = (xmlHashTable *) doctypep->notations;
     107             : 
     108           2 :         intern = Z_DOMOBJ_P(retval);
     109           2 :         dom_namednode_iter(obj, XML_NOTATION_NODE, intern, notationht, NULL, NULL);
     110             : 
     111           2 :         return SUCCESS;
     112             : }
     113             : 
     114             : /* }}} */
     115             : 
     116             : /* {{{ publicId string
     117             : readonly=yes
     118             : URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-Core-DocType-publicId
     119             : Since: DOM Level 2
     120             : */
     121           3 : int dom_documenttype_public_id_read(dom_object *obj, zval *retval)
     122             : {
     123           3 :         xmlDtdPtr dtdptr = (xmlDtdPtr) dom_object_get_node(obj);
     124             : 
     125           3 :         if (dtdptr == NULL) {
     126           1 :                 php_dom_throw_error(INVALID_STATE_ERR, 0);
     127           1 :                 return FAILURE;
     128             :         }
     129             : 
     130           2 :         if (dtdptr->ExternalID) {
     131           2 :                 ZVAL_STRING(retval, (char *) (dtdptr->ExternalID));
     132             :         } else {
     133           1 :                 ZVAL_EMPTY_STRING(retval);
     134             :         }
     135           2 :         return SUCCESS;
     136             : 
     137             : }
     138             : 
     139             : /* }}} */
     140             : 
     141             : /* {{{ systemId string
     142             : readonly=yes
     143             : URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-Core-DocType-systemId
     144             : Since: DOM Level 2
     145             : */
     146           3 : int dom_documenttype_system_id_read(dom_object *obj, zval *retval)
     147             : {
     148           3 :         xmlDtdPtr dtdptr = (xmlDtdPtr) dom_object_get_node(obj);
     149             : 
     150           3 :         if (dtdptr == NULL) {
     151           1 :                 php_dom_throw_error(INVALID_STATE_ERR, 0);
     152           1 :                 return FAILURE;
     153             :         }
     154             : 
     155           2 :         if (dtdptr->SystemID) {
     156           2 :                 ZVAL_STRING(retval, (char *) (dtdptr->SystemID));
     157             :         } else {
     158           1 :                 ZVAL_EMPTY_STRING(retval);
     159             :         }
     160           2 :         return SUCCESS;
     161             : }
     162             : 
     163             : /* }}} */
     164             : 
     165             : /* {{{ internalSubset   string
     166             : readonly=yes
     167             : URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-Core-DocType-internalSubset
     168             : Since: DOM Level 2
     169             : */
     170           6 : int dom_documenttype_internal_subset_read(dom_object *obj, zval *retval)
     171             : {
     172           6 :         xmlDtdPtr dtdptr = (xmlDtdPtr) dom_object_get_node(obj);
     173             :         xmlDtdPtr intsubset;
     174             : 
     175           6 :         if (dtdptr == NULL) {
     176           1 :                 php_dom_throw_error(INVALID_STATE_ERR, 0);
     177           1 :                 return FAILURE;
     178             :         }
     179             : 
     180           5 :         if (dtdptr->doc != NULL && ((intsubset = xmlGetIntSubset(dtdptr->doc)) != NULL)) {
     181           5 :                 smart_str ret_buf = {0};
     182           5 :                 xmlNodePtr cur = intsubset->children;
     183             : 
     184          22 :                 while (cur != NULL) {
     185          12 :                         xmlOutputBuffer *buff = xmlAllocOutputBuffer(NULL);
     186             : 
     187          12 :                         if (buff != NULL) {
     188          12 :                                 xmlNodeDumpOutput (buff, NULL, cur, 0, 0, NULL);
     189          12 :                                 xmlOutputBufferFlush(buff);
     190             : 
     191             : #ifdef LIBXML2_NEW_BUFFER
     192             :                                 smart_str_appendl(&ret_buf, (const char *) xmlOutputBufferGetContent(buff), xmlOutputBufferGetSize(buff));
     193             : #else
     194          12 :                                 smart_str_appendl(&ret_buf, (char *) buff->buffer->content, buff->buffer->use);
     195             : #endif
     196             : 
     197          12 :                                 (void)xmlOutputBufferClose(buff);
     198             :                         }
     199             : 
     200          12 :                         cur = cur->next;
     201             :                 }
     202             : 
     203           5 :                 if (ret_buf.s) {
     204             :                         smart_str_0(&ret_buf);
     205           3 :                         ZVAL_NEW_STR(retval, ret_buf.s);
     206           3 :                         return SUCCESS;
     207             :                 }
     208             :         }
     209             : 
     210           2 :         ZVAL_NULL(retval);
     211             : 
     212           2 :         return SUCCESS;
     213             : 
     214             : }
     215             : 
     216             : /* }}} */
     217             : 
     218             : #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.