X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=php_http_env.c;h=eb7a6304aa53a971b4c5f9535457d49e571c7757;hb=59ffe749e2571c7e4bf0cce12997f95f350bd58c;hp=f8485f57875a72eab436ac3c15718de70d65f332;hpb=2f4ec48ea4021a994fca61cf237db306bfb54e20;p=m6w6%2Fext-http diff --git a/php_http_env.c b/php_http_env.c index f8485f5..eb7a630 100644 --- a/php_http_env.c +++ b/php_http_env.c @@ -10,9 +10,7 @@ +--------------------------------------------------------------------+ */ -#include "php_http.h" - -#include
+#include "php_http_api.h" PHP_RINIT_FUNCTION(http_env) { @@ -664,8 +662,8 @@ PHP_METHOD(HttpEnv, getResponseStatusForCode) PHP_METHOD(HttpEnv, getResponseHeader) { - char *header_name_str; - int header_name_len; + char *header_name_str = NULL; + int header_name_len = 0; if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s!", &header_name_str, &header_name_len)) { if (header_name_str && header_name_len) { @@ -716,62 +714,6 @@ PHP_METHOD(HttpEnv, setResponseCode) RETURN_FALSE; } - -#define PHP_HTTP_DO_NEGOTIATE_DEFAULT(supported) \ - { \ - zval **value; \ - \ - zend_hash_internal_pointer_reset((supported)); \ - if (SUCCESS == zend_hash_get_current_data((supported), (void *) &value)) { \ - RETVAL_ZVAL(*value, 1, 0); \ - } else { \ - RETVAL_NULL(); \ - } \ - } - -#define PHP_HTTP_DO_NEGOTIATE_HANDLE_DEFAULT(supported, rs_array) \ - PHP_HTTP_DO_NEGOTIATE_DEFAULT(supported); \ - if (rs_array) { \ - HashPosition pos; \ - zval **value_ptr; \ - \ - FOREACH_HASH_VAL(pos, supported, value_ptr) { \ - zval *value = php_http_ztyp(IS_STRING, *value_ptr); \ - add_assoc_double(rs_array, Z_STRVAL_P(value), 1.0); \ - zval_ptr_dtor(&value); \ - } \ - } - -#define PHP_HTTP_DO_NEGOTIATE_HANDLE_RESULT(result, supported, rs_array) \ - { \ - char *key; \ - uint key_len; \ - ulong idx; \ - \ - if (zend_hash_num_elements(result) && HASH_KEY_IS_STRING == zend_hash_get_current_key_ex(result, &key, &key_len, &idx, 1, NULL)) { \ - RETVAL_STRINGL(key, key_len-1, 0); \ - } else { \ - PHP_HTTP_DO_NEGOTIATE_DEFAULT(supported); \ - } \ - \ - if (rs_array) { \ - zend_hash_copy(Z_ARRVAL_P(rs_array), result, (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *)); \ - } \ - \ - zend_hash_destroy(result); \ - FREE_HASHTABLE(result); \ - } - -#define PHP_HTTP_DO_NEGOTIATE(type, supported, rs_array) \ - { \ - HashTable *result; \ - if ((result = php_http_negotiate_ ##type(supported TSRMLS_CC))) { \ - PHP_HTTP_DO_NEGOTIATE_HANDLE_RESULT(result, supported, rs_array); \ - } else { \ - PHP_HTTP_DO_NEGOTIATE_HANDLE_DEFAULT(supported, rs_array); \ - } \ - } - PHP_METHOD(HttpEnv, negotiateLanguage) { HashTable *supported;