php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
processinginstruction.c
Go to the documentation of this file.
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#include "dom_properties.h"
26
27/*
28* class DOMProcessingInstruction extends DOMNode
29*
30* URL: https://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-1004215813
31* Since:
32*/
33
34/* {{{ */
36{
37 xmlNodePtr nodep = NULL, oldnode = NULL;
38 dom_object *intern;
39 char *name, *value = NULL;
40 size_t name_len, value_len;
41 int name_valid;
42
43 if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &name, &name_len, &value, &value_len) == FAILURE) {
45 }
46
47 name_valid = xmlValidateName(BAD_CAST name, 0);
48 if (name_valid != 0) {
51 }
52
53 nodep = xmlNewPI(BAD_CAST name, BAD_CAST value);
54
55 if (!nodep) {
58 }
59
60 intern = Z_DOMOBJ_P(ZEND_THIS);
61 oldnode = dom_object_get_node(intern);
62 if (oldnode != NULL) {
63 php_libxml_node_decrement_resource((php_libxml_node_object *)intern);
64 }
65 php_libxml_increment_node_ptr((php_libxml_node_object *)intern, nodep, (void *)intern);
66}
67/* }}} end DOMProcessingInstruction::__construct */
68
69/* {{{ target string
70readonly=yes
71URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-1478689192
72Since:
73*/
75{
76 DOM_PROP_NODE(xmlNodePtr, nodep, obj);
77 ZVAL_STRING(retval, (const char *) nodep->name);
78 return SUCCESS;
79}
80
81/* }}} */
82
83/* {{{ data string
84readonly=no
85URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-837822393
86Since:
87*/
89{
90 DOM_PROP_NODE(xmlNodePtr, nodep, obj);
92 return SUCCESS;
93}
94
96{
97 DOM_PROP_NODE(xmlNodePtr, nodep, obj);
98
99 /* Typed property, this is already a string */
100 ZEND_ASSERT(Z_TYPE_P(newval) == IS_STRING);
101 zend_string *str = Z_STR_P(newval);
102
103 xmlNodeSetContentLen(nodep, BAD_CAST ZSTR_VAL(str), ZSTR_LEN(str));
104
105 return SUCCESS;
106}
107
108/* }}} */
109
110#endif
zend_result dom_processinginstruction_data_write(dom_object *obj, zval *newval)
zend_result dom_processinginstruction_data_read(dom_object *obj, zval *retval)
#define DOM_PROP_NODE(type, name, obj)
zend_result dom_processinginstruction_target_read(dom_object *obj, zval *retval)
void php_dom_throw_error(dom_exception_code error_code, bool strict_error)
@ INVALID_STATE_ERR
@ INVALID_CHARACTER_ERR
#define NULL
Definition gdcache.h:45
#define SUCCESS
Definition hash_sha3.c:261
#define PHP_METHOD
Definition php.h:365
void php_dom_get_content_into_zval(const xmlNode *nodep, zval *target, bool default_is_null)
PHP_DOM_EXPORT xmlNodePtr dom_object_get_node(dom_object *obj)
struct _dom_object dom_object
#define Z_DOMOBJ_P(zv)
Definition xml_common.h:36
ZEND_API zend_result zend_parse_parameters(uint32_t num_args, const char *type_spec,...)
Definition zend_API.c:1300
#define ZEND_NUM_ARGS()
Definition zend_API.h:530
#define ZVAL_STRING(z, s)
Definition zend_API.h:956
#define RETURN_THROWS()
Definition zend_API.h:1060
#define ZEND_THIS
Definition zend_API.h:523
struct _zval_struct zval
struct _zend_string zend_string
#define ZEND_ASSERT(c)
#define ZSTR_VAL(zstr)
Definition zend_string.h:68
#define ZSTR_LEN(zstr)
Definition zend_string.h:69
#define Z_TYPE_P(zval_p)
Definition zend_types.h:660
#define IS_STRING
Definition zend_types.h:606
#define Z_STR_P(zval_p)
Definition zend_types.h:972
@ FAILURE
Definition zend_types.h:61
ZEND_RESULT_CODE zend_result
Definition zend_types.h:64
zval retval
zend_string * name
value