From: Michael Wallner Date: Fri, 19 May 2006 10:33:57 +0000 (+0000) Subject: - fix switch() CS X-Git-Tag: RELEASE_1_0_0~27 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=2f39230d83bdf816dcae52c7e5a1b019347f0e7b;p=m6w6%2Fext-http - fix switch() CS --- diff --git a/http_api.c b/http_api.c index 33cd17d..4744a82 100644 --- a/http_api.c +++ b/http_api.c @@ -154,8 +154,7 @@ STATUS _http_exit_ex(int status, char *header, char *body, zend_bool send_header PHPWRITE(body, strlen(body)); } - switch (status) - { + switch (status) { case 301: http_log(HTTP_G->log.redirect, "301-REDIRECT", header); break; case 302: http_log(HTTP_G->log.redirect, "302-REDIRECT", header); break; case 303: http_log(HTTP_G->log.redirect, "303-REDIRECT", header); break; @@ -362,8 +361,7 @@ PHP_HTTP_API STATUS _http_parse_params_ex(const char *param, int allow_comma_sep ); STR_FREE(tk); STR_FREE(tv); #endif - switch (st) - { + switch (st) { case ST_QUOTE: quote: if (*c == '"') { @@ -382,36 +380,34 @@ PHP_HTTP_API STATUS _http_parse_params_ex(const char *param, int allow_comma_sep st = ST_ADD; } } - break; + break; case ST_VALUE: - switch (*c) - { + switch (*c) { case '"': if (!val) { st = ST_QUOTE; } - break; + break; case ' ': - break; + break; case ';': case '\0': goto add; - break; + break; default: if (!val) { val = c; } - break; + break; } - break; + break; case ST_KEY: - switch (*c) - { + switch (*c) { case ',': if (allow_comma_sep) { goto allow_comma; @@ -422,7 +418,7 @@ PHP_HTTP_API STATUS _http_parse_params_ex(const char *param, int allow_comma_sep case '\013': case '\014': goto failure; - break; + break; case '=': if (key) { @@ -431,14 +427,14 @@ PHP_HTTP_API STATUS _http_parse_params_ex(const char *param, int allow_comma_sep } else { goto failure; } - break; + break; case ' ': if (key) { keylen = c - key; st = ST_ASSIGN; } - break; + break; case ';': case '\0': @@ -447,15 +443,15 @@ PHP_HTTP_API STATUS _http_parse_params_ex(const char *param, int allow_comma_sep keylen = c - key; st = ST_ADD; } - break; + break; default: if (!key) { key = c; } - break; + break; } - break; + break; case ST_ASSIGN: if (*c == '=') { @@ -465,7 +461,7 @@ PHP_HTTP_API STATUS _http_parse_params_ex(const char *param, int allow_comma_sep } else if (*c != ' ') { goto failure; } - break; + break; case ST_ADD: add: @@ -484,7 +480,7 @@ PHP_HTTP_API STATUS _http_parse_params_ex(const char *param, int allow_comma_sep st = ST_KEY; key = val = NULL; keylen = vallen = 0; - break; + break; } if (*c) { diff --git a/http_cache_api.c b/http_cache_api.c index 9fce650..7c748cc 100644 --- a/http_cache_api.c +++ b/http_cache_api.c @@ -63,8 +63,7 @@ PHP_HTTP_API time_t _http_last_modified(const void *data_ptr, http_send_mode dat { php_stream_statbuf ssb; - switch (data_mode) - { + switch (data_mode) { case SEND_DATA: return HTTP_GET_REQUEST_TIME(); case SEND_RSRC: return php_stream_stat((php_stream *) data_ptr, &ssb) ? 0 : ssb.sb.st_mtime; default: return php_stream_stat_path((char *) data_ptr, &ssb) ? 0 : ssb.sb.st_mtime; diff --git a/http_encoding_api.c b/http_encoding_api.c index 89865a2..178c992 100644 --- a/http_encoding_api.c +++ b/http_encoding_api.c @@ -327,12 +327,10 @@ retry_raw_inflate: Z.next_in = (Bytef *) data; Z.avail_in = data_len; - switch (status = http_inflate_rounds(&Z, Z_NO_FLUSH, decoded, decoded_len)) - { + switch (status = http_inflate_rounds(&Z, Z_NO_FLUSH, decoded, decoded_len)) { case Z_OK: case Z_STREAM_END: return SUCCESS; - break; case Z_DATA_ERROR: /* raw deflated data? */ @@ -341,7 +339,6 @@ retry_raw_inflate: wbits = HTTP_WINDOW_BITS_RAW; goto retry_raw_inflate; } - break; } inflateEnd(&Z); } @@ -432,8 +429,7 @@ PHP_HTTP_API STATUS _http_encoding_deflate_stream_update(http_encoding_stream *s s->stream.avail_out = *encoded_len; s->stream.next_out = (Bytef *) *encoded; - switch (status = deflate(&s->stream, HTTP_ENCODING_STREAM_FLUSH_FLAG(s->flags))) - { + switch (status = deflate(&s->stream, HTTP_ENCODING_STREAM_FLUSH_FLAG(s->flags))) { case Z_OK: case Z_STREAM_END: /* cut processed chunk off the buffer */ @@ -448,7 +444,6 @@ PHP_HTTP_API STATUS _http_encoding_deflate_stream_update(http_encoding_stream *s *encoded = erealloc_rel(*encoded, *encoded_len + 1); (*encoded)[*encoded_len] = '\0'; return SUCCESS; - break; } STR_SET(*encoded, NULL); @@ -470,8 +465,7 @@ retry_raw_inflate: s->stream.next_in = (Bytef *) PHPSTR_VAL(s->stream.opaque); s->stream.avail_in = PHPSTR_LEN(s->stream.opaque); - switch (status = http_inflate_rounds(&s->stream, HTTP_ENCODING_STREAM_FLUSH_FLAG(s->flags), decoded, decoded_len)) - { + switch (status = http_inflate_rounds(&s->stream, HTTP_ENCODING_STREAM_FLUSH_FLAG(s->flags), decoded, decoded_len)) { case Z_OK: case Z_STREAM_END: /* cut off */ @@ -481,7 +475,6 @@ retry_raw_inflate: phpstr_reset(PHPSTR(s->stream.opaque)); } return SUCCESS; - break; case Z_DATA_ERROR: /* raw deflated data ? */ @@ -491,7 +484,6 @@ retry_raw_inflate: inflateInit2(&s->stream, HTTP_WINDOW_BITS_RAW); goto retry_raw_inflate; } - break; } http_error_ex(HE_WARNING, HTTP_E_ENCODING, "Failed to update inflate stream: %s", zError(status)); @@ -512,15 +504,13 @@ PHP_HTTP_API STATUS _http_encoding_deflate_stream_flush(http_encoding_stream *s, s->stream.avail_out = *encoded_len; s->stream.next_out = (Bytef *) *encoded; - switch (status = deflate(&s->stream, Z_FULL_FLUSH)) - { + switch (status = deflate(&s->stream, Z_FULL_FLUSH)) { case Z_OK: case Z_STREAM_END: *encoded_len = HTTP_DEFLATE_BUFFER_SIZE - s->stream.avail_out; *encoded = erealloc_rel(*encoded, *encoded_len + 1); (*encoded)[*encoded_len] = '\0'; return SUCCESS; - break; } STR_SET(*encoded, NULL); @@ -675,19 +665,17 @@ void _http_ob_deflatehandler(char *output, uint output_len, char **handled_outpu HTTP_G->send.deflate.encoding = !0; - switch (http_encoding_response_start(0)) - { + switch (http_encoding_response_start(0)) { case HTTP_ENCODING_GZIP: flags = HTTP_DEFLATE_TYPE_GZIP; - break; + break; case HTTP_ENCODING_DEFLATE: flags = HTTP_DEFLATE_TYPE_ZLIB; - break; + break; default: goto deflate_passthru_plain; - break; } flags |= (HTTP_G->send.deflate.start_flags &~ 0xf0); diff --git a/http_exception_object.c b/http_exception_object.c index 06d464e..4cb0044 100644 --- a/http_exception_object.c +++ b/http_exception_object.c @@ -78,8 +78,7 @@ zend_class_entry *_http_exception_get_for_code(long code) { zend_class_entry *ex = http_exception_object_ce; - switch (code) - { + switch (code) { case HTTP_E_RUNTIME: ex = HTTP_EX_CE(runtime); break; case HTTP_E_INVALID_PARAM: ex = HTTP_EX_CE(invalid_param); break; case HTTP_E_HEADER: ex = HTTP_EX_CE(header); break; diff --git a/http_filter_api.c b/http_filter_api.c index 6b58a0b..a6c740f 100644 --- a/http_filter_api.c +++ b/http_filter_api.c @@ -492,8 +492,7 @@ static php_stream_filter *http_filter_create(const char *name, zval *params, int HTTP_FILTER_BUFFER(deflate) *b = NULL; if (params) { - switch (Z_TYPE_P(params)) - { + switch (Z_TYPE_P(params)) { case IS_ARRAY: case IS_OBJECT: if (SUCCESS != zend_hash_find(HASH_OF(params), "flags", sizeof("flags"), (void *) &tmp)) { diff --git a/http_functions.c b/http_functions.c index 155a06f..ceac1a1 100644 --- a/http_functions.c +++ b/http_functions.c @@ -781,20 +781,18 @@ PHP_FUNCTION(http_redirect) FREE_ZVAL(params); } - switch (status) - { + switch (status) { case 300: RETVAL_SUCCESS(http_send_status_header(status, LOC)); efree(LOC); return; - break; case HTTP_REDIRECT_PERM: case HTTP_REDIRECT_FOUND: case HTTP_REDIRECT_POST: case HTTP_REDIRECT_PROXY: case HTTP_REDIRECT_TEMP: - break; + break; case 306: default: @@ -807,7 +805,7 @@ PHP_FUNCTION(http_redirect) } else { status = HTTP_REDIRECT_FOUND; } - break; + break; } RETURN_SUCCESS(http_exit_ex(status, LOC, RED, 1)); @@ -1717,8 +1715,7 @@ PHP_FUNCTION(http_request_body_encode) RETURN_FALSE; } - switch (body.type) - { + switch (body.type) { case HTTP_REQUEST_BODY_CURLPOST: if (CURLE_OK != (rc = Curl_getFormData(&data, body.data, &size))) { http_error_ex(HE_WARNING, HTTP_E_RUNTIME, "Could not encode request body: %s", curl_easy_strerror(rc)); @@ -1749,16 +1746,16 @@ PHP_FUNCTION(http_request_body_encode) } } http_request_body_dtor(&body); - break; + break; case HTTP_REQUEST_BODY_CSTRING: RETVAL_STRINGL(body.data, body.size, 0); - break; + break; default: http_request_body_dtor(&body); RETVAL_FALSE; - break; + break; } } #endif /* HTTP_HAVE_CURL */ @@ -1805,8 +1802,7 @@ PHP_FUNCTION(http_request_method_unregister) RETURN_FALSE; } - switch (Z_TYPE_P(method)) - { + switch (Z_TYPE_P(method)) { case IS_OBJECT: convert_to_string(method); case IS_STRING: @@ -1845,8 +1841,7 @@ PHP_FUNCTION(http_request_method_exists) RETURN_FALSE; } - switch (Z_TYPE_P(method)) - { + switch (Z_TYPE_P(method)) { case IS_OBJECT: convert_to_string(method); case IS_STRING: diff --git a/http_headers_api.c b/http_headers_api.c index 70f36ce..ce5f051 100644 --- a/http_headers_api.c +++ b/http_headers_api.c @@ -200,14 +200,13 @@ PHP_HTTP_API http_range_status _http_get_request_ranges(HashTable *ranges, size_ range += sizeof("bytes=") - 1; do { - switch (c = *(range++)) - { + switch (c = *(range++)) { case '0': /* allow 000... - shall we? */ if (*ptr != -10) { *ptr *= 10; } - break; + break; case '1': case '2': case '3': case '4': case '5': case '6': @@ -229,23 +228,21 @@ PHP_HTTP_API http_range_status _http_get_request_ranges(HashTable *ranges, size_ } else { *ptr = c - '0'; } - break; + break; case '-': ptr = &end; - break; + break; case ' ': - /* IE - ignore for now */ - break; + break; case 0: case ',': if (length) { /* validate ranges */ - switch (begin) - { + switch (begin) { /* "0-12345" */ case -10: /* "0-" */ @@ -257,7 +254,7 @@ PHP_HTTP_API http_range_status _http_get_request_ranges(HashTable *ranges, size_ return RANGE_ERR; } begin = 0; - break; + break; /* "-12345" */ case -1: @@ -267,16 +264,14 @@ PHP_HTTP_API http_range_status _http_get_request_ranges(HashTable *ranges, size_ } begin = length - end; end = length - 1; - break; + break; /* "12345-(xxx)" */ default: - switch (end) - { + switch (end) { /* "12345-0" */ case -10: return RANGE_ERR; - break; /* "12345-" */ case -1: @@ -284,7 +279,7 @@ PHP_HTTP_API http_range_status _http_get_request_ranges(HashTable *ranges, size_ return RANGE_ERR; } end = length - 1; - break; + break; /* "12345-67890" */ default: @@ -293,9 +288,9 @@ PHP_HTTP_API http_range_status _http_get_request_ranges(HashTable *ranges, size_ (end < begin)) { return RANGE_ERR; } - break; + break; } - break; + break; } } { @@ -310,11 +305,10 @@ PHP_HTTP_API http_range_status _http_get_request_ranges(HashTable *ranges, size_ end = -1; ptr = &begin; } - break; + break; default: return RANGE_NO; - break; } } while (c != 0); @@ -339,13 +333,12 @@ PHP_HTTP_API STATUS _http_parse_headers_ex(const char *header, HashTable *header do { int value_len = 0; - switch (*line++) - { + switch (*line++) { case ':': if (!colon) { colon = line - 1; } - break; + break; case 0: --value_len; /* we don't have CR so value length is one char less */ @@ -419,7 +412,7 @@ PHP_HTTP_API STATUS _http_parse_headers_ex(const char *header, HashTable *header value_len = 0; header += line - header; } - break; + break; } } while (MORE_HEADERS); diff --git a/http_info_api.c b/http_info_api.c index 793acd1..0f22902 100644 --- a/http_info_api.c +++ b/http_info_api.c @@ -23,35 +23,33 @@ PHP_HTTP_API void _http_info_default_callback(void **nothing, HashTable **header INIT_ZARR(array, *headers); - switch (info->type) - { + switch (info->type) { case IS_HTTP_REQUEST: add_assoc_string(&array, "Request Method", HTTP_INFO(info).request.method, 1); add_assoc_string(&array, "Request Url", HTTP_INFO(info).request.url, 1); - break; + break; case IS_HTTP_RESPONSE: add_assoc_long(&array, "Response Code", (long) HTTP_INFO(info).response.code); add_assoc_string(&array, "Response Status", HTTP_INFO(info).response.status, 1); - break; + break; } } PHP_HTTP_API void _http_info_dtor(http_info *i) { - switch (i->type) - { + switch (i->type) { case IS_HTTP_REQUEST: STR_SET(HTTP_INFO(i).request.method, NULL); STR_SET(HTTP_INFO(i).request.url, NULL); - break; + break; case IS_HTTP_RESPONSE: STR_SET(HTTP_INFO(i).response.status, NULL); - break; + break; default: - break; + break; } } diff --git a/http_message_api.c b/http_message_api.c index 59fb327..b98db17 100644 --- a/http_message_api.c +++ b/http_message_api.c @@ -45,21 +45,20 @@ static inline void _http_message_init_type(http_message *message, http_message_t { message->http.version = .0; - switch (message->type = type) - { + switch (message->type = type) { case HTTP_MSG_RESPONSE: message->http.info.response.code = 0; message->http.info.response.status = NULL; - break; + break; case HTTP_MSG_REQUEST: message->http.info.request.method = NULL; message->http.info.request.url = NULL; - break; + break; case HTTP_MSG_NONE: default: - break; + break; } } @@ -84,19 +83,18 @@ PHP_HTTP_API void _http_message_set_type(http_message *message, http_message_typ if (type != message->type) { /* free request info */ - switch (message->type) - { + switch (message->type) { case HTTP_MSG_REQUEST: STR_FREE(message->http.info.request.method); STR_FREE(message->http.info.request.url); - break; + break; case HTTP_MSG_RESPONSE: STR_FREE(message->http.info.response.status); - break; + break; default: - break; + break; } /* init */ @@ -108,20 +106,19 @@ PHP_HTTP_API void _http_message_set_info(http_message *message, http_info *info) { message->http.version = info->http.version; - switch (message->type = info->type) - { + switch (message->type = info->type) { case IS_HTTP_REQUEST: HTTP_INFO(message).request.url = estrdup(HTTP_INFO(info).request.url); STR_SET(HTTP_INFO(message).request.method, estrdup(HTTP_INFO(info).request.method)); - break; + break; case IS_HTTP_RESPONSE: HTTP_INFO(message).response.code = HTTP_INFO(info).response.code; STR_SET(HTTP_INFO(message).response.status, estrdup(HTTP_INFO(info).response.status)); - break; + break; default: - break; + break; } } @@ -295,14 +292,13 @@ PHP_HTTP_API void _http_message_tostring(http_message *msg, char **string, size_ phpstr_init_ex(&str, 4096, 0); - switch (msg->type) - { + switch (msg->type) { case HTTP_MSG_REQUEST: phpstr_appendf(&str, "%s %s HTTP/%1.1f" HTTP_CRLF, msg->http.info.request.method, msg->http.info.request.url, msg->http.version); - break; + break; case HTTP_MSG_RESPONSE: phpstr_appendf(&str, "HTTP/%1.1f %d%s%s" HTTP_CRLF, @@ -310,22 +306,21 @@ PHP_HTTP_API void _http_message_tostring(http_message *msg, char **string, size_ msg->http.info.response.code, *msg->http.info.response.status ? " ":"", msg->http.info.response.status); - break; + break; case HTTP_MSG_NONE: default: - break; + break; } FOREACH_HASH_KEYVAL(pos1, &msg->hdrs, key, idx, header) { if (key) { zval **single_header; - switch (Z_TYPE_PP(header)) - { + switch (Z_TYPE_PP(header)) { case IS_STRING: phpstr_appendf(&str, "%s: %s" HTTP_CRLF, key, Z_STRVAL_PP(header)); - break; + break; case IS_ARRAY: { @@ -333,8 +328,8 @@ PHP_HTTP_API void _http_message_tostring(http_message *msg, char **string, size_ FOREACH_VAL(pos2, *header, single_header) { phpstr_appendf(&str, "%s: %s" HTTP_CRLF, key, Z_STRVAL_PP(single_header)); } + break; } - break; } key = NULL; @@ -481,8 +476,7 @@ PHP_HTTP_API STATUS _http_message_send(http_message *message TSRMLS_DC) { STATUS rs = FAILURE; - switch (message->type) - { + switch (message->type) { case HTTP_MSG_RESPONSE: { char *key; @@ -510,8 +504,8 @@ PHP_HTTP_API STATUS _http_message_send(http_message *message TSRMLS_DC) rs = SUCCESS == http_send_status(message->http.info.response.code) && SUCCESS == http_send_data(PHPSTR_VAL(message), PHPSTR_LEN(message)) ? SUCCESS : FAILURE; + break; } - break; case HTTP_MSG_REQUEST: { @@ -567,13 +561,13 @@ PHP_HTTP_API STATUS _http_message_send(http_message *message TSRMLS_DC) #else http_error(HE_WARNING, HTTP_E_RUNTIME, "HTTP requests not supported - ext/http was not linked against libcurl."); #endif - } break; + } case HTTP_MSG_NONE: default: http_error(HE_WARNING, HTTP_E_MESSAGE_TYPE, "HttpMessage is neither of type HTTP_MSG_REQUEST nor HTTP_MSG_RESPONSE"); - break; + break; } return rs; @@ -616,19 +610,18 @@ PHP_HTTP_API void _http_message_dtor(http_message *message) zend_hash_destroy(&message->hdrs); phpstr_dtor(PHPSTR(message)); - switch (message->type) - { + switch (message->type) { case HTTP_MSG_REQUEST: STR_SET(message->http.info.request.method, NULL); STR_SET(message->http.info.request.url, NULL); - break; + break; case HTTP_MSG_RESPONSE: STR_SET(message->http.info.response.status, NULL); - break; + break; default: - break; + break; } } } diff --git a/http_message_object.c b/http_message_object.c index 3c90c58..9a62af4 100644 --- a/http_message_object.c +++ b/http_message_object.c @@ -410,24 +410,24 @@ static zval *_http_message_object_read_prop(zval *object, zval *member, int type case HTTP_MSG_PROPHASH_TYPE: case HTTP_MSG_CHILD_PROPHASH_TYPE: RETVAL_LONG(msg->type); - break; + break; case HTTP_MSG_PROPHASH_HTTP_VERSION: case HTTP_MSG_CHILD_PROPHASH_HTTP_VERSION: RETVAL_DOUBLE(msg->http.version); - break; + break; case HTTP_MSG_PROPHASH_BODY: case HTTP_MSG_CHILD_PROPHASH_BODY: phpstr_fix(PHPSTR(msg)); RETVAL_PHPSTR(PHPSTR(msg), 0, 1); - break; + break; case HTTP_MSG_PROPHASH_HEADERS: case HTTP_MSG_CHILD_PROPHASH_HEADERS: array_init(return_value); zend_hash_copy(Z_ARRVAL_P(return_value), &msg->hdrs, (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *)); - break; + break; case HTTP_MSG_PROPHASH_PARENT_MESSAGE: case HTTP_MSG_CHILD_PROPHASH_PARENT_MESSAGE: @@ -436,7 +436,7 @@ static zval *_http_message_object_read_prop(zval *object, zval *member, int type } else { RETVAL_NULL(); } - break; + break; case HTTP_MSG_PROPHASH_REQUEST_METHOD: case HTTP_MSG_CHILD_PROPHASH_REQUEST_METHOD: @@ -445,7 +445,7 @@ static zval *_http_message_object_read_prop(zval *object, zval *member, int type } else { RETVAL_NULL(); } - break; + break; case HTTP_MSG_PROPHASH_REQUEST_URL: case HTTP_MSG_CHILD_PROPHASH_REQUEST_URL: @@ -454,7 +454,7 @@ static zval *_http_message_object_read_prop(zval *object, zval *member, int type } else { RETVAL_NULL(); } - break; + break; case HTTP_MSG_PROPHASH_RESPONSE_CODE: case HTTP_MSG_CHILD_PROPHASH_RESPONSE_CODE: @@ -463,7 +463,7 @@ static zval *_http_message_object_read_prop(zval *object, zval *member, int type } else { RETVAL_NULL(); } - break; + break; case HTTP_MSG_PROPHASH_RESPONSE_STATUS: case HTTP_MSG_CHILD_PROPHASH_RESPONSE_STATUS: @@ -472,7 +472,7 @@ static zval *_http_message_object_read_prop(zval *object, zval *member, int type } else { RETVAL_NULL(); } - break; + break; default: #ifdef WONKY @@ -480,7 +480,6 @@ static zval *_http_message_object_read_prop(zval *object, zval *member, int type #else RETVAL_NULL(); #endif - break; } return return_value; @@ -514,27 +513,27 @@ static void _http_message_object_write_prop(zval *object, zval *member, zval *va case HTTP_MSG_CHILD_PROPHASH_TYPE: convert_to_long(cpy); http_message_set_type(msg, Z_LVAL_P(cpy)); - break; + break; case HTTP_MSG_PROPHASH_HTTP_VERSION: case HTTP_MSG_CHILD_PROPHASH_HTTP_VERSION: convert_to_double(cpy); msg->http.version = Z_DVAL_P(cpy); - break; + break; case HTTP_MSG_PROPHASH_BODY: case HTTP_MSG_CHILD_PROPHASH_BODY: convert_to_string(cpy); phpstr_dtor(PHPSTR(msg)); phpstr_from_string_ex(PHPSTR(msg), Z_STRVAL_P(cpy), Z_STRLEN_P(cpy)); - break; + break; case HTTP_MSG_PROPHASH_HEADERS: case HTTP_MSG_CHILD_PROPHASH_HEADERS: convert_to_array(cpy); zend_hash_clean(&msg->hdrs); zend_hash_copy(&msg->hdrs, Z_ARRVAL_P(cpy), (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *)); - break; + break; case HTTP_MSG_PROPHASH_PARENT_MESSAGE: case HTTP_MSG_CHILD_PROPHASH_PARENT_MESSAGE: @@ -547,7 +546,7 @@ static void _http_message_object_write_prop(zval *object, zval *member, zval *va Z_OBJ_ADDREF_P(value); obj->parent = value->value.obj; } - break; + break; case HTTP_MSG_PROPHASH_REQUEST_METHOD: case HTTP_MSG_CHILD_PROPHASH_REQUEST_METHOD: @@ -555,7 +554,7 @@ static void _http_message_object_write_prop(zval *object, zval *member, zval *va convert_to_string(cpy); STR_SET(msg->http.info.request.method, estrndup(Z_STRVAL_P(cpy), Z_STRLEN_P(cpy))); } - break; + break; case HTTP_MSG_PROPHASH_REQUEST_URL: case HTTP_MSG_CHILD_PROPHASH_REQUEST_URL: @@ -563,7 +562,7 @@ static void _http_message_object_write_prop(zval *object, zval *member, zval *va convert_to_string(cpy); STR_SET(msg->http.info.request.url, estrndup(Z_STRVAL_P(cpy), Z_STRLEN_P(cpy))); } - break; + break; case HTTP_MSG_PROPHASH_RESPONSE_CODE: case HTTP_MSG_CHILD_PROPHASH_RESPONSE_CODE: @@ -571,7 +570,7 @@ static void _http_message_object_write_prop(zval *object, zval *member, zval *va convert_to_long(cpy); msg->http.info.response.code = Z_LVAL_P(cpy); } - break; + break; case HTTP_MSG_PROPHASH_RESPONSE_STATUS: case HTTP_MSG_CHILD_PROPHASH_RESPONSE_STATUS: @@ -579,13 +578,13 @@ static void _http_message_object_write_prop(zval *object, zval *member, zval *va convert_to_string(cpy); STR_SET(msg->http.info.response.status, estrndup(Z_STRVAL_P(cpy), Z_STRLEN_P(cpy))); } - break; + break; default: #ifdef WONKY zend_get_std_object_handlers()->write_property(object, member, value TSRMLS_CC); #endif - break; + break; } zval_free(&cpy); } @@ -621,21 +620,20 @@ static HashTable *_http_message_object_get_props(zval *object TSRMLS_DC) ASSOC_PROP(array, long, "type", msg->type); ASSOC_PROP(array, double, "httpVersion", msg->http.version); - switch (msg->type) - { + switch (msg->type) { case HTTP_MSG_REQUEST: ASSOC_PROP(array, long, "responseCode", 0); ASSOC_STRINGL(array, "responseStatus", "", 0); ASSOC_STRING(array, "requestMethod", msg->http.info.request.method); ASSOC_STRING(array, "requestUrl", msg->http.info.request.url); - break; + break; case HTTP_MSG_RESPONSE: ASSOC_PROP(array, long, "responseCode", msg->http.info.response.code); ASSOC_STRING(array, "responseStatus", msg->http.info.response.status); ASSOC_STRINGL(array, "requestMethod", "", 0); ASSOC_STRINGL(array, "requestUrl", "", 0); - break; + break; case HTTP_MSG_NONE: default: @@ -643,7 +641,7 @@ static HashTable *_http_message_object_get_props(zval *object TSRMLS_DC) ASSOC_STRINGL(array, "responseStatus", "", 0); ASSOC_STRINGL(array, "requestMethod", "", 0); ASSOC_STRINGL(array, "requestUrl", "", 0); - break; + break; } MAKE_STD_ZVAL(headers); @@ -1219,8 +1217,7 @@ PHP_METHOD(HttpMessage, toMessageTypeObject) if (return_value_used) { getObject(http_message_object, obj); - switch (obj->message->type) - { + switch (obj->message->type) { case HTTP_MSG_REQUEST: { #ifdef HTTP_HAVE_CURL @@ -1263,8 +1260,8 @@ PHP_METHOD(HttpMessage, toMessageTypeObject) #else http_error(HE_WARNING, HTTP_E_RUNTIME, "Cannot transform HttpMessage to HttpRequest (missing curl support)"); #endif + break; } - break; case HTTP_MSG_RESPONSE: { @@ -1288,8 +1285,7 @@ PHP_METHOD(HttpMessage, toMessageTypeObject) INIT_PZVAL(&zkey); ZVAL_STRINGL(&zkey, key, key_len, 0); - switch (Z_TYPE_PP(header)) - { + switch (Z_TYPE_PP(header)) { case IS_ARRAY: case IS_OBJECT: FOREACH_HASH_VAL(pos2, HASH_OF(*header), h) { @@ -1297,13 +1293,13 @@ PHP_METHOD(HttpMessage, toMessageTypeObject) zend_call_method_with_2_params(&return_value, http_response_object_ce, NULL, "setheader", NULL, &zkey, *h); zval_ptr_dtor(h); } - break; + break; default: ZVAL_ADDREF(*header); zend_call_method_with_2_params(&return_value, http_response_object_ce, NULL, "setheader", NULL, &zkey, *header); zval_ptr_dtor(header); - break; + break; } key = NULL; } @@ -1316,12 +1312,12 @@ PHP_METHOD(HttpMessage, toMessageTypeObject) #else http_error(HE_WARNING, HTTP_E_RUNTIME, "Cannot transform HttpMessage to HttpResponse (need PHP 5.1+)"); #endif + break; } - break; default: http_error(HE_WARNING, HTTP_E_MESSAGE_TYPE, "HttpMessage is neither of type HttpMessage::TYPE_REQUEST nor HttpMessage::TYPE_RESPONSE"); - break; + break; } } SET_EH_NORMAL(); diff --git a/http_querystring_object.c b/http_querystring_object.c index 7db43de..d0eed53 100644 --- a/http_querystring_object.c +++ b/http_querystring_object.c @@ -327,8 +327,7 @@ PHP_METHOD(HttpQueryString, get) if (Z_TYPE_P(ztype) == IS_LONG) { type = Z_LVAL_P(ztype); } else if(Z_TYPE_P(ztype) == IS_STRING) { - switch (Z_STRVAL_P(ztype)[0]) - { + switch (Z_STRVAL_P(ztype)[0]) { case 'B': case 'b': type = HTTP_QUERYSTRING_TYPE_BOOL; break; case 'I': diff --git a/http_request_api.c b/http_request_api.c index b101558..1addfd9 100644 --- a/http_request_api.c +++ b/http_request_api.c @@ -838,23 +838,22 @@ PHP_HTTP_API STATUS _http_request_prepare(http_request *request, HashTable *opti } /* request method */ - switch (request->meth) - { + switch (request->meth) { case HTTP_GET: HTTP_CURL_OPT(CURLOPT_HTTPGET, 1); - break; + break; case HTTP_HEAD: HTTP_CURL_OPT(CURLOPT_NOBODY, 1); - break; + break; case HTTP_POST: HTTP_CURL_OPT(CURLOPT_POST, 1); - break; + break; case HTTP_PUT: HTTP_CURL_OPT(CURLOPT_UPLOAD, 1); - break; + break; default: if (http_request_method_exists(0, request->meth, NULL)) { @@ -863,20 +862,19 @@ PHP_HTTP_API STATUS _http_request_prepare(http_request *request, HashTable *opti http_error_ex(HE_WARNING, HTTP_E_REQUEST_METHOD, "Unsupported request method: %d (%s)", request->meth, request->url); return FAILURE; } - break; + break; } /* attach request body */ if (request->body && (request->meth != HTTP_GET) && (request->meth != HTTP_HEAD) && (request->meth != HTTP_OPTIONS)) { - switch (request->body->type) - { + switch (request->body->type) { case HTTP_REQUEST_BODY_EMPTY: /* nothing */ - break; + break; case HTTP_REQUEST_BODY_CURLPOST: HTTP_CURL_OPT(CURLOPT_HTTPPOST, (struct curl_httppost *) request->body->data); - break; + break; case HTTP_REQUEST_BODY_CSTRING: if (request->meth != HTTP_PUT) { @@ -889,13 +887,12 @@ PHP_HTTP_API STATUS _http_request_prepare(http_request *request, HashTable *opti HTTP_CURL_OPT(CURLOPT_IOCTLDATA, request); HTTP_CURL_OPT(CURLOPT_READDATA, request); HTTP_CURL_OPT(CURLOPT_INFILESIZE, request->body->size); - break; + break; default: /* shouldn't ever happen */ http_error_ex(HE_ERROR, 0, "Unknown request body type: %d (%s)", request->body->type, request->url); return FAILURE; - break; } } @@ -961,8 +958,7 @@ static size_t http_curl_read_callback(void *data, size_t len, size_t n, void *ct TSRMLS_FETCH_FROM_CTX(request->tsrm_ls); if (request->body) { - switch (request->body->type) - { + switch (request->body->type) { case HTTP_REQUEST_BODY_CSTRING: { size_t out = MIN(len * n, request->body->size - request->body->priv); @@ -972,12 +968,11 @@ static size_t http_curl_read_callback(void *data, size_t len, size_t n, void *ct request->body->priv += out; return out; } + break; } - break; case HTTP_REQUEST_BODY_UPLOADFILE: return php_stream_read((php_stream *) request->body->data, data, len * n); - break; } } return 0; @@ -1023,18 +1018,17 @@ static curlioerr http_curl_ioctl_callback(CURL *ch, curliocmd cmd, void *ctx) } if (request->body) { - switch (request->body->type) - { + switch (request->body->type) { case HTTP_REQUEST_BODY_CSTRING: request->body->priv = 0; return CURLIOE_OK; - break; + break; case HTTP_REQUEST_BODY_UPLOADFILE: if (SUCCESS == php_stream_rewind((php_stream *) request->body->data)) { return CURLIOE_OK; } - break; + break; } } @@ -1047,22 +1041,21 @@ static int http_curl_raw_callback(CURL *ch, curl_infotype type, char *data, size { http_request *request = (http_request *) ctx; - switch (type) - { + switch (type) { case CURLINFO_DATA_IN: if (request->conv.last_type == CURLINFO_HEADER_IN) { phpstr_appends(&request->conv.response, HTTP_CRLF); } case CURLINFO_HEADER_IN: phpstr_append(&request->conv.response, data, length); - break; + break; case CURLINFO_DATA_OUT: if (request->conv.last_type == CURLINFO_HEADER_OUT) { phpstr_appends(&request->conv.request, HTTP_CRLF); } case CURLINFO_HEADER_OUT: phpstr_append(&request->conv.request, data, length); - break; + break; default: #if 0 fprintf(stderr, "## ", type); @@ -1082,7 +1075,7 @@ static int http_curl_raw_callback(CURL *ch, curl_infotype type, char *data, size fprintf(stderr, "\n"); } #endif - break; + break; } if (type) { diff --git a/http_request_body_api.c b/http_request_body_api.c index fcaa635..816e9c2 100644 --- a/http_request_body_api.c +++ b/http_request_body_api.c @@ -149,21 +149,20 @@ PHP_HTTP_API void _http_request_body_dtor(http_request_body *body TSRMLS_DC) { if (body) { if (body->free) { - switch (body->type) - { + switch (body->type) { case HTTP_REQUEST_BODY_CSTRING: if (body->data) { efree(body->data); } - break; + break; case HTTP_REQUEST_BODY_CURLPOST: curl_formfree(body->data); - break; + break; case HTTP_REQUEST_BODY_UPLOADFILE: php_stream_close(body->data); - break; + break; } } memset(body, 0, sizeof(http_request_body)); diff --git a/http_request_method_api.c b/http_request_method_api.c index 498dbe2..1d73ddd 100644 --- a/http_request_method_api.c +++ b/http_request_method_api.c @@ -190,12 +190,11 @@ PHP_HTTP_API int _http_request_method_register(const char *method_name, int meth method = emalloc(method_name_len + 1); mconst = emalloc(method_name_len + 1); for (i = 0; i < method_name_len; ++i) { - switch (method_name[i]) - { + switch (method_name[i]) { case '-': method[i] = '-'; mconst[i] = '_'; - break; + break; default: if (!isalnum(method_name[i])) { @@ -205,7 +204,7 @@ PHP_HTTP_API int _http_request_method_register(const char *method_name, int meth return 0; } mconst[i] = method[i] = toupper(method_name[i]); - break; + break; } } method[method_name_len] = '\0'; diff --git a/http_request_object.c b/http_request_object.c index 1c0f39a..7fa8ead 100644 --- a/http_request_object.c +++ b/http_request_object.c @@ -524,7 +524,7 @@ STATUS _http_request_object_requesthandler(http_request_object *obj, zval *this_ { case HTTP_GET: case HTTP_HEAD: - break; + break; case HTTP_PUT: { @@ -544,8 +544,8 @@ STATUS _http_request_object_requesthandler(http_request_object *obj, zval *this_ status = FAILURE; } } + break; } - break; case HTTP_POST: default: @@ -571,8 +571,8 @@ STATUS _http_request_object_requesthandler(http_request_object *obj, zval *this_ } } } + break; } - break; } if (status == SUCCESS) { diff --git a/http_response_object.c b/http_response_object.c index 7d2f390..6f6cf4d 100644 --- a/http_response_object.c +++ b/http_response_object.c @@ -573,8 +573,8 @@ PHP_METHOD(HttpResponse, guessContentType) { zval *data = GET_STATIC_PROP(data); ct = http_guess_content_type(magic_file, magic_mode, Z_STRVAL_P(data), Z_STRLEN_P(data), SEND_DATA); + break; } - break; case SEND_RSRC: { @@ -583,12 +583,12 @@ PHP_METHOD(HttpResponse, guessContentType) z->type = IS_RESOURCE; php_stream_from_zval(s, &z); ct = http_guess_content_type(magic_file, magic_mode, s, 0, SEND_RSRC); + break; } - break; default: ct = http_guess_content_type(magic_file, magic_mode, Z_STRVAL_P(GET_STATIC_PROP(file)), 0, -1); - break; + break; } if (ct) { UPD_STATIC_PROP(string, contentType, ct); @@ -1156,8 +1156,7 @@ PHP_METHOD(HttpResponse, send) php_start_ob_buffer(NULL, HTTP_G->send.buffer_size, 0 TSRMLS_CC); /* send */ - switch (Z_LVAL_P(GET_STATIC_PROP(mode))) - { + switch (Z_LVAL_P(GET_STATIC_PROP(mode))) { case SEND_DATA: { zval *zdata_p, *zdata = convert_to_type_ex(IS_STRING, GET_STATIC_PROP(data), &zdata_p); diff --git a/http_send_api.c b/http_send_api.c index 93271db..10b02f6 100644 --- a/http_send_api.c +++ b/http_send_api.c @@ -106,8 +106,7 @@ static inline void _http_send_response_data_fetch(void **buffer, const void *dat char *buf; long got, len = end - begin; - switch (mode) - { + switch (mode) { case SEND_RSRC: { php_stream *s = (php_stream *) data; @@ -123,8 +122,8 @@ static inline void _http_send_response_data_fetch(void **buffer, const void *dat efree(buf); } + break; } - break; case SEND_DATA: { @@ -136,8 +135,8 @@ static inline void _http_send_response_data_fetch(void **buffer, const void *dat len -= got; buf += got; } + break; } - break; EMPTY_SWITCH_DEFAULT_CASE(); } @@ -314,8 +313,7 @@ PHP_HTTP_API STATUS _http_send_ex(const void *data_ptr, size_t data_size, http_s zend_hash_init(&ranges, 0, NULL, ZVAL_PTR_DTOR, 0); range_status = http_get_request_ranges(&ranges, data_size); - switch (range_status) - { + switch (range_status) { case RANGE_ERR: { zend_hash_destroy(&ranges); @@ -493,8 +491,7 @@ PHP_HTTP_API char *_http_guess_content_type(const char *magicfile, long magicmod magic_setflags(magic, magicmode); - switch (data_mode) - { + switch (data_mode) { case SEND_RSRC: { char *buffer; @@ -503,17 +500,17 @@ PHP_HTTP_API char *_http_guess_content_type(const char *magicfile, long magicmod b_len = php_stream_copy_to_mem(data_ptr, &buffer, 65536, 0); ctype = magic_buffer(magic, buffer, b_len); efree(buffer); + break; } - break; case SEND_DATA: ctype = magic_buffer(magic, data_ptr, data_len); - break; + break; default: HTTP_CHECK_OPEN_BASEDIR(data_ptr, magic_close(magic); return NULL); ctype = magic_file(magic, data_ptr); - break; + break; } if (ctype) { diff --git a/http_url_api.c b/http_url_api.c index 827c7b6..65116ae 100644 --- a/http_url_api.c +++ b/http_url_api.c @@ -105,10 +105,10 @@ PHP_HTTP_API void _http_build_url(int flags, const php_url *old_url, const php_u if (!(flags & HTTP_URL_STRIP_PORT)) { url->port = (new_url&&new_url->port) ? new_url->port : ((old_url) ? old_url->port : 0); } - if ((!(flags & HTTP_URL_STRIP_AUTH)) && (!(flags & HTTP_URL_STRIP_USER))) { + if (!(flags & HTTP_URL_STRIP_USER)) { __URLCPY(user); } - if ((!(flags & HTTP_URL_STRIP_AUTH)) && (!(flags & HTTP_URL_STRIP_PASS))) { + if (!(flags & HTTP_URL_STRIP_PASS)) { __URLCPY(pass); } @@ -160,19 +160,17 @@ PHP_HTTP_API void _http_build_url(int flags, const php_url *old_url, const php_u zval *https = http_get_server_var("HTTPS"); if (https && !strcasecmp(Z_STRVAL_P(https), "ON")) { url->scheme = estrndup("https", lenof("https")); - } else - switch (url->port) - { + } else switch (url->port) { case 443: url->scheme = estrndup("https", lenof("https")); - break; + break; #ifndef HTTP_HAVE_NETDB default: #endif case 80: url->scheme = estrndup("http", lenof("http")); - break; + break; #ifdef HTTP_HAVE_NETDB default: @@ -181,7 +179,7 @@ PHP_HTTP_API void _http_build_url(int flags, const php_url *old_url, const php_u } else { url->scheme = estrndup("http", lenof("http")); } - break; + break; #endif } } @@ -229,15 +227,14 @@ PHP_HTTP_API void _http_build_url(int flags, const php_url *old_url, const php_u char *ptr, *end = url->path + strlen(url->path) + 1; for (ptr = strstr(url->path, "/."); ptr; ptr = strstr(ptr, "/.")) { - switch (ptr[2]) - { + switch (ptr[2]) { case '\0': ptr[1] = '\0'; - break; + break; case '/': memmove(&ptr[1], &ptr[3], end - &ptr[3]); - break; + break; case '.': if (ptr[3] == '/') { @@ -249,12 +246,12 @@ PHP_HTTP_API void _http_build_url(int flags, const php_url *old_url, const php_u } memmove(&ptr[1], pos, end - pos); } - break; + break; default: /* something else */ ++ptr; - break; + break; } } } diff --git a/php_http_api.h b/php_http_api.h index ac56e9a..05b9a10 100644 --- a/php_http_api.h +++ b/php_http_api.h @@ -165,8 +165,7 @@ static inline const char *_http_locate_eol(const char *line, int *eol_len) static inline zval *_convert_to_type(int type, zval *z) { if (Z_TYPE_P(z) != type) { - switch (type) - { + switch (type) { case IS_NULL: convert_to_null(z); break; case IS_BOOL: convert_to_boolean(z); break; case IS_LONG: convert_to_long(z); break; @@ -183,8 +182,7 @@ static inline zval *_convert_to_type_ex(int type, zval *z, zval **p) { *p = z; if (Z_TYPE_P(z) != type) { - switch (type) - { + switch (type) { case IS_NULL: convert_to_null_ex(&z); break; case IS_BOOL: convert_to_boolean_ex(&z); break; case IS_LONG: convert_to_long_ex(&z); break; diff --git a/php_http_url_api.h b/php_http_url_api.h index fbb4ae1..4d5cb46 100644 --- a/php_http_url_api.h +++ b/php_http_url_api.h @@ -27,7 +27,7 @@ PHP_HTTP_API char *_http_absolute_url(const char *url TSRMLS_DC); #define HTTP_URL_JOIN_QUERY 0x002 #define HTTP_URL_STRIP_USER 0x004 #define HTTP_URL_STRIP_PASS 0x008 -#define HTTP_URL_STRIP_AUTH 0x010 +#define HTTP_URL_STRIP_AUTH (HTTP_URL_STRIP_USER|HTTP_URL_STRIP_PASS) #define HTTP_URL_STRIP_PORT 0x020 #define HTTP_URL_STRIP_PATH 0x040 #define HTTP_URL_STRIP_QUERY 0x080 @@ -108,8 +108,7 @@ static inline HashTable *_http_url_tostruct(php_url *url, zval *strct TSRMLS_DC) zval arr; if (strct) { - switch (Z_TYPE_P(strct)) - { + switch (Z_TYPE_P(strct)) { default: zval_dtor(strct); array_init(strct);