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: 2014-12-13 Functions: 6 6 100.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10

Generated at Sat, 13 Dec 2014 06:16:11 +0000 (6 days ago)

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