php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
title_element.c
Go to the documentation of this file.
1/*
2 * Copyright (C) 2018 Alexander Borisov
3 *
4 * Author: Alexander Borisov <borisov@lexbor.com>
5 */
6
10
11
14{
16
17 element = lexbor_mraw_calloc(document->dom_document.mraw,
19 if (element == NULL) {
20 return NULL;
21 }
22
24
27
28 return element;
29}
30
48
49const lxb_char_t *
51{
52 if (lxb_dom_interface_node(title)->first_child == NULL) {
53 goto failed;
54 }
55
56 if (lxb_dom_interface_node(title)->first_child->type != LXB_DOM_NODE_TYPE_TEXT) {
57 goto failed;
58 }
59
61
63
64 if (len != NULL) {
65 *len = text->char_data.data.length;
66 }
67
68 return text->char_data.data.data;
69
70failed:
71
72 if (len != NULL) {
73 *len = 0;
74 }
75
76 return NULL;
77}
78
79const lxb_char_t *
81{
82 const lxb_char_t *text;
83 size_t text_len;
84
85 lxb_dom_document_t *doc = lxb_dom_interface_node(title)->owner_document;
86
87 text = lxb_html_title_element_text(title, &text_len);
88 if (text == NULL) {
89 goto failed;
90 }
91
92 if (title->strict_text != NULL) {
93 if (title->strict_text->length < text_len) {
94 const lxb_char_t *data;
95
97 doc->text, (text_len + 1));
98 if (data == NULL) {
99 goto failed;
100 }
101 }
102 }
103 else {
105 sizeof(lexbor_str_t));
106 if (title->strict_text == NULL) {
107 goto failed;
108 }
109
110 lexbor_str_init(title->strict_text, doc->text, text_len);
111 if (title->strict_text->data == NULL) {
113 title->strict_text);
114 goto failed;
115 }
116 }
117
118 memcpy(title->strict_text->data, text, sizeof(lxb_char_t) * text_len);
119
120 title->strict_text->data[text_len] = 0x00;
121 title->strict_text->length = text_len;
122
124
125 if (len != NULL) {
126 *len = title->strict_text->length;
127 }
128
129 return title->strict_text->data;
130
131failed:
132
133 if (len != NULL) {
134 *len = 0;
135 }
136
137 return NULL;
138}
size_t len
Definition apprentice.c:174
struct lxb_dom_document lxb_dom_document_t
Definition interface.h:41
#define lxb_dom_interface_node(obj)
Definition interface.h:31
struct lxb_dom_node lxb_dom_node_t
Definition interface.h:38
struct lxb_dom_text lxb_dom_text_t
Definition interface.h:46
#define lxb_dom_interface_text(obj)
Definition interface.h:34
lxb_inline void * lxb_dom_document_create_struct(lxb_dom_document_t *document, size_t struct_size)
Definition document.h:155
lxb_inline void * lxb_dom_document_destroy_struct(lxb_dom_document_t *document, void *structure)
Definition document.h:161
@ LXB_DOM_NODE_TYPE_ELEMENT
Definition node.h:25
@ LXB_DOM_NODE_TYPE_TEXT
Definition node.h:27
memcpy(ptr1, ptr2, size)
#define NULL
Definition gdcache.h:45
struct lxb_html_title_element lxb_html_title_element_t
Definition interface.h:162
struct lxb_html_document lxb_html_document_t
Definition interface.h:95
lxb_inline lxb_dom_document_t * lxb_html_document_original_ref(lxb_html_document_t *document)
Definition document.h:218
lxb_dom_node_t * lxb_dom_node_interface_destroy(lxb_dom_node_t *node)
Definition node.c:124
void * lexbor_mraw_calloc(lexbor_mraw_t *mraw, size_t size)
Definition mraw.c:227
unsigned const char * text
Definition php_ffi.h:53
zend_constant * data
lxb_char_t * lexbor_str_realloc(lexbor_str_t *str, lexbor_mraw_t *mraw, size_t new_size)
Definition str.c:94
void lexbor_str_strip_collapse_whitespace(lexbor_str_t *target)
Definition str.c:282
lxb_char_t * lexbor_str_init(lexbor_str_t *str, lexbor_mraw_t *mraw, size_t size)
Definition str.c:22
lexbor_str_t * lexbor_str_destroy(lexbor_str_t *str, lexbor_mraw_t *mraw, bool destroy_obj)
Definition str.c:76
lxb_char_t * data
Definition str.h:47
size_t length
Definition str.h:48
lexbor_mraw_t * mraw
Definition document.h:53
lexbor_mraw_t * text
Definition document.h:54
lxb_dom_document_t * owner_document
Definition node.h:50
lxb_dom_node_type_t type
Definition node.h:59
lxb_dom_document_t dom_document
Definition document.h:58
lexbor_str_t * strict_text
const lxb_char_t * lxb_html_title_element_strict_text(lxb_html_title_element_t *title, size_t *len)
const lxb_char_t * lxb_html_title_element_text(lxb_html_title_element_t *title, size_t *len)
lxb_html_title_element_t * lxb_html_title_element_interface_destroy(lxb_html_title_element_t *title)
lxb_html_title_element_t * lxb_html_title_element_interface_create(lxb_html_document_t *document)
unsigned char lxb_char_t
Definition types.h:27
ZEND_API void(ZEND_FASTCALL *zend_touch_vm_stack_data)(void *vm_stack_data)