diff options
author | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2017-04-05 12:45:32 +0300 |
---|---|---|
committer | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2017-04-05 12:56:40 +0300 |
commit | 218694a400beaf164712121475a6e22fd01b7b71 (patch) | |
tree | ced3b1a430831759372112a8d84f1c4e22c9ee9b /src/microhttpd/postprocessor.c | |
parent | 6ac4608cd802dba435d5aa7602ace312cacc8909 (diff) | |
download | libmicrohttpd-218694a400beaf164712121475a6e22fd01b7b71.tar.gz libmicrohttpd-218694a400beaf164712121475a6e22fd01b7b71.zip |
Converted many 'strlen()' from run-time to compile-time processing
Diffstat (limited to 'src/microhttpd/postprocessor.c')
-rw-r--r-- | src/microhttpd/postprocessor.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/microhttpd/postprocessor.c b/src/microhttpd/postprocessor.c index cf3c31ec..208686bb 100644 --- a/src/microhttpd/postprocessor.c +++ b/src/microhttpd/postprocessor.c | |||
@@ -296,19 +296,19 @@ MHD_create_post_processor (struct MHD_Connection *connection, | |||
296 | boundary = NULL; | 296 | boundary = NULL; |
297 | if (! MHD_str_equal_caseless_n_ (MHD_HTTP_POST_ENCODING_FORM_URLENCODED, | 297 | if (! MHD_str_equal_caseless_n_ (MHD_HTTP_POST_ENCODING_FORM_URLENCODED, |
298 | encoding, | 298 | encoding, |
299 | strlen (MHD_HTTP_POST_ENCODING_FORM_URLENCODED))) | 299 | MHD_STATICSTR_LEN_ (MHD_HTTP_POST_ENCODING_FORM_URLENCODED))) |
300 | { | 300 | { |
301 | if (! MHD_str_equal_caseless_n_ (MHD_HTTP_POST_ENCODING_MULTIPART_FORMDATA, | 301 | if (! MHD_str_equal_caseless_n_ (MHD_HTTP_POST_ENCODING_MULTIPART_FORMDATA, |
302 | encoding, | 302 | encoding, |
303 | strlen (MHD_HTTP_POST_ENCODING_MULTIPART_FORMDATA))) | 303 | MHD_STATICSTR_LEN_ (MHD_HTTP_POST_ENCODING_MULTIPART_FORMDATA))) |
304 | return NULL; | 304 | return NULL; |
305 | boundary = | 305 | boundary = |
306 | &encoding[strlen (MHD_HTTP_POST_ENCODING_MULTIPART_FORMDATA)]; | 306 | &encoding[MHD_STATICSTR_LEN_ (MHD_HTTP_POST_ENCODING_MULTIPART_FORMDATA)]; |
307 | /* Q: should this be "strcasestr"? */ | 307 | /* Q: should this be "strcasestr"? */ |
308 | boundary = strstr (boundary, "boundary="); | 308 | boundary = strstr (boundary, "boundary="); |
309 | if (NULL == boundary) | 309 | if (NULL == boundary) |
310 | return NULL; /* failed to determine boundary */ | 310 | return NULL; /* failed to determine boundary */ |
311 | boundary += strlen ("boundary="); | 311 | boundary += MHD_STATICSTR_LEN_ ("boundary="); |
312 | blen = strlen (boundary); | 312 | blen = strlen (boundary); |
313 | if ( (blen == 0) || | 313 | if ( (blen == 0) || |
314 | (blen * 2 + 2 > buffer_size) ) | 314 | (blen * 2 + 2 > buffer_size) ) |
@@ -710,12 +710,12 @@ process_multipart_headers (struct MHD_PostProcessor *pp, | |||
710 | buf[newline] = '\0'; | 710 | buf[newline] = '\0'; |
711 | if (MHD_str_equal_caseless_n_ ("Content-disposition: ", | 711 | if (MHD_str_equal_caseless_n_ ("Content-disposition: ", |
712 | buf, | 712 | buf, |
713 | strlen ("Content-disposition: "))) | 713 | MHD_STATICSTR_LEN_ ("Content-disposition: "))) |
714 | { | 714 | { |
715 | try_get_value (&buf[strlen ("Content-disposition: ")], | 715 | try_get_value (&buf[MHD_STATICSTR_LEN_ ("Content-disposition: ")], |
716 | "name", | 716 | "name", |
717 | &pp->content_name); | 717 | &pp->content_name); |
718 | try_get_value (&buf[strlen ("Content-disposition: ")], | 718 | try_get_value (&buf[MHD_STATICSTR_LEN_ ("Content-disposition: ")], |
719 | "filename", | 719 | "filename", |
720 | &pp->content_filename); | 720 | &pp->content_filename); |
721 | } | 721 | } |
@@ -1043,7 +1043,7 @@ post_process_multipart (struct MHD_PostProcessor *pp, | |||
1043 | if ( (NULL != pp->content_type) && | 1043 | if ( (NULL != pp->content_type) && |
1044 | (MHD_str_equal_caseless_n_ (pp->content_type, | 1044 | (MHD_str_equal_caseless_n_ (pp->content_type, |
1045 | "multipart/mixed", | 1045 | "multipart/mixed", |
1046 | strlen ("multipart/mixed")))) | 1046 | MHD_STATICSTR_LEN_ ("multipart/mixed")))) |
1047 | { | 1047 | { |
1048 | pp->nested_boundary = strstr (pp->content_type, | 1048 | pp->nested_boundary = strstr (pp->content_type, |
1049 | "boundary="); | 1049 | "boundary="); |
@@ -1053,7 +1053,7 @@ post_process_multipart (struct MHD_PostProcessor *pp, | |||
1053 | return MHD_NO; | 1053 | return MHD_NO; |
1054 | } | 1054 | } |
1055 | pp->nested_boundary = | 1055 | pp->nested_boundary = |
1056 | strdup (&pp->nested_boundary[strlen ("boundary=")]); | 1056 | strdup (&pp->nested_boundary[MHD_STATICSTR_LEN_ ("boundary=")]); |
1057 | if (NULL == pp->nested_boundary) | 1057 | if (NULL == pp->nested_boundary) |
1058 | { | 1058 | { |
1059 | /* out of memory */ | 1059 | /* out of memory */ |
@@ -1221,13 +1221,13 @@ MHD_post_process (struct MHD_PostProcessor *pp, | |||
1221 | return MHD_NO; | 1221 | return MHD_NO; |
1222 | if (MHD_str_equal_caseless_n_ (MHD_HTTP_POST_ENCODING_FORM_URLENCODED, | 1222 | if (MHD_str_equal_caseless_n_ (MHD_HTTP_POST_ENCODING_FORM_URLENCODED, |
1223 | pp->encoding, | 1223 | pp->encoding, |
1224 | strlen(MHD_HTTP_POST_ENCODING_FORM_URLENCODED))) | 1224 | MHD_STATICSTR_LEN_(MHD_HTTP_POST_ENCODING_FORM_URLENCODED))) |
1225 | return post_process_urlencoded (pp, | 1225 | return post_process_urlencoded (pp, |
1226 | post_data, | 1226 | post_data, |
1227 | post_data_len); | 1227 | post_data_len); |
1228 | if (MHD_str_equal_caseless_n_ (MHD_HTTP_POST_ENCODING_MULTIPART_FORMDATA, | 1228 | if (MHD_str_equal_caseless_n_ (MHD_HTTP_POST_ENCODING_MULTIPART_FORMDATA, |
1229 | pp->encoding, | 1229 | pp->encoding, |
1230 | strlen (MHD_HTTP_POST_ENCODING_MULTIPART_FORMDATA))) | 1230 | MHD_STATICSTR_LEN_ (MHD_HTTP_POST_ENCODING_MULTIPART_FORMDATA))) |
1231 | return post_process_multipart (pp, | 1231 | return post_process_multipart (pp, |
1232 | post_data, | 1232 | post_data, |
1233 | post_data_len); | 1233 | post_data_len); |