2 +--------------------------------------------------------------------+
4 +--------------------------------------------------------------------+
5 | Redistribution and use in source and binary forms, with or without |
6 | modification, are permitted provided that the conditions mentioned |
7 | in the accompanying LICENSE file are met. |
8 +--------------------------------------------------------------------+
9 | Copyright (c) 2004-2014, Michael Wallner <mike@php.net> |
10 +--------------------------------------------------------------------+
13 #include "php_http_api.h"
15 static php_http_params_token_t def_param_sep
= {",", 1}, *def_param_sep_ptr
[] = {&def_param_sep
, NULL
};
16 static php_http_params_token_t def_arg_sep
= {";", 1}, *def_arg_sep_ptr
[] = {&def_arg_sep
, NULL
};
17 static php_http_params_token_t def_val_sep
= {"=", 1}, *def_val_sep_ptr
[] = {&def_val_sep
, NULL
};
18 static php_http_params_opts_t def_opts
= {
24 PHP_HTTP_PARAMS_DEFAULT
27 php_http_params_opts_t
*php_http_params_opts_default_get(php_http_params_opts_t
*opts
)
30 opts
= emalloc(sizeof(*opts
));
33 memcpy(opts
, &def_opts
, sizeof(def_opts
));
38 typedef struct php_http_params_state
{
39 php_http_params_token_t input
;
40 php_http_params_token_t param
;
41 php_http_params_token_t arg
;
42 php_http_params_token_t val
;
51 } php_http_params_state_t
;
53 static inline void sanitize_escaped(zval
*zv TSRMLS_DC
)
55 if (Z_STRVAL_P(zv
)[0] == '"' && Z_STRVAL_P(zv
)[Z_STRLEN_P(zv
) - 1] == '"') {
56 size_t deq_len
= Z_STRLEN_P(zv
) - 2;
57 char *deq
= estrndup(Z_STRVAL_P(zv
) + 1, deq_len
);
60 ZVAL_STRINGL(zv
, deq
, deq_len
, 0);
63 php_stripcslashes(Z_STRVAL_P(zv
), &Z_STRLEN_P(zv
));
66 static inline void quote_string(zval
*zv
, zend_bool force TSRMLS_DC
)
68 int len
= Z_STRLEN_P(zv
);
70 Z_STRVAL_P(zv
) = php_addcslashes(Z_STRVAL_P(zv
), Z_STRLEN_P(zv
), &Z_STRLEN_P(zv
), 1,
71 ZEND_STRL("\0..\37\173\\\"") TSRMLS_CC
);
73 if (force
|| len
!= Z_STRLEN_P(zv
) || strpbrk(Z_STRVAL_P(zv
), "()<>@,;:\"[]?={} ")) {
75 int len
= Z_STRLEN_P(zv
) + 2;
76 char *str
= emalloc(len
+ 1);
79 memcpy(&str
[1], Z_STRVAL_P(zv
), Z_STRLEN_P(zv
));
84 ZVAL_STRINGL(zv
, str
, len
, 0);
88 static inline void prepare_escaped(zval
*zv TSRMLS_DC
)
90 if (Z_TYPE_P(zv
) == IS_STRING
) {
91 quote_string(zv
, 0 TSRMLS_CC
);
94 ZVAL_EMPTY_STRING(zv
);
98 static inline void sanitize_urlencoded(zval
*zv TSRMLS_DC
)
100 Z_STRLEN_P(zv
) = php_raw_url_decode(Z_STRVAL_P(zv
), Z_STRLEN_P(zv
));
103 static inline void prepare_urlencoded(zval
*zv TSRMLS_DC
)
106 char *str
= php_raw_url_encode(Z_STRVAL_P(zv
), Z_STRLEN_P(zv
), &len
);
109 ZVAL_STRINGL(zv
, str
, len
, 0);
112 static void sanitize_dimension(zval
*zv TSRMLS_DC
)
114 zval
*arr
= NULL
, *tmp
= NULL
, **cur
= NULL
;
115 char *var
= NULL
, *ptr
= Z_STRVAL_P(zv
), *end
= Z_STRVAL_P(zv
) + Z_STRLEN_P(zv
);
129 if (++level
> PG(max_input_nesting_level
)) {
131 php_error_docref(NULL TSRMLS_CC
, E_WARNING
, "Max input nesting level of %ld exceeded", (long) PG(max_input_nesting_level
));
134 if (ptr
- var
== 0) {
144 convert_to_array(*cur
);
149 zend_symtable_update(Z_ARRVAL_PP(cur
), var
, ptr
- var
+ 1, (void *) &tmp
, sizeof(zval
*), (void *) &cur
);
152 zend_hash_next_index_insert(Z_ARRVAL_PP(cur
), (void *) &tmp
, sizeof(zval
*), (void *) &cur
);
162 if (zend_hash_num_elements(Z_ARRVAL_P(arr
))) {
164 #if PHP_VERSION_ID >= 50400
165 ZVAL_COPY_VALUE(zv
, arr
);
167 zv
->value
= arr
->value
;
168 Z_TYPE_P(zv
) = Z_TYPE_P(arr
);
176 static inline void shift_key(php_http_buffer_t
*buf
, char *key_str
, size_t key_len
, const char *ass
, size_t asl
, unsigned flags TSRMLS_DC
);
177 static inline void shift_val(php_http_buffer_t
*buf
, zval
*zvalue
, const char *vss
, size_t vsl
, unsigned flags TSRMLS_DC
);
179 static void prepare_dimension(php_http_buffer_t
*buf
, php_http_buffer_t
*keybuf
, zval
*zvalue
, const char *pss
, size_t psl
, const char *vss
, size_t vsl
, unsigned flags TSRMLS_DC
)
181 HashTable
*ht
= HASH_OF(zvalue
);
183 php_http_array_hashkey_t key
= php_http_array_hashkey_init(0);
185 php_http_buffer_t prefix
;
187 if (!ht
->nApplyCount
++) {
188 php_http_buffer_init(&prefix
);
189 php_http_buffer_append(&prefix
, keybuf
->data
, keybuf
->used
);
191 FOREACH_HASH_KEYVAL(pos
, ht
, key
, val
) {
192 if (key
.type
== HASH_KEY_IS_STRING
&& !*key
.str
) {
193 /* only public properties */
197 php_http_buffer_appends(&prefix
, "[");
198 if (key
.type
== HASH_KEY_IS_STRING
) {
199 php_http_buffer_append(&prefix
, key
.str
, key
.len
- 1);
201 php_http_buffer_appendf(&prefix
, "%lu", key
.num
);
203 php_http_buffer_appends(&prefix
, "]");
205 if (Z_TYPE_PP(val
) == IS_ARRAY
|| Z_TYPE_PP(val
) == IS_OBJECT
) {
206 prepare_dimension(buf
, &prefix
, *val
, pss
, psl
, vss
, vsl
, flags TSRMLS_CC
);
208 zval
*cpy
= php_http_ztyp(IS_STRING
, *val
);
210 shift_key(buf
, prefix
.data
, prefix
.used
, pss
, psl
, flags TSRMLS_CC
);
211 shift_val(buf
, cpy
, vss
, vsl
, flags TSRMLS_CC
);
215 php_http_buffer_cut(&prefix
, keybuf
->used
, prefix
.used
- keybuf
->used
);
217 php_http_buffer_dtor(&prefix
);
222 static inline void sanitize_key(unsigned flags
, char *str
, size_t len
, zval
*zv
, zend_bool
*rfc5987 TSRMLS_DC
)
227 php_trim(str
, len
, NULL
, 0, zv
, 3 TSRMLS_CC
);
229 if (flags
& PHP_HTTP_PARAMS_ESCAPED
) {
230 sanitize_escaped(zv TSRMLS_CC
);
233 if (!Z_STRLEN_P(zv
)) {
237 if (flags
& PHP_HTTP_PARAMS_RFC5987
) {
238 eos
= &Z_STRVAL_P(zv
)[Z_STRLEN_P(zv
)-1];
246 if (flags
& PHP_HTTP_PARAMS_URLENCODED
) {
247 sanitize_urlencoded(zv TSRMLS_CC
);
250 if (flags
& PHP_HTTP_PARAMS_DIMENSION
) {
251 sanitize_dimension(zv TSRMLS_CC
);
255 static inline void sanitize_rfc5987(zval
*zv
, char **language
, zend_bool
*latin1 TSRMLS_DC
)
260 * iso-8850-1'de'bl%f6der%20schei%df%21
261 * utf-8'de-DE'bl%c3%b6der%20schei%c3%9f%21
264 switch (Z_STRVAL_P(zv
)[0]) {
267 if (!strncasecmp(Z_STRVAL_P(zv
), "iso-8859-1", lenof("iso-8859-1"))) {
269 ptr
= Z_STRVAL_P(zv
) + lenof("iso-8859-1");
275 if (!strncasecmp(Z_STRVAL_P(zv
), "utf-8", lenof("utf-8"))) {
277 ptr
= Z_STRVAL_P(zv
) + lenof("utf-8");
285 /* extract language */
287 for (*language
= ++ptr
; *ptr
&& *ptr
!= '\''; ++ptr
);
292 *language
= estrndup(*language
, ptr
- *language
);
295 ptr
= estrdup(++ptr
);
297 ZVAL_STRING(zv
, ptr
, 0);
301 static inline void sanitize_rfc5988(char *str
, size_t len
, zval
*zv TSRMLS_DC
)
304 php_trim(str
, len
, " ><", 3, zv
, 3 TSRMLS_CC
);
307 static inline void prepare_rfc5988(zval
*zv TSRMLS_DC
)
309 if (Z_TYPE_P(zv
) != IS_STRING
) {
311 ZVAL_EMPTY_STRING(zv
);
315 static void utf8encode(zval
*zv
)
318 unsigned char *ptr
= (unsigned char *) Z_STRVAL_P(zv
);
321 if (*ptr
++ >= 0x80) {
327 ptr
= safe_emalloc(1, len
, 1);
328 for (len
= 0, pos
= 0; len
<= Z_STRLEN_P(zv
); ++len
, ++pos
) {
329 ptr
[pos
] = Z_STRVAL_P(zv
)[len
];
330 if ((ptr
[pos
]) >= 0x80) {
331 ptr
[pos
+ 1] = 0x80 | (ptr
[pos
] & 0x3f);
332 ptr
[pos
] = 0xc0 | ((ptr
[pos
] >> 6) & 0x1f);
337 ZVAL_STRINGL(zv
, (char *) ptr
, pos
-1, 0);
340 static inline void sanitize_value(unsigned flags
, char *str
, size_t len
, zval
*zv
, zend_bool rfc5987 TSRMLS_DC
)
342 char *language
= NULL
;
343 zend_bool latin1
= 0;
346 php_trim(str
, len
, NULL
, 0, zv
, 3 TSRMLS_CC
);
349 sanitize_rfc5987(zv
, &language
, &latin1 TSRMLS_CC
);
352 if (flags
& PHP_HTTP_PARAMS_ESCAPED
) {
353 sanitize_escaped(zv TSRMLS_CC
);
356 if ((flags
& PHP_HTTP_PARAMS_URLENCODED
) || (rfc5987
&& language
)) {
357 sanitize_urlencoded(zv TSRMLS_CC
);
360 if (rfc5987
&& language
) {
368 ZVAL_COPY_VALUE(tmp
, zv
);
370 add_assoc_zval(zv
, language
, tmp
);
375 static inline void prepare_key(unsigned flags
, char *old_key
, size_t old_len
, char **new_key
, size_t *new_len TSRMLS_DC
)
380 ZVAL_STRINGL(&zv
, old_key
, old_len
, 1);
382 if (flags
& PHP_HTTP_PARAMS_URLENCODED
) {
383 prepare_urlencoded(&zv TSRMLS_CC
);
386 if (flags
& PHP_HTTP_PARAMS_ESCAPED
) {
387 if (flags
& PHP_HTTP_PARAMS_RFC5988
) {
388 prepare_rfc5988(&zv TSRMLS_CC
);
390 prepare_escaped(&zv TSRMLS_CC
);
394 *new_key
= Z_STRVAL(zv
);
395 *new_len
= Z_STRLEN(zv
);
398 static inline void prepare_value(unsigned flags
, zval
*zv TSRMLS_DC
)
400 if (flags
& PHP_HTTP_PARAMS_URLENCODED
) {
401 prepare_urlencoded(zv TSRMLS_CC
);
404 if (flags
& PHP_HTTP_PARAMS_ESCAPED
) {
405 prepare_escaped(zv TSRMLS_CC
);
409 static void merge_param(HashTable
*params
, zval
*zdata
, zval
***current_param
, zval
***current_args TSRMLS_DC
)
411 zval
**ptr
, **zdata_ptr
;
412 php_http_array_hashkey_t hkey
= php_http_array_hashkey_init(0);
417 INIT_PZVAL_ARRAY(&tmp
, params
);
418 fprintf(stderr
, "params = ");
419 zend_print_zval_r(&tmp
, 1 TSRMLS_CC
);
420 fprintf(stderr
, "\n");
424 hkey
.type
= zend_hash_get_current_key_ex(Z_ARRVAL_P(zdata
), &hkey
.str
, &hkey
.len
, &hkey
.num
, hkey
.dup
, NULL
);
426 if ((hkey
.type
== HASH_KEY_IS_STRING
&& !zend_hash_exists(params
, hkey
.str
, hkey
.len
))
427 || (hkey
.type
== HASH_KEY_IS_LONG
&& !zend_hash_index_exists(params
, hkey
.num
))
429 zval
*tmp
, *arg
, **args
;
431 /* create the entry if it doesn't exist */
432 zend_hash_get_current_data(Z_ARRVAL_P(zdata
), (void *) &ptr
);
436 add_assoc_zval_ex(tmp
, ZEND_STRS("value"), *ptr
);
440 zend_hash_update(Z_ARRVAL_P(tmp
), "arguments", sizeof("arguments"), (void *) &arg
, sizeof(zval
*), (void *) &args
);
441 *current_args
= args
;
443 if (hkey
.type
== HASH_KEY_IS_STRING
) {
444 zend_hash_update(params
, hkey
.str
, hkey
.len
, (void *) &tmp
, sizeof(zval
*), (void *) &ptr
);
446 zend_hash_index_update(params
, hkey
.num
, (void *) &tmp
, sizeof(zval
*), (void *) &ptr
);
450 if (hkey
.type
== HASH_KEY_IS_STRING
) {
451 zend_hash_find(params
, hkey
.str
, hkey
.len
, (void *) &ptr
);
453 zend_hash_index_find(params
, hkey
.num
, (void *) &ptr
);
458 if (Z_TYPE_PP(ptr
) == IS_ARRAY
459 && SUCCESS
== zend_hash_find(Z_ARRVAL_PP(ptr
), "value", sizeof("value"), (void *) &ptr
)
460 && SUCCESS
== zend_hash_get_current_data(Z_ARRVAL_PP(zdata_ptr
), (void *) &zdata_ptr
)
463 * params = [arr => [value => [0 => 1]]]
465 * zdata = [arr => [0 => NULL]]
470 while (Z_TYPE_PP(zdata_ptr
) == IS_ARRAY
471 && SUCCESS
== zend_hash_get_current_data(Z_ARRVAL_PP(zdata_ptr
), (void *) &test_ptr
)
473 if (Z_TYPE_PP(test_ptr
) == IS_ARRAY
) {
475 /* now find key in ptr */
476 if (HASH_KEY_IS_STRING
== zend_hash_get_current_key_ex(Z_ARRVAL_PP(zdata_ptr
), &hkey
.str
, &hkey
.len
, &hkey
.num
, hkey
.dup
, NULL
)) {
477 if (SUCCESS
== zend_hash_find(Z_ARRVAL_PP(ptr
), hkey
.str
, hkey
.len
, (void *) &ptr
)) {
478 zdata_ptr
= test_ptr
;
480 Z_ADDREF_PP(test_ptr
);
481 zend_hash_update(Z_ARRVAL_PP(ptr
), hkey
.str
, hkey
.len
, (void *) test_ptr
, sizeof(zval
*), (void *) &ptr
);
485 if (SUCCESS
== zend_hash_index_find(Z_ARRVAL_PP(ptr
), hkey
.num
, (void *) &ptr
)) {
486 zdata_ptr
= test_ptr
;
487 } else if (hkey
.num
) {
488 Z_ADDREF_PP(test_ptr
);
489 zend_hash_index_update(Z_ARRVAL_PP(ptr
), hkey
.num
, (void *) test_ptr
, sizeof(zval
*), (void *) &ptr
);
492 Z_ADDREF_PP(test_ptr
);
493 zend_hash_next_index_insert(Z_ARRVAL_PP(ptr
), (void *) test_ptr
, sizeof(zval
*), (void *) &ptr
);
498 /* this is the leaf */
499 Z_ADDREF_PP(test_ptr
);
500 if (Z_TYPE_PP(ptr
) != IS_ARRAY
) {
504 if (HASH_KEY_IS_STRING
== zend_hash_get_current_key_ex(Z_ARRVAL_PP(zdata_ptr
), &hkey
.str
, &hkey
.len
, &hkey
.num
, hkey
.dup
, NULL
)) {
505 zend_hash_update(Z_ARRVAL_PP(ptr
), hkey
.str
, hkey
.len
, (void *) test_ptr
, sizeof(zval
*), (void *) &ptr
);
506 } else if (hkey
.num
) {
507 zend_hash_index_update(Z_ARRVAL_PP(ptr
), hkey
.num
, (void *) test_ptr
, sizeof(zval
*), (void *) &ptr
);
509 zend_hash_next_index_insert(Z_ARRVAL_PP(ptr
), (void *) test_ptr
, sizeof(zval
*), (void *) &ptr
);
519 while (Z_TYPE_PP(ptr
) == IS_ARRAY
&& SUCCESS
== zend_hash_get_current_data(Z_ARRVAL_PP(ptr
), (void *) &ptr
));
520 *current_param
= ptr
;
523 static void push_param(HashTable
*params
, php_http_params_state_t
*state
, const php_http_params_opts_t
*opts TSRMLS_DC
)
525 if (state
->val
.str
) {
526 if (0 < (state
->val
.len
= state
->input
.str
- state
->val
.str
)) {
527 sanitize_value(opts
->flags
, state
->val
.str
, state
->val
.len
, *(state
->current
.val
), state
->rfc5987 TSRMLS_CC
);
530 } else if (state
->arg
.str
) {
531 if (0 < (state
->arg
.len
= state
->input
.str
- state
->arg
.str
)) {
533 zend_bool rfc5987
= 0;
537 sanitize_key(opts
->flags
, state
->arg
.str
, state
->arg
.len
, &key
, &rfc5987 TSRMLS_CC
);
538 state
->rfc5987
= rfc5987
;
539 if (Z_TYPE(key
) == IS_STRING
&& Z_STRLEN(key
)) {
546 if (SUCCESS
== zend_hash_find(Z_ARRVAL_PP(state
->current
.args
), ZEND_STRS("*rfc5987*"), (void *) &rfc
)) {
547 zend_symtable_update(Z_ARRVAL_PP(rfc
), Z_STRVAL(key
), Z_STRLEN(key
) + 1, (void *) &val
, sizeof(zval
*), (void *) &state
->current
.val
);
552 array_init_size(tmp
, 1);
553 zend_symtable_update(Z_ARRVAL_P(tmp
), Z_STRVAL(key
), Z_STRLEN(key
) + 1, (void *) &val
, sizeof(zval
*), (void *) &state
->current
.val
);
554 zend_symtable_update(Z_ARRVAL_PP(state
->current
.args
), ZEND_STRS("*rfc5987*"), (void *) &tmp
, sizeof(zval
*), NULL
);
557 zend_symtable_update(Z_ARRVAL_PP(state
->current
.args
), Z_STRVAL(key
), Z_STRLEN(key
) + 1, (void *) &val
, sizeof(zval
*), (void *) &state
->current
.val
);
562 } else if (state
->param
.str
) {
563 if (0 < (state
->param
.len
= state
->input
.str
- state
->param
.str
)) {
564 zval
*prm
, *arg
, *val
, *key
;
565 zend_bool rfc5987
= 0;
569 if (opts
->flags
& PHP_HTTP_PARAMS_RFC5988
) {
570 sanitize_rfc5988(state
->param
.str
, state
->param
.len
, key TSRMLS_CC
);
572 sanitize_key(opts
->flags
, state
->param
.str
, state
->param
.len
, key
, &rfc5987 TSRMLS_CC
);
573 state
->rfc5987
= rfc5987
;
575 if (Z_TYPE_P(key
) != IS_STRING
) {
576 merge_param(params
, key
, &state
->current
.val
, &state
->current
.args TSRMLS_CC
);
577 } else if (Z_STRLEN_P(key
)) {
579 array_init_size(prm
, 2);
583 ZVAL_COPY_VALUE(val
, opts
->defval
);
588 if (rfc5987
&& (opts
->flags
& PHP_HTTP_PARAMS_RFC5987
)) {
589 zend_hash_update(Z_ARRVAL_P(prm
), "*rfc5987*", sizeof("*rfc5987*"), (void *) &val
, sizeof(zval
*), (void *) &state
->current
.val
);
591 zend_hash_update(Z_ARRVAL_P(prm
), "value", sizeof("value"), (void *) &val
, sizeof(zval
*), (void *) &state
->current
.val
);
595 array_init_size(arg
, 3);
596 zend_hash_update(Z_ARRVAL_P(prm
), "arguments", sizeof("arguments"), (void *) &arg
, sizeof(zval
*), (void *) &state
->current
.args
);
598 zend_symtable_update(params
, Z_STRVAL_P(key
), Z_STRLEN_P(key
) + 1, (void *) &prm
, sizeof(zval
*), (void *) &state
->current
.param
);
605 static inline zend_bool
check_str(const char *chk_str
, size_t chk_len
, const char *sep_str
, size_t sep_len
) {
606 return 0 < sep_len
&& chk_len
>= sep_len
&& *chk_str
== *sep_str
&& !memcmp(chk_str
+ 1, sep_str
+ 1, sep_len
- 1);
609 static size_t check_sep(php_http_params_state_t
*state
, php_http_params_token_t
**separators
)
611 php_http_params_token_t
**sep
= separators
;
613 if (state
->quotes
|| state
->escape
) {
617 if (sep
) while (*sep
) {
618 if (check_str(state
->input
.str
, state
->input
.len
, (*sep
)->str
, (*sep
)->len
)) {
626 static void skip_sep(size_t skip
, php_http_params_state_t
*state
, php_http_params_token_t
**param
, php_http_params_token_t
**arg
, php_http_params_token_t
**val TSRMLS_DC
)
630 state
->input
.str
+= skip
;
631 state
->input
.len
-= skip
;
633 while ( (param
&& (sep_len
= check_sep(state
, param
)))
634 || (arg
&& (sep_len
= check_sep(state
, arg
)))
635 || (val
&& (sep_len
= check_sep(state
, val
)))
637 state
->input
.str
+= sep_len
;
638 state
->input
.len
-= sep_len
;
642 HashTable
*php_http_params_parse(HashTable
*params
, const php_http_params_opts_t
*opts TSRMLS_DC
)
644 php_http_params_state_t state
= {{NULL
,0}, {NULL
,0}, {NULL
,0}, {NULL
,0}, {NULL
,NULL
,NULL
}, 0, 0};
646 state
.input
.str
= opts
->input
.str
;
647 state
.input
.len
= opts
->input
.len
;
650 ALLOC_HASHTABLE(params
);
651 ZEND_INIT_SYMTABLE(params
);
654 while (state
.input
.len
) {
655 if ((opts
->flags
& PHP_HTTP_PARAMS_RFC5988
) && !state
.arg
.str
) {
656 if (*state
.input
.str
== '<') {
658 } else if (*state
.input
.str
== '>') {
661 } else if (*state
.input
.str
== '"' && !state
.escape
) {
662 state
.quotes
= !state
.quotes
;
664 state
.escape
= (*state
.input
.str
== '\\');
667 if (!state
.param
.str
) {
669 skip_sep(0, &state
, opts
->param
, opts
->arg
, opts
->val TSRMLS_CC
);
670 state
.param
.str
= state
.input
.str
;
673 /* are we at a param separator? */
674 if (0 < (sep_len
= check_sep(&state
, opts
->param
))) {
675 push_param(params
, &state
, opts TSRMLS_CC
);
677 skip_sep(sep_len
, &state
, opts
->param
, opts
->arg
, opts
->val TSRMLS_CC
);
679 /* start off with a new param */
680 state
.param
.str
= state
.input
.str
;
682 state
.arg
.str
= NULL
;
684 state
.val
.str
= NULL
;
690 /* are we at an arg separator? */
691 if (0 < (sep_len
= check_sep(&state
, opts
->arg
))) {
692 push_param(params
, &state
, opts TSRMLS_CC
);
694 skip_sep(sep_len
, &state
, NULL
, opts
->arg
, opts
->val TSRMLS_CC
);
696 /* continue with a new arg */
697 state
.arg
.str
= state
.input
.str
;
699 state
.val
.str
= NULL
;
705 /* are we at a val separator? */
706 if (0 < (sep_len
= check_sep(&state
, opts
->val
))) {
707 /* only handle separator if we're not already reading in a val */
708 if (!state
.val
.str
) {
709 push_param(params
, &state
, opts TSRMLS_CC
);
711 skip_sep(sep_len
, &state
, NULL
, NULL
, opts
->val TSRMLS_CC
);
713 state
.val
.str
= state
.input
.str
;
721 if (state
.input
.len
) {
727 push_param(params
, &state
, opts TSRMLS_CC
);
732 static inline void shift_key(php_http_buffer_t
*buf
, char *key_str
, size_t key_len
, const char *ass
, size_t asl
, unsigned flags TSRMLS_DC
)
738 php_http_buffer_append(buf
, ass
, asl
);
741 prepare_key(flags
, key_str
, key_len
, &str
, &len TSRMLS_CC
);
742 php_http_buffer_append(buf
, str
, len
);
746 static inline void shift_rfc5987(php_http_buffer_t
*buf
, zval
*zvalue
, const char *vss
, size_t vsl
, unsigned flags TSRMLS_DC
)
748 HashTable
*ht
= HASH_OF(zvalue
);
750 php_http_array_hashkey_t key
= php_http_array_hashkey_init(0);
752 if (SUCCESS
== zend_hash_get_current_data(ht
, (void *) &zdata
)
753 && HASH_KEY_NON_EXISTENT
!= (key
.type
= zend_hash_get_current_key_ex(ht
, &key
.str
, &key
.len
, &key
.num
, key
.dup
, NULL
))
755 php_http_array_hashkey_stringify(&key
);
756 php_http_buffer_appendf(buf
, "*%.*sutf-8'%.*s'",
757 (int) (vsl
> INT_MAX
? INT_MAX
: vsl
), vss
,
758 (int) (key
.len
> INT_MAX
? INT_MAX
: key
.len
), key
.str
);
759 php_http_array_hashkey_stringfree(&key
);
761 tmp
= php_http_zsep(1, IS_STRING
, *zdata
);
762 prepare_value(flags
| PHP_HTTP_PARAMS_URLENCODED
, tmp TSRMLS_CC
);
763 php_http_buffer_append(buf
, Z_STRVAL_P(tmp
), Z_STRLEN_P(tmp
));
768 static inline void shift_rfc5988(php_http_buffer_t
*buf
, char *key_str
, size_t key_len
, const char *ass
, size_t asl
, unsigned flags TSRMLS_DC
)
774 php_http_buffer_append(buf
, ass
, asl
);
777 prepare_key(flags
, key_str
, key_len
, &str
, &len TSRMLS_CC
);
778 php_http_buffer_appends(buf
, "<");
779 php_http_buffer_append(buf
, str
, len
);
780 php_http_buffer_appends(buf
, ">");
784 static inline void shift_rfc5988_val(php_http_buffer_t
*buf
, zval
*zv
, const char *vss
, size_t vsl
, unsigned flags TSRMLS_DC
)
786 zval
*tmp
= php_http_zsep(1, IS_STRING
, zv
);
788 quote_string(tmp
, 1 TSRMLS_CC
);
789 php_http_buffer_append(buf
, vss
, vsl
);
790 php_http_buffer_append(buf
, Z_STRVAL_P(tmp
), Z_STRLEN_P(tmp
));
795 static inline void shift_val(php_http_buffer_t
*buf
, zval
*zvalue
, const char *vss
, size_t vsl
, unsigned flags TSRMLS_DC
)
797 if (Z_TYPE_P(zvalue
) != IS_BOOL
) {
798 zval
*tmp
= php_http_zsep(1, IS_STRING
, zvalue
);
800 prepare_value(flags
, tmp TSRMLS_CC
);
801 php_http_buffer_append(buf
, vss
, vsl
);
802 php_http_buffer_append(buf
, Z_STRVAL_P(tmp
), Z_STRLEN_P(tmp
));
805 } else if (!Z_BVAL_P(zvalue
)) {
806 php_http_buffer_append(buf
, vss
, vsl
);
807 php_http_buffer_appends(buf
, "0");
811 static void shift_arg(php_http_buffer_t
*buf
, char *key_str
, size_t key_len
, zval
*zvalue
, const char *ass
, size_t asl
, const char *vss
, size_t vsl
, unsigned flags TSRMLS_DC
)
813 if (Z_TYPE_P(zvalue
) == IS_ARRAY
|| Z_TYPE_P(zvalue
) == IS_OBJECT
) {
815 php_http_array_hashkey_t key
= php_http_array_hashkey_init(0);
817 zend_bool rfc5987
= !strcmp(key_str
, "*rfc5987*");
820 shift_key(buf
, key_str
, key_len
, ass
, asl
, flags TSRMLS_CC
);
822 FOREACH_KEYVAL(pos
, zvalue
, key
, val
) {
823 /* did you mean recursion? */
824 php_http_array_hashkey_stringify(&key
);
825 if (rfc5987
&& (Z_TYPE_PP(val
) == IS_ARRAY
|| Z_TYPE_PP(val
) == IS_OBJECT
)) {
826 shift_key(buf
, key
.str
, key
.len
-1, ass
, asl
, flags TSRMLS_CC
);
827 shift_rfc5987(buf
, *val
, vss
, vsl
, flags TSRMLS_CC
);
829 shift_arg(buf
, key
.str
, key
.len
-1, *val
, ass
, asl
, vss
, vsl
, flags TSRMLS_CC
);
831 php_http_array_hashkey_stringfree(&key
);
834 shift_key(buf
, key_str
, key_len
, ass
, asl
, flags TSRMLS_CC
);
836 if (flags
& PHP_HTTP_PARAMS_RFC5988
) {
840 case lenof("anchor"):
841 /* some args must be quoted */
842 if (0 <= php_http_select_str(key_str
, 3, "rel", "title", "anchor")) {
843 shift_rfc5988_val(buf
, zvalue
, vss
, vsl
, flags TSRMLS_CC
);
850 shift_val(buf
, zvalue
, vss
, vsl
, flags TSRMLS_CC
);
854 static void shift_param(php_http_buffer_t
*buf
, char *key_str
, size_t key_len
, zval
*zvalue
, const char *pss
, size_t psl
, const char *ass
, size_t asl
, const char *vss
, size_t vsl
, unsigned flags
, zend_bool rfc5987 TSRMLS_DC
)
856 if (Z_TYPE_P(zvalue
) == IS_ARRAY
|| Z_TYPE_P(zvalue
) == IS_OBJECT
) {
857 /* treat as arguments, unless we care for dimensions or rfc5987 */
858 if (flags
& PHP_HTTP_PARAMS_DIMENSION
) {
859 php_http_buffer_t
*keybuf
= php_http_buffer_from_string(key_str
, key_len
);
860 prepare_dimension(buf
, keybuf
, zvalue
, pss
, psl
, vss
, vsl
, flags TSRMLS_CC
);
861 php_http_buffer_free(&keybuf
);
862 } else if (rfc5987
) {
863 shift_key(buf
, key_str
, key_len
, pss
, psl
, flags TSRMLS_CC
);
864 shift_rfc5987(buf
, zvalue
, vss
, vsl
, flags TSRMLS_CC
);
866 shift_arg(buf
, key_str
, key_len
, zvalue
, ass
, asl
, vss
, vsl
, flags TSRMLS_CC
);
869 if (flags
& PHP_HTTP_PARAMS_RFC5988
) {
870 shift_rfc5988(buf
, key_str
, key_len
, pss
, psl
, flags TSRMLS_CC
);
872 shift_key(buf
, key_str
, key_len
, pss
, psl
, flags TSRMLS_CC
);
874 shift_val(buf
, zvalue
, vss
, vsl
, flags TSRMLS_CC
);
878 php_http_buffer_t
*php_http_params_to_string(php_http_buffer_t
*buf
, HashTable
*params
, const char *pss
, size_t psl
, const char *ass
, size_t asl
, const char *vss
, size_t vsl
, unsigned flags TSRMLS_DC
)
881 HashPosition pos
, pos1
;
882 php_http_array_hashkey_t key
= php_http_array_hashkey_init(0), key1
= php_http_array_hashkey_init(0);
883 zend_bool rfc5987
= 0;
886 buf
= php_http_buffer_init(NULL
);
889 FOREACH_HASH_KEYVAL(pos
, params
, key
, zparam
) {
890 zval
**zvalue
, **zargs
;
892 if (Z_TYPE_PP(zparam
) != IS_ARRAY
) {
895 if (SUCCESS
!= zend_hash_find(Z_ARRVAL_PP(zparam
), ZEND_STRS("value"), (void *) &zvalue
)) {
896 if (SUCCESS
!= zend_hash_find(Z_ARRVAL_PP(zparam
), ZEND_STRS("*rfc5987*"), (void *) &zvalue
)) {
904 php_http_array_hashkey_stringify(&key
);
905 shift_param(buf
, key
.str
, key
.len
- 1, *zvalue
, pss
, psl
, ass
, asl
, vss
, vsl
, flags
, rfc5987 TSRMLS_CC
);
906 php_http_array_hashkey_stringfree(&key
);
908 if (Z_TYPE_PP(zparam
) == IS_ARRAY
&& SUCCESS
!= zend_hash_find(Z_ARRVAL_PP(zparam
), ZEND_STRS("arguments"), (void *) &zvalue
)) {
909 if (zvalue
== zparam
) {
915 if (Z_TYPE_PP(zvalue
) == IS_ARRAY
) {
916 FOREACH_KEYVAL(pos1
, *zvalue
, key1
, zargs
) {
917 if (zvalue
== zparam
&& key1
.type
== HASH_KEY_IS_STRING
&& !strcmp(key1
.str
, "value")) {
921 php_http_array_hashkey_stringify(&key1
);
922 shift_arg(buf
, key1
.str
, key1
.len
- 1, *zargs
, ass
, asl
, vss
, vsl
, flags TSRMLS_CC
);
923 php_http_array_hashkey_stringfree(&key1
);
928 php_http_buffer_shrink(buf
);
929 php_http_buffer_fix(buf
);
934 php_http_params_token_t
**php_http_params_separator_init(zval
*zv TSRMLS_DC
)
938 php_http_params_token_t
**ret
, **tmp
;
944 zv
= php_http_ztyp(IS_ARRAY
, zv
);
945 ret
= ecalloc(zend_hash_num_elements(Z_ARRVAL_P(zv
)) + 1, sizeof(*ret
));
948 FOREACH_VAL(pos
, zv
, sep
) {
949 zval
*zt
= php_http_ztyp(IS_STRING
, *sep
);
951 if (Z_STRLEN_P(zt
)) {
952 *tmp
= emalloc(sizeof(**tmp
));
953 (*tmp
)->str
= estrndup(Z_STRVAL_P(zt
), (*tmp
)->len
= Z_STRLEN_P(zt
));
964 void php_http_params_separator_free(php_http_params_token_t
**separator
)
966 php_http_params_token_t
**sep
= separator
;
969 PTR_FREE((*sep
)->str
);
977 ZEND_BEGIN_ARG_INFO_EX(ai_HttpParams___construct
, 0, 0, 0)
978 ZEND_ARG_INFO(0, params
)
979 ZEND_ARG_INFO(0, param_sep
)
980 ZEND_ARG_INFO(0, arg_sep
)
981 ZEND_ARG_INFO(0, val_sep
)
982 ZEND_ARG_INFO(0, flags
)
984 PHP_METHOD(HttpParams
, __construct
)
986 zval
*zcopy
, *zparams
= NULL
, *param_sep
= NULL
, *arg_sep
= NULL
, *val_sep
= NULL
;
987 long flags
= PHP_HTTP_PARAMS_DEFAULT
;
988 zend_error_handling zeh
;
990 php_http_expect(SUCCESS
== zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "|z!/z/z/z/l", &zparams
, ¶m_sep
, &arg_sep
, &val_sep
, &flags
), invalid_arg
, return);
992 zend_replace_error_handling(EH_THROW
, php_http_exception_runtime_class_entry
, &zeh TSRMLS_CC
);
994 switch (ZEND_NUM_ARGS()) {
996 zend_update_property_long(php_http_params_class_entry
, getThis(), ZEND_STRL("flags"), flags TSRMLS_CC
);
999 zend_update_property(php_http_params_class_entry
, getThis(), ZEND_STRL("val_sep"), val_sep TSRMLS_CC
);
1002 zend_update_property(php_http_params_class_entry
, getThis(), ZEND_STRL("arg_sep"), arg_sep TSRMLS_CC
);
1005 zend_update_property(php_http_params_class_entry
, getThis(), ZEND_STRL("param_sep"), param_sep TSRMLS_CC
);
1010 switch (Z_TYPE_P(zparams
)) {
1013 zcopy
= php_http_zsep(1, IS_ARRAY
, zparams
);
1014 zend_update_property(php_http_params_class_entry
, getThis(), ZEND_STRL("params"), zcopy TSRMLS_CC
);
1015 zval_ptr_dtor(&zcopy
);
1018 zcopy
= php_http_ztyp(IS_STRING
, zparams
);
1019 if (Z_STRLEN_P(zcopy
)) {
1020 php_http_params_opts_t opts
= {
1021 {Z_STRVAL_P(zcopy
), Z_STRLEN_P(zcopy
)},
1022 php_http_params_separator_init(zend_read_property(php_http_params_class_entry
, getThis(), ZEND_STRL("param_sep"), 0 TSRMLS_CC
) TSRMLS_CC
),
1023 php_http_params_separator_init(zend_read_property(php_http_params_class_entry
, getThis(), ZEND_STRL("arg_sep"), 0 TSRMLS_CC
) TSRMLS_CC
),
1024 php_http_params_separator_init(zend_read_property(php_http_params_class_entry
, getThis(), ZEND_STRL("val_sep"), 0 TSRMLS_CC
) TSRMLS_CC
),
1028 MAKE_STD_ZVAL(zparams
);
1029 array_init(zparams
);
1030 php_http_params_parse(Z_ARRVAL_P(zparams
), &opts TSRMLS_CC
);
1031 zend_update_property(php_http_params_class_entry
, getThis(), ZEND_STRL("params"), zparams TSRMLS_CC
);
1032 zval_ptr_dtor(&zparams
);
1034 php_http_params_separator_free(opts
.param
);
1035 php_http_params_separator_free(opts
.arg
);
1036 php_http_params_separator_free(opts
.val
);
1038 zval_ptr_dtor(&zcopy
);
1042 MAKE_STD_ZVAL(zparams
);
1043 array_init(zparams
);
1044 zend_update_property(php_http_params_class_entry
, getThis(), ZEND_STRL("params"), zparams TSRMLS_CC
);
1045 zval_ptr_dtor(&zparams
);
1048 zend_restore_error_handling(&zeh TSRMLS_CC
);
1051 ZEND_BEGIN_ARG_INFO_EX(ai_HttpParams_toArray
, 0, 0, 0)
1052 ZEND_END_ARG_INFO();
1053 PHP_METHOD(HttpParams
, toArray
)
1057 if (SUCCESS
!= zend_parse_parameters_none()) {
1060 zparams
= zend_read_property(php_http_params_class_entry
, getThis(), ZEND_STRL("params"), 0 TSRMLS_CC
);
1061 RETURN_ZVAL(zparams
, 1, 0);
1064 ZEND_BEGIN_ARG_INFO_EX(ai_HttpParams_toString
, 0, 0, 0)
1065 ZEND_END_ARG_INFO();
1066 PHP_METHOD(HttpParams
, toString
)
1068 zval
**tmp
, *zparams
, *zpsep
, *zasep
, *zvsep
, *zflags
;
1069 php_http_buffer_t buf
;
1071 zparams
= php_http_zsep(1, IS_ARRAY
, zend_read_property(php_http_params_class_entry
, getThis(), ZEND_STRL("params"), 0 TSRMLS_CC
));
1072 zflags
= php_http_ztyp(IS_LONG
, zend_read_property(php_http_params_class_entry
, getThis(), ZEND_STRL("flags"), 0 TSRMLS_CC
));
1074 zpsep
= zend_read_property(php_http_params_class_entry
, getThis(), ZEND_STRL("param_sep"), 0 TSRMLS_CC
);
1075 if (Z_TYPE_P(zpsep
) == IS_ARRAY
&& SUCCESS
== zend_hash_get_current_data(Z_ARRVAL_P(zpsep
), (void *) &tmp
)) {
1076 zpsep
= php_http_ztyp(IS_STRING
, *tmp
);
1078 zpsep
= php_http_ztyp(IS_STRING
, zpsep
);
1080 zasep
= zend_read_property(php_http_params_class_entry
, getThis(), ZEND_STRL("arg_sep"), 0 TSRMLS_CC
);
1081 if (Z_TYPE_P(zasep
) == IS_ARRAY
&& SUCCESS
== zend_hash_get_current_data(Z_ARRVAL_P(zasep
), (void *) &tmp
)) {
1082 zasep
= php_http_ztyp(IS_STRING
, *tmp
);
1084 zasep
= php_http_ztyp(IS_STRING
, zasep
);
1086 zvsep
= zend_read_property(php_http_params_class_entry
, getThis(), ZEND_STRL("val_sep"), 0 TSRMLS_CC
);
1087 if (Z_TYPE_P(zvsep
) == IS_ARRAY
&& SUCCESS
== zend_hash_get_current_data(Z_ARRVAL_P(zvsep
), (void *) &tmp
)) {
1088 zvsep
= php_http_ztyp(IS_STRING
, *tmp
);
1090 zvsep
= php_http_ztyp(IS_STRING
, zvsep
);
1093 php_http_buffer_init(&buf
);
1094 php_http_params_to_string(&buf
, Z_ARRVAL_P(zparams
), Z_STRVAL_P(zpsep
), Z_STRLEN_P(zpsep
), Z_STRVAL_P(zasep
), Z_STRLEN_P(zasep
), Z_STRVAL_P(zvsep
), Z_STRLEN_P(zvsep
), Z_LVAL_P(zflags
) TSRMLS_CC
);
1096 zval_ptr_dtor(&zparams
);
1097 zval_ptr_dtor(&zpsep
);
1098 zval_ptr_dtor(&zasep
);
1099 zval_ptr_dtor(&zvsep
);
1100 zval_ptr_dtor(&zflags
);
1102 RETVAL_PHP_HTTP_BUFFER_VAL(&buf
);
1105 ZEND_BEGIN_ARG_INFO_EX(ai_HttpParams_offsetExists
, 0, 0, 1)
1106 ZEND_ARG_INFO(0, name
)
1107 ZEND_END_ARG_INFO();
1108 PHP_METHOD(HttpParams
, offsetExists
)
1112 zval
**zparam
, *zparams
;
1114 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "s", &name_str
, &name_len
)) {
1118 zparams
= php_http_ztyp(IS_ARRAY
, zend_read_property(php_http_params_class_entry
, getThis(), ZEND_STRL("params"), 0 TSRMLS_CC
));
1120 if (SUCCESS
== zend_symtable_find(Z_ARRVAL_P(zparams
), name_str
, name_len
+ 1, (void *) &zparam
)) {
1121 RETVAL_BOOL(Z_TYPE_PP(zparam
) != IS_NULL
);
1125 zval_ptr_dtor(&zparams
);
1128 ZEND_BEGIN_ARG_INFO_EX(ai_HttpParams_offsetGet
, 0, 0, 1)
1129 ZEND_ARG_INFO(0, name
)
1130 ZEND_END_ARG_INFO();
1131 PHP_METHOD(HttpParams
, offsetGet
)
1135 zval
**zparam
, *zparams
;
1137 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "s", &name_str
, &name_len
)) {
1141 zparams
= php_http_ztyp(IS_ARRAY
, zend_read_property(php_http_params_class_entry
, getThis(), ZEND_STRL("params"), 0 TSRMLS_CC
));
1143 if (SUCCESS
== zend_symtable_find(Z_ARRVAL_P(zparams
), name_str
, name_len
+ 1, (void *) &zparam
)) {
1144 RETVAL_ZVAL(*zparam
, 1, 0);
1147 zval_ptr_dtor(&zparams
);
1150 ZEND_BEGIN_ARG_INFO_EX(ai_HttpParams_offsetUnset
, 0, 0, 1)
1151 ZEND_ARG_INFO(0, name
)
1152 ZEND_END_ARG_INFO();
1153 PHP_METHOD(HttpParams
, offsetUnset
)
1159 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "s", &name_str
, &name_len
)) {
1163 zparams
= php_http_zsep(1, IS_ARRAY
, zend_read_property(php_http_params_class_entry
, getThis(), ZEND_STRL("params"), 0 TSRMLS_CC
));
1165 zend_symtable_del(Z_ARRVAL_P(zparams
), name_str
, name_len
+ 1);
1166 zend_update_property(php_http_params_class_entry
, getThis(), ZEND_STRL("params"), zparams TSRMLS_CC
);
1168 zval_ptr_dtor(&zparams
);
1171 ZEND_BEGIN_ARG_INFO_EX(ai_HttpParams_offsetSet
, 0, 0, 2)
1172 ZEND_ARG_INFO(0, name
)
1173 ZEND_ARG_INFO(0, value
)
1174 ZEND_END_ARG_INFO();
1175 PHP_METHOD(HttpParams
, offsetSet
)
1180 zval
**zparam
, *zparams
;
1182 if (SUCCESS
!= zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC
, "sz", &name_str
, &name_len
, &nvalue
)) {
1186 zparams
= php_http_zsep(1, IS_ARRAY
, zend_read_property(php_http_params_class_entry
, getThis(), ZEND_STRL("params"), 0 TSRMLS_CC
));
1189 if (Z_TYPE_P(nvalue
) == IS_ARRAY
) {
1192 if (SUCCESS
== zend_symtable_find(Z_ARRVAL_P(zparams
), name_str
, name_len
+ 1, (void *) &zparam
)) {
1193 new_zparam
= php_http_zsep(1, IS_ARRAY
, *zparam
);
1194 array_join(Z_ARRVAL_P(nvalue
), Z_ARRVAL_P(new_zparam
), 0, 0);
1196 new_zparam
= nvalue
;
1197 Z_ADDREF_P(new_zparam
);
1199 add_assoc_zval_ex(zparams
, name_str
, name_len
+ 1, new_zparam
);
1203 if (SUCCESS
== zend_symtable_find(Z_ARRVAL_P(zparams
), name_str
, name_len
+ 1, (void *) &zparam
)) {
1204 tmp
= php_http_zsep(1, IS_ARRAY
, *zparam
);
1211 add_assoc_zval_ex(tmp
, ZEND_STRS("value"), nvalue
);
1212 add_assoc_zval_ex(zparams
, name_str
, name_len
+ 1, tmp
);
1215 zval
*tmp
= php_http_ztyp(IS_STRING
, nvalue
), *arr
;
1219 add_assoc_bool_ex(arr
, ZEND_STRS("value"), 1);
1220 add_assoc_zval_ex(zparams
, Z_STRVAL_P(tmp
), Z_STRLEN_P(tmp
) + 1, arr
);
1221 zval_ptr_dtor(&tmp
);
1224 zend_update_property(php_http_params_class_entry
, getThis(), ZEND_STRL("params"), zparams TSRMLS_CC
);
1225 zval_ptr_dtor(&zparams
);
1228 static zend_function_entry php_http_params_methods
[] = {
1229 PHP_ME(HttpParams
, __construct
, ai_HttpParams___construct
, ZEND_ACC_PUBLIC
|ZEND_ACC_CTOR
|ZEND_ACC_FINAL
)
1231 PHP_ME(HttpParams
, toArray
, ai_HttpParams_toArray
, ZEND_ACC_PUBLIC
)
1232 PHP_ME(HttpParams
, toString
, ai_HttpParams_toString
, ZEND_ACC_PUBLIC
)
1233 ZEND_MALIAS(HttpParams
, __toString
, toString
, ai_HttpParams_toString
, ZEND_ACC_PUBLIC
)
1235 PHP_ME(HttpParams
, offsetExists
, ai_HttpParams_offsetExists
, ZEND_ACC_PUBLIC
)
1236 PHP_ME(HttpParams
, offsetUnset
, ai_HttpParams_offsetUnset
, ZEND_ACC_PUBLIC
)
1237 PHP_ME(HttpParams
, offsetSet
, ai_HttpParams_offsetSet
, ZEND_ACC_PUBLIC
)
1238 PHP_ME(HttpParams
, offsetGet
, ai_HttpParams_offsetGet
, ZEND_ACC_PUBLIC
)
1240 EMPTY_FUNCTION_ENTRY
1243 zend_class_entry
*php_http_params_class_entry
;
1245 PHP_MINIT_FUNCTION(http_params
)
1247 zend_class_entry ce
= {0};
1249 INIT_NS_CLASS_ENTRY(ce
, "http", "Params", php_http_params_methods
);
1250 php_http_params_class_entry
= zend_register_internal_class(&ce TSRMLS_CC
);
1251 php_http_params_class_entry
->create_object
= php_http_params_object_new
;
1252 zend_class_implements(php_http_params_class_entry TSRMLS_CC
, 1, zend_ce_arrayaccess
);
1254 zend_declare_class_constant_stringl(php_http_params_class_entry
, ZEND_STRL("DEF_PARAM_SEP"), ZEND_STRL(",") TSRMLS_CC
);
1255 zend_declare_class_constant_stringl(php_http_params_class_entry
, ZEND_STRL("DEF_ARG_SEP"), ZEND_STRL(";") TSRMLS_CC
);
1256 zend_declare_class_constant_stringl(php_http_params_class_entry
, ZEND_STRL("DEF_VAL_SEP"), ZEND_STRL("=") TSRMLS_CC
);
1257 zend_declare_class_constant_stringl(php_http_params_class_entry
, ZEND_STRL("COOKIE_PARAM_SEP"), ZEND_STRL("") TSRMLS_CC
);
1259 zend_declare_class_constant_long(php_http_params_class_entry
, ZEND_STRL("PARSE_RAW"), PHP_HTTP_PARAMS_RAW TSRMLS_CC
);
1260 zend_declare_class_constant_long(php_http_params_class_entry
, ZEND_STRL("PARSE_ESCAPED"), PHP_HTTP_PARAMS_ESCAPED TSRMLS_CC
);
1261 zend_declare_class_constant_long(php_http_params_class_entry
, ZEND_STRL("PARSE_URLENCODED"), PHP_HTTP_PARAMS_URLENCODED TSRMLS_CC
);
1262 zend_declare_class_constant_long(php_http_params_class_entry
, ZEND_STRL("PARSE_DIMENSION"), PHP_HTTP_PARAMS_DIMENSION TSRMLS_CC
);
1263 zend_declare_class_constant_long(php_http_params_class_entry
, ZEND_STRL("PARSE_RFC5987"), PHP_HTTP_PARAMS_RFC5987 TSRMLS_CC
);
1264 zend_declare_class_constant_long(php_http_params_class_entry
, ZEND_STRL("PARSE_RFC5988"), PHP_HTTP_PARAMS_RFC5988 TSRMLS_CC
);
1265 zend_declare_class_constant_long(php_http_params_class_entry
, ZEND_STRL("PARSE_DEFAULT"), PHP_HTTP_PARAMS_DEFAULT TSRMLS_CC
);
1266 zend_declare_class_constant_long(php_http_params_class_entry
, ZEND_STRL("PARSE_QUERY"), PHP_HTTP_PARAMS_QUERY TSRMLS_CC
);
1268 zend_declare_property_null(php_http_params_class_entry
, ZEND_STRL("params"), ZEND_ACC_PUBLIC TSRMLS_CC
);
1269 zend_declare_property_stringl(php_http_params_class_entry
, ZEND_STRL("param_sep"), ZEND_STRL(","), ZEND_ACC_PUBLIC TSRMLS_CC
);
1270 zend_declare_property_stringl(php_http_params_class_entry
, ZEND_STRL("arg_sep"), ZEND_STRL(";"), ZEND_ACC_PUBLIC TSRMLS_CC
);
1271 zend_declare_property_stringl(php_http_params_class_entry
, ZEND_STRL("val_sep"), ZEND_STRL("="), ZEND_ACC_PUBLIC TSRMLS_CC
);
1272 zend_declare_property_long(php_http_params_class_entry
, ZEND_STRL("flags"), PHP_HTTP_PARAMS_DEFAULT
, ZEND_ACC_PUBLIC TSRMLS_CC
);
1282 * vim600: noet sw=4 ts=4 fdm=marker
1283 * vim<600: noet sw=4 ts=4