php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
encoding.c
Go to the documentation of this file.
1/*
2 * Copyright (C) 2019 Alexander Borisov
3 *
4 * Author: Alexander Borisov <borisov@lexbor.com>
5 */
6
8
9
12{
13 const lxb_char_t *end;
14 const lexbor_shs_entry_t *entry;
15
16 if (length == 0) {
17 return NULL;
18 }
19
20 end = name + length;
21
22 /* Remove any leading */
23 do {
24 switch (*name) {
25 case 0x09: case 0x0A: case 0x0C: case 0x0D: case 0x20:
26 name++;
27 continue;
28 }
29
30 break;
31 }
32 while (name < end);
33
34 /* Remove any trailing */
35 while (name < end) {
36 switch (*(end - 1)) {
37 case 0x09: case 0x0A: case 0x0C: case 0x0D: case 0x20:
38 end--;
39 continue;
40 }
41
42 break;
43 }
44
45 if (name == end) {
46 return NULL;
47 }
48
50 name, (end - name));
51 if (entry == NULL) {
52 return NULL;
53 }
54
55 return entry->value;
56}
57
58/*
59 * No inline functions for ABI.
60 */
63 const lxb_encoding_data_t *encoding_data,
64 lxb_char_t *buffer_out, size_t buffer_length)
65{
66 return lxb_encoding_encode_init(encode, encoding_data,
67 buffer_out, buffer_length);
68}
69
75
81
82void
84 lxb_char_t *buffer_out, size_t buffer_length)
85{
86 lxb_encoding_encode_buf_set(encode, buffer_out, buffer_length);
87}
88
89void
95
96size_t
101
104 const lxb_char_t *replace, size_t length)
105{
106 return lxb_encoding_encode_replace_set(encode, replace, length);
107}
108
115
118 const lxb_encoding_data_t *encoding_data,
119 lxb_codepoint_t *buffer_out, size_t buffer_length)
120{
121 return lxb_encoding_decode_init(decode, encoding_data,
122 buffer_out, buffer_length);
123}
124
130
136
137void
139 lxb_codepoint_t *buffer_out, size_t buffer_length)
140{
141 lxb_encoding_decode_buf_set(decode, buffer_out, buffer_length);
142}
143
144void
146 size_t buffer_used)
147{
148 lxb_encoding_decode_buf_used_set(decode, buffer_used);
149}
150
151size_t
156
159 const lxb_codepoint_t *replace, size_t length)
160{
161 return lxb_encoding_decode_replace_set(decode, replace, length);
162}
163
166 const lxb_codepoint_t *data, size_t length)
167{
168 return lxb_encoding_decode_buf_add_to(decode, data, length);
169}
170
177
178int8_t
184
187 const lxb_encoding_data_t *encoding_data)
188{
189 return lxb_encoding_decode_init_single(decode, encoding_data);
190}
191
197
200{
201 return lxb_encoding_data_by_name(name, length);
202}
203
209
215
221
228
231 const lxb_char_t **data, const lxb_char_t *end)
232{
233 return lxb_encoding_data_call_decode(encoding_data, ctx, data, end);
234}
235
241
242size_t
244{
245 return sizeof(lxb_encoding_encode_t);
246}
247
248size_t
250{
251 return sizeof(lxb_encoding_decode_t);
252}
#define LXB_API
Definition def.h:48
const lxb_encoding_data_t * lxb_encoding_data_by_pre_name(const lxb_char_t *name, size_t length)
Definition encoding.c:11
lxb_status_t lxb_encoding_encode_finish_noi(lxb_encoding_encode_t *encode)
Definition encoding.c:71
size_t lxb_encoding_decode_buf_used_noi(lxb_encoding_decode_t *decode)
Definition encoding.c:152
lxb_codepoint_t * lxb_encoding_decode_buf_noi(lxb_encoding_decode_t *decode)
Definition encoding.c:132
lxb_status_t lxb_encoding_decode_replace_set_noi(lxb_encoding_decode_t *decode, const lxb_codepoint_t *replace, size_t length)
Definition encoding.c:158
const lxb_encoding_data_t * lxb_encoding_data_noi(lxb_encoding_t encoding)
Definition encoding.c:205
lxb_status_t lxb_encoding_decode_finish_single_noi(lxb_encoding_decode_t *decode)
Definition encoding.c:193
lxb_status_t lxb_encoding_encode_init_noi(lxb_encoding_encode_t *encode, const lxb_encoding_data_t *encoding_data, lxb_char_t *buffer_out, size_t buffer_length)
Definition encoding.c:62
lxb_status_t lxb_encoding_data_call_encode_noi(lxb_encoding_data_t *encoding_data, lxb_encoding_encode_t *ctx, const lxb_codepoint_t **cp, const lxb_codepoint_t *end)
Definition encoding.c:223
lxb_status_t lxb_encoding_decode_init_noi(lxb_encoding_decode_t *decode, const lxb_encoding_data_t *encoding_data, lxb_codepoint_t *buffer_out, size_t buffer_length)
Definition encoding.c:117
void lxb_encoding_decode_buf_set_noi(lxb_encoding_decode_t *decode, lxb_codepoint_t *buffer_out, size_t buffer_length)
Definition encoding.c:138
lxb_status_t lxb_encoding_decode_init_single_noi(lxb_encoding_decode_t *decode, const lxb_encoding_data_t *encoding_data)
Definition encoding.c:186
size_t lxb_encoding_encode_t_sizeof(void)
Definition encoding.c:243
void lxb_encoding_encode_buf_set_noi(lxb_encoding_encode_t *encode, lxb_char_t *buffer_out, size_t buffer_length)
Definition encoding.c:83
int8_t lxb_encoding_encode_finish_single_noi(lxb_encoding_encode_t *encode, lxb_char_t **data, const lxb_char_t *end)
Definition encoding.c:179
size_t lxb_encoding_decode_t_sizeof(void)
Definition encoding.c:249
lxb_encoding_encode_f lxb_encoding_encode_function_noi(lxb_encoding_t encoding)
Definition encoding.c:211
lxb_status_t lxb_encoding_encode_replace_set_noi(lxb_encoding_encode_t *encode, const lxb_char_t *replace, size_t length)
Definition encoding.c:103
void lxb_encoding_encode_buf_used_set_noi(lxb_encoding_encode_t *encode, size_t buffer_used)
Definition encoding.c:90
size_t lxb_encoding_encode_buf_used_noi(lxb_encoding_encode_t *encode)
Definition encoding.c:97
void lxb_encoding_decode_buf_used_set_noi(lxb_encoding_decode_t *decode, size_t buffer_used)
Definition encoding.c:145
lxb_status_t lxb_encoding_data_call_decode_noi(lxb_encoding_data_t *encoding_data, lxb_encoding_decode_t *ctx, const lxb_char_t **data, const lxb_char_t *end)
Definition encoding.c:230
LXB_API lxb_char_t * lxb_encoding_encode_buf_noi(lxb_encoding_encode_t *encode)
Definition encoding.c:77
lxb_status_t lxb_encoding_encode_buf_add_to_noi(lxb_encoding_encode_t *encode, lxb_char_t *data, size_t length)
Definition encoding.c:110
lxb_status_t lxb_encoding_decode_buf_add_to_noi(lxb_encoding_decode_t *decode, const lxb_codepoint_t *data, size_t length)
Definition encoding.c:165
const lxb_encoding_data_t * lxb_encoding_data_by_name_noi(const lxb_char_t *name, size_t length)
Definition encoding.c:199
lxb_status_t lxb_encoding_decode_finish_noi(lxb_encoding_decode_t *decode)
Definition encoding.c:126
lxb_encoding_decode_f lxb_encoding_decode_function_noi(lxb_encoding_t encoding)
Definition encoding.c:217
lxb_encoding_t lxb_encoding_data_encoding_noi(lxb_encoding_data_t *data)
Definition encoding.c:237
lxb_status_t lxb_encoding_encode_init_single_noi(lxb_encoding_encode_t *encode, const lxb_encoding_data_t *encoding_data)
Definition encoding.c:172
lxb_status_t(* lxb_encoding_encode_f)(lxb_encoding_encode_t *ctx, const lxb_codepoint_t **cp, const lxb_codepoint_t *end)
Definition base.h:174
struct lxb_encoding_data lxb_encoding_data_t
Definition base.h:103
lxb_status_t(* lxb_encoding_decode_f)(lxb_encoding_decode_t *ctx, const lxb_char_t **data, const lxb_char_t *end)
Definition base.h:178
lxb_encoding_t
Definition const.h:17
lxb_inline lxb_status_t lxb_encoding_data_call_decode(lxb_encoding_data_t *encoding_data, lxb_encoding_decode_t *ctx, const lxb_char_t **data, const lxb_char_t *end)
Definition encoding.h:352
lxb_inline lxb_status_t lxb_encoding_decode_buf_add_to(lxb_encoding_decode_t *decode, const lxb_codepoint_t *data, size_t length)
Definition encoding.h:127
lxb_inline lxb_status_t lxb_encoding_encode_finish(lxb_encoding_encode_t *encode)
Definition encoding.h:57
lxb_inline lxb_status_t lxb_encoding_encode_init(lxb_encoding_encode_t *encode, const lxb_encoding_data_t *encoding_data, lxb_char_t *buffer_out, size_t buffer_length)
Definition encoding.h:39
lxb_inline const lxb_encoding_data_t * lxb_encoding_data_by_name(const lxb_char_t *name, size_t length)
Definition encoding.h:297
lxb_inline const lxb_encoding_data_t * lxb_encoding_data(lxb_encoding_t encoding)
Definition encoding.h:315
lxb_inline lxb_status_t lxb_encoding_data_call_encode(lxb_encoding_data_t *encoding_data, lxb_encoding_encode_t *ctx, const lxb_codepoint_t **cp, const lxb_codepoint_t *end)
Definition encoding.h:345
lxb_inline lxb_encoding_decode_f lxb_encoding_decode_function(lxb_encoding_t encoding)
Definition encoding.h:335
lxb_inline lxb_status_t lxb_encoding_decode_replace_set(lxb_encoding_decode_t *decode, const lxb_codepoint_t *replace, size_t length)
Definition encoding.h:216
lxb_inline lxb_status_t lxb_encoding_decode_init(lxb_encoding_decode_t *decode, const lxb_encoding_data_t *encoding_data, lxb_codepoint_t *buffer_out, size_t buffer_length)
Definition encoding.h:143
lxb_inline void lxb_encoding_decode_buf_set(lxb_encoding_decode_t *decode, lxb_codepoint_t *buffer_out, size_t buffer_length)
Definition encoding.h:194
lxb_inline void lxb_encoding_decode_buf_used_set(lxb_encoding_decode_t *decode, size_t buffer_used)
Definition encoding.h:203
lxb_inline size_t lxb_encoding_decode_buf_used(lxb_encoding_decode_t *decode)
Definition encoding.h:210
lxb_inline void lxb_encoding_encode_buf_set(lxb_encoding_encode_t *encode, lxb_char_t *buffer_out, size_t buffer_length)
Definition encoding.h:73
lxb_inline lxb_status_t lxb_encoding_encode_init_single(lxb_encoding_encode_t *encode, const lxb_encoding_data_t *encoding_data)
Definition encoding.h:233
lxb_inline lxb_encoding_t lxb_encoding_data_encoding(lxb_encoding_data_t *data)
Definition encoding.h:359
lxb_inline lxb_char_t * lxb_encoding_encode_buf(lxb_encoding_encode_t *encode)
Definition encoding.h:67
lxb_inline int8_t lxb_encoding_encode_finish_single(lxb_encoding_encode_t *encode, lxb_char_t **data, const lxb_char_t *end)
Definition encoding.h:248
lxb_inline lxb_codepoint_t * lxb_encoding_decode_buf(lxb_encoding_decode_t *decode)
Definition encoding.h:188
lxb_inline lxb_encoding_encode_f lxb_encoding_encode_function(lxb_encoding_t encoding)
Definition encoding.h:325
lxb_inline lxb_status_t lxb_encoding_encode_replace_set(lxb_encoding_encode_t *encode, const lxb_char_t *replace, size_t length)
Definition encoding.h:95
lxb_inline lxb_status_t lxb_encoding_decode_finish(lxb_encoding_decode_t *decode)
Definition encoding.h:161
lxb_inline lxb_status_t lxb_encoding_encode_buf_add_to(lxb_encoding_encode_t *encode, lxb_char_t *data, size_t length)
Definition encoding.h:109
lxb_inline lxb_status_t lxb_encoding_decode_init_single(lxb_encoding_decode_t *decode, const lxb_encoding_data_t *encoding_data)
Definition encoding.h:262
lxb_inline lxb_status_t lxb_encoding_decode_finish_single(lxb_encoding_decode_t *decode)
Definition encoding.h:277
lxb_inline size_t lxb_encoding_encode_buf_used(lxb_encoding_encode_t *encode)
Definition encoding.h:89
lxb_inline void lxb_encoding_encode_buf_used_set(lxb_encoding_encode_t *encode, size_t buffer_used)
Definition encoding.h:82
#define NULL
Definition gdcache.h:45
unsigned const char * end
Definition php_ffi.h:51
xmlCharEncodingHandlerPtr encoding
Definition php_soap.h:170
struct _encode encode
Definition php_soap.h:42
zend_constant * data
LXB_API const lexbor_shs_entry_t lxb_encoding_res_shs_entities[220]
Definition res.c:110
const lexbor_shs_entry_t * lexbor_shs_entry_get_lower_static(const lexbor_shs_entry_t *root, const lxb_char_t *key, size_t key_len)
Definition shs.c:63
Definition shs.h:19
void * value
Definition shs.h:21
unsigned int lxb_status_t
Definition types.h:28
unsigned char lxb_char_t
Definition types.h:27
uint32_t lxb_codepoint_t
Definition types.h:26
zend_string * name