libmicrohttpd

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

commit 7389c3452884ad29faf5a2d6856aebd364ffae6b
parent e0a076284525eaf2ec4cb356a40cccc25e24f2b1
Author: Christian Grothoff <christian@grothoff.org>
Date:   Thu, 31 Oct 2019 13:06:08 +0100

tighten formatting rules

Diffstat:
Mcontrib/uncrustify.cfg | 17+++++++++++++++++
Msrc/examples/authorization_example.c | 1-
Msrc/examples/benchmark.c | 1-
Msrc/examples/benchmark_https.c | 1-
Msrc/examples/chunked_example.c | 9++-------
Msrc/examples/connection_close.c | 1+
Msrc/examples/demo.c | 3+++
Msrc/examples/demo_https.c | 3+++
Msrc/examples/digest_auth_example.c | 1+
Msrc/examples/http_chunked_compression.c | 4++++
Msrc/examples/http_compression.c | 3+++
Msrc/examples/https_fileserver_example.c | 2++
Msrc/examples/minimal_example_comet.c | 2++
Msrc/examples/post_example.c | 3---
Msrc/examples/querystring_example.c | 1+
Msrc/examples/refuse_post_example.c | 2++
Msrc/gnutls/handshake.c | 1-
Msrc/gnutls/init.c | 1+
Msrc/gnutls/init.h | 1+
Msrc/include/mhd_options.h | 1-
Msrc/include/microhttpd.h | 4----
Msrc/include/microhttpd2.h | 7-------
Msrc/include/microhttpd_tls.h | 1-
Msrc/lib/action_continue.c | 1+
Msrc/lib/action_from_response.c | 3++-
Msrc/lib/action_parse_post.c | 2+-
Msrc/lib/action_suspend.c | 1+
Msrc/lib/connection_add.c | 5++++-
Msrc/lib/connection_call_handlers.c | 31+++++++++++++++----------------
Msrc/lib/connection_cleanup.c | 6++++--
Msrc/lib/connection_close.c | 4++--
Msrc/lib/connection_finish_forward.c | 5+++--
Msrc/lib/connection_info.c | 1+
Msrc/lib/connection_options.c | 1+
Msrc/lib/connection_update_last_activity.c | 1+
Msrc/lib/daemon_close_all_connections.c | 1+
Msrc/lib/daemon_destroy.c | 1+
Msrc/lib/daemon_epoll.c | 7+++++--
Msrc/lib/daemon_get_timeout.c | 1+
Msrc/lib/daemon_info.c | 1+
Msrc/lib/daemon_ip_limit.c | 1+
Msrc/lib/daemon_poll.c | 6++++++
Msrc/lib/daemon_poll.h | 2++
Msrc/lib/daemon_quiesce.c | 5++---
Msrc/lib/daemon_run.c | 1+
Msrc/lib/daemon_select.c | 8++++++++
Msrc/lib/daemon_select.h | 1+
Msrc/lib/daemon_start.c | 2++
Msrc/lib/init.c | 3+++
Msrc/lib/init.h | 1+
Msrc/lib/internal.c | 5+++++
Msrc/lib/internal.h | 8+-------
Msrc/lib/md5.c | 4++++
Msrc/lib/mhd_byteorder.h | 2+-
Msrc/lib/mhd_compat.c | 10+++++++---
Msrc/lib/mhd_compat.h | 2++
Msrc/lib/mhd_itc.c | 2++
Msrc/lib/mhd_itc.h | 1+
Msrc/lib/mhd_mono_clock.c | 1-
Msrc/lib/mhd_sockets.c | 4+++-
Msrc/lib/mhd_sockets.h | 1+
Msrc/lib/mhd_str.c | 43+++++++++++++++++++++++++++++++------------
Msrc/lib/mhd_str.h | 1+
Msrc/lib/mhd_threads.c | 12+++++++-----
Msrc/lib/response.c | 1+
Msrc/lib/response_for_upgrade.c | 1+
Msrc/lib/response_from_buffer.c | 1+
Msrc/lib/response_from_fd.c | 1+
Msrc/lib/tsearch.c | 3++-
Msrc/lib/upgrade_process.c | 12+++++-------
Msrc/lib/version.c | 2+-
Msrc/microhttpd/basicauth.c | 3++-
Msrc/microhttpd/connection.c | 36+++++++++++++++++++-----------------
Msrc/microhttpd/connection.h | 3+++
Msrc/microhttpd/connection_https.c | 1+
Msrc/microhttpd/connection_https.h | 1+
Msrc/microhttpd/daemon.c | 71++++++++++++++++++++++++++++++++++++++++++++++++-----------------------
Msrc/microhttpd/digestauth.c | 19++++++-------------
Msrc/microhttpd/internal.c | 5+++++
Msrc/microhttpd/internal.h | 3++-
Msrc/microhttpd/md5.c | 1+
Msrc/microhttpd/memorypool.c | 1+
Msrc/microhttpd/mhd_byteorder.h | 2+-
Msrc/microhttpd/mhd_compat.c | 10+++++++---
Msrc/microhttpd/mhd_compat.h | 2++
Msrc/microhttpd/mhd_itc.c | 2++
Msrc/microhttpd/mhd_itc.h | 1+
Msrc/microhttpd/mhd_mono_clock.c | 1-
Msrc/microhttpd/mhd_send.c | 6++++--
Msrc/microhttpd/mhd_send.h | 1+
Msrc/microhttpd/mhd_sockets.c | 6++++--
Msrc/microhttpd/mhd_sockets.h | 1+
Msrc/microhttpd/mhd_str.c | 44+++++++++++++++++++++++++++++++-------------
Msrc/microhttpd/mhd_str.h | 1+
Msrc/microhttpd/mhd_threads.c | 12+++++++-----
Msrc/microhttpd/postprocessor.c | 4++--
Msrc/microhttpd/response.c | 3+++
Msrc/microhttpd/sha256.c | 2++
Msrc/microhttpd/test_helpers.h | 3++-
Msrc/microhttpd/test_http_reasons.c | 35++++++++++++++++++++++++++---------
Msrc/microhttpd/test_options.c | 2++
Msrc/microhttpd/test_postprocessor.c | 3+--
Msrc/microhttpd/test_postprocessor_amp.c | 9+++++----
Msrc/microhttpd/test_postprocessor_large.c | 1+
Msrc/microhttpd/test_sha256.c | 2++
Msrc/microhttpd/test_shutdown_select.c | 6++++--
Msrc/microhttpd/test_start_stop.c | 3+++
Msrc/microhttpd/test_str.c | 221+++++++++++++++++++++++++++++++++++++++++++++++--------------------------------
Msrc/microhttpd/test_str_token.c | 13++++++++++---
Msrc/microhttpd/test_upgrade.c | 17+++++++++++++----
Msrc/microhttpd/test_upgrade_large.c | 17+++++++++++++----
Msrc/microhttpd/tsearch.c | 3++-
Msrc/testcurl/curl_version_check.c | 27+++++++++++++++------------
Msrc/testcurl/https/test_empty_response.c | 10+++++-----
Msrc/testcurl/https/test_https_get.c | 8++++----
Msrc/testcurl/https/test_https_get_parallel_threads.c | 1+
Msrc/testcurl/https/test_https_get_select.c | 10+++++-----
Msrc/testcurl/https/test_https_multi_daemon.c | 4++--
Msrc/testcurl/https/test_https_session_info.c | 4+++-
Msrc/testcurl/https/test_https_sni.c | 8+++++---
Msrc/testcurl/https/test_https_time_out.c | 2+-
Msrc/testcurl/https/test_tls_authentication.c | 3+--
Msrc/testcurl/https/test_tls_extensions.c | 5++---
Msrc/testcurl/https/tls_test_common.c | 8+++++++-
Msrc/testcurl/perf_get.c | 24+++++++++++++-----------
Msrc/testcurl/perf_get_concurrent.c | 19++++++++++---------
Msrc/testcurl/test_callback.c | 9+++++----
Msrc/testcurl/test_concurrent_stop.c | 14++++++++++----
Msrc/testcurl/test_delete.c | 21++++++++++++---------
Msrc/testcurl/test_digestauth_with_arguments.c | 3++-
Msrc/testcurl/test_get.c | 27++++++++++++++-------------
Msrc/testcurl/test_get_chunked.c | 20++++++++++++--------
Msrc/testcurl/test_get_empty.c | 27++++++++++++++-------------
Msrc/testcurl/test_get_response_cleanup.c | 10+++++-----
Msrc/testcurl/test_get_sendfile.c | 19++++++++++---------
Msrc/testcurl/test_iplimit.c | 10+++++++---
Msrc/testcurl/test_large_put.c | 40+++++++++++++++++++++++-----------------
Msrc/testcurl/test_long_header.c | 9++++++---
Msrc/testcurl/test_parse_cookies.c | 13++++++++-----
Msrc/testcurl/test_post.c | 27++++++++++++++++-----------
Msrc/testcurl/test_post_loop.c | 14+++++++++-----
Msrc/testcurl/test_postform.c | 21+++++++++++++--------
Msrc/testcurl/test_process_arguments.c | 11++++++-----
Msrc/testcurl/test_process_headers.c | 23++++++++++++++---------
Msrc/testcurl/test_put.c | 22+++++++++++++---------
Msrc/testcurl/test_put_chunked.c | 20++++++++++++--------
Msrc/testcurl/test_quiesce.c | 24+++++++++++++-----------
Msrc/testcurl/test_quiesce_stream.c | 4++--
Msrc/testcurl/test_termination.c | 4+++-
Msrc/testcurl/test_timeout.c | 7++++---
Msrc/testcurl/test_urlparse.c | 6++++--
Msrc/testzzuf/socat.c | 1+
Msrc/testzzuf/test_get.c | 2++
Msrc/testzzuf/test_get_chunked.c | 6+++++-
Msrc/testzzuf/test_long_header.c | 2++
Msrc/testzzuf/test_post.c | 2++
Msrc/testzzuf/test_post_form.c | 2++
Msrc/testzzuf/test_put.c | 4+++-
Msrc/testzzuf/test_put_chunked.c | 4+++-
Msrc/testzzuf/test_put_large.c | 4+++-
160 files changed, 902 insertions(+), 529 deletions(-)

diff --git a/contrib/uncrustify.cfg b/contrib/uncrustify.cfg @@ -49,8 +49,12 @@ nl_assign_brace=remove # No extra newlines that cause noisy diffs nl_start_of_file=remove +nl_after_func_proto = 2 +nl_after_func_body = 3 # If there's no new line, it's not a text file! nl_end_of_file=add +nl_max_blank_in_func = 3 +nl_max = 3 sp_inside_paren = remove @@ -69,6 +73,7 @@ sp_between_ptr_star = remove sp_before_sparen = add sp_inside_fparen = remove +sp_inside_sparen = remove # add space before function call and decl: "foo (x)" sp_func_call_paren = add @@ -76,3 +81,15 @@ sp_func_proto_paren = add sp_func_proto_paren_empty = add sp_func_def_paren = add sp_func_def_paren_empty = add + +# We'd want it for "if ( (foo) || (bar) )", but not for "if (m())", +# so as uncrustify doesn't give exactly what we want => ignore +sp_paren_paren = ignore +sp_inside_paren = remove +sp_bool = force + +nl_func_type_name = force +#nl_branch_else = add +nl_else_brace = add +nl_elseif_brace = add +nl_for_brace = add diff --git a/src/examples/authorization_example.c b/src/examples/authorization_example.c @@ -39,7 +39,6 @@ "<html><head><title>Access denied</title></head><body>Access denied</body></html>" - static int ahc_echo (void *cls, struct MHD_Connection *connection, diff --git a/src/examples/benchmark.c b/src/examples/benchmark.c @@ -49,7 +49,6 @@ static unsigned int small_deltas[SMALL]; static struct MHD_Response *response; - /** * Signature of the callback used by MHD to notify the * application about completed requests. diff --git a/src/examples/benchmark_https.c b/src/examples/benchmark_https.c @@ -49,7 +49,6 @@ static unsigned int small_deltas[SMALL]; static struct MHD_Response *response; - /** * Signature of the callback used by MHD to notify the * application about completed requests. diff --git a/src/examples/chunked_example.c b/src/examples/chunked_example.c @@ -57,9 +57,7 @@ callback (void *cls, // Consider suspending connection until data will be ready. return 0; } - * End of pseudo code. */ - - if (buf_size < (param->response_size - pos)) + * End of pseudo code. */if (buf_size < (param->response_size - pos)) size_to_copy = buf_size; else size_to_copy = param->response_size - pos; @@ -72,10 +70,7 @@ callback (void *cls, // Close connection with error. return MHD_CONTENT_READER_END_WITH_ERROR; } - * End of pseudo code. */ - - /* Return amount of data copied to buffer. */ - return size_to_copy; + * End of pseudo code. *//* Return amount of data copied to buffer. */return size_to_copy; } diff --git a/src/examples/connection_close.c b/src/examples/connection_close.c @@ -62,6 +62,7 @@ ahc_echo (void *cls, return ret; } + #include <x86intrin.h> static void diff --git a/src/examples/demo.c b/src/examples/demo.c @@ -871,6 +871,8 @@ ignore_sigpipe () fprintf (stderr, "Failed to install SIGPIPE handler: %s\n", strerror (errno)); } + + #endif @@ -958,4 +960,5 @@ main (int argc, char *const *argv) return 0; } + /* end of demo.c */ diff --git a/src/examples/demo_https.c b/src/examples/demo_https.c @@ -872,6 +872,8 @@ ignore_sigpipe (void) fprintf (stderr, "Failed to install SIGPIPE handler: %s\n", strerror (errno)); } + + #endif /* test server key */ @@ -1013,4 +1015,5 @@ main (int argc, char *const *argv) return 0; } + /* end of demo_https.c */ diff --git a/src/examples/digest_auth_example.c b/src/examples/digest_auth_example.c @@ -149,4 +149,5 @@ main (int argc, char *const *argv) return 0; } + /* end of digest_auth_example.c */ diff --git a/src/examples/http_chunked_compression.c b/src/examples/http_chunked_compression.c @@ -100,6 +100,7 @@ compress_buf (z_stream *strm, const void *src, size_t src_size, size_t *offset, return (Z_OK == ret) ? MHD_YES : MHD_NO; } + static ssize_t read_cb (void *cls, uint64_t pos, char *mem, size_t size) { @@ -139,6 +140,7 @@ done: return ret; } + static void free_cb (void *cls) { @@ -149,6 +151,7 @@ free_cb (void *cls) free (holder); } + static int ahc_echo (void *cls, struct MHD_Connection *con, const char *url, const char *method, const char *version, @@ -207,6 +210,7 @@ file_error: return MHD_NO; } + int main (int argc, char *const *argv) { diff --git a/src/examples/http_compression.c b/src/examples/http_compression.c @@ -59,6 +59,7 @@ can_compress (struct MHD_Connection *con) return MHD_NO; } + static int body_compress (void **buf, size_t *buf_size) @@ -88,6 +89,7 @@ body_compress (void **buf, return MHD_YES; } + static int ahc_echo (void *cls, struct MHD_Connection *connection, @@ -156,6 +158,7 @@ ahc_echo (void *cls, return ret; } + int main (int argc, char *const *argv) { diff --git a/src/examples/https_fileserver_example.c b/src/examples/https_fileserver_example.c @@ -103,6 +103,7 @@ file_reader (void *cls, uint64_t pos, char *buf, size_t max) return fread (buf, 1, max, file); } + static void file_free_callback (void *cls) { @@ -110,6 +111,7 @@ file_free_callback (void *cls) fclose (file); } + /* HTTP access handler call back */ static int http_ahc (void *cls, diff --git a/src/examples/minimal_example_comet.c b/src/examples/minimal_example_comet.c @@ -37,6 +37,7 @@ data_generator (void *cls, uint64_t pos, char *buf, size_t max) return 80; } + static int ahc_echo (void *cls, struct MHD_Connection *connection, @@ -71,6 +72,7 @@ ahc_echo (void *cls, return ret; } + int main (int argc, char *const *argv) { diff --git a/src/examples/post_example.c b/src/examples/post_example.c @@ -143,8 +143,6 @@ struct Request static struct Session *sessions; - - /** * Return the session handle for this connection, or * create one if this is a new user. @@ -452,7 +450,6 @@ static struct Page pages[] = { }; - /** * Iterator over key-value pairs where the value * maybe made available in increments and/or may diff --git a/src/examples/querystring_example.c b/src/examples/querystring_example.c @@ -74,6 +74,7 @@ ahc_echo (void *cls, return ret; } + int main (int argc, char *const *argv) { diff --git a/src/examples/refuse_post_example.c b/src/examples/refuse_post_example.c @@ -83,6 +83,7 @@ ahc_echo (void *cls, return ret; } + int main (int argc, char *const *argv) { @@ -105,4 +106,5 @@ main (int argc, char *const *argv) return 0; } + /* end of refuse_post_example.c */ diff --git a/src/gnutls/handshake.c b/src/gnutls/handshake.c @@ -3,7 +3,6 @@ enum MHD_Bool struct MHD_TLS_ConnectionState *cs) : - if (MHD_TLS_CONN_NO_TLS != connection->tls_state) { /* HTTPS connection. */ if (MHD_TLS_CONN_CONNECTED > connection->tls_state) diff --git a/src/gnutls/init.c b/src/gnutls/init.c @@ -157,6 +157,7 @@ MHD_TLS_fini (void) gnutls_global_deinit (); } + #ifdef _AUTOINIT_FUNCS_ARE_SUPPORTED _SET_INIT_AND_DEINIT_FUNCS (MHD_TLS_init, MHD_TLS_fini); #endif /* _AUTOINIT_FUNCS_ARE_SUPPORTED */ diff --git a/src/gnutls/init.h b/src/gnutls/init.h @@ -39,6 +39,7 @@ */ void MHD_TLS_check_global_init_ (void); + #endif /* ! _AUTOINIT_FUNCS_ARE_SUPPORTED */ diff --git a/src/include/mhd_options.h b/src/include/mhd_options.h @@ -42,7 +42,6 @@ #define _(String) (String) - #ifndef _MHD_EXTERN #if defined(BUILDING_MHD_LIB) && defined(_WIN32) && \ (defined(DLL_EXPORT) || defined(MHD_W32DLL)) diff --git a/src/include/microhttpd.h b/src/include/microhttpd.h @@ -2670,8 +2670,6 @@ MHD_run_from_select (struct MHD_Daemon *daemon, const fd_set *except_fd_set); - - /* **************** Connection handling functions ***************** */ /** @@ -3085,8 +3083,6 @@ MHD_create_response_from_buffer (size_t size, enum MHD_ResponseMemoryMode mode); - - /** * Create a response object. The response object can be extended with * header information and then be used any number of times. diff --git a/src/include/microhttpd2.h b/src/include/microhttpd2.h @@ -124,7 +124,6 @@ typedef intptr_t ssize_t; #define MHD_VERSION 0x01000000 - /** * Representation of 'bool' in the public API as stdbool.h may not * always be available. @@ -526,7 +525,6 @@ enum MHD_StatusCode MHD_SC_CHUNKED_ENCODING_MALFORMED = 40007, - /* 50000-level errors are because of an error internal to the MHD logic, possibly including our interaction with the operating system (but not the application) */ @@ -826,7 +824,6 @@ enum MHD_StatusCode MHD_SC_FAILED_RESPONSE_HEADER_GENERATION = 50056, - /* 60000-level errors are because the application logic did something wrong or generated an error. */ @@ -1137,7 +1134,6 @@ enum MHD_Method /** @} */ /* end of group postenc */ - /** * @defgroup headers HTTP headers * These are the standard headers found in HTTP requests and responses. @@ -2656,7 +2652,6 @@ enum MHD_ValueKind }; - /** * Iterator over key-value pairs. This iterator can be used to * iterate over all of the cookies, headers, or POST-data fields of a @@ -2747,7 +2742,6 @@ MHD_request_lookup_value (struct MHD_Request *request, MHD_NONNULL (1); - /** * @defgroup httpcode HTTP response codes. * These are the status codes defined for HTTP responses. @@ -3587,7 +3581,6 @@ MHD_action_parse_post (size_t buffer_size, MHD_NONNULL (2); - /* ********************** generic query functions ********************** */ diff --git a/src/include/microhttpd_tls.h b/src/include/microhttpd_tls.h @@ -46,7 +46,6 @@ struct MHD_TLS_ConnectionState; - /** * Callback functions to use for TLS operations. */ diff --git a/src/lib/action_continue.c b/src/lib/action_continue.c @@ -61,4 +61,5 @@ MHD_action_continue (void) return &acont; } + /* end of action_continue.c */ diff --git a/src/lib/action_from_response.c b/src/lib/action_from_response.c @@ -48,7 +48,7 @@ response_action (void *cls, #ifdef UPGRADE_SUPPORT if ( (NULL != response->upgrade_handler) && - daemon->disallow_upgrade ) + daemon->disallow_upgrade) { #ifdef HAVE_MESSAGES MHD_DLOG (daemon, @@ -128,4 +128,5 @@ MHD_action_from_response (struct MHD_Response *response, return &response->action; } + /* end of action_from_response */ diff --git a/src/lib/action_parse_post.c b/src/lib/action_parse_post.c @@ -25,7 +25,6 @@ #include "internal.h" - /** * Create an action that parses a POST request. * @@ -58,4 +57,5 @@ MHD_action_parse_post (size_t buffer_size, return NULL; /* not yet implemented */ } + /* end of action_parse_post.c */ diff --git a/src/lib/action_suspend.c b/src/lib/action_suspend.c @@ -134,4 +134,5 @@ MHD_action_suspend (void) return &suspend; } + /* end of action_suspend.c */ diff --git a/src/lib/connection_add.c b/src/lib/connection_add.c @@ -69,6 +69,8 @@ thread_main_connection_upgrade (struct MHD_Connection *con) /* Do not set 'urh->clean_ready' yet as 'urh' will be used * in connection thread for a little while. */ } + + #endif /* UPGRADE_SUPPORT */ @@ -1054,7 +1056,7 @@ MHD_accept_connection_ (struct MHD_Daemon *daemon) { MHD_socket_close_chk_ (s); } - if ( MHD_SCKT_ERR_IS_LOW_RESOURCES_ (err) ) + if (MHD_SCKT_ERR_IS_LOW_RESOURCES_ (err) ) { /* system/process out of resources */ if (0 == daemon->connections) @@ -1134,4 +1136,5 @@ MHD_accept_connection_ (struct MHD_Daemon *daemon) sk_nonbl); } + /* end of connection_add.c */ diff --git a/src/lib/connection_call_handlers.c b/src/lib/connection_call_handlers.c @@ -146,9 +146,10 @@ MHD_conn_init_static_ (void) } #endif /* SF_FLAGS */ } -#endif /* HAVE_FREEBSD_SENDFILE */ +#endif /* HAVE_FREEBSD_SENDFILE */ + /** * Message to transmit when http 1.1 request is received @@ -439,8 +440,7 @@ sendfile_adapter (struct MHD_Connection *connection) supported for FD or other 'unusual' errors occurred, so we should try to fall back to 'SEND'; see also this thread for info on odd libc/Linux behavior with sendfile: - http://lists.gnu.org/archive/html/libmicrohttpd/2011-02/msg00015.html */ - request->resp_sender = MHD_resp_sender_std; + http://lists.gnu.org/archive/html/libmicrohttpd/2011-02/msg00015.html */request->resp_sender = MHD_resp_sender_std; return MHD_ERR_AGAIN_; #else /* HAVE_SOLARIS_SENDFILE */ if ( (EAFNOSUPPORT == err) || @@ -534,6 +534,8 @@ sendfile_adapter (struct MHD_Connection *connection) #endif /* HAVE_FREEBSD_SENDFILE */ return ret; } + + #endif /* _MHD_HAVE_SENDFILE */ @@ -694,7 +696,7 @@ try_ready_chunked_body (struct MHD_Request *request) = (size_t) (request->response_write_position - response->data_start); /* buffer already ready, use what is there for the chunk */ ret = response->data_size - data_write_offset; - if ( ((size_t) ret) > request->write_buffer_size - sizeof (cbuf) - 2 ) + if ( ((size_t) ret) > request->write_buffer_size - sizeof (cbuf) - 2) ret = request->write_buffer_size - sizeof (cbuf) - 2; memcpy (&request->write_buffer[sizeof (cbuf)], &response->data[data_write_offset], @@ -1434,8 +1436,7 @@ build_header_response (struct MHD_Request *request) Note that the change from 'SHOULD NOT' to 'MUST NOT' is a recent development of the HTTP 1.1 specification. - */ - content_length_len + */content_length_len = MHD_snprintf_ (content_length_buf, sizeof (content_length_buf), MHD_HTTP_HEADER_CONTENT_LENGTH ": " @@ -1926,8 +1927,7 @@ process_header_line (struct MHD_Request *request, header at the beginning of the while loop since we need to be able to inspect the *next* header line (in case it starts - with a space...) */ - request->last = line; + with a space...) */request->last = line; request->colon = colon; return true; } @@ -1975,8 +1975,7 @@ process_broken_line (struct MHD_Request *request, adjacency); also, in the case where these are not adjacent (not sure how it can happen!), we would want to allocate from the end of the pool, so as to not destroy the read-buffer's - ability to grow nicely. */ - last = MHD_pool_reallocate (connection->pool, + ability to grow nicely. */last = MHD_pool_reallocate (connection->pool, last, last_len + 1, last_len + tmp_len + 1); @@ -2926,6 +2925,8 @@ connection_epoll_update_ (struct MHD_Connection *connection) } return true; } + + #endif @@ -3014,8 +3015,7 @@ connection_update_event_loop_info (struct MHD_Connection *connection) or if we do nothing, we would just timeout on the connection (if a timeout is even set!). - Solution: we kill the connection with an error */ - transmit_error_response (request, + Solution: we kill the connection with an error */transmit_error_response (request, MHD_SC_APPLICATION_HUNG_CONNECTION_CLOSED, MHD_HTTP_INTERNAL_SERVER_ERROR, INTERNAL_ERROR); @@ -3675,10 +3675,8 @@ MHD_connection_call_handlers_ (struct MHD_Connection *con, immediately. As writeability of socket was not checked and it may have some data pending in system buffers, use this optimization - only for non-blocking sockets. */ - /* No need to check 'ret' as connection is always in - * MHD_CONNECTION_CLOSED state if 'ret' is equal 'MHD_NO'. */ - else if (on_fasttrack && + only for non-blocking sockets. *//* No need to check 'ret' as connection is always in + * MHD_CONNECTION_CLOSED state if 'ret' is equal 'MHD_NO'. */else if (on_fasttrack && con->sk_nonblck) { if (MHD_REQUEST_HEADERS_SENDING == con->request.state) @@ -3722,4 +3720,5 @@ MHD_connection_call_handlers_ (struct MHD_Connection *con, return ret; } + /* end of connection_call_handlers.c */ diff --git a/src/lib/connection_cleanup.c b/src/lib/connection_cleanup.c @@ -59,6 +59,8 @@ connection_cleanup_upgraded (struct MHD_Connection *connection) connection->request.urh = NULL; free (urh); } + + #endif /* UPGRADE_SUPPORT */ @@ -129,8 +131,7 @@ MHD_connection_cleanup_ (struct MHD_Daemon *daemon) this is not true as if we fail to do manually remove it, we are still seeing an event for this fd in epoll, causing grief (use-after-free...) --- at least on my - system. */ - if (0 != epoll_ctl (daemon->epoll_fd, + system. */if (0 != epoll_ctl (daemon->epoll_fd, EPOLL_CTL_DEL, pos->socket_fd, NULL)) @@ -155,4 +156,5 @@ MHD_connection_cleanup_ (struct MHD_Daemon *daemon) MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex); } + /* end of connection_cleanup.c */ diff --git a/src/lib/connection_close.c b/src/lib/connection_close.c @@ -48,8 +48,7 @@ MHD_connection_mark_closed_ (struct MHD_Connection *connection) * and do not shutdown TCP socket. This give more * chances to send TLS closure data to remote side. * Closure of TLS layer will be interpreted by - * remote side as end of transmission. */ - if (NULL != (tls = daemon->tls_api)) + * remote side as end of transmission. */if (NULL != (tls = daemon->tls_api)) { if (MHD_YES != tls->shutdown_connection (tls->cls, @@ -100,4 +99,5 @@ MHD_connection_close_ (struct MHD_Connection *connection, MHD_CONNECTION_NOTIFY_CLOSED); } + /* end of connection_close.c */ diff --git a/src/lib/connection_finish_forward.c b/src/lib/connection_finish_forward.c @@ -87,8 +87,9 @@ MHD_connection_finish_forward_ (struct MHD_Connection *connection) * used with MHD_UPGRADE_ACTION_CLOSE. They will be * closed by MHD_cleanup_upgraded_connection_() during * connection's final cleanup. - */ -} + */} + + #endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT*/ /* end of connection_finish_forward.c */ diff --git a/src/lib/connection_info.c b/src/lib/connection_info.c @@ -107,4 +107,5 @@ MHD_connection_get_information_sz (struct MHD_Connection *connection, #undef CHECK_SIZE } + /* end of connection_info.c */ diff --git a/src/lib/connection_options.c b/src/lib/connection_options.c @@ -114,4 +114,5 @@ MHD_update_last_activity_ (struct MHD_Connection *connection) MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex); } + /* end of connection_options.c */ diff --git a/src/lib/connection_update_last_activity.c b/src/lib/connection_update_last_activity.c @@ -61,4 +61,5 @@ MHD_connection_update_last_activity_ (struct MHD_Connection *connection) MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex); } + /* end of connection_update_last_activity.c */ diff --git a/src/lib/daemon_close_all_connections.c b/src/lib/daemon_close_all_connections.c @@ -233,4 +233,5 @@ MHD_daemon_close_all_connections_ (struct MHD_Daemon *daemon) MHD_connection_cleanup_ (daemon); } + /* end of daemon_close_all_connections.c */ diff --git a/src/lib/daemon_destroy.c b/src/lib/daemon_destroy.c @@ -199,4 +199,5 @@ MHD_daemon_destroy (struct MHD_Daemon *daemon) free (daemon); } + /* end of daemon_destroy.c */ diff --git a/src/lib/daemon_epoll.c b/src/lib/daemon_epoll.c @@ -199,6 +199,8 @@ run_epoll_for_upgrade (struct MHD_Daemon *daemon) return MHD_SC_OK; } + + #endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */ @@ -488,8 +490,7 @@ MHD_daemon_epoll_ (struct MHD_Daemon *daemon, here. Connections with custom timeouts must all be looked at, as we - do not bother to sort that (presumably very short) list. */ - prev = daemon->manual_timeout_tail; + do not bother to sort that (presumably very short) list. */prev = daemon->manual_timeout_tail; while (NULL != (pos = prev)) { prev = pos->prevX; @@ -509,6 +510,8 @@ MHD_daemon_epoll_ (struct MHD_Daemon *daemon, } return MHD_SC_OK; } + + #endif /* end of daemon_epoll.c */ diff --git a/src/lib/daemon_get_timeout.c b/src/lib/daemon_get_timeout.c @@ -123,4 +123,5 @@ MHD_daemon_get_timeout (struct MHD_Daemon *daemon, return MHD_SC_OK; } + /* end of daemon_get_timeout.c */ diff --git a/src/lib/daemon_info.c b/src/lib/daemon_info.c @@ -102,4 +102,5 @@ MHD_daemon_get_information_sz (struct MHD_Daemon *daemon, #undef CHECK_SIZE } + /* end of daemon_info.c */ diff --git a/src/lib/daemon_ip_limit.c b/src/lib/daemon_ip_limit.c @@ -299,4 +299,5 @@ MHD_ip_limit_del (struct MHD_Daemon *daemon, MHD_ip_count_unlock (daemon); } + /* end of daemon_ip_limit.c */ diff --git a/src/lib/daemon_poll.c b/src/lib/daemon_poll.c @@ -125,6 +125,8 @@ urh_from_pollfd (struct MHD_UpgradeResponseHandle *urh, if (0 != (p[1].revents & MHD_POLL_REVENTS_ERRROR)) urh->mhd.celi |= MHD_EPOLL_STATE_READ_READY | MHD_EPOLL_STATE_WRITE_READY; } + + #endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */ @@ -429,6 +431,8 @@ MHD_daemon_poll_listen_socket_ (struct MHD_Daemon *daemon, (void) MHD_accept_connection_ (daemon); return MHD_SC_OK; } + + #endif @@ -516,6 +520,8 @@ MHD_daemon_upgrade_connection_with_poll_ (struct MHD_Connection *con) MHD_upgrade_response_handle_process_ (urh); } } + + #endif #endif diff --git a/src/lib/daemon_poll.h b/src/lib/daemon_poll.h @@ -65,6 +65,7 @@ enum MHD_StatusCode MHD_daemon_poll_ (struct MHD_Daemon *daemon, bool may_block) MHD_NONNULL (1); + #endif @@ -79,6 +80,7 @@ MHD_NONNULL (1); void MHD_daemon_upgrade_connection_with_poll_ (struct MHD_Connection *con) MHD_NONNULL (1); + #endif #endif diff --git a/src/lib/daemon_quiesce.c b/src/lib/daemon_quiesce.c @@ -121,9 +121,8 @@ MHD_daemon_quiesce (struct MHD_Daemon *daemon) to be sure that the threads have stopped using the listen socket, otherwise there is still the possibility of a race between a thread accept()ing and the caller closing and - re-binding the socket. */ - - return listen_socket; + re-binding the socket. */return listen_socket; } + /* end of daemon_quiesce.c */ diff --git a/src/lib/daemon_run.c b/src/lib/daemon_run.c @@ -79,4 +79,5 @@ MHD_daemon_run (struct MHD_Daemon *daemon) } } + /* end of daemon_run.c */ diff --git a/src/lib/daemon_select.c b/src/lib/daemon_select.c @@ -160,6 +160,8 @@ urh_to_fdset (struct MHD_UpgradeResponseHandle *urh, return res; } + + #endif @@ -392,6 +394,8 @@ urh_from_fdset (struct MHD_UpgradeResponseHandle *urh, urh->mhd.celi |= MHD_EPOLL_STATE_ERROR; } } + + #endif @@ -575,6 +579,8 @@ MHD_daemon_upgrade_connection_with_select_ (struct MHD_Connection *con) MHD_upgrade_response_handle_process_ (urh); } } + + #endif @@ -742,6 +748,8 @@ MHD_daemon_select_ (struct MHD_Daemon *daemon, #if defined(MHD_WINSOCK_SOCKETS) } } + + #endif /* MHD_WINSOCK_SOCKETS */ } /* Stop listening if we are at the configured connection limit */ diff --git a/src/lib/daemon_select.h b/src/lib/daemon_select.h @@ -50,6 +50,7 @@ MHD_NONNULL (1); void MHD_daemon_upgrade_connection_with_select_ (struct MHD_Connection *con) MHD_NONNULL (1); + #endif #endif diff --git a/src/lib/daemon_start.c b/src/lib/daemon_start.c @@ -603,6 +603,8 @@ setup_epoll_to_listen (struct MHD_Daemon *daemon) } return MHD_SC_OK; } + + #endif diff --git a/src/lib/init.c b/src/lib/init.c @@ -121,6 +121,7 @@ MHD_fini (void) MHD_monotonic_sec_counter_finish (); } + #ifdef _AUTOINIT_FUNCS_ARE_SUPPORTED _SET_INIT_AND_DEINIT_FUNCS (MHD_init, MHD_fini); @@ -143,4 +144,6 @@ MHD_check_global_init_ (void) MHD_mutex_unlock_chk_ (&global_init_mutex_); #endif /* MHD_MUTEX_STATIC_DEFN_INIT_ */ } + + #endif diff --git a/src/lib/init.h b/src/lib/init.h @@ -39,6 +39,7 @@ */ void MHD_check_global_init_ (void); + #endif /* ! _AUTOINIT_FUNCS_ARE_SUPPORTED */ diff --git a/src/lib/internal.c b/src/lib/internal.c @@ -80,6 +80,8 @@ MHD_state_to_string (enum MHD_CONNECTION_STATE state) return "unrecognized connection state"; } } + + #endif #endif @@ -107,6 +109,8 @@ MHD_DLOG (const struct MHD_Daemon *daemon, va); va_end (va); } + + #endif @@ -280,4 +284,5 @@ MHD_parse_arguments_ (struct MHD_Request *request, return true; } + /* end of internal.c */ diff --git a/src/lib/internal.h b/src/lib/internal.h @@ -87,6 +87,7 @@ MHD_DLOG (const struct MHD_Daemon *daemon, enum MHD_StatusCode sc, const char *format, ...); + #endif @@ -147,7 +148,6 @@ extern void *mhd_panic_cls; #endif /* ! MHD_STATICSTR_LEN_ */ - /** * Ability to use same connection for next request */ @@ -1692,7 +1692,6 @@ struct MHD_Response }; - /** * Callback invoked when iterating over @a key / @a value * argument pairs during parsing. @@ -1733,7 +1732,6 @@ MHD_parse_arguments_ (struct MHD_Request *request, unsigned int *num_headers); - /** * Insert an element at the head of a DLL. Assumes that head, tail and * element are structs with prev and next fields. @@ -1777,7 +1775,6 @@ MHD_parse_arguments_ (struct MHD_Request *request, (element)->prev = NULL; } while (0) - /** * Insert an element at the head of a XDLL. Assumes that head, tail and * element are structs with prevX and nextX fields. @@ -1860,7 +1857,6 @@ MHD_parse_arguments_ (struct MHD_Request *request, (element)->prevE = NULL; } while (0) - /** * Error code similar to EGAIN or EINTR */ @@ -1893,6 +1889,4 @@ MHD_parse_arguments_ (struct MHD_Request *request, #define MHD_ERR_INVAL_ (-3078) - - #endif diff --git a/src/lib/md5.c b/src/lib/md5.c @@ -59,6 +59,7 @@ MHD_MD5Init (struct MD5Context *ctx) ctx->state[3] = 0x10325476; } + /* * Update context to reflect the concatenation of another buffer full * of bytes. @@ -103,6 +104,7 @@ MHD_MD5Update (struct MD5Context *ctx, const unsigned char *input, size_t len) memcpy (ctx->buffer + have, input, len); } + /* * Pad pad to 64-byte boundary with the bit pattern * 1 0* (64-bit count of bits processed, MSB-first) @@ -128,6 +130,7 @@ MD5Pad (struct MD5Context *ctx) MHD_MD5Update (ctx, count, 8); } + /* * Final wrapup--call MD5Pad, fill in digest and zero out ctx. */ @@ -261,4 +264,5 @@ MD5Transform (uint32_t state[4], const uint8_t block[MD5_BLOCK_SIZE]) state[3] += d; } + /* end of md5.c */ diff --git a/src/lib/mhd_byteorder.h b/src/lib/mhd_byteorder.h @@ -123,7 +123,7 @@ defined(_M_IX86) || defined(_X86_) || defined (__THW_INTEL__) /* x86 family is little endian */ #define _MHD_BYTE_ORDER _MHD_LITTLE_ENDIAN -#elif defined(__ARMEB__) || defined(__THUMBEB__) || defined(__AARCH64EB__) || \ +#elif defined(__ARMEB__) || defined(__THUMBEB__) || defined(__AARCH64EB__) || \ defined(_MIPSEB) || defined(__MIPSEB) || defined(__MIPSEB__) /* Looks like we are on ARM/MIPS in big endian mode */ #define _MHD_BYTE_ORDER _MHD_BIG_ENDIAN diff --git a/src/lib/mhd_compat.c b/src/lib/mhd_compat.c @@ -79,6 +79,7 @@ W32_snprintf (char *__restrict s, return ret; } + #endif /* HAVE_SNPRINTF */ #endif /* _WIN32 && !__CYGWIN__ */ @@ -93,16 +94,17 @@ W32_snprintf (char *__restrict s, #endif /* __GNUC__ >= 5 */ -void *MHD_calloc_ (size_t nelem, size_t elsize) +void * +MHD_calloc_ (size_t nelem, size_t elsize) { size_t alloc_size; void *ptr; #ifdef MHD_HAVE_NUL_OVERFLOW - if (__builtin_mul_overflow (nelem, elsize, &alloc_size) ||(0 == alloc_size)) + if (__builtin_mul_overflow (nelem, elsize, &alloc_size) || (0 == alloc_size)) return NULL; #else /* ! MHD_HAVE_NUL_OVERFLOW */ alloc_size = nelem * elsize; - if ((0 == alloc_size)||(elsize != alloc_size / nelem)) + if ((0 == alloc_size) || (elsize != alloc_size / nelem)) return NULL; #endif /* ! MHD_HAVE_NUL_OVERFLOW */ ptr = malloc (alloc_size); @@ -111,4 +113,6 @@ void *MHD_calloc_ (size_t nelem, size_t elsize) memset (ptr, 0, alloc_size); return ptr; } + + #endif /* ! HAVE_CALLOC */ diff --git a/src/lib/mhd_compat.h b/src/lib/mhd_compat.h @@ -51,6 +51,7 @@ /* Emulate snprintf function on W32 */ int W32_snprintf (char *__restrict s, size_t n, const char *__restrict format, ...); + #define MHD_snprintf_ W32_snprintf #else /* ! _WIN32 || __CYGWIN__ */ #error \ @@ -84,6 +85,7 @@ int W32_snprintf (char *__restrict s, size_t n, const char *__restrict format, * MHD_calloc_ is platform-independent calloc() */ void *MHD_calloc_ (size_t nelem, size_t elsize); + #endif /* ! HAVE_CALLOC */ #endif /* MHD_COMPAT_H */ diff --git a/src/lib/mhd_itc.c b/src/lib/mhd_itc.c @@ -65,6 +65,8 @@ MHD_itc_nonblocking_ (struct MHD_itc_ itc) } return ! 0; } + + #endif /* ! HAVE_PIPE2_FUNC */ #endif /* !_WIN32 || __CYGWIN__ */ #endif /* _MHD_ITC_EVENTFD || _MHD_ITC_PIPE */ diff --git a/src/lib/mhd_itc.h b/src/lib/mhd_itc.h @@ -242,6 +242,7 @@ static const uint64_t _MHD_itc_wr_data = 1; */ int MHD_itc_nonblocking_ (struct MHD_itc_ itc); + #endif /* ! HAVE_PIPE2_FUNC */ diff --git a/src/lib/mhd_mono_clock.c b/src/lib/mhd_mono_clock.c @@ -94,7 +94,6 @@ static int64_t perf_start; #endif /* _WIN32 */ - /** * Type of monotonic clock source */ diff --git a/src/lib/mhd_sockets.c b/src/lib/mhd_sockets.c @@ -37,7 +37,8 @@ * @param err the WinSock error code. * @return pointer to string description of specified WinSock error. */ -const char*MHD_W32_strerror_winsock_ (int err) +const char* +MHD_W32_strerror_winsock_ (int err) { switch (err) { @@ -358,6 +359,7 @@ MHD_W32_socket_pair_ (SOCKET sockets_pair[2], int non_blk) return 0; } + #endif /* MHD_WINSOCK_SOCKETS */ diff --git a/src/lib/mhd_sockets.h b/src/lib/mhd_sockets.h @@ -534,6 +534,7 @@ typedef int MHD_SCKT_SEND_SIZE_; * @return pointer to string description of specified WinSock error. */ const char*MHD_W32_strerror_winsock_ (int err); + #endif /* MHD_WINSOCK_SOCKETS */ /* MHD_socket_last_strerr_ is description string of specified socket error code */ diff --git a/src/lib/mhd_str.c b/src/lib/mhd_str.c @@ -63,6 +63,8 @@ isasciilower (char c) { return (c >= 'a') && (c <= 'z'); } + + #endif /* Disable unused functions. */ @@ -91,6 +93,8 @@ isasciialpha (char c) { return isasciilower (c) || isasciiupper (c); } + + #endif /* Disable unused functions. */ @@ -106,6 +110,7 @@ isasciidigit (char c) return (c >= '0') && (c <= '9'); } + #if 0 /* Disable unused functions. */ /** * Check whether character is hexadecimal digit in US-ASCII @@ -133,6 +138,8 @@ isasciialnum (char c) { return isasciialpha (c) || isasciidigit (c); } + + #endif /* Disable unused functions. */ @@ -167,6 +174,8 @@ toasciiupper (char c) { return isasciilower (c) ? (c - 'a' + 'A') : c; } + + #endif /* Disable unused functions. */ @@ -185,6 +194,8 @@ todigitvalue (char c) return -1; } + + #endif /* MHD_FAVOR_SMALL_CODE */ @@ -206,6 +217,8 @@ toxdigitvalue (char c) return -1; } + + #else /* !INLINE_FUNC */ @@ -345,6 +358,8 @@ MHD_str_equal_caseless_ (const char *str1, } return 0 == (*str2); } + + #endif /* ! MHD_FAVOR_SMALL_CODE */ @@ -427,7 +442,7 @@ MHD_str_has_token_caseless_ (const char *str, while (' ' == *str || '\t' == *str) str++; /* End of (sub)string? */ - if ((0 == *str) ||(',' == *str) ) + if ((0 == *str) || (',' == *str) ) return true; /* Unmatched chars at end of substring. */ break; @@ -440,6 +455,7 @@ MHD_str_has_token_caseless_ (const char *str, return false; } + #ifndef MHD_FAVOR_SMALL_CODE /* Use individual function for each case */ @@ -554,8 +570,8 @@ MHD_strx_to_uint32_ (const char *str, while (digit >= 0) { if ( (res < (UINT32_MAX / 16)) || - ((res == (UINT32_MAX / 16)) &&( (uint32_t) digit <= (UINT32_MAX - % 16)) ) ) + ((res == (UINT32_MAX / 16)) && ( (uint32_t) digit <= (UINT32_MAX + % 16)) ) ) { res *= 16; res += digit; @@ -601,8 +617,8 @@ MHD_strx_to_uint32_n_ (const char *str, while (i < maxlen && (digit = toxdigitvalue (str[i])) >= 0) { if ( (res > (UINT32_MAX / 16)) || - ((res == (UINT32_MAX / 16)) &&( (uint32_t) digit > (UINT32_MAX - % 16)) ) ) + ((res == (UINT32_MAX / 16)) && ( (uint32_t) digit > (UINT32_MAX + % 16)) ) ) return 0; res *= 16; @@ -641,8 +657,8 @@ MHD_strx_to_uint64_ (const char *str, while (digit >= 0) { if ( (res < (UINT64_MAX / 16)) || - ((res == (UINT64_MAX / 16)) &&( (uint64_t) digit <= (UINT64_MAX - % 16)) ) ) + ((res == (UINT64_MAX / 16)) && ( (uint64_t) digit <= (UINT64_MAX + % 16)) ) ) { res *= 16; res += digit; @@ -688,8 +704,8 @@ MHD_strx_to_uint64_n_ (const char *str, while (i < maxlen && (digit = toxdigitvalue (str[i])) >= 0) { if ( (res > (UINT64_MAX / 16)) || - ((res == (UINT64_MAX / 16)) &&( (uint64_t) digit > (UINT64_MAX - % 16)) ) ) + ((res == (UINT64_MAX / 16)) && ( (uint64_t) digit > (UINT64_MAX + % 16)) ) ) return 0; res *= 16; @@ -702,6 +718,7 @@ MHD_strx_to_uint64_n_ (const char *str, return i; } + #else /* MHD_FAVOR_SMALL_CODE */ /** @@ -738,8 +755,8 @@ MHD_str_to_uvalue_n_ (const char *str, int (*const dfunc)(char) = (base == 16) ? toxdigitvalue : todigitvalue; - if ( ! str || ! out_val || - ((base != 16)&&(base != 10)) ) + if (! str || ! out_val || + ((base != 16) && (base != 10)) ) return 0; res = 0; @@ -747,7 +764,7 @@ MHD_str_to_uvalue_n_ (const char *str, while (maxlen > i && 0 <= (digit = dfunc (str[i]))) { if ( ((max_v_div_b) < res) || - (( (max_v_div_b) == res) &&( (max_v_mod_b) < (uint64_t) digit) ) ) + (( (max_v_div_b) == res) && ( (max_v_mod_b) < (uint64_t) digit) ) ) return 0; res *= base; @@ -766,4 +783,6 @@ MHD_str_to_uvalue_n_ (const char *str, } return i; } + + #endif /* MHD_FAVOR_SMALL_CODE */ diff --git a/src/lib/mhd_str.h b/src/lib/mhd_str.h @@ -60,6 +60,7 @@ int MHD_str_equal_caseless_ (const char *str1, const char *str2); + #else /* MHD_FAVOR_SMALL_CODE */ /* Reuse MHD_str_equal_caseless_n_() to reduce size */ #define MHD_str_equal_caseless_(s1,s2) MHD_str_equal_caseless_n_ ((s1),(s2), \ diff --git a/src/lib/mhd_threads.c b/src/lib/mhd_threads.c @@ -80,8 +80,7 @@ MHD_set_thread_name_ (const MHD_thread_ID_ thread_id, * third argument is single argument for printf; * OSF1 use 3 arguments too, but last one always must be zero (NULL). * MHD doesn't use '%' in thread names, so both form are used in same way. - */ - return ! pthread_setname_np (thread_id, thread_name, 0); + */return ! pthread_setname_np (thread_id, thread_name, 0); #endif /* HAVE_PTHREAD_SETNAME_NP_NETBSD */ } @@ -235,6 +234,7 @@ MHD_create_thread_ (MHD_thread_handle_ID_ *thread, #endif } + #ifdef MHD_USE_THREAD_NAME_ #ifndef MHD_USE_THREAD_ATTR_SETNAME @@ -276,6 +276,8 @@ named_thread_starter (void *data) return thr_func (arg); } + + #endif /* ! MHD_USE_THREAD_ATTR_SETNAME */ @@ -308,14 +310,13 @@ MHD_create_named_thread_ (MHD_thread_handle_ID_ *thread, * third argument is single argument for printf; * OSF1 use 3 arguments too, but last one always must be zero (NULL). * MHD doesn't use '%' in thread names, so both form are used in same way. - */ - res = pthread_attr_setname_np (&attr, thread_name, 0); + */res = pthread_attr_setname_np (&attr, thread_name, 0); #elif defined(HAVE_PTHREAD_ATTR_SETNAME_NP_IBMI) res = pthread_attr_setname_np (&attr, thread_name); #else #error No pthread_attr_setname_np() function. #endif - if ((res == 0) &&(0 != stack_size) ) + if ((res == 0) && (0 != stack_size) ) res = pthread_attr_setstacksize (&attr, stack_size); if (0 == res) @@ -362,4 +363,5 @@ MHD_create_named_thread_ (MHD_thread_handle_ID_ *thread, #endif /* ! MHD_USE_THREAD_ATTR_SETNAME */ } + #endif /* MHD_USE_THREAD_NAME_ */ diff --git a/src/lib/response.c b/src/lib/response.c @@ -256,4 +256,5 @@ MHD_response_get_header (struct MHD_Response *response, return NULL; } + /* end of response.c */ diff --git a/src/lib/response_for_upgrade.c b/src/lib/response_for_upgrade.c @@ -91,4 +91,5 @@ MHD_response_for_upgrade (MHD_UpgradeHandler upgrade_handler, #endif } + /* end of response_for_upgrade.c */ diff --git a/src/lib/response_from_buffer.c b/src/lib/response_from_buffer.c @@ -85,4 +85,5 @@ MHD_response_from_buffer (enum MHD_HTTP_StatusCode sc, return response; } + /* end of response_from_buffer.c */ diff --git a/src/lib/response_from_fd.c b/src/lib/response_from_fd.c @@ -207,4 +207,5 @@ MHD_response_from_fd (enum MHD_HTTP_StatusCode sc, return response; } + /* end of response_from_fd.c */ diff --git a/src/lib/tsearch.c b/src/lib/tsearch.c @@ -102,7 +102,7 @@ tdelete (const void *__restrict vkey, node_t *r; int cmp; - if ((rootp == NULL)||((p = *rootp) == NULL)) + if ((rootp == NULL) || ((p = *rootp) == NULL)) return NULL; while ((cmp = (*compar)(vkey, (*rootp)->key)) != 0) @@ -140,4 +140,5 @@ tdelete (const void *__restrict vkey, return p; } + /* end of tsearch.c */ diff --git a/src/lib/upgrade_process.c b/src/lib/upgrade_process.c @@ -85,8 +85,7 @@ MHD_upgrade_response_handle_process_ (struct MHD_UpgradeResponseHandle *urh) * check for any pending data even if socket is not marked * as 'ready' (signal may arrive after poll()/select()). * Socketpair for forwarding is always in non-blocking mode - * so no risk that recv() will block the thread. */ - if (0 != urh->out_buffer_size) + * so no risk that recv() will block the thread. */if (0 != urh->out_buffer_size) urh->mhd.celi |= MHD_EPOLL_STATE_READ_READY; /* Discard any data received form remote. */ urh->in_buffer_used = 0; @@ -102,11 +101,8 @@ MHD_upgrade_response_handle_process_ (struct MHD_UpgradeResponseHandle *urh) * fail after remote disconnect was detected) may discard data in system * buffers received by system but not yet read by recv(). * So, before trying send() on any socket, recv() must be performed at first - * otherwise last part of incoming data may be lost. */ - - /* If disconnect or error was detected - try to read from socket - * to dry data possibly pending is system buffers. */ - if (0 != (MHD_EPOLL_STATE_ERROR & urh->app.celi)) + * otherwise last part of incoming data may be lost. *//* If disconnect or error was detected - try to read from socket + * to dry data possibly pending is system buffers. */if (0 != (MHD_EPOLL_STATE_ERROR & urh->app.celi)) urh->app.celi |= MHD_EPOLL_STATE_READ_READY; if (0 != (MHD_EPOLL_STATE_ERROR & urh->mhd.celi)) urh->mhd.celi |= MHD_EPOLL_STATE_READ_READY; @@ -392,6 +388,8 @@ MHD_upgrade_response_handle_process_ (struct MHD_UpgradeResponseHandle *urh) urh->mhd.celi &= ~MHD_EPOLL_STATE_READ_READY; } } + + #endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */ /* end of upgrade_process.c */ diff --git a/src/lib/version.c b/src/lib/version.c @@ -46,7 +46,7 @@ MHD_get_version (void) (((int) MHD_VERSION >> 24) & 0xFF), (((int) MHD_VERSION >> 16) & 0xFF), (((int) MHD_VERSION >> 8) & 0xFF)); - if ((0 >= res)||(sizeof(ver) <= res)) + if ((0 >= res) || (sizeof(ver) <= res)) return "0.0.0"; /* Can't return real version*/ } return ver; diff --git a/src/microhttpd/basicauth.c b/src/microhttpd/basicauth.c @@ -143,7 +143,7 @@ MHD_queue_basic_auth_fail_response (struct MHD_Connection *connection, hlen, "Basic realm=\"%s\"", realm); - if ((res > 0)&&((size_t) res < hlen)) + if ((res > 0) && ((size_t) res < hlen)) ret = MHD_add_response_header (response, MHD_HTTP_HEADER_WWW_AUTHENTICATE, header); @@ -167,4 +167,5 @@ MHD_queue_basic_auth_fail_response (struct MHD_Connection *connection, return ret; } + /* end of basicauth.c */ diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c @@ -175,6 +175,8 @@ MHD_conn_init_static_ (void) } #endif /* SF_FLAGS */ } + + #endif /* HAVE_FREEBSD_SENDFILE */ /** * Callback for receiving data from the socket. @@ -634,10 +636,12 @@ MHD_lookup_header_token_ci (const struct MHD_Connection *connection, { struct MHD_HTTP_Header *pos; - if ((NULL == connection)||(NULL == header)||(0 == header[0])||(NULL == - token) ||(0 == - token - [0]) ) + if ((NULL == connection) || (NULL == header) || (0 == header[0]) || (NULL == + token) || + (0 == + token + [ + 0]) ) return false; for (pos = connection->headers_received; NULL != pos; pos = pos->next) @@ -721,8 +725,7 @@ MHD_connection_mark_closed_ (struct MHD_Connection *connection) * and do not shutdown TCP socket. This give more * chances to send TLS closure data to remote side. * Closure of TLS layer will be interpreted by - * remote side as end of transmission. */ - if (0 != (daemon->options & MHD_USE_TLS)) + * remote side as end of transmission. */if (0 != (daemon->options & MHD_USE_TLS)) { if (! MHD_tls_connection_shutdown (connection)) shutdown (connection->socket_fd, @@ -829,8 +832,9 @@ MHD_connection_finish_forward_ (struct MHD_Connection *connection) * used with MHD_UPGRADE_ACTION_CLOSE. They will be * closed by MHD_cleanup_upgraded_connection_() during * connection's final cleanup. - */ -} + */} + + #endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT*/ @@ -999,7 +1003,7 @@ try_ready_chunked_body (struct MHD_Connection *connection) = (size_t) (connection->response_write_position - response->data_start); /* buffer already ready, use what is there for the chunk */ ret = response->data_size - data_write_offset; - if ( ((size_t) ret) > connection->write_buffer_size - sizeof (cbuf) - 2 ) + if ( ((size_t) ret) > connection->write_buffer_size - sizeof (cbuf) - 2) ret = connection->write_buffer_size - sizeof (cbuf) - 2; memcpy (&connection->write_buffer[sizeof (cbuf)], &response->data[data_write_offset], @@ -1454,8 +1458,7 @@ build_header_response (struct MHD_Connection *connection) Note that the change from 'SHOULD NOT' to 'MUST NOT' is a recent development of the HTTP 1.1 specification. - */ - content_length_len + */content_length_len = MHD_snprintf_ (content_length_buf, sizeof (content_length_buf), MHD_HTTP_HEADER_CONTENT_LENGTH ": " @@ -1788,8 +1791,7 @@ MHD_connection_update_event_loop_info (struct MHD_Connection *connection) or if we do nothing, we would just timeout on the connection (if a timeout is even set!). - Solution: we kill the connection with an error */ - transmit_error_response (connection, + Solution: we kill the connection with an error */transmit_error_response (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, INTERNAL_ERROR); continue; @@ -2559,8 +2561,7 @@ process_header_line (struct MHD_Connection *connection, header at the beginning of the while loop since we need to be able to inspect the *next* header line (in case it starts - with a space...) */ - connection->last = line; + with a space...) */connection->last = line; connection->colon = colon; return MHD_YES; } @@ -2607,8 +2608,7 @@ process_broken_line (struct MHD_Connection *connection, adjacency); also, in the case where these are not adjacent (not sure how it can happen!), we would want to allocate from the end of the pool, so as to not destroy the read-buffer's - ability to grow nicely. */ - last = MHD_pool_reallocate (connection->pool, + ability to grow nicely. */last = MHD_pool_reallocate (connection->pool, last, last_len + 1, last_len + tmp_len + 1); @@ -3804,6 +3804,8 @@ MHD_connection_epoll_update_ (struct MHD_Connection *connection) } return MHD_YES; } + + #endif diff --git a/src/microhttpd/connection.h b/src/microhttpd/connection.h @@ -68,6 +68,7 @@ */ void MHD_conn_init_static_ (void); + #endif /* HAVE_FREEBSD_SENDFILE */ @@ -152,6 +153,7 @@ MHD_connection_close_ (struct MHD_Connection *connection, */ void MHD_connection_finish_forward_ (struct MHD_Connection *connection); + #else /* ! HTTPS_SUPPORT */ #define MHD_connection_finish_forward_(conn) (void) conn #endif /* ! HTTPS_SUPPORT */ @@ -168,6 +170,7 @@ MHD_connection_finish_forward_ (struct MHD_Connection *connection); */ int MHD_connection_epoll_update_ (struct MHD_Connection *connection); + #endif /** diff --git a/src/microhttpd/connection_https.c b/src/microhttpd/connection_https.c @@ -226,4 +226,5 @@ MHD_tls_connection_shutdown (struct MHD_Connection *connection) return false; } + /* end of connection_https.c */ diff --git a/src/microhttpd/connection_https.h b/src/microhttpd/connection_https.h @@ -74,6 +74,7 @@ ssize_t send_tls_adapter (struct MHD_Connection *connection, const void *other, size_t i); + #endif /* HTTPS_SUPPORT */ #endif diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c @@ -216,6 +216,8 @@ MHD_check_global_init_ (void) #endif /* MHD_MUTEX_STATIC_DEFN_INIT_ */ #endif } + + #endif /* ! _AUTOINIT_FUNCS_ARE_SUPPORTED */ @@ -654,6 +656,7 @@ MHD_init_daemon_certificate (struct MHD_Daemon *daemon) return -1; } + /** * Initialize security aspects of the HTTPS daemon * @@ -684,6 +687,8 @@ MHD_TLS_init (struct MHD_Daemon *daemon) return -1; } } + + #endif /* HTTPS_SUPPORT */ @@ -858,6 +863,7 @@ urh_from_fdset (struct MHD_UpgradeResponseHandle *urh, } } + #ifdef HAVE_POLL /** @@ -950,6 +956,8 @@ urh_from_pollfd (struct MHD_UpgradeResponseHandle *urh, if (0 != (p[1].revents & MHD_POLL_REVENTS_ERRROR)) urh->mhd.celi |= MHD_EPOLL_STATE_READ_READY | MHD_EPOLL_STATE_WRITE_READY; } + + #endif /* HAVE_POLL */ #endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */ @@ -1236,10 +1244,8 @@ call_handlers (struct MHD_Connection *con, immediately. As writeability of socket was not checked and it may have some data pending in system buffers, use this optimization - only for non-blocking sockets. */ - /* No need to check 'ret' as connection is always in - * MHD_CONNECTION_CLOSED state if 'ret' is equal 'MHD_NO'. */ - else if (on_fasttrack && con->sk_nonblck) + only for non-blocking sockets. *//* No need to check 'ret' as connection is always in + * MHD_CONNECTION_CLOSED state if 'ret' is equal 'MHD_NO'. */else if (on_fasttrack && con->sk_nonblck) { if (MHD_CONNECTION_HEADERS_SENDING == con->state) { @@ -1312,6 +1318,8 @@ cleanup_upgraded_connection (struct MHD_Connection *connection) connection->urh = NULL; free (urh); } + + #endif /* UPGRADE_SUPPORT */ @@ -1371,8 +1379,7 @@ process_urh (struct MHD_UpgradeResponseHandle *urh) * check for any pending data even if socket is not marked * as 'ready' (signal may arrive after poll()/select()). * Socketpair for forwarding is always in non-blocking mode - * so no risk that recv() will block the thread. */ - if (0 != urh->out_buffer_size) + * so no risk that recv() will block the thread. */if (0 != urh->out_buffer_size) urh->mhd.celi |= MHD_EPOLL_STATE_READ_READY; /* Discard any data received form remote. */ urh->in_buffer_used = 0; @@ -1388,11 +1395,8 @@ process_urh (struct MHD_UpgradeResponseHandle *urh) * fail after remote disconnect was detected) may discard data in system * buffers received by system but not yet read by recv(). * So, before trying send() on any socket, recv() must be performed at first - * otherwise last part of incoming data may be lost. */ - - /* If disconnect or error was detected - try to read from socket - * to dry data possibly pending is system buffers. */ - if (0 != (MHD_EPOLL_STATE_ERROR & urh->app.celi)) + * otherwise last part of incoming data may be lost. *//* If disconnect or error was detected - try to read from socket + * to dry data possibly pending is system buffers. */if (0 != (MHD_EPOLL_STATE_ERROR & urh->app.celi)) urh->app.celi |= MHD_EPOLL_STATE_READ_READY; if (0 != (MHD_EPOLL_STATE_ERROR & urh->mhd.celi)) urh->mhd.celi |= MHD_EPOLL_STATE_READ_READY; @@ -1669,6 +1673,8 @@ process_urh (struct MHD_UpgradeResponseHandle *urh) urh->mhd.celi &= ~MHD_EPOLL_STATE_READ_READY; } } + + #endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */ #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) @@ -1823,6 +1829,8 @@ thread_main_connection_upgrade (struct MHD_Connection *con) /* Do not set 'urh->clean_ready' yet as 'urh' will be used * in connection thread for a little while. */ } + + #endif /* UPGRADE_SUPPORT */ @@ -2182,7 +2190,7 @@ thread_main_handle_connection (void *data) MHD_REQUEST_TERMINATED_DAEMON_SHUTDOWN : MHD_REQUEST_TERMINATED_WITH_ERROR); MHD_connection_handle_idle (con); - exit: +exit: if (NULL != con->response) { MHD_destroy_response (con->response); @@ -2208,6 +2216,8 @@ thread_main_handle_connection (void *data) } return (MHD_THRD_RTRN_TYPE_) 0; } + + #endif @@ -2248,6 +2258,8 @@ MHD_tls_push_func_ (gnutls_transport_ptr_t trnsp, #endif /* (MHD_SCKT_SEND_MAX_SIZE_ < SSIZE_MAX) || (0 == SSIZE_MAX) */ return MHD_send_ ((MHD_socket) (intptr_t) (trnsp), data, data_size); } + + #endif /* MHD_TLSLIB_DONT_SUPPRESS_SIGPIPE */ @@ -2327,6 +2339,8 @@ psk_gnutls_adapter (gnutls_session_t session, return -1; #endif } + + #endif /* HTTPS_SUPPORT */ @@ -2742,7 +2756,7 @@ internal_add_connection (struct MHD_Daemon *daemon, #endif } return MHD_YES; - cleanup: +cleanup: if (NULL != daemon->notify_connection) daemon->notify_connection (daemon->notify_connection_cls, connection, @@ -3223,7 +3237,7 @@ MHD_accept_connection (struct MHD_Daemon *daemon) { MHD_socket_close_chk_ (s); } - if ( MHD_SCKT_ERR_IS_LOW_RESOURCES_ (err) ) + if (MHD_SCKT_ERR_IS_LOW_RESOURCES_ (err) ) { /* system/process out of resources */ if (0 == daemon->connections) @@ -3375,8 +3389,7 @@ MHD_cleanup_connections (struct MHD_Daemon *daemon) this is not true as if we fail to do manually remove it, we are still seeing an event for this fd in epoll, causing grief (use-after-free...) --- at least on my - system. */ - if (0 != epoll_ctl (daemon->epoll_fd, + system. */if (0 != epoll_ctl (daemon->epoll_fd, EPOLL_CTL_DEL, pos->socket_fd, NULL)) @@ -3632,7 +3645,7 @@ MHD_run_from_select (struct MHD_Daemon *daemon, if (0 != (daemon->options & (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_POLL)) ) return MHD_NO; - if ((NULL == read_fd_set)||(NULL == write_fd_set)) + if ((NULL == read_fd_set) || (NULL == write_fd_set)) return MHD_NO; if (NULL == except_fd_set) { /* Workaround to maintain backward compatibility. */ @@ -3770,6 +3783,8 @@ MHD_select (struct MHD_Daemon *daemon, #if defined(MHD_WINSOCK_SOCKETS) } } + + #endif /* MHD_WINSOCK_SOCKETS */ } /* Stop listening if we are at the configured connection limit */ @@ -4130,6 +4145,8 @@ MHD_poll_listen_socket (struct MHD_Daemon *daemon, (void) MHD_accept_connection (daemon); return MHD_YES; } + + #endif @@ -4319,6 +4336,8 @@ run_epoll_for_upgrade (struct MHD_Daemon *daemon) return MHD_YES; } + + #endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */ @@ -4607,8 +4626,7 @@ MHD_epoll (struct MHD_Daemon *daemon, here. Connections with custom timeouts must all be looked at, as we - do not bother to sort that (presumably very short) list. */ - prev = daemon->manual_timeout_tail; + do not bother to sort that (presumably very short) list. */prev = daemon->manual_timeout_tail; while (NULL != (pos = prev)) { prev = pos->prevX; @@ -4628,6 +4646,8 @@ MHD_epoll (struct MHD_Daemon *daemon, } return MHD_YES; } + + #endif @@ -4759,6 +4779,8 @@ MHD_polling_thread (void *cls) return (MHD_THRD_RTRN_TYPE_) 0; } + + #endif @@ -5644,6 +5666,8 @@ setup_epoll_to_listen (struct MHD_Daemon *daemon) } return MHD_YES; } + + #endif @@ -6553,7 +6577,7 @@ MHD_start_daemon_va (unsigned int flags, return daemon; #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) - thread_failed: +thread_failed: /* If no worker threads created, then shut down normally. Calling MHD_stop_daemon (as we do below) doesn't work here since it assumes a 0-sized thread pool means we had been in the default @@ -6577,7 +6601,7 @@ MHD_start_daemon_va (unsigned int flags, return NULL; #endif - free_and_fail: +free_and_fail: /* clean up basic memory state in 'daemon' and return NULL to indicate failure */ #ifdef EPOLL_SUPPORT @@ -7053,7 +7077,7 @@ MHD_get_version (void) (((int) MHD_VERSION >> 24) & 0xFF), (((int) MHD_VERSION >> 16) & 0xFF), (((int) MHD_VERSION >> 8) & 0xFF)); - if ((0 >= res)||(sizeof(ver) <= res)) + if ((0 >= res) || (sizeof(ver) <= res)) return "0.0.0"; /* Can't return real version*/ } return ver; @@ -7301,7 +7325,7 @@ MHD_init (void) if (0 != WSAStartup (MAKEWORD (2, 2), &wsd)) MHD_PANIC (_ ("Failed to initialize winsock\n")); mhd_winsock_inited_ = 1; - if ((2 != LOBYTE (wsd.wVersion))&&(2 != HIBYTE (wsd.wVersion))) + if ((2 != LOBYTE (wsd.wVersion)) && (2 != HIBYTE (wsd.wVersion))) MHD_PANIC (_ ("Winsock version 2.2 is not available\n")); #endif /* MHD_WINSOCK_SOCKETS */ #ifdef HTTPS_SUPPORT @@ -7346,6 +7370,7 @@ MHD_fini (void) MHD_monotonic_sec_counter_finish (); } + #ifdef _AUTOINIT_FUNCS_ARE_SUPPORTED _SET_INIT_AND_DEINIT_FUNCS (MHD_init, MHD_fini); #endif /* _AUTOINIT_FUNCS_ARE_SUPPORTED */ diff --git a/src/microhttpd/digestauth.c b/src/microhttpd/digestauth.c @@ -555,8 +555,7 @@ check_nonce_nc (struct MHD_Connection *connection, * Look for the nonce, if it does exist and its corresponding * nonce counter is less than the current nonce counter by 1, * then only increase the nonce counter by one. - */ - nn = &daemon->nnc[off]; + */nn = &daemon->nnc[off]; #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) MHD_mutex_lock_chk_ (&daemon->nnc_lock); #endif @@ -938,8 +937,7 @@ digest_auth_check_all (struct MHD_Connection *connection, large, but of course in theory the #MHD_OPTION_CONNECTION_MEMORY_LIMIT might be very large and would thus permit sending a >32k authorization - header value. */ - return MHD_NO; + header value. */return MHD_NO; } if (TIMESTAMP_BIN_SIZE * 2 != MHD_strx_to_uint32_n_ (nonce + len - TIMESTAMP_BIN_SIZE * 2, @@ -957,8 +955,7 @@ digest_auth_check_all (struct MHD_Connection *connection, * First level vetting for the nonce validity: if the timestamp * attached to the nonce exceeds `nonce_timeout', then the nonce is * invalid. - */ - if ( (t > nonce_time + nonce_timeout) || + */if ( (t > nonce_time + nonce_timeout) || (nonce_time + nonce_timeout < nonce_time) ) { /* too old */ @@ -981,9 +978,7 @@ digest_auth_check_all (struct MHD_Connection *connection, * able to generate a "sane" nonce, which if he does * not, the nonce fabrication process going to be * very hard to achieve. - */ - - if (0 != strcmp (nonce, + */if (0 != strcmp (nonce, noncehashexp)) { return MHD_INVALID_NONCE; @@ -1003,7 +998,7 @@ digest_auth_check_all (struct MHD_Connection *connection, (0 == (len = lookup_sub_value (nc, sizeof (nc), header, - "nc")) ) || + "nc")) ) || (0 == lookup_sub_value (response, sizeof (response), header, @@ -1030,8 +1025,7 @@ digest_auth_check_all (struct MHD_Connection *connection, * Checking if that combination of nonce and nc is sound * and not a replay attack attempt. Also adds the nonce * to the nonce-nc map if it does not exist there. - */ - if (MHD_YES != + */if (MHD_YES != check_nonce_nc (connection, nonce, nci)) @@ -1219,7 +1213,6 @@ MHD_digest_auth_check (struct MHD_Connection *connection, } while (0) - /** * Authenticates the authorization header sent by the client. * diff --git a/src/microhttpd/internal.c b/src/microhttpd/internal.c @@ -81,6 +81,8 @@ MHD_state_to_string (enum MHD_CONNECTION_STATE state) return "unrecognized connection state"; } } + + #endif #endif @@ -105,6 +107,8 @@ MHD_DLOG (const struct MHD_Daemon *daemon, va); va_end (va); } + + #endif @@ -288,4 +292,5 @@ MHD_parse_arguments_ (struct MHD_Connection *connection, return MHD_YES; } + /* end of internal.c */ diff --git a/src/microhttpd/internal.h b/src/microhttpd/internal.h @@ -255,6 +255,7 @@ void MHD_DLOG (const struct MHD_Daemon *daemon, const char *format, ...); + #endif @@ -562,6 +563,7 @@ enum MHD_TLS_CONN_STATE #if DEBUG_STATES const char * MHD_state_to_string (enum MHD_CONNECTION_STATE state); + #endif #endif @@ -1802,7 +1804,6 @@ struct MHD_Daemon (element)->prev = NULL; } while (0) - /** * Insert an element at the head of a XDLL. Assumes that head, tail and * element are structs with prevX and nextX fields. diff --git a/src/microhttpd/md5.c b/src/microhttpd/md5.c @@ -46,6 +46,7 @@ MHD_MD5Init (void *ctx_) ctx->state[3] = 0x10325476; } + static void MD5Transform (uint32_t state[4], const uint8_t block[MD5_BLOCK_SIZE]); diff --git a/src/microhttpd/memorypool.c b/src/microhttpd/memorypool.c @@ -100,6 +100,7 @@ MHD_init_mem_pools_ (void) #endif /* _WIN32 */ } + /** * Handle for a memory pool. Pools are not reentrant and must not be * used by multiple threads. diff --git a/src/microhttpd/mhd_byteorder.h b/src/microhttpd/mhd_byteorder.h @@ -125,7 +125,7 @@ defined(_M_IX86) || defined(_X86_) || defined (__THW_INTEL__) /* x86 family is little endian */ #define _MHD_BYTE_ORDER _MHD_LITTLE_ENDIAN -#elif defined(__ARMEB__) || defined(__THUMBEB__) || defined(__AARCH64EB__) || \ +#elif defined(__ARMEB__) || defined(__THUMBEB__) || defined(__AARCH64EB__) || \ defined(_MIPSEB) || defined(__MIPSEB) || defined(__MIPSEB__) /* Looks like we are on ARM/MIPS in big endian mode */ #define _MHD_BYTE_ORDER _MHD_BIG_ENDIAN diff --git a/src/microhttpd/mhd_compat.c b/src/microhttpd/mhd_compat.c @@ -79,6 +79,7 @@ W32_snprintf (char *__restrict s, return ret; } + #endif /* HAVE_SNPRINTF */ #endif /* _WIN32 && !__CYGWIN__ */ @@ -93,16 +94,17 @@ W32_snprintf (char *__restrict s, #endif /* __GNUC__ >= 5 */ -void *MHD_calloc_ (size_t nelem, size_t elsize) +void * +MHD_calloc_ (size_t nelem, size_t elsize) { size_t alloc_size; void *ptr; #ifdef MHD_HAVE_NUL_OVERFLOW - if (__builtin_mul_overflow (nelem, elsize, &alloc_size) ||(0 == alloc_size)) + if (__builtin_mul_overflow (nelem, elsize, &alloc_size) || (0 == alloc_size)) return NULL; #else /* ! MHD_HAVE_NUL_OVERFLOW */ alloc_size = nelem * elsize; - if ((0 == alloc_size)||(elsize != alloc_size / nelem)) + if ((0 == alloc_size) || (elsize != alloc_size / nelem)) return NULL; #endif /* ! MHD_HAVE_NUL_OVERFLOW */ ptr = malloc (alloc_size); @@ -111,4 +113,6 @@ void *MHD_calloc_ (size_t nelem, size_t elsize) memset (ptr, 0, alloc_size); return ptr; } + + #endif /* ! HAVE_CALLOC */ diff --git a/src/microhttpd/mhd_compat.h b/src/microhttpd/mhd_compat.h @@ -51,6 +51,7 @@ /* Emulate snprintf function on W32 */ int W32_snprintf (char *__restrict s, size_t n, const char *__restrict format, ...); + #define MHD_snprintf_ W32_snprintf #else /* ! _WIN32 || __CYGWIN__ */ #error \ @@ -84,6 +85,7 @@ int W32_snprintf (char *__restrict s, size_t n, const char *__restrict format, * MHD_calloc_ is platform-independent calloc() */ void *MHD_calloc_ (size_t nelem, size_t elsize); + #endif /* ! HAVE_CALLOC */ #endif /* MHD_COMPAT_H */ diff --git a/src/microhttpd/mhd_itc.c b/src/microhttpd/mhd_itc.c @@ -65,6 +65,8 @@ MHD_itc_nonblocking_ (struct MHD_itc_ itc) } return ! 0; } + + #endif /* ! HAVE_PIPE2_FUNC */ #endif /* !_WIN32 || __CYGWIN__ */ #endif /* _MHD_ITC_EVENTFD || _MHD_ITC_PIPE */ diff --git a/src/microhttpd/mhd_itc.h b/src/microhttpd/mhd_itc.h @@ -242,6 +242,7 @@ static const uint64_t _MHD_itc_wr_data = 1; */ int MHD_itc_nonblocking_ (struct MHD_itc_ itc); + #endif /* ! HAVE_PIPE2_FUNC */ diff --git a/src/microhttpd/mhd_mono_clock.c b/src/microhttpd/mhd_mono_clock.c @@ -94,7 +94,6 @@ static int64_t perf_start; #endif /* _WIN32 */ - /** * Type of monotonic clock source */ diff --git a/src/microhttpd/mhd_send.c b/src/microhttpd/mhd_send.c @@ -448,6 +448,7 @@ MHD_send_on_connection2_ (struct MHD_Connection *connection, #endif } + /** * sendfile() chuck size */ @@ -561,8 +562,7 @@ MHD_send_sendfile_ (struct MHD_Connection *connection) supported for FD or other 'unusual' errors occurred, so we should try to fall back to 'SEND'; see also this thread for info on odd libc/Linux behavior with sendfile: - http://lists.gnu.org/archive/html/libmicrohttpd/2011-02/msg00015.html */ - connection->resp_sender = MHD_resp_sender_std; + http://lists.gnu.org/archive/html/libmicrohttpd/2011-02/msg00015.html */connection->resp_sender = MHD_resp_sender_std; return MHD_ERR_AGAIN_; #else /* HAVE_SOLARIS_SENDFILE */ if ( (EAFNOSUPPORT == err) || @@ -662,4 +662,6 @@ MHD_send_sendfile_ (struct MHD_Connection *connection) return ret; } + + #endif /* _MHD_HAVE_SENDFILE */ diff --git a/src/microhttpd/mhd_send.h b/src/microhttpd/mhd_send.h @@ -94,6 +94,7 @@ MHD_send_on_connection2_ (struct MHD_Connection *connection, #if defined(_MHD_HAVE_SENDFILE) ssize_t MHD_send_sendfile_ (struct MHD_Connection *connection); + #endif #endif /* MHD_SEND_H */ diff --git a/src/microhttpd/mhd_sockets.c b/src/microhttpd/mhd_sockets.c @@ -37,7 +37,8 @@ * @param err the WinSock error code. * @return pointer to string description of specified WinSock error. */ -const char*MHD_W32_strerror_winsock_ (int err) +const char* +MHD_W32_strerror_winsock_ (int err) { switch (err) { @@ -358,6 +359,7 @@ MHD_W32_socket_pair_ (SOCKET sockets_pair[2], int non_blk) return 0; } + #endif /* MHD_WINSOCK_SOCKETS */ @@ -515,7 +517,7 @@ MHD_socket_cork_ (MHD_socket sock, (const void *) (on ? &on_val : &off_val), sizeof (off_val))) return 0; /* failed */ -#if defined(__FreeBSD__) && __FreeBSD__ + 0 >= 9 +#if defined(__FreeBSD__) && __FreeBSD__ + 0 >= 9 /* FreeBSD do not need zero-send for flushing starting from version 9 */ return 1; #elif defined(TCP_NOPUSH) && ! defined(TCP_CORK) diff --git a/src/microhttpd/mhd_sockets.h b/src/microhttpd/mhd_sockets.h @@ -554,6 +554,7 @@ typedef int MHD_SCKT_SEND_SIZE_; * @return pointer to string description of specified WinSock error. */ const char*MHD_W32_strerror_winsock_ (int err); + #endif /* MHD_WINSOCK_SOCKETS */ /* MHD_socket_last_strerr_ is description string of specified socket error code */ diff --git a/src/microhttpd/mhd_str.c b/src/microhttpd/mhd_str.c @@ -63,6 +63,8 @@ isasciilower (char c) { return (c >= 'a') && (c <= 'z'); } + + #endif /* Disable unused functions. */ @@ -91,6 +93,8 @@ isasciialpha (char c) { return isasciilower (c) || isasciiupper (c); } + + #endif /* Disable unused functions. */ @@ -106,6 +110,7 @@ isasciidigit (char c) return (c >= '0') && (c <= '9'); } + #if 0 /* Disable unused functions. */ /** * Check whether character is hexadecimal digit in US-ASCII @@ -133,6 +138,8 @@ isasciialnum (char c) { return isasciialpha (c) || isasciidigit (c); } + + #endif /* Disable unused functions. */ @@ -167,6 +174,8 @@ toasciiupper (char c) { return isasciilower (c) ? (c - 'a' + 'A') : c; } + + #endif /* Disable unused functions. */ @@ -185,6 +194,8 @@ todigitvalue (char c) return -1; } + + #endif /* MHD_FAVOR_SMALL_CODE */ @@ -206,6 +217,8 @@ toxdigitvalue (char c) return -1; } + + #else /* !INLINE_FUNC */ @@ -345,6 +358,8 @@ MHD_str_equal_caseless_ (const char *str1, } return 0 == (*str2); } + + #endif /* ! MHD_FAVOR_SMALL_CODE */ @@ -408,7 +423,6 @@ MHD_str_equal_caseless_bin_n_ (const char *const str1, } - /** * Check whether @a str has case-insensitive @a token. * Token could be surrounded by spaces and tabs and delimited by comma. @@ -456,7 +470,7 @@ MHD_str_has_token_caseless_ (const char *str, while (' ' == *str || '\t' == *str) str++; /* End of (sub)string? */ - if ((0 == *str) ||(',' == *str) ) + if ((0 == *str) || (',' == *str) ) return true; /* Unmatched chars at end of substring. */ break; @@ -469,6 +483,7 @@ MHD_str_has_token_caseless_ (const char *str, return false; } + #ifndef MHD_FAVOR_SMALL_CODE /* Use individual function for each case */ @@ -583,8 +598,8 @@ MHD_strx_to_uint32_ (const char *str, while (digit >= 0) { if ( (res < (UINT32_MAX / 16)) || - ((res == (UINT32_MAX / 16)) &&( (uint32_t) digit <= (UINT32_MAX - % 16)) ) ) + ((res == (UINT32_MAX / 16)) && ( (uint32_t) digit <= (UINT32_MAX + % 16)) ) ) { res *= 16; res += digit; @@ -630,8 +645,8 @@ MHD_strx_to_uint32_n_ (const char *str, while (i < maxlen && (digit = toxdigitvalue (str[i])) >= 0) { if ( (res > (UINT32_MAX / 16)) || - ((res == (UINT32_MAX / 16)) &&( (uint32_t) digit > (UINT32_MAX - % 16)) ) ) + ((res == (UINT32_MAX / 16)) && ( (uint32_t) digit > (UINT32_MAX + % 16)) ) ) return 0; res *= 16; @@ -670,8 +685,8 @@ MHD_strx_to_uint64_ (const char *str, while (digit >= 0) { if ( (res < (UINT64_MAX / 16)) || - ((res == (UINT64_MAX / 16)) &&( (uint64_t) digit <= (UINT64_MAX - % 16)) ) ) + ((res == (UINT64_MAX / 16)) && ( (uint64_t) digit <= (UINT64_MAX + % 16)) ) ) { res *= 16; res += digit; @@ -717,8 +732,8 @@ MHD_strx_to_uint64_n_ (const char *str, while (i < maxlen && (digit = toxdigitvalue (str[i])) >= 0) { if ( (res > (UINT64_MAX / 16)) || - ((res == (UINT64_MAX / 16)) &&( (uint64_t) digit > (UINT64_MAX - % 16)) ) ) + ((res == (UINT64_MAX / 16)) && ( (uint64_t) digit > (UINT64_MAX + % 16)) ) ) return 0; res *= 16; @@ -731,6 +746,7 @@ MHD_strx_to_uint64_n_ (const char *str, return i; } + #else /* MHD_FAVOR_SMALL_CODE */ /** @@ -767,8 +783,8 @@ MHD_str_to_uvalue_n_ (const char *str, int (*const dfunc)(char) = (base == 16) ? toxdigitvalue : todigitvalue; - if ( ! str || ! out_val || - ((base != 16)&&(base != 10)) ) + if (! str || ! out_val || + ((base != 16) && (base != 10)) ) return 0; res = 0; @@ -776,7 +792,7 @@ MHD_str_to_uvalue_n_ (const char *str, while (maxlen > i && 0 <= (digit = dfunc (str[i]))) { if ( ((max_v_div_b) < res) || - (( (max_v_div_b) == res) &&( (max_v_mod_b) < (uint64_t) digit) ) ) + (( (max_v_div_b) == res) && ( (max_v_mod_b) < (uint64_t) digit) ) ) return 0; res *= base; @@ -795,4 +811,6 @@ MHD_str_to_uvalue_n_ (const char *str, } return i; } + + #endif /* MHD_FAVOR_SMALL_CODE */ diff --git a/src/microhttpd/mhd_str.h b/src/microhttpd/mhd_str.h @@ -60,6 +60,7 @@ int MHD_str_equal_caseless_ (const char *str1, const char *str2); + #else /* MHD_FAVOR_SMALL_CODE */ /* Reuse MHD_str_equal_caseless_n_() to reduce size */ #define MHD_str_equal_caseless_(s1,s2) MHD_str_equal_caseless_n_ ((s1),(s2), \ diff --git a/src/microhttpd/mhd_threads.c b/src/microhttpd/mhd_threads.c @@ -80,8 +80,7 @@ MHD_set_thread_name_ (const MHD_thread_ID_ thread_id, * third argument is single argument for printf; * OSF1 use 3 arguments too, but last one always must be zero (NULL). * MHD doesn't use '%' in thread names, so both form are used in same way. - */ - return ! pthread_setname_np (thread_id, thread_name, 0); + */return ! pthread_setname_np (thread_id, thread_name, 0); #endif /* HAVE_PTHREAD_SETNAME_NP_NETBSD */ } @@ -235,6 +234,7 @@ MHD_create_thread_ (MHD_thread_handle_ID_ *thread, #endif } + #ifdef MHD_USE_THREAD_NAME_ #ifndef MHD_USE_THREAD_ATTR_SETNAME @@ -276,6 +276,8 @@ named_thread_starter (void *data) return thr_func (arg); } + + #endif /* ! MHD_USE_THREAD_ATTR_SETNAME */ @@ -308,8 +310,7 @@ MHD_create_named_thread_ (MHD_thread_handle_ID_ *thread, * third argument is single argument for printf; * OSF1 use 3 arguments too, but last one always must be zero (NULL). * MHD doesn't use '%' in thread names, so both form are used in same way. - */ - res = pthread_attr_setname_np (&attr, + */res = pthread_attr_setname_np (&attr, thread_name, 0); #elif defined(HAVE_PTHREAD_ATTR_SETNAME_NP_IBMI) @@ -318,7 +319,7 @@ MHD_create_named_thread_ (MHD_thread_handle_ID_ *thread, #else #error No pthread_attr_setname_np() function. #endif - if ((res == 0) &&(0 != stack_size) ) + if ((res == 0) && (0 != stack_size) ) res = pthread_attr_setstacksize (&attr, stack_size); if (0 == res) @@ -365,4 +366,5 @@ MHD_create_named_thread_ (MHD_thread_handle_ID_ *thread, #endif /* ! MHD_USE_THREAD_ATTR_SETNAME */ } + #endif /* MHD_USE_THREAD_NAME_ */ diff --git a/src/microhttpd/postprocessor.c b/src/microhttpd/postprocessor.c @@ -1013,8 +1013,7 @@ post_process_multipart (struct MHD_PostProcessor *pp, * > generally be left blank, and implementations must ignore * > anything that appears before the first boundary delimiter * > line or after the last one. - */ - (void) find_boundary (pp, + */(void) find_boundary (pp, pp->boundary, pp->blen, &ioff, @@ -1290,4 +1289,5 @@ MHD_destroy_post_processor (struct MHD_PostProcessor *pp) return ret; } + /* end of postprocessor.c */ diff --git a/src/microhttpd/response.c b/src/microhttpd/response.c @@ -541,6 +541,7 @@ free_callback (void *cls) response->fd = -1; } + #undef MHD_create_response_from_fd_at_offset /** @@ -1195,6 +1196,8 @@ MHD_create_response_for_upgrade (MHD_UpgradeHandler upgrade_handler, } return response; } + + #endif /* UPGRADE_SUPPORT */ diff --git a/src/microhttpd/sha256.c b/src/microhttpd/sha256.c @@ -62,6 +62,7 @@ MHD_SHA256_init (void *ctx_) ctx->count = 0; } + /** * Number of bytes in single SHA-256 word * used to process data @@ -246,6 +247,7 @@ sha256_transform (uint32_t H[_SHA256_DIGEST_LENGTH], H[7] += h; } + /** * Process portion of bytes. * diff --git a/src/microhttpd/test_helpers.h b/src/microhttpd/test_helpers.h @@ -64,6 +64,7 @@ has_in_name (const char *prog_name, const char *marker) return strstr (prog_name + name_pos, marker) != (char*) 0; } + /** * Check whether one of strings in array is equal to @a param. * String @a argv[0] is ignored. @@ -83,7 +84,7 @@ has_param (int argc, char *const argv[], const char *param) for (i = 1; i < argc; i++) { - if (argv[i] &&(strcmp (argv[i], param) == 0) ) + if (argv[i] && (strcmp (argv[i], param) == 0) ) return ! 0; } diff --git a/src/microhttpd/test_http_reasons.c b/src/microhttpd/test_http_reasons.c @@ -28,7 +28,8 @@ #include "microhttpd.h" #include "mhd_str.h" -static int expect_result (int code, const char*expected) +static int +expect_result (int code, const char*expected) { const char*const reason = MHD_get_reason_phrase_for (code); if (MHD_str_equal_caseless_ (reason, expected)) @@ -39,12 +40,16 @@ static int expect_result (int code, const char*expected) return 1; } -static int expect_absent (int code) + +static int +expect_absent (int code) { return expect_result (code, "unknown"); } -static int test_absent_codes (void) + +static int +test_absent_codes (void) { int errcount = 0; errcount += expect_absent (0); @@ -58,7 +63,9 @@ static int test_absent_codes (void) return errcount; } -static int test_1xx (void) + +static int +test_1xx (void) { int errcount = 0; errcount += expect_result (MHD_HTTP_CONTINUE, "continue"); @@ -68,7 +75,9 @@ static int test_1xx (void) return errcount; } -static int test_2xx (void) + +static int +test_2xx (void) { int errcount = 0; errcount += expect_result (MHD_HTTP_OK, "ok"); @@ -80,7 +89,9 @@ static int test_2xx (void) return errcount; } -static int test_3xx (void) + +static int +test_3xx (void) { int errcount = 0; errcount += expect_result (MHD_HTTP_MULTIPLE_CHOICES, "multiple choices"); @@ -91,7 +102,9 @@ static int test_3xx (void) return errcount; } -static int test_4xx (void) + +static int +test_4xx (void) { int errcount = 0; errcount += expect_result (MHD_HTTP_BAD_REQUEST, "bad request"); @@ -108,7 +121,9 @@ static int test_4xx (void) return errcount; } -static int test_5xx (void) + +static int +test_5xx (void) { int errcount = 0; errcount += expect_result (MHD_HTTP_INTERNAL_SERVER_ERROR, @@ -123,7 +138,9 @@ static int test_5xx (void) return errcount; } -int main (int argc, char *argv[]) + +int +main (int argc, char *argv[]) { int errcount = 0; (void) argc; (void) argv; /* Unused. Silent compiler warning. */ diff --git a/src/microhttpd/test_options.c b/src/microhttpd/test_options.c @@ -56,6 +56,7 @@ ahc_echo (void *cls, return 0; } + static int test_wrap_loc (char *test_name, int (*test)(void)) { @@ -122,6 +123,7 @@ test_ip_addr_option () return 0; } + /* setup a temporary transfer test file */ int main (int argc, char *const *argv) diff --git a/src/microhttpd/test_postprocessor.c b/src/microhttpd/test_postprocessor.c @@ -82,6 +82,7 @@ mismatch (const char *a, const char *b) return 0 != strcmp (a, b); } + static int value_checker (void *cls, enum MHD_ValueKind kind, @@ -347,8 +348,6 @@ test_empty_value (void) } - - int main (int argc, char *const *argv) { diff --git a/src/microhttpd/test_postprocessor_amp.c b/src/microhttpd/test_postprocessor_amp.c @@ -7,10 +7,11 @@ uint64_t num_errors; -int check_post (void *cls, enum MHD_ValueKind kind, const char*key, - const char*filename, const char*content_type, - const char*content_encoding, const char*data, - uint64_t off, size_t size) +int +check_post (void *cls, enum MHD_ValueKind kind, const char*key, + const char*filename, const char*content_type, + const char*content_encoding, const char*data, + uint64_t off, size_t size) { (void) cls; (void) kind; (void) filename; (void) content_type; /* Unused. Silent compiler warning. */ (void) content_encoding; (void) data; (void) off; (void) size; /* Unused. Silent compiler warning. */ diff --git a/src/microhttpd/test_postprocessor_large.c b/src/microhttpd/test_postprocessor_large.c @@ -98,6 +98,7 @@ test_simple_large () return 0; } + int main (int argc, char *const *argv) { diff --git a/src/microhttpd/test_sha256.c b/src/microhttpd/test_sha256.c @@ -285,6 +285,7 @@ bin2hex (const uint8_t *bin, *hex = 0; } + static int check_result (const char *test_name, unsigned int check_num, @@ -365,6 +366,7 @@ test1_bin (void) return num_failed; } + /* Calculated SHA-256 as two iterations for whole data */ static int test2_str (void) diff --git a/src/microhttpd/test_shutdown_select.c b/src/microhttpd/test_shutdown_select.c @@ -255,6 +255,8 @@ poll_thread (void*data) return (MHD_THRD_RTRN_TYPE_) 0; } + + #endif /* HAVE_POLL */ @@ -306,7 +308,7 @@ main (int argc, char *const *argv) ver_req = MAKEWORD (2, 2); err = WSAStartup (ver_req, &wsa_data); - if ((err != 0)||(MAKEWORD (2, 2) != wsa_data.wVersion)) + if ((err != 0) || (MAKEWORD (2, 2) != wsa_data.wVersion)) { printf ("WSAStartup() failed\n"); WSACleanup (); @@ -370,7 +372,7 @@ main (int argc, char *const *argv) /* fprintf (stdout, "Thread finished.\n"); */ MHD_socket_close_chk_ (listen_socket); - if ((start_t == (time_t) -1) ||(end_t == (time_t) -1) ) + if ((start_t == (time_t) -1) || (end_t == (time_t) -1) ) { MHD_socket_close_chk_ (listen_socket); fprintf (stderr, "Can't get current time\n"); diff --git a/src/microhttpd/test_start_stop.c b/src/microhttpd/test_start_stop.c @@ -67,6 +67,7 @@ testInternalGet (int poll_flag) return 0; } + static int testMultithreadedGet (int poll_flag) { @@ -97,6 +98,8 @@ testMultithreadedPoolGet (int poll_flag) MHD_stop_daemon (d); return 0; } + + #endif diff --git a/src/microhttpd/test_str.c b/src/microhttpd/test_str.c @@ -208,7 +208,8 @@ static const unsigned int locale_name_count = sizeof(locale_names) * Helper functions */ -int set_test_locale (unsigned int num) +int +set_test_locale (unsigned int num) { if (num >= locale_name_count) return -1; @@ -225,17 +226,21 @@ int set_test_locale (unsigned int num) return 0; } -const char *get_current_locale_str (void) + +const char * +get_current_locale_str (void) { char const *loc_str = setlocale (LC_ALL, NULL); return loc_str ? loc_str : "unknown"; } + static char tmp_bufs[4][4 * 1024]; /* should be enough for testing */ static size_t buf_idx = 0; /* print non-printable chars as char codes */ -char *n_prnt (const char *str) +char * +n_prnt (const char *str) { static char *buf; /* should be enough for testing */ static const size_t buf_size = sizeof(tmp_bufs[0]); @@ -248,14 +253,14 @@ char *n_prnt (const char *str) while (*p && w_pos + 1 < buf_size) { const unsigned char c = *p; - if ((c == '\\') ||(c == '"') ) + if ((c == '\\') || (c == '"') ) { if (w_pos + 2 >= buf_size) break; buf[w_pos++] = '\\'; buf[w_pos++] = c; } - else if ((c >= 0x20) &&(c <= 0x7E) ) + else if ((c >= 0x20) && (c <= 0x7E) ) buf[w_pos++] = c; else { @@ -497,7 +502,8 @@ static const struct two_neq_strs neq_strings[] = { }; -int check_eq_strings (void) +int +check_eq_strings (void) { size_t t_failed = 0; size_t i, j; @@ -532,7 +538,7 @@ int check_eq_strings (void) " Locale: %s\n", n_prnt (t->s2.str), n_prnt (t->s1.str), get_current_locale_str ()); } - if ((verbose > 1) &&(j == locale_name_count - 1) && ! c_failed[i]) + if ((verbose > 1) && (j == locale_name_count - 1) && ! c_failed[i]) printf ("PASSED: MHD_str_equal_caseless_(\"%s\", \"%s\") != 0 && \\\n" " MHD_str_equal_caseless_(\"%s\", \"%s\") != 0\n", n_prnt (t->s1.str), n_prnt (t->s2.str), @@ -542,7 +548,9 @@ int check_eq_strings (void) return t_failed; } -int check_neq_strings (void) + +int +check_neq_strings (void) { size_t t_failed = 0; size_t i, j; @@ -577,7 +585,7 @@ int check_neq_strings (void) " Locale: %s\n", n_prnt (t->s2.str), n_prnt (t->s1.str), get_current_locale_str ()); } - if ((verbose > 1) &&(j == locale_name_count - 1) && ! c_failed[i]) + if ((verbose > 1) && (j == locale_name_count - 1) && ! c_failed[i]) printf ("PASSED: MHD_str_equal_caseless_(\"%s\", \"%s\") == 0 && \\\n" " MHD_str_equal_caseless_(\"%s\", \"%s\") == 0\n", n_prnt (t->s1.str), n_prnt (t->s2.str), @@ -587,7 +595,9 @@ int check_neq_strings (void) return t_failed; } -int check_eq_strings_n (void) + +int +check_eq_strings_n (void) { size_t t_failed = 0; size_t i, j, k; @@ -627,7 +637,7 @@ int check_eq_strings_n (void) get_current_locale_str ()); } } - if ((verbose > 1) &&(j == locale_name_count - 1) && ! c_failed[i]) + if ((verbose > 1) && (j == locale_name_count - 1) && ! c_failed[i]) printf ( "PASSED: MHD_str_equal_caseless_n_(\"%s\", \"%s\", N) != 0 && \\\n" " MHD_str_equal_caseless_n_(\"%s\", \"%s\", N) != 0, where N is 0..%u\n", @@ -638,7 +648,9 @@ int check_eq_strings_n (void) return t_failed; } -int check_neq_strings_n (void) + +int +check_neq_strings_n (void) { size_t t_failed = 0; size_t i, j, k; @@ -732,7 +744,7 @@ int check_neq_strings_n (void) } } } - if ((verbose > 1) &&(j == locale_name_count - 1) && ! c_failed[i]) + if ((verbose > 1) && (j == locale_name_count - 1) && ! c_failed[i]) { printf ( "PASSED: MHD_str_equal_caseless_n_(\"%s\", \"%s\", N) != 0 && \\\n" @@ -753,10 +765,12 @@ int check_neq_strings_n (void) return t_failed; } + /* * Run eq/neq strings tests */ -int run_eq_neq_str_tests (void) +int +run_eq_neq_str_tests (void) { int str_equal_caseless_fails = 0; int str_equal_caseless_n_fails = 0; @@ -851,6 +865,7 @@ int run_eq_neq_str_tests (void) return 0; } + /* * Digits in string -> value tests */ @@ -1118,7 +1133,8 @@ const struct str_with_len strx_ovflw[] = { }; -int check_str_to_uint64_valid (void) +int +check_str_to_uint64_valid (void) { size_t t_failed = 0; size_t i, j; @@ -1175,7 +1191,7 @@ int check_str_to_uint64_valid (void) t->str.str), rv, rv, t->val, get_current_locale_str ()); } - if ((verbose > 1) &&(j == locale_name_count - 1) && ! c_failed[i]) + if ((verbose > 1) && (j == locale_name_count - 1) && ! c_failed[i]) printf ( "PASSED: MHD_str_to_uint64_(\"%s\", ->%" PRIu64 ") == %" PRIuPTR "\n", n_prnt (t->str.str), rv, rs); @@ -1185,7 +1201,8 @@ int check_str_to_uint64_valid (void) } -int check_str_to_uint64_all_chars (void) +int +check_str_to_uint64_all_chars (void) { static const size_t n_checks = 256; /* from 0 to 255 */ int c_failed[n_checks]; @@ -1204,9 +1221,9 @@ int check_str_to_uint64_all_chars (void) { static const uint64_t rnd_val = 24941852; size_t rs; - if ((c >= '0') &&(c <= '9') ) + if ((c >= '0') && (c <= '9') ) continue; /* skip digits */ - for (test_val = 0; test_val <= rnd_val&& ! c_failed[c]; test_val += + for (test_val = 0; test_val <= rnd_val && ! c_failed[c]; test_val += rnd_val) { char test_str[] = "0123"; @@ -1236,7 +1253,7 @@ int check_str_to_uint64_all_chars (void) n_prnt (test_str), test_val, rv, get_current_locale_str ()); } } - if ((verbose > 1) &&(j == locale_name_count - 1) && ! c_failed[c]) + if ((verbose > 1) && (j == locale_name_count - 1) && ! c_failed[c]) { char test_str[] = "0123"; test_str[0] = (char) (unsigned char) c; /* replace first char with non-digit char */ @@ -1251,7 +1268,8 @@ int check_str_to_uint64_all_chars (void) } -int check_str_to_uint64_overflow (void) +int +check_str_to_uint64_overflow (void) { size_t t_failed = 0; size_t i, j; @@ -1298,7 +1316,7 @@ int check_str_to_uint64_overflow (void) n_prnt (t->str), test_val, rv, get_current_locale_str ()); } } - if ((verbose > 1) &&(j == locale_name_count - 1) && ! c_failed[i]) + if ((verbose > 1) && (j == locale_name_count - 1) && ! c_failed[i]) printf ( "PASSED: MHD_str_to_uint64_(\"%s\", &ret_val) == 0, value of ret_val is unmodified\n", n_prnt (t->str)); @@ -1308,7 +1326,8 @@ int check_str_to_uint64_overflow (void) } -int check_str_to_uint64_no_val (void) +int +check_str_to_uint64_no_val (void) { size_t t_failed = 0; size_t i, j; @@ -1355,7 +1374,7 @@ int check_str_to_uint64_no_val (void) n_prnt (t->str), test_val, rv, get_current_locale_str ()); } } - if ((verbose > 1) &&(j == locale_name_count - 1) && ! c_failed[i]) + if ((verbose > 1) && (j == locale_name_count - 1) && ! c_failed[i]) printf ( "PASSED: MHD_str_to_uint64_(\"%s\", &ret_val) == 0, value of ret_val is unmodified\n", n_prnt (t->str)); @@ -1365,7 +1384,8 @@ int check_str_to_uint64_no_val (void) } -int check_str_to_uint64_n_valid (void) +int +check_str_to_uint64_n_valid (void) { size_t t_failed = 0; size_t i, j; @@ -1423,7 +1443,7 @@ int check_str_to_uint64_n_valid (void) t->val, get_current_locale_str ()); } } - if ((verbose > 1) &&(j == locale_name_count - 1) && ! c_failed[i]) + if ((verbose > 1) && (j == locale_name_count - 1) && ! c_failed[i]) printf ( "PASSED: MHD_str_to_uint64_n_(\"%s\", %" PRIuPTR "..%" PRIuPTR ", ->%" PRIu64 ")" @@ -1436,7 +1456,8 @@ int check_str_to_uint64_n_valid (void) } -int check_str_to_uint64_n_all_chars (void) +int +check_str_to_uint64_n_all_chars (void) { static const size_t n_checks = 256; /* from 0 to 255 */ int c_failed[n_checks]; @@ -1457,12 +1478,12 @@ int check_str_to_uint64_n_all_chars (void) size_t rs; size_t len; - if ((c >= '0') &&(c <= '9') ) + if ((c >= '0') && (c <= '9') ) continue; /* skip digits */ for (len = 0; len <= 5; len++) { - for (test_val = 0; test_val <= rnd_val&& ! c_failed[c]; test_val += + for (test_val = 0; test_val <= rnd_val && ! c_failed[c]; test_val += rnd_val) { char test_str[] = "0123"; @@ -1497,7 +1518,7 @@ int check_str_to_uint64_n_all_chars (void) } } } - if ((verbose > 1) &&(j == locale_name_count - 1) && ! c_failed[c]) + if ((verbose > 1) && (j == locale_name_count - 1) && ! c_failed[c]) { char test_str[] = "0123"; test_str[0] = (char) (unsigned char) c; /* replace first char with non-digit char */ @@ -1512,7 +1533,8 @@ int check_str_to_uint64_n_all_chars (void) } -int check_str_to_uint64_n_overflow (void) +int +check_str_to_uint64_n_overflow (void) { size_t t_failed = 0; size_t i, j; @@ -1567,7 +1589,7 @@ int check_str_to_uint64_n_overflow (void) } } } - if ((verbose > 1) &&(j == locale_name_count - 1) && ! c_failed[i]) + if ((verbose > 1) && (j == locale_name_count - 1) && ! c_failed[i]) printf ( "PASSED: MHD_str_to_uint64_n_(\"%s\", %" PRIuPTR "..%" PRIuPTR ", &ret_val) == 0," @@ -1580,7 +1602,8 @@ int check_str_to_uint64_n_overflow (void) } -int check_str_to_uint64_n_no_val (void) +int +check_str_to_uint64_n_no_val (void) { size_t t_failed = 0; size_t i, j; @@ -1635,7 +1658,7 @@ int check_str_to_uint64_n_no_val (void) } } } - if ((verbose > 1) &&(j == locale_name_count - 1) && ! c_failed[i]) + if ((verbose > 1) && (j == locale_name_count - 1) && ! c_failed[i]) printf ( "PASSED: MHD_str_to_uint64_n_(\"%s\", 0..%" PRIuPTR ", &ret_val) == 0," @@ -1647,7 +1670,8 @@ int check_str_to_uint64_n_no_val (void) } -int check_strx_to_uint32_valid (void) +int +check_strx_to_uint32_valid (void) { size_t t_failed = 0; size_t i, j; @@ -1708,7 +1732,7 @@ int check_strx_to_uint32_valid (void) t->str.str), (uint64_t) rv, (uint64_t) rv, t->val, get_current_locale_str ()); } - if ((verbose > 1) &&(j == locale_name_count - 1) && ! c_failed[i]) + if ((verbose > 1) && (j == locale_name_count - 1) && ! c_failed[i]) printf ( "PASSED: MHD_strx_to_uint32_(\"%s\", ->0x%" PRIX64 ") == %" PRIuPTR "\n", @@ -1719,7 +1743,8 @@ int check_strx_to_uint32_valid (void) } -int check_strx_to_uint32_all_chars (void) +int +check_strx_to_uint32_all_chars (void) { static const size_t n_checks = 256; /* from 0 to 255 */ int c_failed[n_checks]; @@ -1738,12 +1763,13 @@ int check_strx_to_uint32_all_chars (void) { static const uint32_t rnd_val = 234234; size_t rs; - if (((c >= '0') &&(c <= '9') ) || ((c >= 'A') &&(c <= 'F') ) ||((c >= - 'a') && - (c <= - 'f') )) + if (((c >= '0') && (c <= '9') ) || ((c >= 'A') && (c <= 'F') ) || ((c >= + 'a') + && + (c <= + 'f') )) continue; /* skip xdigits */ - for (test_val = 0; test_val <= rnd_val&& ! c_failed[c]; test_val += + for (test_val = 0; test_val <= rnd_val && ! c_failed[c]; test_val += rnd_val) { char test_str[] = "0123"; @@ -1774,7 +1800,7 @@ int check_strx_to_uint32_all_chars (void) get_current_locale_str ()); } } - if ((verbose > 1) &&(j == locale_name_count - 1) && ! c_failed[c]) + if ((verbose > 1) && (j == locale_name_count - 1) && ! c_failed[c]) { char test_str[] = "0123"; test_str[0] = (char) (unsigned char) c; /* replace first char with non-digit char */ @@ -1789,7 +1815,8 @@ int check_strx_to_uint32_all_chars (void) } -int check_strx_to_uint32_overflow (void) +int +check_strx_to_uint32_overflow (void) { size_t t_failed = 0; size_t i, j; @@ -1854,7 +1881,7 @@ int check_strx_to_uint32_overflow (void) get_current_locale_str ()); } } - if ((verbose > 1) &&(j == locale_name_count - 1) && ! c_failed[i]) + if ((verbose > 1) && (j == locale_name_count - 1) && ! c_failed[i]) printf ( "PASSED: MHD_strx_to_uint32_(\"%s\", &ret_val) == 0, value of ret_val is unmodified\n", n_prnt (str)); @@ -1864,7 +1891,8 @@ int check_strx_to_uint32_overflow (void) } -int check_strx_to_uint32_no_val (void) +int +check_strx_to_uint32_no_val (void) { size_t t_failed = 0; size_t i, j; @@ -1912,7 +1940,7 @@ int check_strx_to_uint32_no_val (void) get_current_locale_str ()); } } - if ((verbose > 1) &&(j == locale_name_count - 1) && ! c_failed[i]) + if ((verbose > 1) && (j == locale_name_count - 1) && ! c_failed[i]) printf ( "PASSED: MHD_strx_to_uint32_(\"%s\", &ret_val) == 0, value of ret_val is unmodified\n", n_prnt (t->str)); @@ -1922,7 +1950,8 @@ int check_strx_to_uint32_no_val (void) } -int check_strx_to_uint32_n_valid (void) +int +check_strx_to_uint32_n_valid (void) { size_t t_failed = 0; size_t i, j; @@ -1984,7 +2013,7 @@ int check_strx_to_uint32_n_valid (void) t->val, get_current_locale_str ()); } } - if ((verbose > 1) &&(j == locale_name_count - 1) && ! c_failed[i]) + if ((verbose > 1) && (j == locale_name_count - 1) && ! c_failed[i]) printf ( "PASSED: MHD_strx_to_uint32_n_(\"%s\", %" PRIuPTR "..%" PRIuPTR ", ->0x%" @@ -1998,7 +2027,8 @@ int check_strx_to_uint32_n_valid (void) } -int check_strx_to_uint32_n_all_chars (void) +int +check_strx_to_uint32_n_all_chars (void) { static const size_t n_checks = 256; /* from 0 to 255 */ int c_failed[n_checks]; @@ -2019,15 +2049,16 @@ int check_strx_to_uint32_n_all_chars (void) size_t rs; size_t len; - if (((c >= '0') &&(c <= '9') ) || ((c >= 'A') &&(c <= 'F') ) || ((c >= - 'a') && - (c <= - 'f') )) + if (((c >= '0') && (c <= '9') ) || ((c >= 'A') && (c <= 'F') ) || ((c >= + 'a') + && + (c <= + 'f') )) continue; /* skip xdigits */ for (len = 0; len <= 5; len++) { - for (test_val = 0; test_val <= rnd_val&& ! c_failed[c]; test_val += + for (test_val = 0; test_val <= rnd_val && ! c_failed[c]; test_val += rnd_val) { char test_str[] = "0123"; @@ -2063,7 +2094,7 @@ int check_strx_to_uint32_n_all_chars (void) } } } - if ((verbose > 1) &&(j == locale_name_count - 1) && ! c_failed[c]) + if ((verbose > 1) && (j == locale_name_count - 1) && ! c_failed[c]) { char test_str[] = "0123"; test_str[0] = (char) (unsigned char) c; /* replace first char with non-digit char */ @@ -2078,7 +2109,8 @@ int check_strx_to_uint32_n_all_chars (void) } -int check_strx_to_uint32_n_overflow (void) +int +check_strx_to_uint32_n_overflow (void) { size_t t_failed = 0; size_t i, j; @@ -2166,7 +2198,7 @@ int check_strx_to_uint32_n_overflow (void) } } } - if ((verbose > 1) &&(j == locale_name_count - 1) && ! c_failed[i]) + if ((verbose > 1) && (j == locale_name_count - 1) && ! c_failed[i]) printf ( "PASSED: MHD_strx_to_uint32_n_(\"%s\", %" PRIuPTR "..%" PRIuPTR ", &ret_val) == 0," @@ -2179,7 +2211,8 @@ int check_strx_to_uint32_n_overflow (void) } -int check_strx_to_uint32_n_no_val (void) +int +check_strx_to_uint32_n_no_val (void) { size_t t_failed = 0; size_t i, j; @@ -2235,7 +2268,7 @@ int check_strx_to_uint32_n_no_val (void) } } } - if ((verbose > 1) &&(j == locale_name_count - 1) && ! c_failed[i]) + if ((verbose > 1) && (j == locale_name_count - 1) && ! c_failed[i]) printf ( "PASSED: MHD_strx_to_uint32_n_(\"%s\", 0..%" PRIuPTR ", &ret_val) == 0," @@ -2247,7 +2280,8 @@ int check_strx_to_uint32_n_no_val (void) } -int check_strx_to_uint64_valid (void) +int +check_strx_to_uint64_valid (void) { size_t t_failed = 0; size_t i, j; @@ -2304,7 +2338,7 @@ int check_strx_to_uint64_valid (void) t->str.str), rv, rv, t->val, get_current_locale_str ()); } - if ((verbose > 1) &&(j == locale_name_count - 1) && ! c_failed[i]) + if ((verbose > 1) && (j == locale_name_count - 1) && ! c_failed[i]) printf ( "PASSED: MHD_strx_to_uint64_(\"%s\", ->0x%" PRIX64 ") == %" PRIuPTR "\n", @@ -2315,7 +2349,8 @@ int check_strx_to_uint64_valid (void) } -int check_strx_to_uint64_all_chars (void) +int +check_strx_to_uint64_all_chars (void) { static const size_t n_checks = 256; /* from 0 to 255 */ int c_failed[n_checks]; @@ -2334,12 +2369,13 @@ int check_strx_to_uint64_all_chars (void) { static const uint64_t rnd_val = 234234; size_t rs; - if (((c >= '0') &&(c <= '9') ) || ((c >= 'A') &&(c <= 'F') ) || ((c >= - 'a') && - (c <= - 'f') )) + if (((c >= '0') && (c <= '9') ) || ((c >= 'A') && (c <= 'F') ) || ((c >= + 'a') + && + (c <= + 'f') )) continue; /* skip xdigits */ - for (test_val = 0; test_val <= rnd_val&& ! c_failed[c]; test_val += + for (test_val = 0; test_val <= rnd_val && ! c_failed[c]; test_val += rnd_val) { char test_str[] = "0123"; @@ -2369,7 +2405,7 @@ int check_strx_to_uint64_all_chars (void) n_prnt (test_str), test_val, rv, get_current_locale_str ()); } } - if ((verbose > 1) &&(j == locale_name_count - 1) && ! c_failed[c]) + if ((verbose > 1) && (j == locale_name_count - 1) && ! c_failed[c]) { char test_str[] = "0123"; test_str[0] = (char) (unsigned char) c; /* replace first char with non-digit char */ @@ -2384,7 +2420,8 @@ int check_strx_to_uint64_all_chars (void) } -int check_strx_to_uint64_overflow (void) +int +check_strx_to_uint64_overflow (void) { size_t t_failed = 0; size_t i, j; @@ -2431,7 +2468,7 @@ int check_strx_to_uint64_overflow (void) n_prnt (t->str), test_val, rv, get_current_locale_str ()); } } - if ((verbose > 1) &&(j == locale_name_count - 1) && ! c_failed[i]) + if ((verbose > 1) && (j == locale_name_count - 1) && ! c_failed[i]) printf ( "PASSED: MHD_strx_to_uint64_(\"%s\", &ret_val) == 0, value of ret_val is unmodified\n", n_prnt (t->str)); @@ -2441,7 +2478,8 @@ int check_strx_to_uint64_overflow (void) } -int check_strx_to_uint64_no_val (void) +int +check_strx_to_uint64_no_val (void) { size_t t_failed = 0; size_t i, j; @@ -2488,7 +2526,7 @@ int check_strx_to_uint64_no_val (void) n_prnt (t->str), test_val, rv, get_current_locale_str ()); } } - if ((verbose > 1) &&(j == locale_name_count - 1) && ! c_failed[i]) + if ((verbose > 1) && (j == locale_name_count - 1) && ! c_failed[i]) printf ( "PASSED: MHD_strx_to_uint64_(\"%s\", &ret_val) == 0, value of ret_val is unmodified\n", n_prnt (t->str)); @@ -2498,7 +2536,8 @@ int check_strx_to_uint64_no_val (void) } -int check_strx_to_uint64_n_valid (void) +int +check_strx_to_uint64_n_valid (void) { size_t t_failed = 0; size_t i, j; @@ -2556,7 +2595,7 @@ int check_strx_to_uint64_n_valid (void) t->val, get_current_locale_str ()); } } - if ((verbose > 1) &&(j == locale_name_count - 1) && ! c_failed[i]) + if ((verbose > 1) && (j == locale_name_count - 1) && ! c_failed[i]) printf ( "PASSED: MHD_strx_to_uint64_n_(\"%s\", %" PRIuPTR "..%" PRIuPTR ", ->0x%" @@ -2570,7 +2609,8 @@ int check_strx_to_uint64_n_valid (void) } -int check_strx_to_uint64_n_all_chars (void) +int +check_strx_to_uint64_n_all_chars (void) { static const size_t n_checks = 256; /* from 0 to 255 */ int c_failed[n_checks]; @@ -2591,15 +2631,16 @@ int check_strx_to_uint64_n_all_chars (void) size_t rs; size_t len; - if (((c >= '0') &&(c <= '9') ) || ((c >= 'A') &&(c <= 'F') ) || ((c >= - 'a') && - (c <= - 'f') )) + if (((c >= '0') && (c <= '9') ) || ((c >= 'A') && (c <= 'F') ) || ((c >= + 'a') + && + (c <= + 'f') )) continue; /* skip xdigits */ for (len = 0; len <= 5; len++) { - for (test_val = 0; test_val <= rnd_val&& ! c_failed[c]; test_val += + for (test_val = 0; test_val <= rnd_val && ! c_failed[c]; test_val += rnd_val) { char test_str[] = "0123"; @@ -2635,7 +2676,7 @@ int check_strx_to_uint64_n_all_chars (void) } } } - if ((verbose > 1) &&(j == locale_name_count - 1) && ! c_failed[c]) + if ((verbose > 1) && (j == locale_name_count - 1) && ! c_failed[c]) { char test_str[] = "0123"; test_str[0] = (char) (unsigned char) c; /* replace first char with non-digit char */ @@ -2650,7 +2691,8 @@ int check_strx_to_uint64_n_all_chars (void) } -int check_strx_to_uint64_n_overflow (void) +int +check_strx_to_uint64_n_overflow (void) { size_t t_failed = 0; size_t i, j; @@ -2706,7 +2748,7 @@ int check_strx_to_uint64_n_overflow (void) } } } - if ((verbose > 1) &&(j == locale_name_count - 1) && ! c_failed[i]) + if ((verbose > 1) && (j == locale_name_count - 1) && ! c_failed[i]) printf ( "PASSED: MHD_strx_to_uint64_n_(\"%s\", %" PRIuPTR "..%" PRIuPTR ", &ret_val) == 0," @@ -2719,7 +2761,8 @@ int check_strx_to_uint64_n_overflow (void) } -int check_strx_to_uint64_n_no_val (void) +int +check_strx_to_uint64_n_no_val (void) { size_t t_failed = 0; size_t i, j; @@ -2775,7 +2818,7 @@ int check_strx_to_uint64_n_no_val (void) } } } - if ((verbose > 1) &&(j == locale_name_count - 1) && ! c_failed[i]) + if ((verbose > 1) && (j == locale_name_count - 1) && ! c_failed[i]) printf ( "PASSED: MHD_strx_to_uint64_n_(\"%s\", 0..%" PRIuPTR ", &ret_val) == 0," @@ -2787,7 +2830,8 @@ int check_strx_to_uint64_n_no_val (void) } -int run_str_to_X_tests (void) +int +run_str_to_X_tests (void) { int str_to_uint64_fails = 0; int str_to_uint64_n_fails = 0; @@ -3270,7 +3314,8 @@ int run_str_to_X_tests (void) } -int main (int argc, char *argv[]) +int +main (int argc, char *argv[]) { if (has_param (argc, argv, "-v") || has_param (argc, argv, "--verbose") || has_param (argc, argv, "--verbose1")) diff --git a/src/microhttpd/test_str_token.c b/src/microhttpd/test_str_token.c @@ -41,6 +41,7 @@ expect_found_n (const char *str, const char *token, size_t token_len) return 0; } + #define expect_found(s,t) expect_found_n ((s),(t),MHD_STATICSTR_LEN_ (t)) static int @@ -56,10 +57,12 @@ expect_not_found_n (const char *str, const char *token, size_t token_len) return 0; } + #define expect_not_found(s,t) expect_not_found_n ((s),(t),MHD_STATICSTR_LEN_ ( \ t)) -int check_match (void) +int +check_match (void) { int errcount = 0; errcount += expect_found ("string", "string"); @@ -85,7 +88,9 @@ int check_match (void) return errcount; } -int check_not_match (void) + +int +check_not_match (void) { int errcount = 0; errcount += expect_not_found ("strin", "string"); @@ -111,7 +116,9 @@ int check_not_match (void) return errcount; } -int main (int argc, char *argv[]) + +int +main (int argc, char *argv[]) { int errcount = 0; (void) argc; (void) argv; /* Unused. Silent compiler warning. */ diff --git a/src/microhttpd/test_upgrade.c b/src/microhttpd/test_upgrade.c @@ -139,6 +139,8 @@ gnutlscli_connect (int *sock, } _exit (1); } + + #endif /* HTTPS_SUPPORT && HAVE_FORK && HAVE_WAITPID */ @@ -296,14 +298,14 @@ wr_connect (struct wr_socket *s, * it require processing on MHD side and * when testing with "external" polling, * test will call MHD processing only - * after return from wr_connect(). */ - s->tls_connected = 0; + * after return from wr_connect(). */s->tls_connected = 0; return 0; } #endif /* HTTPS_SUPPORT */ return -1; } + #ifdef HTTPS_SUPPORT /* Only to be called from wr_send() and wr_recv() ! */ static bool @@ -318,6 +320,8 @@ wr_handshake (struct wr_socket *s) MHD_socket_set_error_ (MHD_SCKT_ECONNABORTED_); /* hard error */ return s->tls_connected; } + + #endif /* HTTPS_SUPPORT */ @@ -924,6 +928,7 @@ run_mhd_select_loop (struct MHD_Daemon *daemon) } } + #ifdef HAVE_POLL /** @@ -937,6 +942,8 @@ run_mhd_poll_loop (struct MHD_Daemon *daemon) (void) daemon; /* Unused. Silent compiler warning. */ abort (); /* currently not implementable with existing MHD API */ } + + #endif /* HAVE_POLL */ @@ -983,6 +990,8 @@ run_mhd_epoll_loop (struct MHD_Daemon *daemon) MHD_run (daemon); } } + + #endif /* EPOLL_SUPPORT */ /** @@ -1076,7 +1085,7 @@ test_upgrade (int flags, if ( (NULL == dinfo) || (0 == dinfo->port) ) abort (); - if (! test_tls ||(TLS_LIB_GNUTLS == use_tls_tool)) + if (! test_tls || (TLS_LIB_GNUTLS == use_tls_tool)) { sock = test_tls ? wr_create_tls_sckt () : wr_create_plain_sckt (); if (NULL == sock) @@ -1134,7 +1143,7 @@ test_upgrade (int flags, pthread_join (pt, NULL); #if defined(HTTPS_SUPPORT) && defined(HAVE_FORK) && defined(HAVE_WAITPID) - if (test_tls &&(TLS_LIB_GNUTLS != use_tls_tool)) + if (test_tls && (TLS_LIB_GNUTLS != use_tls_tool)) waitpid (pid, NULL, 0); #endif /* HTTPS_SUPPORT && HAVE_FORK && HAVE_WAITPID */ MHD_stop_daemon (d); diff --git a/src/microhttpd/test_upgrade_large.c b/src/microhttpd/test_upgrade_large.c @@ -149,6 +149,8 @@ gnutlscli_connect (int *sock, } _exit (1); } + + #endif /* HTTPS_SUPPORT && HAVE_FORK && HAVE_WAITPID */ @@ -306,14 +308,14 @@ wr_connect (struct wr_socket *s, * it require processing on MHD side and * when testing with "external" polling, * test will call MHD processing only - * after return from wr_connect(). */ - s->tls_connected = 0; + * after return from wr_connect(). */s->tls_connected = 0; return 0; } #endif /* HTTPS_SUPPORT */ return -1; } + #ifdef HTTPS_SUPPORT /* Only to be called from wr_send() and wr_recv() ! */ static bool @@ -328,6 +330,8 @@ wr_handshake (struct wr_socket *s) MHD_socket_set_error_ (MHD_SCKT_ECONNABORTED_); /* hard error */ return s->tls_connected; } + + #endif /* HTTPS_SUPPORT */ @@ -958,6 +962,7 @@ run_mhd_select_loop (struct MHD_Daemon *daemon) kicker[1] = -1; } + #ifdef HAVE_POLL /** @@ -971,6 +976,8 @@ run_mhd_poll_loop (struct MHD_Daemon *daemon) (void) daemon; /* Unused. Silent compiler warning. */ abort (); /* currently not implementable with existing MHD API */ } + + #endif /* HAVE_POLL */ @@ -1026,6 +1033,8 @@ run_mhd_epoll_loop (struct MHD_Daemon *daemon) kicker[0] = -1; kicker[1] = -1; } + + #endif /* EPOLL_SUPPORT */ /** @@ -1121,7 +1130,7 @@ test_upgrade (int flags, if ( (NULL == dinfo) || (0 == dinfo->port) ) abort (); - if (! test_tls ||(TLS_LIB_GNUTLS == use_tls_tool)) + if (! test_tls || (TLS_LIB_GNUTLS == use_tls_tool)) { sock = test_tls ? wr_create_tls_sckt () : wr_create_plain_sckt (); if (NULL == sock) @@ -1179,7 +1188,7 @@ test_upgrade (int flags, pthread_join (pt, NULL); #if defined(HTTPS_SUPPORT) && defined(HAVE_FORK) && defined(HAVE_WAITPID) - if (test_tls &&(TLS_LIB_GNUTLS != use_tls_tool)) + if (test_tls && (TLS_LIB_GNUTLS != use_tls_tool)) waitpid (pid, NULL, 0); #endif /* HTTPS_SUPPORT && HAVE_FORK && HAVE_WAITPID */ MHD_stop_daemon (d); diff --git a/src/microhttpd/tsearch.c b/src/microhttpd/tsearch.c @@ -102,7 +102,7 @@ tdelete (const void *__restrict vkey, node_t *r; int cmp; - if ((rootp == NULL)||((p = *rootp) == NULL)) + if ((rootp == NULL) || ((p = *rootp) == NULL)) return NULL; while ((cmp = (*compar)(vkey, (*rootp)->key)) != 0) @@ -140,4 +140,5 @@ tdelete (const void *__restrict vkey, return p; } + /* end of tsearch.c */ diff --git a/src/testcurl/curl_version_check.c b/src/testcurl/curl_version_check.c @@ -50,6 +50,7 @@ parse_version_number (const char **s) return atoi (num); } + const char * parse_version_string (const char *s, int *major, int *minor, int *micro) { @@ -67,12 +68,15 @@ parse_version_string (const char *s, int *major, int *minor, int *micro) return s; } + #ifdef HTTPS_SUPPORT int curl_uses_nss_ssl () { return (strstr (curl_version (), " NSS/") != NULL) ? 0 : -1; } + + #endif /* HTTPS_SUPPORT */ /* @@ -99,8 +103,7 @@ curl_check_version (const char *req_version) * this call relies on the cURL string to be of the exact following format : * 'libcurl/7.16.4 OpenSSL/0.9.8g zlib/1.2.3.3 libidn/0.6.5' OR * 'libcurl/7.18.2 GnuTLS/2.4.0 zlib/1.2.3.3 libidn/0.6.5' - */ - curl_ver = strchr (ver, '/'); + */curl_ver = strchr (ver, '/'); if (curl_ver == NULL) return -1; curl_ver++; @@ -113,11 +116,11 @@ curl_check_version (const char *req_version) /* Compare version numbers. */ if (((loc_major > rq_major) - || ((loc_major == rq_major)&&(loc_minor > rq_minor)) - || ((loc_major == rq_major)&&(loc_minor == rq_minor) - &&(loc_micro > rq_micro)) || ((loc_major == rq_major) - &&(loc_minor == rq_minor) - &&(loc_micro == rq_micro) )) == 0) + || ((loc_major == rq_major) && (loc_minor > rq_minor)) + || ((loc_major == rq_major) && (loc_minor == rq_minor) + && (loc_micro > rq_micro)) || ((loc_major == rq_major) + && (loc_minor == rq_minor) + && (loc_micro == rq_micro) )) == 0) { fprintf (stderr, "Error: running curl test depends on local libcurl version > %s\n", @@ -164,11 +167,11 @@ curl_check_version (const char *req_version) return -1; if (((loc_major > rq_major) - || ((loc_major == rq_major)&&(loc_minor > rq_minor)) - || ((loc_major == rq_major)&&(loc_minor == rq_minor) - &&(loc_micro > rq_micro)) || ((loc_major == rq_major) - &&(loc_minor == rq_minor) - &&(loc_micro == rq_micro) )) == 0) + || ((loc_major == rq_major) && (loc_minor > rq_minor)) + || ((loc_major == rq_major) && (loc_minor == rq_minor) + && (loc_micro > rq_micro)) || ((loc_major == rq_major) + && (loc_minor == rq_minor) + && (loc_micro == rq_micro) )) == 0) { fprintf (stderr, "Error: running curl test depends on local libcurl SSL version > %s\n", diff --git a/src/testcurl/https/test_empty_response.c b/src/testcurl/https/test_empty_response.c @@ -101,7 +101,7 @@ testInternalSelectGet () { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -177,10 +177,10 @@ testInternalSelectGet () if (EINTR != errno) abort (); #else - if ((WSAEINVAL != WSAGetLastError ()) ||(0 != rs.fd_count) ||(0 != - ws. - fd_count) - ||(0 != es.fd_count) ) + if ((WSAEINVAL != WSAGetLastError ()) || (0 != rs.fd_count) || (0 != + ws. + fd_count) + || (0 != es.fd_count) ) abort (); Sleep (1000); #endif diff --git a/src/testcurl/https/test_https_get.c b/src/testcurl/https/test_https_get.c @@ -74,7 +74,7 @@ test_secure_get (FILE *test_fd, { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return -1; } @@ -148,8 +148,8 @@ curlExcessFound (CURL *c, (void) c; /* Unused. Silence compiler warning. */ if ((CURLINFO_TEXT == type) - &&(size >= str_size) - &&(0 == strncmp (excess_found, data, str_size))) + && (size >= str_size) + && (0 == strncmp (excess_found, data, str_size))) *(int *) cls = 1; return 0; } @@ -189,7 +189,7 @@ testEmptyGet (int poll_flag) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } diff --git a/src/testcurl/https/test_https_get_parallel_threads.c b/src/testcurl/https/test_https_get_parallel_threads.c @@ -70,6 +70,7 @@ https_transfer_thread_adapter (void *args) return &nonnull; } + /** * Test non-parallel requests. * diff --git a/src/testcurl/https/test_https_get_select.c b/src/testcurl/https/test_https_get_select.c @@ -118,7 +118,7 @@ testExternalGet (int flags) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -201,10 +201,10 @@ testExternalGet (int flags) if (EINTR != errno) abort (); #else - if ((WSAEINVAL != WSAGetLastError ()) ||(0 != rs.fd_count) ||(0 != - ws. - fd_count) - ||(0 != es.fd_count) ) + if ((WSAEINVAL != WSAGetLastError ()) || (0 != rs.fd_count) || (0 != + ws. + fd_count) + || (0 != es.fd_count) ) abort (); Sleep (1000); #endif diff --git a/src/testcurl/https/test_https_multi_daemon.c b/src/testcurl/https/test_https_multi_daemon.c @@ -78,7 +78,7 @@ test_concurent_daemon_pair (void *cls, { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d1, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d1); return -1; } @@ -103,7 +103,7 @@ test_concurent_daemon_pair (void *cls, { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d2, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d1); MHD_stop_daemon (d2); diff --git a/src/testcurl/https/test_https_session_info.c b/src/testcurl/https/test_https_session_info.c @@ -132,7 +132,7 @@ test_query_session () { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); free (cbc.buf); @@ -188,6 +188,8 @@ test_query_session () free (cbc.buf); return 0; } + + #endif int diff --git a/src/testcurl/https/test_https_sni.c b/src/testcurl/https/test_https_sni.c @@ -120,7 +120,6 @@ load_keys (const char *hostname, } - /** * @param session the session we are giving a cert for * @param req_ca_dn NULL on server side @@ -297,7 +296,7 @@ main (int argc, char *const *argv) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return -1; } @@ -318,10 +317,13 @@ main (int argc, char *const *argv) #else -int main (void) +int +main (void) { fprintf (stderr, "SNI not supported by GnuTLS < 3.0\n"); return 77; } + + #endif diff --git a/src/testcurl/https/test_https_time_out.c b/src/testcurl/https/test_https_time_out.c @@ -144,7 +144,7 @@ main (int argc, char *const *argv) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return -1; } diff --git a/src/testcurl/https/test_tls_authentication.c b/src/testcurl/https/test_tls_authentication.c @@ -38,7 +38,6 @@ extern const char srv_signed_cert_pem[]; extern const char srv_signed_key_pem[]; - /* perform a HTTP GET request via SSL/TLS */ static int test_secure_get (void *cls, char *cipher_suite, int proto_version) @@ -70,7 +69,7 @@ test_secure_get (void *cls, char *cipher_suite, int proto_version) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return -1; } diff --git a/src/testcurl/https/test_tls_extensions.c b/src/testcurl/https/test_tls_extensions.c @@ -132,8 +132,7 @@ test_hello_extension (gnutls_session_t session, int port, extensions_t exten_t, * len = ciphersuite data + 2 bytes ciphersuite length \ * 1 byte compression length + 1 byte compression data + \ * 2 bytes extension length, extensions data - */ - ciphersuite_len = MHD__gnutls_copy_ciphersuites (session, extdata, + */ciphersuite_len = MHD__gnutls_copy_ciphersuites (session, extdata, sizeof (extdata)); exten_data_len = ext_count * (2 + 2 + ext_length); datalen += ciphersuite_len + 2 + 2 + exten_data_len; @@ -259,7 +258,7 @@ main (int argc, char *const *argv) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return -1; } diff --git a/src/testcurl/https/tls_test_common.c b/src/testcurl/https/tls_test_common.c @@ -232,6 +232,7 @@ http_dummy_ahc (void *cls, return 0; } + /** * send a test http request to the daemon * @param url @@ -414,6 +415,7 @@ cleanup: return ret; } + /** * setup test case * @@ -439,7 +441,7 @@ setup_testcase (struct MHD_Daemon **d, int port, int daemon_flags, va_list { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (*d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (*d); return 0; @@ -450,12 +452,14 @@ setup_testcase (struct MHD_Daemon **d, int port, int daemon_flags, va_list return port; } + void teardown_testcase (struct MHD_Daemon *d) { MHD_stop_daemon (d); } + int setup_session (gnutls_session_t *session, gnutls_datum_t *key, @@ -501,6 +505,7 @@ setup_session (gnutls_session_t *session, return 0; } + int teardown_session (gnutls_session_t session, gnutls_datum_t *key, @@ -518,6 +523,7 @@ teardown_session (gnutls_session_t session, return 0; } + /* TODO test_wrap: change sig to (setup_func, test, va_list test_arg) */ int test_wrap (const char *test_name, int diff --git a/src/testcurl/perf_get.c b/src/testcurl/perf_get.c @@ -150,6 +150,7 @@ copyBuffer (void *ptr, return size * nmemb; } + static int ahc_echo (void *cls, struct MHD_Connection *connection, @@ -205,7 +206,7 @@ testInternalGet (int port, int poll_flag) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -284,7 +285,7 @@ testMultithreadedGet (int port, int poll_flag) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -339,6 +340,7 @@ testMultithreadedGet (int port, int poll_flag) return 0; } + static int testMultithreadedPoolGet (int port, int poll_flag) { @@ -365,7 +367,7 @@ testMultithreadedPoolGet (int port, int poll_flag) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -417,6 +419,7 @@ testMultithreadedPoolGet (int port, int poll_flag) return 0; } + static int testExternalGet (int port) { @@ -458,7 +461,7 @@ testExternalGet (int port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -535,10 +538,10 @@ testExternalGet (int port) if (EINTR != errno) abort (); #else - if ((WSAEINVAL != WSAGetLastError ()) ||(0 != rs.fd_count) ||(0 != - ws. - fd_count) - ||(0 != es.fd_count) ) + if ((WSAEINVAL != WSAGetLastError ()) || (0 != rs.fd_count) || (0 != + ws. + fd_count) + || (0 != es.fd_count) ) abort (); Sleep (1000); #endif @@ -566,8 +569,7 @@ testExternalGet (int port) in actual runtime right now, even though the number of select calls is virtually cut in half (and 'select' is the most expensive of our system - calls according to 'strace') */ - if (0) + calls according to 'strace') */if (0) MHD_run (d); else MHD_run_from_select (d, &rs, &ws, &es); @@ -600,7 +602,7 @@ main (int argc, char *const *argv) int port = 1130; (void) argc; /* Unused. Silent compiler warning. */ - if ((NULL == argv)||(0 == argv[0])) + if ((NULL == argv) || (0 == argv[0])) return 99; oneone = has_in_name (argv[0], "11"); if (oneone) diff --git a/src/testcurl/perf_get_concurrent.c b/src/testcurl/perf_get_concurrent.c @@ -276,7 +276,7 @@ testInternalGet (int port, int poll_flag) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -327,7 +327,7 @@ testMultithreadedGet (int port, int poll_flag) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -375,7 +375,7 @@ testMultithreadedPoolGet (int port, int poll_flag) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -423,7 +423,7 @@ testExternalGet (int port) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -462,9 +462,10 @@ testExternalGet (int port) "select failed: %s\n", strerror (errno)); #else - if ((WSAEINVAL == WSAGetLastError ()) &&(0 == rs.fd_count) &&(0 == - ws.fd_count) - &&(0 == es.fd_count) ) + if ((WSAEINVAL == WSAGetLastError ()) && (0 == rs.fd_count) && (0 == + ws. + fd_count) + && (0 == es.fd_count) ) { Sleep (1000); continue; @@ -478,7 +479,7 @@ testExternalGet (int port) stop ("external select"); MHD_stop_daemon (d); - if ((0 != pthread_join (pid, (void**) &ret_val))|| + if ((0 != pthread_join (pid, (void**) &ret_val)) || (NULL != ret_val) ) { fprintf (stderr, @@ -498,7 +499,7 @@ main (int argc, char *const *argv) int port = 1100; (void) argc; /* Unused. Silent compiler warning. */ - if ((NULL == argv)||(0 == argv[0])) + if ((NULL == argv) || (0 == argv[0])) return 99; oneone = has_in_name (argv[0], "11"); if (oneone) diff --git a/src/testcurl/test_callback.c b/src/testcurl/test_callback.c @@ -150,7 +150,7 @@ main (int argc, char **argv) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 48; } @@ -218,9 +218,10 @@ main (int argc, char **argv) if (EINTR != errno) abort (); #else - if ((WSAEINVAL != WSAGetLastError ()) ||(0 != rs.fd_count) ||(0 != - ws.fd_count) - ||(0 != es.fd_count) ) + if ((WSAEINVAL != WSAGetLastError ()) || (0 != rs.fd_count) || (0 != + ws. + fd_count) + || (0 != es.fd_count) ) abort (); Sleep (1000); #endif diff --git a/src/testcurl/test_concurrent_stop.c b/src/testcurl/test_concurrent_stop.c @@ -95,6 +95,7 @@ thread_watchdog (void *param) return NULL; } + pthread_t watchdog_tid; static void @@ -110,6 +111,7 @@ start_watchdog (int timeout, const char *obj_name) } } + static void stop_watchdog (void) { @@ -121,6 +123,7 @@ stop_watchdog (void) } } + static size_t copyBuffer (void *ptr, size_t size, size_t nmemb, @@ -163,6 +166,7 @@ ahc_echo (void *cls, return ret; } + static void * thread_gets (void *param) { @@ -204,6 +208,7 @@ thread_gets (void *param) return NULL; } + static void * do_gets (void *param) { @@ -239,7 +244,8 @@ do_gets (void *param) } -pthread_t start_gets (int port) +pthread_t +start_gets (int port) { pthread_t tid; continue_requesting = 1; @@ -272,7 +278,7 @@ testMultithreadedGet (int port, { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -309,7 +315,7 @@ testMultithreadedPoolGet (int port, { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -342,7 +348,7 @@ main (int argc, char *const *argv) /* Do reuse connection, otherwise all available local ports may exhausted. */ oneone = 1; - if ((0 != port)&& oneone) + if ((0 != port) && oneone) port += 5; if (0 != curl_global_init (CURL_GLOBAL_WIN32)) return 2; diff --git a/src/testcurl/test_delete.c b/src/testcurl/test_delete.c @@ -67,6 +67,7 @@ putBuffer (void *stream, size_t size, size_t nmemb, void *ptr) return wrt; } + static size_t copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx) { @@ -79,6 +80,7 @@ copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx) return size * nmemb; } + static int ahc_echo (void *cls, struct MHD_Connection *connection, @@ -148,7 +150,7 @@ testInternalDelete () { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -224,7 +226,7 @@ testMultithreadedDelete () { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -270,6 +272,7 @@ testMultithreadedDelete () return 0; } + static int testMultithreadedPoolDelete () { @@ -300,7 +303,7 @@ testMultithreadedPoolDelete () { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -391,7 +394,7 @@ testExternalDelete () { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -469,9 +472,10 @@ testExternalDelete () if (EINTR != errno) abort (); #else - if ((WSAEINVAL != WSAGetLastError ()) ||(0 != rs.fd_count) ||(0 != - ws.fd_count) - ||(0 != es.fd_count) ) + if ((WSAEINVAL != WSAGetLastError ()) || (0 != rs.fd_count) || (0 != + ws. + fd_count) + || (0 != es.fd_count) ) abort (); Sleep (1000); #endif @@ -513,14 +517,13 @@ testExternalDelete () } - int main (int argc, char *const *argv) { unsigned int errorCount = 0; (void) argc; /* Unused. Silent compiler warning. */ - if ((NULL == argv)||(0 == argv[0])) + if ((NULL == argv) || (0 == argv[0])) return 99; oneone = has_in_name (argv[0], "11"); if (0 != curl_global_init (CURL_GLOBAL_WIN32)) diff --git a/src/testcurl/test_digestauth_with_arguments.c b/src/testcurl/test_digestauth_with_arguments.c @@ -70,6 +70,7 @@ copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx) return size * nmemb; } + static int ahc_echo (void *cls, struct MHD_Connection *connection, @@ -214,7 +215,7 @@ testDigestAuth () { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } diff --git a/src/testcurl/test_get.c b/src/testcurl/test_get.c @@ -202,7 +202,7 @@ testInternalGet (int poll_flag) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -276,7 +276,7 @@ testMultithreadedGet (int poll_flag) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -350,7 +350,7 @@ testMultithreadedPoolGet (int poll_flag) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -433,7 +433,7 @@ testExternalGet () { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -510,9 +510,10 @@ testExternalGet () if (EINTR != errno) abort (); #else - if ((WSAEINVAL != WSAGetLastError ()) ||(0 != rs.fd_count) ||(0 != - ws.fd_count) - ||(0 != es.fd_count) ) + if ((WSAEINVAL != WSAGetLastError ()) || (0 != rs.fd_count) || (0 != + ws. + fd_count) + || (0 != es.fd_count) ) _exit (99); Sleep (1000); #endif @@ -598,7 +599,7 @@ testUnknownPortGet (int poll_flag) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -673,7 +674,7 @@ testStopRace (int poll_flag) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -769,8 +770,8 @@ curlExcessFound (CURL *c, (void) c; /* Unused. Silent compiler warning. */ if ((CURLINFO_TEXT == type) - &&(size >= str_size) - &&(0 == strncmp (excess_found, data, str_size))) + && (size >= str_size) + && (0 == strncmp (excess_found, data, str_size))) *(int *) cls = 1; return 0; } @@ -809,7 +810,7 @@ testEmptyGet (int poll_flag) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -860,7 +861,7 @@ main (int argc, char *const *argv) unsigned int test_result = 0; int verbose = 0; - if ((NULL == argv)||(0 == argv[0])) + if ((NULL == argv) || (0 == argv[0])) return 99; oneone = has_in_name (argv[0], "11"); verbose = has_param (argc, argv, "-v") || has_param (argc, argv, "--verbose"); diff --git a/src/testcurl/test_get_chunked.c b/src/testcurl/test_get_chunked.c @@ -178,6 +178,7 @@ validate (struct CBC cbc, int ebase) return 0; } + static int testInternalGet () { @@ -204,7 +205,7 @@ testInternalGet () { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -237,6 +238,7 @@ testInternalGet () return validate (cbc, 4); } + static int testMultithreadedGet () { @@ -264,7 +266,7 @@ testMultithreadedGet () { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -297,6 +299,7 @@ testMultithreadedGet () return validate (cbc, 64); } + static int testMultithreadedPoolGet () { @@ -324,7 +327,7 @@ testMultithreadedPoolGet () { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -357,6 +360,7 @@ testMultithreadedPoolGet () return validate (cbc, 64); } + static int testExternalGet () { @@ -398,7 +402,7 @@ testExternalGet () { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -468,9 +472,10 @@ testExternalGet () if (EINTR != errno) abort (); #else - if ((WSAEINVAL != WSAGetLastError ()) ||(0 != rs.fd_count) ||(0 != - ws.fd_count) - ||(0 != es.fd_count) ) + if ((WSAEINVAL != WSAGetLastError ()) || (0 != rs.fd_count) || (0 != + ws. + fd_count) + || (0 != es.fd_count) ) abort (); Sleep (1000); #endif @@ -508,7 +513,6 @@ testExternalGet () } - int main (int argc, char *const *argv) { diff --git a/src/testcurl/test_get_empty.c b/src/testcurl/test_get_empty.c @@ -170,7 +170,7 @@ testInternalGet (int poll_flag) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -242,7 +242,7 @@ testMultithreadedGet (int poll_flag) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -314,7 +314,7 @@ testMultithreadedPoolGet (int poll_flag) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -395,7 +395,7 @@ testExternalGet () { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -472,9 +472,10 @@ testExternalGet () if (EINTR != errno) abort (); #else - if ((WSAEINVAL != WSAGetLastError ()) ||(0 != rs.fd_count) ||(0 != - ws.fd_count) - ||(0 != es.fd_count) ) + if ((WSAEINVAL != WSAGetLastError ()) || (0 != rs.fd_count) || (0 != + ws. + fd_count) + || (0 != es.fd_count) ) _exit (99); Sleep (1000); #endif @@ -558,7 +559,7 @@ testUnknownPortGet (int poll_flag) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -631,7 +632,7 @@ testStopRace (int poll_flag) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -721,8 +722,8 @@ curlExcessFound (CURL *c, curl_infotype type, char *data, size_t size, (void) c; /* Unused. Silent compiler warning. */ if ((CURLINFO_TEXT == type) - &&(size >= str_size) - &&(0 == strncmp (excess_found, data, str_size))) + && (size >= str_size) + && (0 == strncmp (excess_found, data, str_size))) *(int *) cls = 1; return 0; } @@ -761,7 +762,7 @@ testEmptyGet (int poll_flag) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -812,7 +813,7 @@ main (int argc, char *const *argv) unsigned int test_result = 0; int verbose = 0; - if ((NULL == argv)||(0 == argv[0])) + if ((NULL == argv) || (0 == argv[0])) return 99; oneone = has_in_name (argv[0], "11"); verbose = has_param (argc, argv, "-v") || has_param (argc, argv, "--verbose"); diff --git a/src/testcurl/test_get_response_cleanup.c b/src/testcurl/test_get_response_cleanup.c @@ -180,7 +180,7 @@ testInternalGet () { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -231,7 +231,7 @@ testMultithreadedGet () { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -292,7 +292,7 @@ testMultithreadedPoolGet () { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -346,7 +346,7 @@ testExternalGet () { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -426,7 +426,7 @@ main (int argc, char *const *argv) } #endif /* _WIN32 */ - if ((NULL == argv)||(0 == argv[0])) + if ((NULL == argv) || (0 == argv[0])) return 99; oneone = has_in_name (argv[0], "11"); if (MHD_YES == MHD_is_feature_supported (MHD_FEATURE_THREADS)) diff --git a/src/testcurl/test_get_sendfile.c b/src/testcurl/test_get_sendfile.c @@ -147,7 +147,7 @@ testInternalGet () { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -219,7 +219,7 @@ testMultithreadedGet () { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -291,7 +291,7 @@ testMultithreadedPoolGet () { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -377,7 +377,7 @@ testExternalGet () { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -450,9 +450,10 @@ testExternalGet () if (EINTR != errno) abort (); #else - if ((WSAEINVAL != WSAGetLastError ()) ||(0 != rs.fd_count) ||(0 != - ws.fd_count) - ||(0 != es.fd_count) ) + if ((WSAEINVAL != WSAGetLastError ()) || (0 != rs.fd_count) || (0 != + ws. + fd_count) + || (0 != es.fd_count) ) abort (); Sleep (1000); #endif @@ -539,7 +540,7 @@ testUnknownPortGet () { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -591,7 +592,7 @@ main (int argc, char *const *argv) FILE *f; (void) argc; /* Unused. Silent compiler warning. */ - if ((NULL == argv)||(0 == argv[0])) + if ((NULL == argv) || (0 == argv[0])) return 99; oneone = has_in_name (argv[0], "11"); diff --git a/src/testcurl/test_iplimit.c b/src/testcurl/test_iplimit.c @@ -73,6 +73,7 @@ copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx) return size * nmemb; } + static int ahc_echo (void *cls, struct MHD_Connection *connection, @@ -106,6 +107,7 @@ ahc_echo (void *cls, return ret; } + static int testMultithreadedGet () { @@ -140,7 +142,7 @@ testMultithreadedGet () { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -220,6 +222,7 @@ testMultithreadedGet () return 0; } + static int testMultithreadedPoolGet () { @@ -251,7 +254,7 @@ testMultithreadedPoolGet () { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -338,13 +341,14 @@ testMultithreadedPoolGet () return 0; } + int main (int argc, char *const *argv) { unsigned int errorCount = 0; (void) argc; /* Unused. Silent compiler warning. */ - if ((NULL == argv)||(0 == argv[0])) + if ((NULL == argv) || (0 == argv[0])) return 99; oneone = has_in_name (argv[0], "11"); if (0 != curl_global_init (CURL_GLOBAL_WIN32)) diff --git a/src/testcurl/test_large_put.c b/src/testcurl/test_large_put.c @@ -86,6 +86,7 @@ alloc_init (size_t buf_size) return buf; } + static size_t putBuffer (void *stream, size_t size, size_t nmemb, void *ptr) { @@ -103,6 +104,7 @@ putBuffer (void *stream, size_t size, size_t nmemb, void *ptr) return wrt; } + static size_t copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx) { @@ -115,6 +117,7 @@ copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx) return size * nmemb; } + static int ahc_echo (void *cls, struct MHD_Connection *connection, @@ -213,7 +216,7 @@ testPutInternalThread (unsigned int add_flag) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -257,6 +260,7 @@ testPutInternalThread (unsigned int add_flag) return 0; } + static int testPutThreadPerConn (unsigned int add_flag) { @@ -297,7 +301,7 @@ testPutThreadPerConn (unsigned int add_flag) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -344,6 +348,7 @@ testPutThreadPerConn (unsigned int add_flag) return 0; } + static int testPutThreadPool (unsigned int add_flag) { @@ -384,7 +389,7 @@ testPutThreadPool (unsigned int add_flag) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -431,6 +436,7 @@ testPutThreadPool (unsigned int add_flag) return 0; } + static int testPutExternal (void) { @@ -484,7 +490,7 @@ testPutExternal (void) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -561,9 +567,10 @@ testPutExternal (void) if (EINTR != errno) abort (); #else - if ((WSAEINVAL != WSAGetLastError ()) ||(0 != rs.fd_count) ||(0 != - ws.fd_count) - ||(0 != es.fd_count) ) + if ((WSAEINVAL != WSAGetLastError ()) || (0 != rs.fd_count) || (0 != + ws. + fd_count) + || (0 != es.fd_count) ) abort (); Sleep (1000); #endif @@ -608,7 +615,6 @@ testPutExternal (void) } - int main (int argc, char *const *argv) { @@ -624,40 +630,40 @@ main (int argc, char *const *argv) if (NULL == put_buffer) return 99; lastErr = testPutExternal (); - if (verbose &&(0 != lastErr)) + if (verbose && (0 != lastErr)) fprintf (stderr, "Error during testing with external select().\n"); errorCount += lastErr; if (MHD_YES == MHD_is_feature_supported (MHD_FEATURE_THREADS)) { lastErr = testPutInternalThread (0); - if (verbose &&(0 != lastErr) ) + if (verbose && (0 != lastErr) ) fprintf (stderr, "Error during testing with internal thread with select().\n"); errorCount += lastErr; lastErr = testPutThreadPerConn (0); - if (verbose &&(0 != lastErr) ) + if (verbose && (0 != lastErr) ) fprintf (stderr, "Error during testing with internal thread per connection with select().\n"); errorCount += lastErr; lastErr = testPutThreadPool (0); - if (verbose &&(0 != lastErr) ) + if (verbose && (0 != lastErr) ) fprintf (stderr, "Error during testing with thread pool per connection with select().\n"); errorCount += lastErr; if (MHD_is_feature_supported (MHD_FEATURE_POLL)) { lastErr = testPutInternalThread (MHD_USE_POLL); - if (verbose &&(0 != lastErr) ) + if (verbose && (0 != lastErr) ) fprintf (stderr, "Error during testing with internal thread with poll().\n"); errorCount += lastErr; lastErr = testPutThreadPerConn (MHD_USE_POLL); - if (verbose &&(0 != lastErr) ) + if (verbose && (0 != lastErr) ) fprintf (stderr, "Error during testing with internal thread per connection with poll().\n"); errorCount += lastErr; lastErr = testPutThreadPool (MHD_USE_POLL); - if (verbose &&(0 != lastErr) ) + if (verbose && (0 != lastErr) ) fprintf (stderr, "Error during testing with thread pool per connection with poll().\n"); errorCount += lastErr; @@ -665,12 +671,12 @@ main (int argc, char *const *argv) if (MHD_is_feature_supported (MHD_FEATURE_EPOLL)) { lastErr = testPutInternalThread (MHD_USE_EPOLL); - if (verbose &&(0 != lastErr) ) + if (verbose && (0 != lastErr) ) fprintf (stderr, "Error during testing with internal thread with epoll.\n"); errorCount += lastErr; lastErr = testPutThreadPool (MHD_USE_EPOLL); - if (verbose &&(0 != lastErr) ) + if (verbose && (0 != lastErr) ) fprintf (stderr, "Error during testing with thread pool per connection with epoll.\n"); errorCount += lastErr; diff --git a/src/testcurl/test_long_header.c b/src/testcurl/test_long_header.c @@ -53,6 +53,7 @@ apc_all (void *cls, const struct sockaddr *addr, socklen_t addrlen) return MHD_YES; } + struct CBC { char *buf; @@ -67,6 +68,7 @@ copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx) return size * nmemb; } + static int ahc_echo (void *cls, struct MHD_Connection *connection, @@ -130,7 +132,7 @@ testLongUrlGet (size_t buff_size) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -223,7 +225,7 @@ testLongHeaderGet (size_t buff_size) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -283,13 +285,14 @@ testLongHeaderGet (size_t buff_size) return 0; } + int main (int argc, char *const *argv) { unsigned int errorCount = 0; (void) argc; /* Unused. Silent compiler warning. */ - if ((NULL == argv)||(0 == argv[0])) + if ((NULL == argv) || (0 == argv[0])) return 99; oneone = has_in_name (argv[0], "11"); if (0 != curl_global_init (CURL_GLOBAL_WIN32)) diff --git a/src/testcurl/test_parse_cookies.c b/src/testcurl/test_parse_cookies.c @@ -58,6 +58,7 @@ copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx) return size * nmemb; } + static int ahc_echo (void *cls, struct MHD_Connection *connection, @@ -105,6 +106,7 @@ ahc_echo (void *cls, return ret; } + static int testExternalGet () { @@ -150,7 +152,7 @@ testExternalGet () { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -228,9 +230,10 @@ testExternalGet () if (EINTR != errno) abort (); #else - if ((WSAEINVAL != WSAGetLastError ()) ||(0 != rs.fd_count) ||(0 != - ws.fd_count) - ||(0 != es.fd_count) ) + if ((WSAEINVAL != WSAGetLastError ()) || (0 != rs.fd_count) || (0 != + ws. + fd_count) + || (0 != es.fd_count) ) abort (); Sleep (1000); #endif @@ -278,7 +281,7 @@ main (int argc, char *const *argv) unsigned int errorCount = 0; (void) argc; /* Unused. Silent compiler warning. */ - if ((NULL == argv)||(0 == argv[0])) + if ((NULL == argv) || (0 == argv[0])) return 99; oneone = has_in_name (argv[0], "11"); if (0 != curl_global_init (CURL_GLOBAL_WIN32)) diff --git a/src/testcurl/test_post.c b/src/testcurl/test_post.c @@ -196,7 +196,7 @@ testInternalPost () { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -239,6 +239,7 @@ testInternalPost () return 0; } + static int testMultithreadedPost () { @@ -272,7 +273,7 @@ testMultithreadedPost () { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -315,6 +316,7 @@ testMultithreadedPost () return 0; } + static int testMultithreadedPoolPost () { @@ -348,7 +350,7 @@ testMultithreadedPoolPost () { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -391,6 +393,7 @@ testMultithreadedPoolPost () return 0; } + static int testExternalPost () { @@ -438,7 +441,7 @@ testExternalPost () { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -514,9 +517,10 @@ testExternalPost () if (EINTR != errno) abort (); #else - if ((WSAEINVAL != WSAGetLastError ()) ||(0 != rs.fd_count) ||(0 != - ws.fd_count) - ||(0 != es.fd_count) ) + if ((WSAEINVAL != WSAGetLastError ()) || (0 != rs.fd_count) || (0 != + ws. + fd_count) + || (0 != es.fd_count) ) abort (); Sleep (1000); #endif @@ -599,6 +603,7 @@ ahc_cancel (void *cls, } } + struct CRBC { const char *buffer; @@ -681,7 +686,7 @@ testMultithreadedPostCancelPart (int flags) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -728,8 +733,8 @@ testMultithreadedPostCancelPart (int flags) { #ifdef _WIN32 curl_version_info_data *curlverd = curl_version_info (CURLVERSION_NOW); - if ((0 != (flags & FLAG_SLOW_READ)) &&(CURLE_RECV_ERROR == errornum) && - ((curlverd == NULL) ||(curlverd->ares_num < 0x073100) ) ) + if ((0 != (flags & FLAG_SLOW_READ)) && (CURLE_RECV_ERROR == errornum) && + ((curlverd == NULL) || (curlverd->ares_num < 0x073100) ) ) { /* libcurl up to version 7.49.0 didn't have workaround for WinSock bug */ fprintf (stderr, "Ignored curl_easy_perform expected failure on W32 with \"slow read\".\n"); @@ -792,7 +797,7 @@ main (int argc, char *const *argv) unsigned int errorCount = 0; (void) argc; /* Unused. Silent compiler warning. */ - if ((NULL == argv)||(0 == argv[0])) + if ((NULL == argv) || (0 == argv[0])) return 99; oneone = has_in_name (argv[0], "11"); if (0 != curl_global_init (CURL_GLOBAL_WIN32)) diff --git a/src/testcurl/test_post_loop.c b/src/testcurl/test_post_loop.c @@ -71,6 +71,7 @@ copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx) return size * nmemb; } + static int ahc_echo (void *cls, struct MHD_Connection *connection, @@ -141,7 +142,7 @@ testInternalPost () { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -198,6 +199,7 @@ testInternalPost () return 0; } + static int testMultithreadedPost () { @@ -232,7 +234,7 @@ testMultithreadedPost () { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -289,6 +291,7 @@ testMultithreadedPost () return 0; } + static int testMultithreadedPoolPost () { @@ -321,7 +324,7 @@ testMultithreadedPoolPost () { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -378,6 +381,7 @@ testMultithreadedPoolPost () return 0; } + static int testExternalPost () { @@ -427,7 +431,7 @@ testExternalPost () { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -592,7 +596,7 @@ main (int argc, char *const *argv) unsigned int errorCount = 0; (void) argc; /* Unused. Silent compiler warning. */ - if ((NULL == argv)||(0 == argv[0])) + if ((NULL == argv) || (0 == argv[0])) return 99; oneone = has_in_name (argv[0], "11"); if (0 != curl_global_init (CURL_GLOBAL_WIN32)) diff --git a/src/testcurl/test_postform.c b/src/testcurl/test_postform.c @@ -164,6 +164,7 @@ ahc_echo (void *cls, return MHD_YES; } + static struct curl_httppost * make_form () { @@ -211,7 +212,7 @@ testInternalPost () { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -255,6 +256,7 @@ testInternalPost () return 0; } + static int testMultithreadedPost () { @@ -289,7 +291,7 @@ testMultithreadedPost () { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -333,6 +335,7 @@ testMultithreadedPost () return 0; } + static int testMultithreadedPoolPost () { @@ -367,7 +370,7 @@ testMultithreadedPoolPost () { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -411,6 +414,7 @@ testMultithreadedPoolPost () return 0; } + static int testExternalPost () { @@ -459,7 +463,7 @@ testExternalPost () { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -538,9 +542,10 @@ testExternalPost () if (EINTR != errno) abort (); #else - if ((WSAEINVAL != WSAGetLastError ()) ||(0 != rs.fd_count) ||(0 != - ws.fd_count) - ||(0 != es.fd_count) ) + if ((WSAEINVAL != WSAGetLastError ()) || (0 != rs.fd_count) || (0 != + ws. + fd_count) + || (0 != es.fd_count) ) abort (); Sleep (1000); #endif @@ -598,7 +603,7 @@ main (int argc, char *const *argv) #endif #endif #endif /* MHD_HTTPS_REQUIRE_GRYPT */ - if ((NULL == argv)||(0 == argv[0])) + if ((NULL == argv) || (0 == argv[0])) return 99; oneone = has_in_name (argv[0], "11"); if (0 != curl_global_init (CURL_GLOBAL_WIN32)) diff --git a/src/testcurl/test_process_arguments.c b/src/testcurl/test_process_arguments.c @@ -155,7 +155,7 @@ testExternalGet () { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -229,9 +229,10 @@ testExternalGet () if (EINTR != errno) abort (); #else - if ((WSAEINVAL != WSAGetLastError ()) ||(0 != rs.fd_count) ||(0 != - ws.fd_count) - ||(0 != es.fd_count) ) + if ((WSAEINVAL != WSAGetLastError ()) || (0 != rs.fd_count) || (0 != + ws. + fd_count) + || (0 != es.fd_count) ) abort (); Sleep (1000); #endif @@ -279,7 +280,7 @@ main (int argc, char *const *argv) unsigned int errorCount = 0; (void) argc; /* Unused. Silent compiler warning. */ - if ((NULL == argv)||(0 == argv[0])) + if ((NULL == argv) || (0 == argv[0])) return 99; oneone = has_in_name (argv[0], "11"); if (0 != curl_global_init (CURL_GLOBAL_WIN32)) diff --git a/src/testcurl/test_process_headers.c b/src/testcurl/test_process_headers.c @@ -65,6 +65,7 @@ copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx) return size * nmemb; } + static int kv_cb (void *cls, enum MHD_ValueKind kind, const char *key, const char *value) { @@ -78,6 +79,7 @@ kv_cb (void *cls, enum MHD_ValueKind kind, const char *key, const char *value) return MHD_YES; } + static int ahc_echo (void *cls, struct MHD_Connection *connection, @@ -179,7 +181,7 @@ testInternalGet () { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -219,6 +221,7 @@ testInternalGet () return 0; } + static int testMultithreadedGet () { @@ -250,7 +253,7 @@ testMultithreadedGet () { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -290,6 +293,7 @@ testMultithreadedGet () return 0; } + static int testMultithreadedPoolGet () { @@ -321,7 +325,7 @@ testMultithreadedPoolGet () { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -361,6 +365,7 @@ testMultithreadedPoolGet () return 0; } + static int testExternalGet () { @@ -406,7 +411,7 @@ testExternalGet () { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -479,9 +484,10 @@ testExternalGet () if (EINTR != errno) abort (); #else - if ((WSAEINVAL != WSAGetLastError ()) ||(0 != rs.fd_count) ||(0 != - ws.fd_count) - ||(0 != es.fd_count) ) + if ((WSAEINVAL != WSAGetLastError ()) || (0 != rs.fd_count) || (0 != + ws. + fd_count) + || (0 != es.fd_count) ) abort (); Sleep (1000); #endif @@ -523,14 +529,13 @@ testExternalGet () } - int main (int argc, char *const *argv) { unsigned int errorCount = 0; (void) argc; /* Unused. Silent compiler warning. */ - if ((NULL == argv)||(0 == argv[0])) + if ((NULL == argv) || (0 == argv[0])) return 99; oneone = has_in_name (argv[0], "11"); if (MHD_YES == MHD_is_feature_supported (MHD_FEATURE_THREADS)) diff --git a/src/testcurl/test_put.c b/src/testcurl/test_put.c @@ -67,6 +67,7 @@ putBuffer (void *stream, size_t size, size_t nmemb, void *ptr) return wrt; } + static size_t copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx) { @@ -79,6 +80,7 @@ copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx) return size * nmemb; } + static int ahc_echo (void *cls, struct MHD_Connection *connection, @@ -152,7 +154,7 @@ testInternalPut () { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -196,6 +198,7 @@ testInternalPut () return 0; } + static int testMultithreadedPut () { @@ -230,7 +233,7 @@ testMultithreadedPut () { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -275,6 +278,7 @@ testMultithreadedPut () return 0; } + static int testMultithreadedPoolPut () { @@ -309,7 +313,7 @@ testMultithreadedPoolPut () { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -399,7 +403,7 @@ testExternalPut () { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -480,9 +484,10 @@ testExternalPut () if (EINTR != errno) abort (); #else - if ((WSAEINVAL != WSAGetLastError ()) ||(0 != rs.fd_count) ||(0 != - ws.fd_count) - ||(0 != es.fd_count) ) + if ((WSAEINVAL != WSAGetLastError ()) || (0 != rs.fd_count) || (0 != + ws. + fd_count) + || (0 != es.fd_count) ) _exit (99); Sleep (1000); #endif @@ -524,14 +529,13 @@ testExternalPut () } - int main (int argc, char *const *argv) { unsigned int errorCount = 0; (void) argc; /* Unused. Silent compiler warning. */ - if ((NULL == argv)||(0 == argv[0])) + if ((NULL == argv) || (0 == argv[0])) return 99; oneone = has_in_name (argv[0], "11"); if (0 != curl_global_init (CURL_GLOBAL_WIN32)) diff --git a/src/testcurl/test_put_chunked.c b/src/testcurl/test_put_chunked.c @@ -67,6 +67,7 @@ putBuffer (void *stream, size_t size, size_t nmemb, void *ptr) return wrt; } + static size_t copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx) { @@ -79,6 +80,7 @@ copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx) return size * nmemb; } + static int ahc_echo (void *cls, struct MHD_Connection *connection, @@ -159,7 +161,7 @@ testInternalPut () { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -203,6 +205,7 @@ testInternalPut () return 0; } + static int testMultithreadedPut () { @@ -233,7 +236,7 @@ testMultithreadedPut () { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -278,6 +281,7 @@ testMultithreadedPut () return 0; } + static int testMultithreadedPoolPut () { @@ -308,7 +312,7 @@ testMultithreadedPoolPut () { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -398,7 +402,7 @@ testExternalPut () { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -475,9 +479,10 @@ testExternalPut () if (EINTR != errno) abort (); #else - if ((WSAEINVAL != WSAGetLastError ()) ||(0 != rs.fd_count) ||(0 != - ws.fd_count) - ||(0 != es.fd_count) ) + if ((WSAEINVAL != WSAGetLastError ()) || (0 != rs.fd_count) || (0 != + ws. + fd_count) + || (0 != es.fd_count) ) abort (); Sleep (1000); #endif @@ -520,7 +525,6 @@ testExternalPut () } - int main (int argc, char *const *argv) { diff --git a/src/testcurl/test_quiesce.c b/src/testcurl/test_quiesce.c @@ -157,9 +157,10 @@ ServeOneRequest (void *param) if (EINTR != errno) abort (); #else - if ((WSAEINVAL != WSAGetLastError ()) ||(0 != rs.fd_count) ||(0 != - ws.fd_count) - ||(0 != es.fd_count) ) + if ((WSAEINVAL != WSAGetLastError ()) || (0 != rs.fd_count) || (0 != + ws. + fd_count) + || (0 != es.fd_count) ) abort (); Sleep (1000); #endif @@ -228,7 +229,8 @@ testGet (int type, int pool_count, int poll_flag) MHD_OPTION_END); } - else { + else + { d = MHD_start_daemon (type | MHD_USE_ERROR_LOG | MHD_USE_ITC | poll_flag, port, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); } @@ -238,7 +240,7 @@ testGet (int type, int pool_count, int poll_flag) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -395,7 +397,7 @@ testExternalGet () { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -456,10 +458,10 @@ testExternalGet () if (EINTR != errno) abort (); #else - if ((WSAEINVAL != WSAGetLastError ()) ||(0 != rs.fd_count) ||(0 != - ws. - fd_count) - ||(0 != es.fd_count) ) + if ((WSAEINVAL != WSAGetLastError ()) || (0 != rs.fd_count) || (0 != + ws. + fd_count) + || (0 != es.fd_count) ) abort (); Sleep (1000); #endif @@ -472,7 +474,7 @@ testExternalGet () break; if (msg->msg == CURLMSG_DONE) { - if ((i == 0) &&(msg->data.result != CURLE_OK) ) + if ((i == 0) && (msg->data.result != CURLE_OK) ) printf ("%s failed at %s:%d: `%s'\n", "curl_multi_perform", __FILE__, diff --git a/src/testcurl/test_quiesce_stream.c b/src/testcurl/test_quiesce_stream.c @@ -108,7 +108,7 @@ http_ContentReaderCallback (void *cls, struct ContentReaderUserdata *userdata = cls; (void) pos; (void) max; /* Unused. Silent compiler warning. */ - if ( userdata->bytes_written >= 1024) + if (userdata->bytes_written >= 1024) { fprintf (stderr, "finish: %d\n", @@ -218,7 +218,7 @@ main (void) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (daemon, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (daemon); return 32; } diff --git a/src/testcurl/test_termination.c b/src/testcurl/test_termination.c @@ -82,6 +82,7 @@ connection_handler (void *cls, return ret; } + static size_t write_data (void *ptr, size_t size, size_t nmemb, void *stream) { @@ -89,6 +90,7 @@ write_data (void *ptr, size_t size, size_t nmemb, void *stream) return size * nmemb; } + int main (void) { @@ -119,7 +121,7 @@ main (void) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (daemon, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (daemon); return 32; } diff --git a/src/testcurl/test_timeout.c b/src/testcurl/test_timeout.c @@ -199,7 +199,7 @@ testWithoutTimeout () { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -240,6 +240,7 @@ testWithoutTimeout () return 0; } + static int testWithTimeout () { @@ -276,7 +277,7 @@ testWithTimeout () { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -325,7 +326,7 @@ main (int argc, char *const *argv) unsigned int errorCount = 0; (void) argc; /* Unused. Silent compiler warning. */ - if ((NULL == argv)||(0 == argv[0])) + if ((NULL == argv) || (0 == argv[0])) return 99; oneone = has_in_name (argv[0], "11"); if (0 != curl_global_init (CURL_GLOBAL_WIN32)) diff --git a/src/testcurl/test_urlparse.c b/src/testcurl/test_urlparse.c @@ -68,6 +68,7 @@ copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx) return size * nmemb; } + static int test_values (void *cls, enum MHD_ValueKind kind, @@ -87,6 +88,7 @@ test_values (void *cls, return MHD_YES; } + static int ahc_echo (void *cls, struct MHD_Connection *connection, @@ -156,7 +158,7 @@ testInternalGet (int poll_flag) { const union MHD_DaemonInfo *dinfo; dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); - if ((NULL == dinfo) ||(0 == dinfo->port) ) + if ((NULL == dinfo) || (0 == dinfo->port) ) { MHD_stop_daemon (d); return 32; } @@ -205,7 +207,7 @@ main (int argc, char *const *argv) unsigned int errorCount = 0; (void) argc; /* Unused. Silent compiler warning. */ - if ((NULL == argv)||(0 == argv[0])) + if ((NULL == argv) || (0 == argv[0])) return 99; oneone = has_in_name (argv[0], "11"); if (0 != curl_global_init (CURL_GLOBAL_WIN32)) diff --git a/src/testzzuf/socat.c b/src/testzzuf/socat.c @@ -109,4 +109,5 @@ zzuf_socat_stop () } } + /* end of socat.c */ diff --git a/src/testzzuf/test_get.c b/src/testzzuf/test_get.c @@ -59,6 +59,7 @@ copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx) return size * nmemb; } + static int ahc_echo (void *cls, struct MHD_Connection *connection, @@ -138,6 +139,7 @@ testInternalGet () return 0; } + static int testMultithreadedGet () { diff --git a/src/testzzuf/test_get_chunked.c b/src/testzzuf/test_get_chunked.c @@ -57,6 +57,7 @@ copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx) return size * nmemb; } + /** * MHD content reader callback that returns * data in chunks. @@ -77,6 +78,7 @@ crc (void *cls, uint64_t pos, char *buf, size_t max) return 128; } + /** * Dummy function that does nothing. */ @@ -86,6 +88,7 @@ crcf (void *ptr) free (ptr); } + static int ahc_echo (void *cls, struct MHD_Connection *connection, @@ -132,6 +135,7 @@ ahc_echo (void *cls, return ret; } + static int testInternalGet () { @@ -174,6 +178,7 @@ testInternalGet () return 0; } + static int testMultithreadedGet () { @@ -328,7 +333,6 @@ testExternalGet () } - int main (int argc, char *const *argv) { diff --git a/src/testzzuf/test_long_header.c b/src/testzzuf/test_long_header.c @@ -54,6 +54,7 @@ apc_all (void *cls, const struct sockaddr *addr, socklen_t addrlen) return MHD_YES; } + struct CBC { char *buf; @@ -68,6 +69,7 @@ copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx) return size * nmemb; } + static int ahc_echo (void *cls, struct MHD_Connection *connection, diff --git a/src/testzzuf/test_post.c b/src/testzzuf/test_post.c @@ -106,6 +106,7 @@ post_iterator (void *cls, return MHD_YES; } + static int ahc_echo (void *cls, struct MHD_Connection *connection, @@ -201,6 +202,7 @@ testInternalPost () return 0; } + static int testMultithreadedPost () { diff --git a/src/testzzuf/test_post_form.c b/src/testzzuf/test_post_form.c @@ -76,6 +76,7 @@ copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx) return size * nmemb; } + /** * Note that this post_iterator is not perfect * in that it fails to support incremental processing. @@ -153,6 +154,7 @@ ahc_echo (void *cls, return MHD_YES; } + static struct curl_httppost * make_form () { diff --git a/src/testzzuf/test_put.c b/src/testzzuf/test_put.c @@ -62,6 +62,7 @@ putBuffer (void *stream, size_t size, size_t nmemb, void *ptr) return wrt; } + static size_t copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx) { @@ -74,6 +75,7 @@ copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx) return size * nmemb; } + static int ahc_echo (void *cls, struct MHD_Connection *connection, @@ -167,6 +169,7 @@ testInternalPut () return 0; } + static int testMultithreadedPut () { @@ -281,7 +284,6 @@ testExternalPut () curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); - mret = curl_multi_add_handle (multi, c); if (mret != CURLM_OK) { diff --git a/src/testzzuf/test_put_chunked.c b/src/testzzuf/test_put_chunked.c @@ -62,6 +62,7 @@ putBuffer (void *stream, size_t size, size_t nmemb, void *ptr) return wrt; } + static size_t copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx) { @@ -74,6 +75,7 @@ copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx) return size * nmemb; } + static int ahc_echo (void *cls, struct MHD_Connection *connection, @@ -172,6 +174,7 @@ testInternalPut () return 0; } + static int testMultithreadedPut () { @@ -355,7 +358,6 @@ testExternalPut () } - int main (int argc, char *const *argv) { diff --git a/src/testzzuf/test_put_large.c b/src/testzzuf/test_put_large.c @@ -70,6 +70,7 @@ putBuffer (void *stream, size_t size, size_t nmemb, void *ptr) return wrt; } + static size_t copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx) { @@ -82,6 +83,7 @@ copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx) return size * nmemb; } + static int ahc_echo (void *cls, struct MHD_Connection *connection, @@ -182,6 +184,7 @@ testInternalPut () return 0; } + static int testMultithreadedPut () { @@ -299,7 +302,6 @@ testExternalPut () curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); - mret = curl_multi_add_handle (multi, c); if (mret != CURLM_OK) {