cvs: pecl /http http_querystring_object.c
| From: | Michael Wallner | Date: | Sat, 18 Feb 2006 19:44:40 +0000 |
| Subject: | cvs: pecl /http http_querystring_object.c | ||
| Groups: | php.pecl.cvs | ||
| Request: | Send a blank email to pecl-cvs+get-5206@lists.php.net to get a copy of this message | ||
mike Sat Feb 18 19:44:40 2006 UTC
Modified files:
/pecl/http http_querystring_object.c
Log:
- simplify
http://cvs.php.net/viewcvs.cgi/pecl/http/http_querystring_object.c?r1=1.10&r2=1.11&diff_format=u
Index: pecl/http/http_querystring_object.c
diff -u pecl/http/http_querystring_object.c:1.10 pecl/http/http_querystring_object.c:1.11
--- pecl/http/http_querystring_object.c:1.10 Sat Feb 18 19:11:33 2006
+++ pecl/http/http_querystring_object.c Sat Feb 18 19:44:40 2006
@@ -10,7 +10,7 @@
+--------------------------------------------------------------------+
*/
-/* $Id: http_querystring_object.c,v 1.10 2006/02/18 19:11:33 mike Exp $ */
+/* $Id: http_querystring_object.c,v 1.11 2006/02/18 19:44:40 mike Exp $ */
#define HTTP_WANT_SAPI
#include "php_http.h"
@@ -196,8 +196,6 @@
/* {{{ querystring helpers */
#define http_querystring_update(qa, qs) _http_querystring_update((qa), (qs) TSRMLS_CC)
static inline void _http_querystring_update(zval *qarray, zval *qstring TSRMLS_DC);
-#define http_querystring_modify_ex(a, k, l, v) _http_querystring_modify_ex((a), (k), (l), (v)
TSRMLS_CC)
-static inline int _http_querystring_modify_ex(zval *qarray, char *key, uint keylen, zval *data
TSRMLS_DC);
#define http_querystring_modify_array_ex(q, k, kl, pe) _http_querystring_modify_array_ex((q), (k),
(kl), (pe) TSRMLS_CC)
static inline int _http_querystring_modify_array_ex(zval *qarray, char *key, int keylen, zval
*params_entry TSRMLS_DC);
#define http_querystring_modify_array(q, p) _http_querystring_modify_array((q), (p) TSRMLS_CC)
@@ -240,33 +238,33 @@
http_error(HE_WARNING, HTTP_E_QUERYSTRING, "Failed to update query string");
}
}
-static inline int _http_querystring_modify_ex(zval *qarray, char *key, uint keylen, zval *data
TSRMLS_DC)
-{
- if (Z_TYPE_P(data) == IS_NULL) {
- if (SUCCESS != zend_hash_del(Z_ARRVAL_P(qarray), key, keylen)) {
- return 0;
- }
- } else {
- ZVAL_ADDREF(data);
- add_assoc_zval(qarray, key, data);
- }
- return 1;
-}
static inline int _http_querystring_modify_array_ex(zval *qarray, char *key, int keylen, zval
*params_entry TSRMLS_DC)
{
zval **qarray_entry;
- if ( (Z_TYPE_P(params_entry) == IS_ARRAY) &&
- (SUCCESS == zend_hash_find(Z_ARRVAL_P(qarray), key, keylen, (void**) &qarray_entry))) {
- if (http_querystring_modify_array(*qarray_entry, params_entry)) {
- return 1;
+ /* delete */
+ if (Z_TYPE_P(params_entry) == IS_NULL) {
+ return (SUCCESS == zend_hash_del(Z_ARRVAL_P(qarray), key, keylen));
+ }
+
+ /* update */
+ if (SUCCESS == zend_hash_find(Z_ARRVAL_P(qarray), key, keylen, (void **) &qarray_entry)) {
+ zval equal;
+
+ /* recursive */
+ if (Z_TYPE_P(params_entry) == IS_ARRAY) {
+ return http_querystring_modify_array(*qarray_entry, params_entry);
}
- } else {
- if (http_querystring_modify_ex(qarray, key, keylen, params_entry)) {
- return 1;
+ /* equal */
+ if ((SUCCESS == is_equal_function(&equal, *qarray_entry, params_entry TSRMLS_CC)) &&
Z_BVAL(equal)) {
+ return 0;
}
}
- return 0;
+
+ /* add */
+ ZVAL_ADDREF(params_entry);
+ add_assoc_zval_ex(qarray, key, keylen, params_entry);
+ return 1;
}
static inline int _http_querystring_modify_array(zval *qarray, zval *params TSRMLS_DC)
{
@@ -442,13 +440,19 @@
if (Z_TYPE_P(ztype) == IS_LONG) {
type = Z_LVAL_P(ztype);
} else if(Z_TYPE_P(ztype) == IS_STRING) {
- switch (tolower(Z_STRVAL_P(ztype)[0]))
+ switch (Z_STRVAL_P(ztype)[0])
{
+ case 'B':
case 'b': type = HTTP_QUERYSTRING_TYPE_BOOL; break;
+ case 'I':
case 'i': type = HTTP_QUERYSTRING_TYPE_INT; break;
+ case 'F':
case 'f': type = HTTP_QUERYSTRING_TYPE_FLOAT; break;
+ case 'S':
case 's': type = HTTP_QUERYSTRING_TYPE_STRING; break;
+ case 'A':
case 'a': type = HTTP_QUERYSTRING_TYPE_ARRAY; break;
+ case 'O':
case 'o': type = HTTP_QUERYSTRING_TYPE_OBJECT; break;
}
}