libmicrohttpd

HTTP/1.x server C library (MHD 1.x, stable)
Log | Files | Refs | Submodules | README | LICENSE

commit f8e92c1eb9d56a41b5461d9a54bbc1b1cb76e812
parent 1a23dd25c36bdb0e0be264730e9088a49a1e8152
Author: Christian Grothoff <christian@grothoff.org>
Date:   Thu,  5 Oct 2017 23:25:41 +0200

use more c99

Diffstat:
Msrc/microhttpd/response.c | 32++++++++++++++++++++------------
1 file changed, 20 insertions(+), 12 deletions(-)

diff --git a/src/microhttpd/response.c b/src/microhttpd/response.c @@ -169,7 +169,7 @@ MHD_del_response_header (struct MHD_Response *response, return MHD_NO; prev = NULL; pos = response->first_header; - while (pos != NULL) + while (NULL != pos) { if ((0 == strcmp (header, pos->header)) && @@ -207,10 +207,11 @@ MHD_get_response_headers (struct MHD_Response *response, MHD_KeyValueIterator iterator, void *iterator_cls) { - struct MHD_HTTP_Header *pos; int numHeaders = 0; - for (pos = response->first_header; NULL != pos; pos = pos->next) + for (struct MHD_HTTP_Header *pos = response->first_header; + NULL != pos; + pos = pos->next) { numHeaders++; if ((NULL != iterator) && @@ -236,11 +237,11 @@ const char * MHD_get_response_header (struct MHD_Response *response, const char *key) { - struct MHD_HTTP_Header *pos; - if (NULL == key) return NULL; - for (pos = response->first_header; NULL != pos; pos = pos->next) + for (struct MHD_HTTP_Header *pos = response->first_header; + NULL != pos; + pos = pos->next) { if ( MHD_str_equal_caseless_ (pos->header, key) ) return pos->value; @@ -253,6 +254,7 @@ MHD_get_response_header (struct MHD_Response *response, * * Token could be surrounded by spaces and tabs and delimited by comma. * Case-insensitive match used for header names and tokens. + * * @param response the response to query * @param key header name * @param token the token to find @@ -267,16 +269,22 @@ MHD_check_response_header_token_ci (const struct MHD_Response *response, const char *token, size_t token_len) { - struct MHD_HTTP_Header *pos; - - if (NULL == key || 0 == key[0] || NULL == token || 0 == token[0]) + if ( (NULL == key) || + ('\0' == key[0]) || + (NULL == token) || + ('\0' == token[0]) ) return false; - for (pos = response->first_header; NULL != pos; pos = pos->next) + for (struct MHD_HTTP_Header *pos = response->first_header; + NULL != pos; + pos = pos->next) { if ( (pos->kind == MHD_HEADER_KIND) && - MHD_str_equal_caseless_ (pos->header, key) && - MHD_str_has_token_caseless_ (pos->value, token, token_len) ) + MHD_str_equal_caseless_ (pos->header, + key) && + MHD_str_has_token_caseless_ (pos->value, + token, + token_len) ) return true; } return false;