1 /*
2    +----------------------------------------------------------------------+
3    | Copyright (c) The PHP Group                                          |
4    +----------------------------------------------------------------------+
5    | This source file is subject to version 3.01 of the PHP license,      |
6    | that is bundled with this package in the file LICENSE, and is        |
7    | available through the world-wide-web at the following url:           |
8    | https://www.php.net/license/3_01.txt                                 |
9    | If you did not receive a copy of the PHP license and are unable to   |
10    | obtain it through the world-wide-web, please send a note to          |
11    | license@php.net so we can mail you a copy immediately.               |
12    +----------------------------------------------------------------------+
13    | Authors: Christian Stocker <chregu@php.net>                          |
14    |          Rob Richards <rrichards@php.net>                            |
15    +----------------------------------------------------------------------+
16 */
17 
18 #ifdef HAVE_CONFIG_H
19 #include "config.h"
20 #endif
21 
22 #include "php.h"
23 #if defined(HAVE_LIBXML) && defined(HAVE_DOM)
24 #include "php_dom.h"
25 
26 
27 /*
28 * class DOMEntity extends DOMNode
29 *
30 * URL: https://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-527DCFF2
31 * Since:
32 */
33 
34 /* {{{ publicId	string
35 readonly=yes
36 URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-D7303025
37 Since:
38 */
dom_entity_public_id_read(dom_object * obj,zval * retval)39 int dom_entity_public_id_read(dom_object *obj, zval *retval)
40 {
41 	xmlEntity *nodep = (xmlEntity *) dom_object_get_node(obj);
42 
43 	if (nodep == NULL) {
44 		php_dom_throw_error(INVALID_STATE_ERR, 1);
45 		return FAILURE;
46 	}
47 
48 	if (nodep->etype != XML_EXTERNAL_GENERAL_UNPARSED_ENTITY) {
49 		ZVAL_NULL(retval);
50 	} else {
51 		ZVAL_STRING(retval, (char *) (nodep->ExternalID));
52 	}
53 
54 	return SUCCESS;
55 }
56 
57 /* }}} */
58 
59 /* {{{ systemId	string
60 readonly=yes
61 URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-D7C29F3E
62 Since:
63 */
dom_entity_system_id_read(dom_object * obj,zval * retval)64 int dom_entity_system_id_read(dom_object *obj, zval *retval)
65 {
66 	xmlEntity *nodep = (xmlEntity *) dom_object_get_node(obj);
67 
68 	if (nodep == NULL) {
69 		php_dom_throw_error(INVALID_STATE_ERR, 1);
70 		return FAILURE;
71 	}
72 
73 	if (nodep->etype != XML_EXTERNAL_GENERAL_UNPARSED_ENTITY) {
74 		ZVAL_NULL(retval);
75 	} else {
76 		ZVAL_STRING(retval, (char *) (nodep->SystemID));
77 	}
78 
79 	return SUCCESS;
80 }
81 
82 /* }}} */
83 
84 /* {{{ notationName	string
85 readonly=yes
86 URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-6ABAEB38
87 Since:
88 */
dom_entity_notation_name_read(dom_object * obj,zval * retval)89 int dom_entity_notation_name_read(dom_object *obj, zval *retval)
90 {
91 	xmlEntity *nodep = (xmlEntity *) dom_object_get_node(obj);
92 	char *content;
93 
94 	if (nodep == NULL) {
95 		php_dom_throw_error(INVALID_STATE_ERR, 1);
96 		return FAILURE;
97 	}
98 
99 	if (nodep->etype != XML_EXTERNAL_GENERAL_UNPARSED_ENTITY) {
100 		ZVAL_NULL(retval);
101 	} else {
102 		content = (char *) xmlNodeGetContent((xmlNodePtr) nodep);
103 		ZVAL_STRING(retval, content);
104 		xmlFree(content);
105 	}
106 
107 	return SUCCESS;
108 }
109 
110 /* }}} */
111 
112 /* {{{ actualEncoding	string
113 readonly=yes
114 URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#Entity3-actualEncoding
115 Since: DOM Level 3
116 */
dom_entity_actual_encoding_read(dom_object * obj,zval * retval)117 int dom_entity_actual_encoding_read(dom_object *obj, zval *retval)
118 {
119 	ZVAL_NULL(retval);
120 	return SUCCESS;
121 }
122 
123 /* }}} */
124 
125 /* {{{ encoding	string
126 readonly=yes
127 URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#Entity3-encoding
128 Since: DOM Level 3
129 */
dom_entity_encoding_read(dom_object * obj,zval * retval)130 int dom_entity_encoding_read(dom_object *obj, zval *retval)
131 {
132 	ZVAL_NULL(retval);
133 	return SUCCESS;
134 }
135 
136 /* }}} */
137 
138 /* {{{ version	string
139 readonly=yes
140 URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#Entity3-version
141 Since: DOM Level 3
142 */
dom_entity_version_read(dom_object * obj,zval * retval)143 int dom_entity_version_read(dom_object *obj, zval *retval)
144 {
145 	ZVAL_NULL(retval);
146 	return SUCCESS;
147 }
148 
149 /* }}} */
150 
151 #endif
152