From ccd556e32e7264830790ec13b72a9b0e3760684b Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Mon, 27 Feb 2006 14:35:04 +0000 Subject: [PATCH] - ditch warnings - give anonymous types a name --- http_cookie_api.c | 9 ++++----- http_filter_api.c | 2 +- http_info_api.c | 12 +++++------- http_response_object.c | 8 +++----- php_http_cache_api.h | 2 +- php_http_cookie_api.h | 2 +- php_http_deflatestream_object.h | 2 +- php_http_encoding_api.h | 4 ++-- php_http_headers_api.h | 2 +- php_http_inflatestream_object.h | 2 +- php_http_info_api.h | 12 ++++++------ php_http_message_api.h | 6 +++--- php_http_message_object.h | 2 +- php_http_querystring_object.h | 2 +- php_http_request_api.h | 2 +- php_http_request_body_api.h | 2 +- php_http_request_method_api.h | 6 ++++-- php_http_request_object.h | 2 +- php_http_request_pool_api.h | 2 +- php_http_requestpool_object.h | 2 +- php_http_send_api.h | 2 +- phpstr/phpstr.h | 4 ++-- tests/request_cookies.phpt | 12 ++++++------ 23 files changed, 49 insertions(+), 52 deletions(-) diff --git a/http_cookie_api.c b/http_cookie_api.c index bf9af40..c216e2d 100644 --- a/http_cookie_api.c +++ b/http_cookie_api.c @@ -66,7 +66,7 @@ PHP_HTTP_API void _http_cookie_list_free(http_cookie_list **list TSRMLS_DC) PHP_HTTP_API const char *_http_cookie_list_get_cookie(http_cookie_list *list, const char *name, size_t name_len TSRMLS_DC) { zval **cookie = NULL; - if ((SUCCESS != zend_hash_find(&list->cookies, name, name_len + 1, (void **) &cookie)) || (Z_TYPE_PP(cookie) != IS_STRING)) { + if ((SUCCESS != zend_hash_find(&list->cookies, (char *) name, name_len + 1, (void **) &cookie)) || (Z_TYPE_PP(cookie) != IS_STRING)) { return NULL; } return Z_STRVAL_PP(cookie); @@ -75,7 +75,7 @@ PHP_HTTP_API const char *_http_cookie_list_get_cookie(http_cookie_list *list, co PHP_HTTP_API const char *_http_cookie_list_get_extra(http_cookie_list *list, const char *name, size_t name_len TSRMLS_DC) { zval **extra = NULL; - if ((SUCCESS != zend_hash_find(&list->extras,name, name_len + 1, (void **) &extra)) || (Z_TYPE_PP(extra) != IS_STRING)) { + if ((SUCCESS != zend_hash_find(&list->extras, (char *) name, name_len + 1, (void **) &extra)) || (Z_TYPE_PP(extra) != IS_STRING)) { return NULL; } return Z_STRVAL_PP(extra); @@ -86,7 +86,7 @@ PHP_HTTP_API void _http_cookie_list_add_cookie(http_cookie_list *list, const cha zval *cookie_value; MAKE_STD_ZVAL(cookie_value); ZVAL_STRINGL(cookie_value, estrndup(value, value_len), value_len, 0); - zend_hash_update(&list->cookies, name, name_len + 1, (void *) &cookie_value, sizeof(zval *), NULL); + zend_hash_update(&list->cookies, (char *) name, name_len + 1, (void *) &cookie_value, sizeof(zval *), NULL); } PHP_HTTP_API void _http_cookie_list_add_extra(http_cookie_list *list, const char *name, size_t name_len, const char *value, size_t value_len TSRMLS_DC) @@ -94,7 +94,7 @@ PHP_HTTP_API void _http_cookie_list_add_extra(http_cookie_list *list, const char zval *cookie_value; MAKE_STD_ZVAL(cookie_value); ZVAL_STRINGL(cookie_value, estrndup(value, value_len), value_len, 0); - zend_hash_update(&list->extras, name, name_len + 1, (void *) &cookie_value, sizeof(zval *), NULL); + zend_hash_update(&list->extras, (char *) name, name_len + 1, (void *) &cookie_value, sizeof(zval *), NULL); } #define http_cookie_list_set_item_ex(l, i, il, v, vl, f, a) _http_cookie_list_set_item_ex((l), (i), (il), (v), (vl), (f), (a) TSRMLS_CC) @@ -219,7 +219,6 @@ PHP_HTTP_API http_cookie_list *_http_parse_cookie_ex(http_cookie_list *list, con case ';': case '\0': goto add; - st = ST_ADD; break; default: diff --git a/http_filter_api.c b/http_filter_api.c index 35cff1c..dcc7186 100644 --- a/http_filter_api.c +++ b/http_filter_api.c @@ -74,7 +74,7 @@ PHP_MINIT_FUNCTION(http_filter) php_stream_bucket_append(buckets_out, __buck TSRMLS_CC); \ } -typedef struct { +typedef struct _http_chunked_decode_filter_buffer_t { phpstr buffer; ulong hexlen; } HTTP_FILTER_BUFFER(chunked_decode); diff --git a/http_info_api.c b/http_info_api.c index 8e45de3..5140b6c 100644 --- a/http_info_api.c +++ b/http_info_api.c @@ -37,19 +37,17 @@ PHP_HTTP_API void _http_info_default_callback(void **nothing, HashTable **header } } -PHP_HTTP_API void _http_info_dtor(http_info *info) +PHP_HTTP_API void _http_info_dtor(http_info *i) { - http_info_t *i = (http_info_t *) info; - - switch (info->type) + switch (i->type) { case IS_HTTP_REQUEST: - STR_SET(i->request.method, NULL); - STR_SET(i->request.url, NULL); + STR_SET(HTTP_INFO(i).request.method, NULL); + STR_SET(HTTP_INFO(i).request.url, NULL); break; case IS_HTTP_RESPONSE: - STR_SET(i->response.status, NULL); + STR_SET(HTTP_INFO(i).response.status, NULL); break; default: diff --git a/http_response_object.c b/http_response_object.c index 011944d..02578d0 100644 --- a/http_response_object.c +++ b/http_response_object.c @@ -567,15 +567,12 @@ PHP_METHOD(HttpResponse, getContentType) */ PHP_METHOD(HttpResponse, guessContentType) { +#ifdef HTTP_HAVE_MAGIC char *magic_file, *ct = NULL; int magic_file_len; - long magic_mode = 0; + long magic_mode = MAGIC_MIME; RETVAL_FALSE; - -#ifdef HTTP_HAVE_MAGIC - magic_mode = MAGIC_MIME; - SET_EH_THROW_HTTP(); if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &magic_file, &magic_file_len, &magic_mode)) { switch (Z_LVAL_P(GET_STATIC_PROP(mode))) { @@ -608,6 +605,7 @@ PHP_METHOD(HttpResponse, guessContentType) SET_EH_NORMAL(); #else http_error(HE_THROW, HTTP_E_RUNTIME, "Cannot guess Content-Type; libmagic not available"); + RETURN_FALSE; #endif } /* }}} */ diff --git a/php_http_cache_api.h b/php_http_cache_api.h index 6c2121c..6efe1d8 100644 --- a/php_http_cache_api.h +++ b/php_http_cache_api.h @@ -116,7 +116,7 @@ static inline void _http_etag_update(void *ctx, const char *data_ptr, size_t dat if (mode && ((!strcasecmp(mode, "crc32")) || (!strcasecmp(mode, "crc32b")))) { uint i, c = *((uint *) ctx); for (i = 0; i < data_len; ++i) { - c = CRC32(c, data_ptr[i]); + CRC32(c, data_ptr[i]); } *((uint *)ctx) = c; } else if (mode && (!strcasecmp(mode, "sha1"))) { diff --git a/php_http_cookie_api.h b/php_http_cookie_api.h index 2a9d628..dfdcdc5 100644 --- a/php_http_cookie_api.h +++ b/php_http_cookie_api.h @@ -27,7 +27,7 @@ extern PHP_MINIT_FUNCTION(http_cookie); cookie params like those from rfc2109 and rfc2965 are just put into extras, if one specifies them in allowed extras, else they're treated like cookies themself */ -typedef struct { +typedef struct _http_cookie_list_t { HashTable cookies; HashTable extras; long flags; diff --git a/php_http_deflatestream_object.h b/php_http_deflatestream_object.h index 13c3350..7af1011 100644 --- a/php_http_deflatestream_object.h +++ b/php_http_deflatestream_object.h @@ -16,7 +16,7 @@ #define PHP_HTTP_DEFLATESTREAM_OBJECT_H #if defined(ZEND_ENGINE_2) && defined(HTTP_HAVE_ZLIB) -typedef struct { +typedef struct _http_deflatestream_object_t { zend_object zo; http_encoding_stream *stream; } http_deflatestream_object; diff --git a/php_http_encoding_api.h b/php_http_encoding_api.h index 883d676..8854033 100644 --- a/php_http_encoding_api.h +++ b/php_http_encoding_api.h @@ -27,7 +27,7 @@ extern PHP_MINIT_FUNCTION(http_encoding); extern PHP_RINIT_FUNCTION(http_encoding); extern PHP_RSHUTDOWN_FUNCTION(http_encoding); -typedef enum { +typedef enum _http_encoding_type_t { HTTP_ENCODING_NONE, HTTP_ENCODING_GZIP, HTTP_ENCODING_DEFLATE, @@ -64,7 +64,7 @@ typedef enum { #define HTTP_ENCODING_STREAM_PERSISTENT 0x01000000 -typedef struct { +typedef struct _http_encoding_stream_t { z_stream stream; int flags; void *storage; diff --git a/php_http_headers_api.h b/php_http_headers_api.h index 799f488..52c0a50 100644 --- a/php_http_headers_api.h +++ b/php_http_headers_api.h @@ -17,7 +17,7 @@ #include "php_http_info_api.h" -typedef enum { +typedef enum http_range_status_t { RANGE_OK, RANGE_NO, RANGE_ERR diff --git a/php_http_inflatestream_object.h b/php_http_inflatestream_object.h index 0853d04..f7f2dc6 100644 --- a/php_http_inflatestream_object.h +++ b/php_http_inflatestream_object.h @@ -16,7 +16,7 @@ #define PHP_HTTP_INFLATESTREAM_OBJECT_H #if defined(ZEND_ENGINE_2) && defined(HTTP_HAVE_ZLIB) -typedef struct { +typedef struct _http_inflatestream_object_t { zend_object zo; http_encoding_stream *stream; } http_inflatestream_object; diff --git a/php_http_info_api.h b/php_http_info_api.h index 6d36a64..94a8d31 100644 --- a/php_http_info_api.h +++ b/php_http_info_api.h @@ -20,27 +20,27 @@ #define HTTP_INFO(ptr) (ptr)->http.info -typedef struct { +typedef struct _http_request_info_t { char *method; char *url; } http_request_info; -typedef struct { +typedef struct _http_response_info_t { int code; char *status; } http_response_info; -typedef union { +typedef union _http_info_union_t { http_request_info request; http_response_info response; -} http_info_t; +} http_info_union; struct http_info { - http_info_t info; + http_info_union info; double version; }; -typedef struct { +typedef struct _http_info_t { struct http_info http; int type; } http_info; diff --git a/php_http_message_api.h b/php_http_message_api.h index 52149f0..763cd47 100644 --- a/php_http_message_api.h +++ b/php_http_message_api.h @@ -17,15 +17,15 @@ #include "php_http_info_api.h" -typedef enum { +typedef enum _http_message_type_t { HTTP_MSG_NONE = 0, HTTP_MSG_REQUEST = IS_HTTP_REQUEST, HTTP_MSG_RESPONSE = IS_HTTP_RESPONSE, } http_message_type; -typedef struct _http_message http_message; +typedef struct _http_message_t http_message; -struct _http_message { +struct _http_message_t { phpstr body; HashTable hdrs; http_message_type type; diff --git a/php_http_message_object.h b/php_http_message_object.h index b3a836e..1004ac6 100644 --- a/php_http_message_object.h +++ b/php_http_message_object.h @@ -16,7 +16,7 @@ #define PHP_HTTP_MESSAGE_OBJECT_H #ifdef ZEND_ENGINE_2 -typedef struct { +typedef struct _http_message_object_t { zend_object zo; http_message *message; zend_object_value parent; diff --git a/php_http_querystring_object.h b/php_http_querystring_object.h index b65229f..b37f303 100644 --- a/php_http_querystring_object.h +++ b/php_http_querystring_object.h @@ -16,7 +16,7 @@ #define PHP_HTTP_QUERYSTRING_OBJECT_H #ifdef ZEND_ENGINE_2 -typedef struct { +typedef struct _http_querystring_object_t { zend_object zo; } http_querystring_object; diff --git a/php_http_request_api.h b/php_http_request_api.h index 16523f6..5b4b752 100644 --- a/php_http_request_api.h +++ b/php_http_request_api.h @@ -23,7 +23,7 @@ extern PHP_MINIT_FUNCTION(http_request); extern PHP_MSHUTDOWN_FUNCTION(http_request); -typedef struct { +typedef struct _http_request_t { CURL *ch; char *url; http_request_method meth; diff --git a/php_http_request_body_api.h b/php_http_request_body_api.h index 346544d..2a9559f 100644 --- a/php_http_request_body_api.h +++ b/php_http_request_body_api.h @@ -21,7 +21,7 @@ #define HTTP_REQUEST_BODY_CSTRING 1 #define HTTP_REQUEST_BODY_CURLPOST 2 #define HTTP_REQUEST_BODY_UPLOADFILE 3 -typedef struct { +typedef struct _http_request_body_t { uint type:3; uint free:1; uint priv:28; diff --git a/php_http_request_method_api.h b/php_http_request_method_api.h index 4fcf2be..3941d54 100644 --- a/php_http_request_method_api.h +++ b/php_http_request_method_api.h @@ -15,7 +15,9 @@ #ifndef PHP_HTTP_REQUEST_METHOD_API_H #define PHP_HTTP_REQUEST_METHOD_API_H -typedef enum { +typedef enum _http_request_method_t { + /* force the enum to be signed */ + HTTP_NEG_REQUEST_METHOD =-1, HTTP_NO_REQUEST_METHOD = 0, /* HTTP/1.1 */ HTTP_GET = 1, @@ -54,7 +56,7 @@ typedef enum { #define HTTP_MIN_REQUEST_METHOD (HTTP_NO_REQUEST_METHOD + 1) #define HTTP_CUSTOM_REQUEST_METHOD_START HTTP_MAX_REQUEST_METHOD -typedef struct { +typedef struct _http_request_method_entry_t { char *name; char *cnst; } http_request_method_entry; diff --git a/php_http_request_object.h b/php_http_request_object.h index 00c2eb0..0326f01 100644 --- a/php_http_request_object.h +++ b/php_http_request_object.h @@ -19,7 +19,7 @@ #include "php_http_request_pool_api.h" -typedef struct { +typedef struct _http_request_object_t { zend_object zo; http_request *request; http_request_pool *pool; diff --git a/php_http_request_pool_api.h b/php_http_request_pool_api.h index 986c9ed..79a3e4e 100644 --- a/php_http_request_pool_api.h +++ b/php_http_request_pool_api.h @@ -16,7 +16,7 @@ #define PHP_HTTP_REQUEST_POOL_API_H #ifdef HTTP_HAVE_CURL -typedef struct { +typedef struct _http_request_pool_t { CURLM *ch; zend_llist finished; zend_llist handles; diff --git a/php_http_requestpool_object.h b/php_http_requestpool_object.h index f6f7736..b0ab065 100644 --- a/php_http_requestpool_object.h +++ b/php_http_requestpool_object.h @@ -17,7 +17,7 @@ #ifdef HTTP_HAVE_CURL #ifdef ZEND_ENGINE_2 -typedef struct { +typedef struct _http_requestpool_object_t { zend_object zo; http_request_pool pool; struct { diff --git a/php_http_send_api.h b/php_http_send_api.h index fa76b01..dd0b50a 100644 --- a/php_http_send_api.h +++ b/php_http_send_api.h @@ -15,7 +15,7 @@ #ifndef PHP_HTTP_SEND_API_H #define PHP_HTTP_SEND_API_H -typedef enum { +typedef enum _http_send_mode_t { SEND_DATA, SEND_RSRC } http_send_mode; diff --git a/phpstr/phpstr.h b/phpstr/phpstr.h index 9b6628e..295ba3c 100644 --- a/phpstr/phpstr.h +++ b/phpstr/phpstr.h @@ -68,7 +68,7 @@ RETVAL_STRINGL((STR)->data, (STR)->used, (dup)); \ FREE_PHPSTR((free), (STR)); -typedef struct { +typedef struct _phpstr_t { size_t size; char *data; size_t used; @@ -76,7 +76,7 @@ typedef struct { int pmem; } phpstr; -typedef enum { +typedef enum _phpstr_free_t { PHPSTR_FREE_NOT = 0, PHPSTR_FREE_PTR, /* pefree() */ PHPSTR_FREE_VAL, /* phpstr_dtor() */ diff --git a/tests/request_cookies.phpt b/tests/request_cookies.phpt index ef99125..38428f3 100644 --- a/tests/request_cookies.phpt +++ b/tests/request_cookies.phpt @@ -23,6 +23,11 @@ echo "Done\n"; ?> --EXPECTF-- %sTEST +GET /.print_request.php HTTP/1.1 +User-Agent: %s +Host: dev.iworks.at +Accept: */* +Cookie: name=val%3Due HTTP/1.1 200 OK %s @@ -35,7 +40,7 @@ GET /.print_request.php HTTP/1.1 User-Agent: %s Host: dev.iworks.at Accept: */* -Cookie: name=val%3Due +Cookie: name=val=ue; HTTP/1.1 200 OK %s @@ -44,9 +49,4 @@ Array [name] => val=ue ) -GET /.print_request.php HTTP/1.1 -User-Agent: %s -Host: dev.iworks.at -Accept: */* -Cookie: name=val=ue; Done -- 2.30.2