From: Michael Wallner Date: Thu, 1 Mar 2012 13:31:58 +0000 (+0000) Subject: separate http_env_request; add getQuer(), getPost(), getFiles() X-Git-Tag: DEV_2-before-client~32 X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=commitdiff_plain;h=14aec371d6123fbedbe13ca73b6a6d5768c635cb separate http_env_request; add getQuer(), getPost(), getFiles() --- diff --git a/config9.m4 b/config9.m4 index 005e77f..2a03cef 100644 --- a/config9.m4 +++ b/config9.m4 @@ -397,6 +397,7 @@ dnl ---- php_http_cookie.c \ php_http_encoding.c \ php_http_env.c \ + php_http_env_request.c \ php_http_env_response.c \ php_http_etag.c \ php_http_exception.c \ @@ -440,6 +441,7 @@ dnl ---- php_http_cookie.h \ php_http_encoding.h \ php_http_env.h \ + php_http_env_request.h \ php_http_env_response.h \ php_http_etag.h \ php_http_exception.h \ diff --git a/php_http.c b/php_http.c index 2cd6549..d5211bc 100644 --- a/php_http.c +++ b/php_http.c @@ -150,6 +150,7 @@ PHP_MINIT_FUNCTION(http) || SUCCESS != PHP_MINIT_CALL(http_request_pool) || SUCCESS != PHP_MINIT_CALL(http_url) || SUCCESS != PHP_MINIT_CALL(http_env) + || SUCCESS != PHP_MINIT_CALL(http_env_request) || SUCCESS != PHP_MINIT_CALL(http_env_response) || SUCCESS != PHP_MINIT_CALL(http_params) ) { diff --git a/php_http_api.h b/php_http_api.h index 50ff615..a6ea120 100644 --- a/php_http_api.h +++ b/php_http_api.h @@ -78,6 +78,7 @@ typedef int STATUS; #include "php_http_curl.h" #include "php_http_encoding.h" #include "php_http_env.h" +#include "php_http_env_request.h" #include "php_http_env_response.h" #include "php_http_etag.h" #include "php_http_exception.h" diff --git a/php_http_env.c b/php_http_env.c index 9fd8e59..926e252 100644 --- a/php_http_env.c +++ b/php_http_env.c @@ -105,9 +105,22 @@ PHP_HTTP_API int php_http_env_got_request_header(const char *name_str, size_t na return got; } +PHP_HTTP_API zval *php_http_env_get_superglobal(const char *key, size_t key_len TSRMLS_DC) +{ + zval **hsv; + + zend_is_auto_global(key, key_len TSRMLS_CC); + + if ((SUCCESS != zend_hash_find(&EG(symbol_table), key, key_len + 1, (void *) &hsv)) || (Z_TYPE_PP(hsv) != IS_ARRAY)) { + return NULL; + } + + return *hsv; +} + PHP_HTTP_API zval *php_http_env_get_server_var(const char *key, size_t key_len, zend_bool check TSRMLS_DC) { - zval **hsv, **var; + zval *hsv, **var; char *env; /* if available, this is a lot faster than accessing $_SERVER */ @@ -123,12 +136,10 @@ PHP_HTTP_API zval *php_http_env_get_server_var(const char *key, size_t key_len, return PHP_HTTP_G->env.server_var; } - zend_is_auto_global(ZEND_STRL("_SERVER") TSRMLS_CC); - - if ((SUCCESS != zend_hash_find(&EG(symbol_table), ZEND_STRS("_SERVER"), (void *) &hsv)) || (Z_TYPE_PP(hsv) != IS_ARRAY)) { + if (!(hsv = php_http_env_get_superglobal(ZEND_STRL("_SERVER") TSRMLS_CC))) { return NULL; } - if ((SUCCESS != zend_symtable_find(Z_ARRVAL_PP(hsv), key, key_len + 1, (void *) &var))) { + if ((SUCCESS != zend_symtable_find(Z_ARRVAL_P(hsv), key, key_len + 1, (void *) &var))) { return NULL; } if (check && !((Z_TYPE_PP(var) == IS_STRING) && Z_STRVAL_PP(var) && Z_STRLEN_PP(var))) { @@ -832,41 +843,10 @@ PHP_METHOD(HttpEnv, cleanPersistentHandles) } } -zend_class_entry *php_http_env_request_class_entry; - -#undef PHP_HTTP_BEGIN_ARGS -#undef PHP_HTTP_EMPTY_ARGS -#define PHP_HTTP_BEGIN_ARGS(method, req_args) PHP_HTTP_BEGIN_ARGS_EX(HttpEnvRequest, method, 0, req_args) -#define PHP_HTTP_EMPTY_ARGS(method) PHP_HTTP_EMPTY_ARGS_EX(HttpEnvRequest, method, 0) -#define PHP_HTTP_ENV_REQUEST_ME(method, visibility) PHP_ME(HttpEnvRequest, method, PHP_HTTP_ARGS(HttpEnvRequest, method), visibility) - -PHP_HTTP_EMPTY_ARGS(__construct); - -zend_function_entry php_http_env_request_method_entry[] = { - PHP_HTTP_ENV_REQUEST_ME(__construct, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR) - - EMPTY_FUNCTION_ENTRY -}; - -PHP_METHOD(HttpEnvRequest, __construct) -{ - with_error_handling(EH_THROW, php_http_exception_class_entry) { - if (SUCCESS == zend_parse_parameters_none()) { - php_http_message_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC); - - with_error_handling(EH_THROW, php_http_exception_class_entry) { - obj->message = php_http_message_init_env(obj->message, PHP_HTTP_REQUEST TSRMLS_CC); - } end_error_handling(); - } - } end_error_handling(); -} - PHP_MINIT_FUNCTION(http_env) { PHP_HTTP_REGISTER_CLASS(http, Env, http_env, NULL, 0); - PHP_HTTP_REGISTER_CLASS(http\\Env, Request, http_env_request, php_http_message_class_entry, 0); - return SUCCESS; } diff --git a/php_http_env.h b/php_http_env.h index 493f1e0..be0215b 100644 --- a/php_http_env.h +++ b/php_http_env.h @@ -68,6 +68,7 @@ PHP_HTTP_API STATUS php_http_env_set_response_header_format(long http_code, zend PHP_HTTP_API zval *php_http_env_get_server_var(const char *key_str, size_t key_len, zend_bool check TSRMLS_DC); #define php_http_env_got_server_var(v) (NULL != php_http_env_get_server_var((v), strlen(v), 1 TSRMLS_CC)) +PHP_HTTP_API zval *php_http_env_get_superglobal(const char *key, size_t key_len TSRMLS_DC); extern zend_class_entry *php_http_env_class_entry; extern zend_function_entry php_http_env_method_entry[]; @@ -87,11 +88,6 @@ PHP_METHOD(HttpEnv, negotiate); PHP_METHOD(HttpEnv, statPersistentHandles); PHP_METHOD(HttpEnv, cleanPersistentHandles); -extern zend_class_entry *php_http_env_request_class_entry; -extern zend_function_entry php_http_env_request_method_entry[]; - -PHP_METHOD(HttpEnvRequest, __construct); - PHP_MINIT_FUNCTION(http_env); PHP_RINIT_FUNCTION(http_env); PHP_RSHUTDOWN_FUNCTION(http_env); diff --git a/php_http_env_request.c b/php_http_env_request.c new file mode 100644 index 0000000..c11f730 --- /dev/null +++ b/php_http_env_request.c @@ -0,0 +1,200 @@ +/* + +--------------------------------------------------------------------+ + | PECL :: http | + +--------------------------------------------------------------------+ + | Redistribution and use in source and binary forms, with or without | + | modification, are permitted provided that the conditions mentioned | + | in the accompanying LICENSE file are met. | + +--------------------------------------------------------------------+ + | Copyright (c) 2004-2011, Michael Wallner | + +--------------------------------------------------------------------+ +*/ + +#include "php_http_api.h" + + +zend_class_entry *php_http_env_request_class_entry; + +#undef PHP_HTTP_BEGIN_ARGS +#undef PHP_HTTP_EMPTY_ARGS +#define PHP_HTTP_BEGIN_ARGS(method, req_args) PHP_HTTP_BEGIN_ARGS_EX(HttpEnvRequest, method, 0, req_args) +#define PHP_HTTP_EMPTY_ARGS(method) PHP_HTTP_EMPTY_ARGS_EX(HttpEnvRequest, method, 0) +#define PHP_HTTP_ENV_REQUEST_ME(method, visibility) PHP_ME(HttpEnvRequest, method, PHP_HTTP_ARGS(HttpEnvRequest, method), visibility) + +PHP_HTTP_EMPTY_ARGS(__construct); +PHP_HTTP_EMPTY_ARGS(getPost); +PHP_HTTP_EMPTY_ARGS(getQuery); +PHP_HTTP_EMPTY_ARGS(getFiles); + +zend_function_entry php_http_env_request_method_entry[] = { + PHP_HTTP_ENV_REQUEST_ME(__construct, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR) + PHP_HTTP_ENV_REQUEST_ME(getPost, ZEND_ACC_PUBLIC) + PHP_HTTP_ENV_REQUEST_ME(getQuery, ZEND_ACC_PUBLIC) + PHP_HTTP_ENV_REQUEST_ME(getFiles, ZEND_ACC_PUBLIC) + + EMPTY_FUNCTION_ENTRY +}; + +static int grab_file(void *zpp TSRMLS_DC, int argc, va_list argv, zend_hash_key *key) +{ + zval *zfiles, **name, **zname, **error, **zerror, **type, **ztype, **size, **zsize, **tmp_name = zpp; + zend_hash_key *file_key; + + zfiles = (zval *) va_arg(argv, zval *); + file_key = (zend_hash_key *) va_arg(argv, zend_hash_key *); + name = (zval **) va_arg(argv, zval **); + size = (zval **) va_arg(argv, zval **); + type = (zval **) va_arg(argv, zval **); + error = (zval **) va_arg(argv, zval **); + + if (SUCCESS == zend_hash_index_find(Z_ARRVAL_PP(name), key->h, (void *) &zname) + && SUCCESS == zend_hash_index_find(Z_ARRVAL_PP(size), key->h, (void *) &zsize) + && SUCCESS == zend_hash_index_find(Z_ARRVAL_PP(type), key->h, (void *) &ztype) + && SUCCESS == zend_hash_index_find(Z_ARRVAL_PP(error), key->h, (void *) &zerror) + ) { + zval *entry; + + MAKE_STD_ZVAL(entry); + array_init(entry); + + Z_ADDREF_PP(tmp_name); + add_assoc_zval_ex(entry, ZEND_STRS("file"), *tmp_name); + Z_ADDREF_PP(zname); + add_assoc_zval_ex(entry, ZEND_STRS("name"), *zname); + Z_ADDREF_PP(zsize); + add_assoc_zval_ex(entry, ZEND_STRS("size"), *zsize); + Z_ADDREF_PP(ztype); + add_assoc_zval_ex(entry, ZEND_STRS("type"), *ztype); + Z_ADDREF_PP(zerror); + add_assoc_zval_ex(entry, ZEND_STRS("error"), *zerror); + + zend_hash_quick_update(Z_ARRVAL_P(zfiles), file_key->arKey, file_key->nKeyLength, file_key->h, (void *) &entry, sizeof(zval *), NULL); + } + + return ZEND_HASH_APPLY_KEEP; +} + +static int grab_files(void *zpp TSRMLS_DC, int argc, va_list argv, zend_hash_key *key) +{ + zval *zfiles, **name, **tmp_name, **error, **type, **size, **val = zpp; + + zfiles = (zval *) va_arg(argv, zval *); + + if (Z_TYPE_PP(val) == IS_ARRAY + && SUCCESS == zend_hash_find(Z_ARRVAL_PP(val), ZEND_STRS("tmp_name"), (void *) &tmp_name) + && SUCCESS == zend_hash_find(Z_ARRVAL_PP(val), ZEND_STRS("name"), (void *) &name) + && SUCCESS == zend_hash_find(Z_ARRVAL_PP(val), ZEND_STRS("size"), (void *) &size) + && SUCCESS == zend_hash_find(Z_ARRVAL_PP(val), ZEND_STRS("type"), (void *) &type) + && SUCCESS == zend_hash_find(Z_ARRVAL_PP(val), ZEND_STRS("error"), (void *) &error) + ) { + int count; + + if (Z_TYPE_PP(tmp_name) == IS_ARRAY && (count = zend_hash_num_elements(Z_ARRVAL_PP(tmp_name))) > 1) { + if (count == zend_hash_num_elements(Z_ARRVAL_PP(name)) + && count == zend_hash_num_elements(Z_ARRVAL_PP(size)) + && count == zend_hash_num_elements(Z_ARRVAL_PP(type)) + && count == zend_hash_num_elements(Z_ARRVAL_PP(error)) + ) { + zend_hash_apply_with_arguments(Z_ARRVAL_PP(tmp_name) TSRMLS_CC, grab_file, 6, zfiles, key, name, size, type, error); + } else { + /* wat?! */ + return ZEND_HASH_APPLY_STOP; + } + } else { + zval *cpy, **tmp; + + MAKE_STD_ZVAL(cpy); + MAKE_COPY_ZVAL(val, cpy); + if (SUCCESS == zend_hash_find(Z_ARRVAL_P(cpy), ZEND_STRS("tmp_name"), (void *) &tmp)) { + Z_ADDREF_PP(tmp); + add_assoc_zval_ex(cpy, ZEND_STRS("file"), *tmp); + zend_hash_del_key_or_index(Z_ARRVAL_P(cpy), ZEND_STRS("tmp_name"), 0, HASH_DEL_KEY); + } + zend_hash_quick_update(Z_ARRVAL_P(zfiles), key->arKey, key->nKeyLength, key->h, (void *) &cpy, sizeof(zval *), NULL); + } + } + + return ZEND_HASH_APPLY_KEEP; +} + +PHP_METHOD(HttpEnvRequest, __construct) +{ + with_error_handling(EH_THROW, php_http_exception_class_entry) { + if (SUCCESS == zend_parse_parameters_none()) { + php_http_message_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC); + zval *zsg; + + obj->message = php_http_message_init_env(obj->message, PHP_HTTP_REQUEST TSRMLS_CC); + + if ((zsg = php_http_env_get_superglobal(ZEND_STRL("_GET") TSRMLS_CC))) { + zval *zquery; + + MAKE_STD_ZVAL(zquery); + object_init_ex(zquery, php_http_querystring_class_entry); + if (SUCCESS == php_http_querystring_ctor(zquery, zsg TSRMLS_CC)) { + zend_update_property(php_http_env_request_class_entry, getThis(), ZEND_STRL("query"), zquery TSRMLS_CC); + } + } + if ((zsg = php_http_env_get_superglobal(ZEND_STRL("_POST") TSRMLS_CC))) { + zval *zpost; + + MAKE_STD_ZVAL(zpost); + object_init_ex(zpost, php_http_querystring_class_entry); + if (SUCCESS == php_http_querystring_ctor(zpost, zsg TSRMLS_CC)) { + zend_update_property(php_http_env_request_class_entry, getThis(), ZEND_STRL("post"), zpost TSRMLS_CC); + } + } + if ((zsg = php_http_env_get_superglobal(ZEND_STRL("_FILES") TSRMLS_CC))) { + zval *zfiles; + + MAKE_STD_ZVAL(zfiles); + array_init(zfiles); + zend_hash_apply_with_arguments(Z_ARRVAL_P(zsg) TSRMLS_CC, grab_files, 1, zfiles); + + zend_update_property(php_http_env_request_class_entry, getThis(), ZEND_STRL("files"), zfiles TSRMLS_CC); + } + } + } end_error_handling(); +} + +PHP_METHOD(HttpEnvRequest, getPost) +{ + if (SUCCESS == zend_parse_parameters_none()) { + RETURN_PROP(php_http_env_request_class_entry, "post"); + } +} + +PHP_METHOD(HttpEnvRequest, getQuery) +{ + if (SUCCESS == zend_parse_parameters_none()) { + RETURN_PROP(php_http_env_request_class_entry, "query"); + } +} + +PHP_METHOD(HttpEnvRequest, getFiles) +{ + if (SUCCESS == zend_parse_parameters_none()) { + RETURN_PROP(php_http_env_request_class_entry, "files"); + } +} + + +PHP_MINIT_FUNCTION(http_env_request) +{ + PHP_HTTP_REGISTER_CLASS(http\\Env, Request, http_env_request, php_http_message_class_entry, 0); + zend_declare_property_null(php_http_env_request_class_entry, ZEND_STRL("query"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(php_http_env_request_class_entry, ZEND_STRL("post"), ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_null(php_http_env_request_class_entry, ZEND_STRL("files"), ZEND_ACC_PROTECTED TSRMLS_CC); + + return SUCCESS; +} + + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * End: + * vim600: noet sw=4 ts=4 fdm=marker + * vim<600: noet sw=4 ts=4 + */ diff --git a/php_http_env_request.h b/php_http_env_request.h new file mode 100644 index 0000000..9a27f10 --- /dev/null +++ b/php_http_env_request.h @@ -0,0 +1,35 @@ +/* + +--------------------------------------------------------------------+ + | PECL :: http | + +--------------------------------------------------------------------+ + | Redistribution and use in source and binary forms, with or without | + | modification, are permitted provided that the conditions mentioned | + | in the accompanying LICENSE file are met. | + +--------------------------------------------------------------------+ + | Copyright (c) 2004-2011, Michael Wallner | + +--------------------------------------------------------------------+ +*/ + +#ifndef PHP_HTTP_ENV_REQUEST_H +#define PHP_HTTP_ENV_REQUEST_H + +extern zend_class_entry *php_http_env_request_class_entry; +extern zend_function_entry php_http_env_request_method_entry[]; + +PHP_METHOD(HttpEnvRequest, __construct); +PHP_METHOD(HttpEnvRequest, getPost); +PHP_METHOD(HttpEnvRequest, getQuery); +PHP_METHOD(HttpEnvRequest, getFiles); + +PHP_MINIT_FUNCTION(http_env_request); + +#endif + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * End: + * vim600: noet sw=4 ts=4 fdm=marker + * vim<600: noet sw=4 ts=4 + */ diff --git a/php_http_info.c b/php_http_info.c index cc015a8..09964bb 100644 --- a/php_http_info.c +++ b/php_http_info.c @@ -111,7 +111,7 @@ PHP_HTTP_API php_http_info_t *php_http_info_parse(php_http_info_t *info, const c } /* is request */ - else if (*(http - 1) == ' ' && !http[lenof("HTTP/1.x")] || http[lenof("HTTP/1.x")] == '\r' || http[lenof("HTTP/1.x")] == '\n') { + else if (*(http - 1) == ' ' && (!http[lenof("HTTP/1.x")] || http[lenof("HTTP/1.x")] == '\r' || http[lenof("HTTP/1.x")] == '\n')) { const char *url = strchr(pre_header, ' '); info->type = PHP_HTTP_REQUEST; diff --git a/php_http_querystring.c b/php_http_querystring.c index 7c569de..177701b 100644 --- a/php_http_querystring.c +++ b/php_http_querystring.c @@ -20,6 +20,62 @@ # include #endif + +#define QS_MERGE 1 + +static inline void php_http_querystring_set(zval *instance, zval *params, int flags TSRMLS_DC) +{ + zval *qa; + + if (flags & QS_MERGE) { + qa = php_http_zsep(1, IS_ARRAY, zend_read_property(php_http_querystring_class_entry, instance, ZEND_STRL("queryArray"), 0 TSRMLS_CC)); + } else { + MAKE_STD_ZVAL(qa); + array_init(qa); + } + + php_http_querystring_update(qa, params, NULL TSRMLS_CC); + zend_update_property(php_http_querystring_class_entry, instance, ZEND_STRL("queryArray"), qa TSRMLS_CC); + zval_ptr_dtor(&qa); +} + +static inline void php_http_querystring_str(zval *instance, zval *return_value TSRMLS_DC) +{ + zval *qa = zend_read_property(php_http_querystring_class_entry, instance, ZEND_STRL("queryArray"), 0 TSRMLS_CC); + + if (Z_TYPE_P(qa) == IS_ARRAY) { + php_http_querystring_update(qa, NULL, return_value TSRMLS_CC); + } else { + RETURN_EMPTY_STRING(); + } +} + +static inline void php_http_querystring_get(zval *this_ptr, int type, char *name, uint name_len, zval *defval, zend_bool del, zval *return_value TSRMLS_DC) +{ + zval **arrval, *qarray = zend_read_property(php_http_querystring_class_entry, getThis(), ZEND_STRL("queryArray"), 0 TSRMLS_CC); + + if ((Z_TYPE_P(qarray) == IS_ARRAY) && (SUCCESS == zend_symtable_find(Z_ARRVAL_P(qarray), name, name_len + 1, (void *) &arrval))) { + if (type) { + zval *value = php_http_ztyp(type, *arrval); + RETVAL_ZVAL(value, 1, 1); + } else { + RETVAL_ZVAL(*arrval, 1, 0); + } + + if (del) { + zval *delarr; + + MAKE_STD_ZVAL(delarr); + array_init(delarr); + add_assoc_null_ex(delarr, name, name_len + 1); + php_http_querystring_set(this_ptr, delarr, QS_MERGE TSRMLS_CC); + zval_ptr_dtor(&delarr); + } + } else if(defval) { + RETURN_ZVAL(defval, 1, 0); + } +} + #ifdef PHP_HTTP_HAVE_ICONV PHP_HTTP_API STATUS php_http_querystring_xlate(zval *dst, zval *src, const char *ie, const char *oe TSRMLS_DC) { @@ -76,6 +132,12 @@ PHP_HTTP_API STATUS php_http_querystring_xlate(zval *dst, zval *src, const char } #endif /* HAVE_ICONV */ +PHP_HTTP_API STATUS php_http_querystring_ctor(zval *instance, zval *params TSRMLS_DC) +{ + php_http_querystring_set(instance, params, 0 TSRMLS_CC); + return SUCCESS; +} + PHP_HTTP_API STATUS php_http_querystring_update(zval *qarray, zval *params, zval *outstring TSRMLS_DC) { /* enforce proper type */ @@ -313,60 +375,6 @@ PHP_MINIT_FUNCTION(http_querystring) return SUCCESS; } -#define QS_MERGE 1 - -static inline void php_http_querystring_set(zval *instance, zval *params, int flags TSRMLS_DC) -{ - zval *qa; - - if (flags & QS_MERGE) { - qa = php_http_zsep(1, IS_ARRAY, zend_read_property(php_http_querystring_class_entry, instance, ZEND_STRL("queryArray"), 0 TSRMLS_CC)); - } else { - MAKE_STD_ZVAL(qa); - array_init(qa); - } - - php_http_querystring_update(qa, params, NULL TSRMLS_CC); - zend_update_property(php_http_querystring_class_entry, instance, ZEND_STRL("queryArray"), qa TSRMLS_CC); - zval_ptr_dtor(&qa); -} - -static inline void php_http_querystring_str(zval *instance, zval *return_value TSRMLS_DC) -{ - zval *qa = zend_read_property(php_http_querystring_class_entry, instance, ZEND_STRL("queryArray"), 0 TSRMLS_CC); - - if (Z_TYPE_P(qa) == IS_ARRAY) { - php_http_querystring_update(qa, NULL, return_value TSRMLS_CC); - } else { - RETURN_EMPTY_STRING(); - } -} - -static inline void php_http_querystring_get(zval *this_ptr, int type, char *name, uint name_len, zval *defval, zend_bool del, zval *return_value TSRMLS_DC) -{ - zval **arrval, *qarray = zend_read_property(php_http_querystring_class_entry, getThis(), ZEND_STRL("queryArray"), 0 TSRMLS_CC); - - if ((Z_TYPE_P(qarray) == IS_ARRAY) && (SUCCESS == zend_symtable_find(Z_ARRVAL_P(qarray), name, name_len + 1, (void *) &arrval))) { - if (type) { - zval *value = php_http_ztyp(type, *arrval); - RETVAL_ZVAL(value, 1, 1); - } else { - RETVAL_ZVAL(*arrval, 1, 0); - } - - if (del) { - zval *delarr; - - MAKE_STD_ZVAL(delarr); - array_init(delarr); - add_assoc_null_ex(delarr, name, name_len + 1); - php_http_querystring_set(this_ptr, delarr, QS_MERGE TSRMLS_CC); - zval_ptr_dtor(&delarr); - } - } else if(defval) { - RETURN_ZVAL(defval, 1, 0); - } -} PHP_METHOD(HttpQueryString, __construct) { zval *params = NULL; diff --git a/php_http_querystring.h b/php_http_querystring.h index e586964..9331fcd 100644 --- a/php_http_querystring.h +++ b/php_http_querystring.h @@ -17,6 +17,7 @@ PHP_HTTP_API STATUS php_http_querystring_xlate(zval *dst, zval *src, const char *ie, const char *oe TSRMLS_DC); #endif /* PHP_HTTP_HAVE_ICONV */ PHP_HTTP_API STATUS php_http_querystring_update(zval *qarray, zval *params, zval *qstring TSRMLS_DC); +PHP_HTTP_API STATUS php_http_querystring_ctor(zval *instance, zval *params TSRMLS_DC); typedef php_http_object_t php_http_querystring_object_t;