xref: /PHP-7.1/ext/dom/entity.c (revision ccd4716e)
1 /*
2    +----------------------------------------------------------------------+
3    | PHP Version 7                                                        |
4    +----------------------------------------------------------------------+
5    | Copyright (c) 1997-2018 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 /*
32 * class DOMEntity extends DOMNode
33 *
34 * URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-527DCFF2
35 * Since:
36 */
37 
38 const zend_function_entry php_dom_entity_class_functions[] = {
39 	PHP_FE_END
40 };
41 
42 /* {{{ publicId	string
43 readonly=yes
44 URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-D7303025
45 Since:
46 */
dom_entity_public_id_read(dom_object * obj,zval * retval)47 int dom_entity_public_id_read(dom_object *obj, zval *retval)
48 {
49 	xmlEntity *nodep = (xmlEntity *) dom_object_get_node(obj);
50 
51 	if (nodep == NULL) {
52 		php_dom_throw_error(INVALID_STATE_ERR, 0);
53 		return FAILURE;
54 	}
55 
56 	if (nodep->etype != XML_EXTERNAL_GENERAL_UNPARSED_ENTITY) {
57 		ZVAL_NULL(retval);
58 	} else {
59 		ZVAL_STRING(retval, (char *) (nodep->ExternalID));
60 	}
61 
62 	return SUCCESS;
63 }
64 
65 /* }}} */
66 
67 /* {{{ systemId	string
68 readonly=yes
69 URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-D7C29F3E
70 Since:
71 */
dom_entity_system_id_read(dom_object * obj,zval * retval)72 int dom_entity_system_id_read(dom_object *obj, zval *retval)
73 {
74 	xmlEntity *nodep = (xmlEntity *) dom_object_get_node(obj);
75 
76 	if (nodep == NULL) {
77 		php_dom_throw_error(INVALID_STATE_ERR, 0);
78 		return FAILURE;
79 	}
80 
81 	if (nodep->etype != XML_EXTERNAL_GENERAL_UNPARSED_ENTITY) {
82 		ZVAL_NULL(retval);
83 	} else {
84 		ZVAL_STRING(retval, (char *) (nodep->SystemID));
85 	}
86 
87 	return SUCCESS;
88 }
89 
90 /* }}} */
91 
92 /* {{{ notationName	string
93 readonly=yes
94 URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-6ABAEB38
95 Since:
96 */
dom_entity_notation_name_read(dom_object * obj,zval * retval)97 int dom_entity_notation_name_read(dom_object *obj, zval *retval)
98 {
99 	xmlEntity *nodep = (xmlEntity *) dom_object_get_node(obj);
100 	char *content;
101 
102 	if (nodep == NULL) {
103 		php_dom_throw_error(INVALID_STATE_ERR, 0);
104 		return FAILURE;
105 	}
106 
107 	if (nodep->etype != XML_EXTERNAL_GENERAL_UNPARSED_ENTITY) {
108 		ZVAL_NULL(retval);
109 	} else {
110 		content = (char *) xmlNodeGetContent((xmlNodePtr) nodep);
111 		ZVAL_STRING(retval, content);
112 		xmlFree(content);
113 	}
114 
115 	return SUCCESS;
116 }
117 
118 /* }}} */
119 
120 /* {{{ actualEncoding	string
121 readonly=no
122 URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#Entity3-actualEncoding
123 Since: DOM Level 3
124 */
dom_entity_actual_encoding_read(dom_object * obj,zval * retval)125 int dom_entity_actual_encoding_read(dom_object *obj, zval *retval)
126 {
127 	ZVAL_NULL(retval);
128 	return SUCCESS;
129 }
130 
dom_entity_actual_encoding_write(dom_object * obj,zval * newval)131 int dom_entity_actual_encoding_write(dom_object *obj, zval *newval)
132 {
133 	return SUCCESS;
134 }
135 
136 /* }}} */
137 
138 /* {{{ encoding	string
139 readonly=no
140 URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#Entity3-encoding
141 Since: DOM Level 3
142 */
dom_entity_encoding_read(dom_object * obj,zval * retval)143 int dom_entity_encoding_read(dom_object *obj, zval *retval)
144 {
145 	ZVAL_NULL(retval);
146 	return SUCCESS;
147 }
148 
dom_entity_encoding_write(dom_object * obj,zval * newval)149 int dom_entity_encoding_write(dom_object *obj, zval *newval)
150 {
151 	return SUCCESS;
152 }
153 
154 /* }}} */
155 
156 /* {{{ version	string
157 readonly=no
158 URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#Entity3-version
159 Since: DOM Level 3
160 */
dom_entity_version_read(dom_object * obj,zval * retval)161 int dom_entity_version_read(dom_object *obj, zval *retval)
162 {
163 	ZVAL_NULL(retval);
164 	return SUCCESS;
165 }
166 
dom_entity_version_write(dom_object * obj,zval * newval)167 int dom_entity_version_write(dom_object *obj, zval *newval)
168 {
169 	return SUCCESS;
170 }
171 
172 /* }}} */
173 
174 #endif
175 
176 /*
177  * Local variables:
178  * tab-width: 4
179  * c-basic-offset: 4
180  * End:
181  * vim600: noet sw=4 ts=4 fdm=marker
182  * vim<600: noet sw=4 ts=4
183  */
184