tests: fix formatting nits
No binary (build failed)
—
(log yok)
| @@ -62,7 +62,8 @@ static int curltest_post_config(apr_pool_t *p, apr_pool_t *plog, | |
| void *data = NULL; | |
| const char *key = "mod_curltest_init_counter"; | |
| - | (void)plog;(void)ptemp; |
| + | (void)plog; |
| + | (void)ptemp; |
| apr_pool_userdata_get(&data, key, s->process->pool); | |
| if(!data) { | |
| @@ -93,8 +94,8 @@ static void curltest_hooks(apr_pool_t *pool) | |
| ap_hook_handler(curltest_sslinfo_handler, NULL, NULL, APR_HOOK_MIDDLE); | |
| } | |
| - | #define SECS_PER_HOUR (60*60) |
| - | #define SECS_PER_DAY (24*SECS_PER_HOUR) |
| + | #define SECS_PER_HOUR (60 * 60) |
| + | #define SECS_PER_DAY (24 * SECS_PER_HOUR) |
| static apr_status_t duration_parse(apr_interval_time_t *ptimeout, | |
| const char *value, const char *def_unit) | |
| @@ -124,12 +125,12 @@ static apr_status_t duration_parse(apr_interval_time_t *ptimeout, | |
| break; | |
| case 's': | |
| case 'S': | |
| - | *ptimeout = (apr_interval_time_t) apr_time_from_sec(n); |
| + | *ptimeout = (apr_interval_time_t)apr_time_from_sec(n); |
| break; | |
| case 'h': | |
| case 'H': | |
| /* Time is in hours */ | |
| - | *ptimeout = (apr_interval_time_t) apr_time_from_sec(n * SECS_PER_HOUR); |
| + | *ptimeout = (apr_interval_time_t)apr_time_from_sec(n * SECS_PER_HOUR); |
| break; | |
| case 'm': | |
| case 'M': | |
| @@ -137,12 +138,12 @@ static apr_status_t duration_parse(apr_interval_time_t *ptimeout, | |
| /* Time is in milliseconds */ | |
| case 's': | |
| case 'S': | |
| - | *ptimeout = (apr_interval_time_t) n * 1000; |
| + | *ptimeout = (apr_interval_time_t)n * 1000; |
| break; | |
| /* Time is in minutes */ | |
| case 'i': | |
| case 'I': | |
| - | *ptimeout = (apr_interval_time_t) apr_time_from_sec(n * 60); |
| + | *ptimeout = (apr_interval_time_t)apr_time_from_sec(n * 60); |
| break; | |
| default: | |
| return APR_EGENERAL; | |
| @@ -154,7 +155,7 @@ static apr_status_t duration_parse(apr_interval_time_t *ptimeout, | |
| /* Time is in microseconds */ | |
| case 's': | |
| case 'S': | |
| - | *ptimeout = (apr_interval_time_t) n; |
| + | *ptimeout = (apr_interval_time_t)n; |
| break; | |
| default: | |
| return APR_EGENERAL; | |
| @@ -266,8 +267,7 @@ static int curltest_echo_handler(request_rec *r) | |
| apr_table_get(r->headers_in, "TE")); | |
| if(read_delay) { | |
| - | ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r, |
| - | "put_handler: read_delay"); |
| + | ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r, "put_handler: read_delay"); |
| apr_sleep(read_delay); | |
| } | |
| @@ -343,7 +343,7 @@ static int curltest_tweak_handler(request_rec *r) | |
| apr_bucket_brigade *bb; | |
| apr_bucket *b; | |
| apr_status_t rv; | |
| - | char buffer[16*1024]; |
| + | char buffer[16 * 1024]; |
| int i, chunks = 3, error_bucket = 1; | |
| size_t chunk_size = sizeof(buffer); | |
| const char *request_id = "none"; | |
| @@ -579,7 +579,7 @@ static int curltest_put_handler(request_rec *r) | |
| apr_bucket_brigade *bb; | |
| apr_bucket *b; | |
| apr_status_t rv; | |
| - | char buffer[128*1024]; |
| + | char buffer[128 * 1024]; |
| const char *ct; | |
| apr_off_t rbody_len = 0; | |
| apr_off_t rbody_max_len = -1; | |
| @@ -650,8 +650,7 @@ static int curltest_put_handler(request_rec *r) | |
| ap_set_content_type(r, ct ? ct : "text/plain"); | |
| if(read_delay) { | |
| - | ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r, |
| - | "put_handler: read_delay"); |
| + | ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r, "put_handler: read_delay"); |
| apr_sleep(read_delay); | |
| } | |
| bb = apr_brigade_create(r->pool, c->bucket_alloc); | |
| @@ -674,7 +673,7 @@ static int curltest_put_handler(request_rec *r) | |
| } | |
| } | |
| /* we are done */ | |
| - | s_rbody_len = apr_psprintf(r->pool, "%"APR_OFF_T_FMT, rbody_len); |
| + | s_rbody_len = apr_psprintf(r->pool, "%" APR_OFF_T_FMT, rbody_len); |
| apr_table_setn(r->headers_out, "Received-Length", s_rbody_len); | |
| rv = apr_brigade_puts(bb, NULL, NULL, s_rbody_len); | |
| if(APR_SUCCESS != rv) | |
| @@ -38,8 +38,7 @@ static void usage_h2_pausing(const char *msg) | |
| ); | |
| } | |
| - | struct handle |
| - | { |
| + | struct handle { |
| size_t idx; | |
| int paused; | |
| int resumed; | |
| @@ -51,7 +50,7 @@ struct handle | |
| static size_t cb(char *data, size_t size, size_t nmemb, void *clientp) | |
| { | |
| size_t realsize = size * nmemb; | |
| - | struct handle *handle = (struct handle *) clientp; |
| + | struct handle *handle = (struct handle *)clientp; |
| curl_off_t totalsize; | |
| (void)data; | |
| @@ -163,7 +162,7 @@ static CURLcode test_cli_h2_pausing(const char *URL) | |
| goto cleanup; | |
| } | |
| memset(&resolve, 0, sizeof(resolve)); | |
| - | curl_msnprintf(resolve_buf, sizeof(resolve_buf)-1, "%s:%s:127.0.0.1", |
| + | curl_msnprintf(resolve_buf, sizeof(resolve_buf) - 1, "%s:%s:127.0.0.1", |
| host, port); | |
| resolve = curl_slist_append(resolve, resolve_buf); | |
| @@ -120,7 +120,7 @@ static CURLcode test_cli_h2_upgrade_extreme(const char *URL) | |
| curl_easy_getinfo(msg->easy_handle, CURLINFO_XFER_ID, &xfer_id); | |
| curl_easy_getinfo(msg->easy_handle, CURLINFO_RESPONSE_CODE, &status); | |
| if(msg->data.result == CURLE_SEND_ERROR || | |
| - | msg->data.result == CURLE_RECV_ERROR) { |
| + | msg->data.result == CURLE_RECV_ERROR) { |
| /* We get these if the server had a GOAWAY in transit on | |
| * reusing a connection */ | |
| } | |
| @@ -88,7 +88,7 @@ static size_t my_write_d_cb(char *buf, size_t nitems, size_t buflen, | |
| "pause_at=%" CURL_FORMAT_CURL_OFF_T "\n", | |
| t->idx, blen, t->recv_size, t->pause_at); | |
| if(!t->out) { | |
| - | curl_msnprintf(t->filename, sizeof(t->filename)-1, "download_%zu.data", |
| + | curl_msnprintf(t->filename, sizeof(t->filename) - 1, "download_%zu.data", |
| t->idx); | |
| t->out = curlx_fopen(t->filename, "wb"); | |
| if(!t->out) | |
| @@ -149,7 +149,7 @@ static int my_progress_d_cb(void *userdata, | |
| switch(tls->backend) { | |
| #if defined(USE_QUICHE) || defined(USE_OPENSSL) | |
| case CURLSSLBACKEND_OPENSSL: { | |
| - | const char *version = SSL_get_version((SSL*)tls->internals); |
| + | const char *version = SSL_get_version((SSL *)tls->internals); |
| assert(version); | |
| assert(strcmp(version, "unknown")); | |
| curl_mfprintf(stderr, "[t-%zu] info OpenSSL using %s\n", | |
| @@ -159,7 +159,7 @@ static int my_progress_d_cb(void *userdata, | |
| #endif | |
| #ifdef USE_WOLFSSL | |
| case CURLSSLBACKEND_WOLFSSL: { | |
| - | const char *version = wolfSSL_get_version((WOLFSSL*)tls->internals); |
| + | const char *version = wolfSSL_get_version((WOLFSSL *)tls->internals); |
| assert(version); | |
| assert(strcmp(version, "unknown")); | |
| curl_mfprintf(stderr, "[t-%zu] info wolfSSL using %s\n", | |
| @@ -72,7 +72,7 @@ static size_t my_write_u_cb(char *buf, size_t nitems, size_t buflen, | |
| "pause_at=%" CURL_FORMAT_CURL_OFF_T "\n", | |
| t->idx, blen, t->recv_size, t->pause_at); | |
| if(!t->out) { | |
| - | curl_msnprintf(t->filename, sizeof(t->filename)-1, "download_%zu.data", |
| + | curl_msnprintf(t->filename, sizeof(t->filename) - 1, "download_%zu.data", |
| t->idx); | |
| t->out = curlx_fopen(t->filename, "wb"); | |
| if(!t->out) | |
| @@ -462,7 +462,6 @@ static CURLcode test_cli_hx_upload(const char *URL) | |
| } | |
| } | |
| - | |
| /* nothing happening, maintenance */ | |
| if(abort_paused) { | |
| /* abort paused transfers */ | |
| @@ -83,7 +83,6 @@ static CURL *tse_add_transfer(CURLM *multi, CURLSH *share, | |
| if(resolve) | |
| curl_easy_setopt(curl, CURLOPT_RESOLVE, resolve); | |
| - | |
| mc = curl_multi_add_handle(multi, curl); | |
| if(mc != CURLM_OK) { | |
| curl_mfprintf(stderr, "curl_multi_add_handle: %s\n", | |
| @@ -144,7 +143,7 @@ static CURLcode test_cli_tls_session_reuse(const char *URL) | |
| goto cleanup; | |
| } | |
| - | curl_msnprintf(resolve_buf, sizeof(resolve_buf)-1, "%s:%s:127.0.0.1", |
| + | curl_msnprintf(resolve_buf, sizeof(resolve_buf) - 1, "%s:%s:127.0.0.1", |
| host, port); | |
| resolve = curl_slist_append(resolve, resolve_buf); | |
| @@ -161,7 +160,6 @@ static CURLcode test_cli_tls_session_reuse(const char *URL) | |
| } | |
| curl_share_setopt(share, CURLSHOPT_SHARE, CURL_LOCK_DATA_SSL_SESSION); | |
| - | |
| if(!tse_add_transfer(multi, share, resolve, URL, http_version)) | |
| goto cleanup; | |
| ++ongoing; | |
| @@ -205,7 +203,7 @@ static CURLcode test_cli_tls_session_reuse(const char *URL) | |
| curl_easy_getinfo(msg->easy_handle, CURLINFO_XFER_ID, &xfer_id); | |
| curl_easy_getinfo(msg->easy_handle, CURLINFO_RESPONSE_CODE, &status); | |
| if(msg->data.result == CURLE_SEND_ERROR || | |
| - | msg->data.result == CURLE_RECV_ERROR) { |
| + | msg->data.result == CURLE_RECV_ERROR) { |
| /* We get these if the server had a GOAWAY in transit on | |
| * reusing a connection */ | |
| } | |
| @@ -154,7 +154,7 @@ static CURLcode test_cli_upload_pausing(const char *URL) | |
| goto cleanup; | |
| } | |
| memset(&resolve, 0, sizeof(resolve)); | |
| - | curl_msnprintf(resolve_buf, sizeof(resolve_buf)-1, "%s:%s:127.0.0.1", |
| + | curl_msnprintf(resolve_buf, sizeof(resolve_buf) - 1, "%s:%s:127.0.0.1", |
| host, port); | |
| resolve = curl_slist_append(resolve, resolve_buf); | |
| @@ -27,10 +27,9 @@ | |
| #ifndef CURL_DISABLE_WEBSOCKETS | |
| - | static CURLcode |
| - | test_ws_data_m2_check_recv(const struct curl_ws_frame *frame, |
| - | size_t r_offset, size_t nread, |
| - | size_t exp_len) |
| + | static CURLcode test_ws_data_m2_check_recv(const struct curl_ws_frame *frame, |
| + | size_t r_offset, size_t nread, |
| + | size_t exp_len) |
| { | |
| if(!frame) | |
| return CURLE_OK; | |
| @@ -362,7 +361,6 @@ static CURLcode test_ws_data_m1_echo(const char *url, | |
| r = CURLE_RECV_ERROR; | |
| goto out; | |
| } | |
| - | |
| } | |
| curl_multi_remove_handle(multi, m1_ctx.curl); | |
| @@ -393,7 +391,6 @@ out: | |
| return r; | |
| } | |
| - | |
| static void test_ws_data_usage(const char *msg) | |
| { | |
| if(msg) | |
| @@ -62,7 +62,7 @@ int unitfail; /* for unittests */ | |
| int coptind; | |
| const char *coptarg; | |
| - | int cgetopt(int argc, const char * const argv[], const char *optstring) |
| + | int cgetopt(int argc, const char *const argv[], const char *optstring) |
| { | |
| static int optpos = 1; | |
| int coptopt; | |
| @@ -204,7 +204,6 @@ void ws_close(CURL *curl) | |
| } | |
| #endif /* CURL_DISABLE_WEBSOCKETS */ | |
| - | |
| int main(int argc, const char **argv) | |
| { | |
| const char *URL = ""; | |
| @@ -79,7 +79,7 @@ extern struct curltime tv_test_start; /* for test timing */ | |
| extern int coptind; | |
| extern const char *coptarg; | |
| - | int cgetopt(int argc, const char * const argv[], const char *optstring); |
| + | int cgetopt(int argc, const char *const argv[], const char *optstring); |
| extern int select_wrapper(int nfds, fd_set *rd, fd_set *wr, fd_set *exc, | |
| struct timeval *tv); | |
| @@ -96,27 +96,27 @@ static int onetest(CURL *curl, const char *url, const struct testparams *p, | |
| test_setopt(curl, CURLOPT_VERBOSE, 1L); | |
| test_setopt(curl, CURLOPT_RESUME_FROM, (p->flags & F_RESUME) ? 3L : 0L); | |
| test_setopt(curl, CURLOPT_RANGE, !(p->flags & F_RESUME) ? | |
| - | "3-1000000": (char *)NULL); |
| + | "3-1000000" : (char *)NULL); |
| test_setopt(curl, CURLOPT_FAILONERROR, (p->flags & F_FAIL) ? 1L : 0L); | |
| hasbody = 0; | |
| res = curl_easy_perform(curl); | |
| if(res != p->res) { | |
| curl_mprintf("%zu: bad error code (%d): resume=%s, fail=%s, http416=%s, " | |
| "content-range=%s, expected=%d\n", num, res, | |
| - | (p->flags & F_RESUME) ? "yes": "no", |
| - | (p->flags & F_FAIL) ? "yes": "no", |
| - | (p->flags & F_HTTP416) ? "yes": "no", |
| - | (p->flags & F_CONTENTRANGE) ? "yes": "no", |
| + | (p->flags & F_RESUME) ? "yes" : "no", |
| + | (p->flags & F_FAIL) ? "yes" : "no", |
| + | (p->flags & F_HTTP416) ? "yes" : "no", |
| + | (p->flags & F_CONTENTRANGE) ? "yes" : "no", |
| p->res); | |
| return 1; | |
| } | |
| if(hasbody && (p->flags & F_IGNOREBODY)) { | |
| curl_mprintf("body should be ignored and is not: resume=%s, fail=%s, " | |
| "http416=%s, content-range=%s\n", | |
| - | (p->flags & F_RESUME) ? "yes": "no", |
| - | (p->flags & F_FAIL) ? "yes": "no", |
| - | (p->flags & F_HTTP416) ? "yes": "no", |
| - | (p->flags & F_CONTENTRANGE) ? "yes": "no"); |
| + | (p->flags & F_RESUME) ? "yes" : "no", |
| + | (p->flags & F_FAIL) ? "yes" : "no", |
| + | (p->flags & F_HTTP416) ? "yes" : "no", |
| + | (p->flags & F_CONTENTRANGE) ? "yes" : "no"); |
| return 1; | |
| } | |
| return 0; | |
| @@ -26,7 +26,7 @@ | |
| static size_t print_httppost_callback(void *arg, const char *buf, size_t len) | |
| { | |
| fwrite(buf, len, 1, stdout); | |
| - | (*(size_t *) arg) += len; |
| + | (*(size_t *)arg) += len; |
| return len; | |
| } | |
| @@ -37,7 +37,7 @@ static size_t t1514_read_cb(char *ptr, size_t size, size_t nmemb, void *userp) | |
| { | |
| struct t1514_WriteThis *pooh = (struct t1514_WriteThis *)userp; | |
| - | if(size*nmemb < 1) |
| + | if(size * nmemb < 1) |
| return 0; | |
| if(pooh->sizeleft) { | |
| @@ -98,7 +98,6 @@ static CURLcode test_lib1517(const char *URL) | |
| /* detect HTTP error codes >= 400 */ | |
| /* test_setopt(curl, CURLOPT_FAILONERROR, 1L); */ | |
| - | |
| /* Perform the request, res will get the return code */ | |
| res = curl_easy_perform(curl); | |
| @@ -46,7 +46,7 @@ static size_t t1520_read_cb(char *ptr, size_t size, size_t nmemb, void *userp) | |
| struct upload_status *upload_ctx = (struct upload_status *)userp; | |
| const char *data; | |
| - | if((size == 0) || (nmemb == 0) || ((size*nmemb) < 1)) { |
| + | if((size == 0) || (nmemb == 0) || ((size * nmemb) < 1)) { |
| return 0; | |
| } | |
| @@ -78,7 +78,7 @@ static CURLcode test_lib1522(const char *URL) | |
| curl_mprintf("uploadSize = %" CURL_FORMAT_CURL_OFF_T "\n", uploadSize); | |
| - | if((size_t) uploadSize == sizeof(g_Data)) { |
| + | if((size_t)uploadSize == sizeof(g_Data)) { |
| curl_mprintf("!!!!!!!!!! PASS\n"); | |
| } | |
| else { | |
| @@ -41,7 +41,7 @@ static size_t t1523_write_cb(char *d, size_t n, size_t l, void *p) | |
| /* take care of the data here, ignored in this example */ | |
| (void)d; | |
| (void)p; | |
| - | return n*l; |
| + | return n * l; |
| } | |
| static CURLcode run(CURL *curl, long limit, long time) | |
| @@ -34,7 +34,7 @@ static const char t1525_testdata[] = "Hello Cloud!\n"; | |
| static size_t t1525_read_cb(char *ptr, size_t size, size_t nmemb, void *stream) | |
| { | |
| - | size_t amount = nmemb * size; /* Total bytes curl wants */ |
| + | size_t amount = nmemb * size; /* Total bytes curl wants */ |
| if(amount < strlen(t1525_testdata)) { | |
| return strlen(t1525_testdata); | |
| } | |
| @@ -33,7 +33,7 @@ static const char t1526_testdata[] = "Hello Cloud!\n"; | |
| static size_t t1526_read_cb(char *ptr, size_t size, size_t nmemb, void *stream) | |
| { | |
| - | size_t amount = nmemb * size; /* Total bytes curl wants */ |
| + | size_t amount = nmemb * size; /* Total bytes curl wants */ |
| if(amount < strlen(t1526_testdata)) { | |
| return strlen(t1526_testdata); | |
| } | |
| @@ -33,7 +33,7 @@ static const char t1527_testdata[] = "Hello Cloud!\n"; | |
| static size_t t1527_read_cb(char *ptr, size_t size, size_t nmemb, void *stream) | |
| { | |
| - | size_t amount = nmemb * size; /* Total bytes curl wants */ |
| + | size_t amount = nmemb * size; /* Total bytes curl wants */ |
| if(amount < strlen(t1527_testdata)) { | |
| return strlen(t1527_testdata); | |
| } | |
| @@ -119,7 +119,6 @@ static CURLcode perform_and_check_connections(CURL *curl, | |
| return TEST_ERR_SUCCESS; | |
| } | |
| - | |
| static CURLcode test_lib1533(const char *URL) | |
| { | |
| struct cb_data data; | |
| @@ -36,7 +36,7 @@ static CURLcode test_lib1534(const char *URL) | |
| easy_init(curl); | |
| /* Test that a filetime is properly initialized on curl_easy_init. | |
| - | */ |
| + | */ |
| res = curl_easy_getinfo(curl, CURLINFO_FILETIME, &filetime); | |
| if(res) { | |
| @@ -65,7 +65,7 @@ static CURLcode test_lib1534(const char *URL) | |
| } | |
| /* Test that a filetime is properly set after receiving an HTTP resource. | |
| - | */ |
| + | */ |
| res = curl_easy_getinfo(curl, CURLINFO_FILETIME, &filetime); | |
| if(res) { | |
| @@ -83,7 +83,7 @@ static CURLcode test_lib1534(const char *URL) | |
| } | |
| /* Test that a filetime is properly initialized on curl_easy_duphandle. | |
| - | */ |
| + | */ |
| dupe = curl_easy_duphandle(curl); | |
| if(!dupe) { | |
| @@ -109,7 +109,7 @@ static CURLcode test_lib1534(const char *URL) | |
| } | |
| /* Test that a filetime is properly initialized on curl_easy_reset. | |
| - | */ |
| + | */ |
| curl_easy_reset(curl); | |
| @@ -36,7 +36,7 @@ static CURLcode test_lib1535(const char *URL) | |
| easy_init(curl); | |
| /* Test that protocol is properly initialized on curl_easy_init. | |
| - | */ |
| + | */ |
| res = curl_easy_getinfo(curl, CURLINFO_PROTOCOL, &protocol); | |
| @@ -65,7 +65,7 @@ static CURLcode test_lib1535(const char *URL) | |
| } | |
| /* Test that a protocol is properly set after receiving an HTTP resource. | |
| - | */ |
| + | */ |
| res = curl_easy_getinfo(curl, CURLINFO_PROTOCOL, &protocol); | |
| @@ -85,7 +85,7 @@ static CURLcode test_lib1535(const char *URL) | |
| } | |
| /* Test that a protocol is properly initialized on curl_easy_duphandle. | |
| - | */ |
| + | */ |
| dupe = curl_easy_duphandle(curl); | |
| if(!dupe) { | |
| @@ -112,7 +112,7 @@ static CURLcode test_lib1535(const char *URL) | |
| } | |
| /* Test that a protocol is properly initialized on curl_easy_reset. | |
| - | */ |
| + | */ |
| curl_easy_reset(curl); | |
| @@ -36,7 +36,7 @@ static CURLcode test_lib1536(const char *URL) | |
| easy_init(curl); | |
| /* Test that scheme is properly initialized on curl_easy_init. | |
| - | */ |
| + | */ |
| res = curl_easy_getinfo(curl, CURLINFO_SCHEME, &scheme); | |
| if(res) { | |
| @@ -64,7 +64,7 @@ static CURLcode test_lib1536(const char *URL) | |
| } | |
| /* Test that a scheme is properly set after receiving an HTTP resource. | |
| - | */ |
| + | */ |
| res = curl_easy_getinfo(curl, CURLINFO_SCHEME, &scheme); | |
| if(res) { | |
| @@ -83,7 +83,7 @@ static CURLcode test_lib1536(const char *URL) | |
| } | |
| /* Test that a scheme is properly initialized on curl_easy_duphandle. | |
| - | */ |
| + | */ |
| dupe = curl_easy_duphandle(curl); | |
| if(!dupe) { | |
| @@ -108,7 +108,7 @@ static CURLcode test_lib1536(const char *URL) | |
| } | |
| /* Test that a scheme is properly initialized on curl_easy_reset. | |
| - | */ |
| + | */ |
| curl_easy_reset(curl); | |
| @@ -25,7 +25,7 @@ | |
| static CURLcode test_lib1559(const char *URL) | |
| { | |
| - | static const int EXCESSIVE = 10*1000*1000; |
| + | static const int EXCESSIVE = 10 * 1000 * 1000; |
| CURLcode res = CURLE_OK; | |
| CURL *curl = NULL; | |
| @@ -43,7 +43,7 @@ static CURLcode test_lib1559(const char *URL) | |
| } | |
| memset(longurl, 'a', EXCESSIVE); | |
| - | longurl[EXCESSIVE-1] = 0; |
| + | longurl[EXCESSIVE - 1] = 0; |
| res = curl_easy_setopt(curl, CURLOPT_URL, longurl); | |
| curl_mprintf("CURLOPT_URL %d bytes URL == %d\n", | |
| @@ -68,10 +68,10 @@ static int checkparts(CURLU *u, const char *in, const char *wanted, | |
| size_t n; | |
| rc = curl_url_get(u, parts[i].part, &p, getflags); | |
| if(!rc && p) { | |
| - | curl_msnprintf(bufp, len, "%s%s", buf[0]?" | ":"", p); |
| + | curl_msnprintf(bufp, len, "%s%s", buf[0] ? " | " : "", p); |
| } | |
| else | |
| - | curl_msnprintf(bufp, len, "%s[%d]", buf[0]?" | ":"", rc); |
| + | curl_msnprintf(bufp, len, "%s[%d]", buf[0] ? " | " : "", rc); |
| n = strlen(bufp); | |
| bufp += n; | |
| @@ -80,7 +80,7 @@ static CURLcode test_lib1597(const char *URL) | |
| n = 0; | |
| for(proto = curlinfo->protocols; *proto; proto++) { | |
| - | if((size_t) n >= sizeof(protolist)) { |
| + | if((size_t)n >= sizeof(protolist)) { |
| puts("protolist buffer too small\n"); | |
| res = TEST_ERR_FAILURE; | |
| goto test_cleanup; | |
| @@ -34,7 +34,7 @@ static size_t t1662_read_cb(char *ptr, size_t size, size_t nmemb, void *userp) | |
| struct t1662_WriteThis *pooh = (struct t1662_WriteThis *)userp; | |
| size_t len = strlen(testdata); | |
| - | if(size*nmemb < len) |
| + | if(size * nmemb < len) |
| return 0; | |
| if(pooh->sizeleft) { | |
| @@ -30,8 +30,7 @@ struct state { | |
| }; | |
| /* "read" is from the point of the library, it wants data from us */ | |
| - | static CURLSTScode hstsread(CURL *curl, struct curl_hstsentry *e, |
| - | void *userp) |
| + | static CURLSTScode hstsread(CURL *curl, struct curl_hstsentry *e, void *userp) |
| { | |
| struct entry { | |
| const char *name; | |
| @@ -33,9 +33,9 @@ static CURLcode test_lib1919(const char *URL) | |
| easy_init(curl); | |
| easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_BEARER); | |
| easy_setopt(curl, CURLOPT_XOAUTH2_BEARER, | |
| - | "c4e448d652a961fda0ab64f882c8c161d5985f805d45d80c9ddca1"); |
| + | "c4e448d652a961fda0ab64f882c8c161d5985f805d45d80c9ddca1"); |
| easy_setopt(curl, CURLOPT_SASL_AUTHZID, | |
| - | "c4e448d652a961fda0ab64f882c8c161d5985f805d45d80c9ddca2"); |
| + | "c4e448d652a961fda0ab64f882c8c161d5985f805d45d80c9ddca2"); |
| easy_setopt(curl, CURLOPT_URL, URL); | |
| for(i = 0; i < 2; i++) { | |
| @@ -28,7 +28,7 @@ static size_t t1940_write_cb(char *data, size_t n, size_t l, void *userp) | |
| /* take care of the data here, ignored in this example */ | |
| (void)data; | |
| (void)userp; | |
| - | return n*l; |
| + | return n * l; |
| } | |
| static void t1940_showem(CURL *curl, int header_request, unsigned int type) | |
| @@ -41,7 +41,7 @@ static size_t t1945_write_cb(char *data, size_t n, size_t l, void *userp) | |
| /* take care of the data here, ignored in this example */ | |
| (void)data; | |
| (void)userp; | |
| - | return n*l; |
| + | return n * l; |
| } | |
| static CURLcode test_lib1945(const char *URL) | |
| @@ -67,7 +67,7 @@ static CURLcode test_lib1945(const char *URL) | |
| if(res) { | |
| curl_mprintf("badness: %d\n", res); | |
| } | |
| - | t1945_showem(curl, CURLH_CONNECT|CURLH_HEADER|CURLH_TRAILER|CURLH_1XX); |
| + | t1945_showem(curl, CURLH_CONNECT | CURLH_HEADER | CURLH_TRAILER | CURLH_1XX); |
| test_cleanup: | |
| curl_easy_cleanup(curl); | |
| @@ -28,7 +28,7 @@ static size_t t1947_write_cb(char *data, size_t n, size_t l, void *userp) | |
| /* ignore the data */ | |
| (void)data; | |
| (void)userp; | |
| - | return n*l; |
| + | return n * l; |
| } | |
| static CURLcode test_lib1947(const char *URL) | |
| @@ -56,8 +56,8 @@ static CURLcode test_lib1947(const char *URL) | |
| /* count the number of requests by reading the first header of each | |
| request. */ | |
| - | origins = (CURLH_HEADER|CURLH_TRAILER|CURLH_CONNECT| |
| - | CURLH_1XX|CURLH_PSEUDO); |
| + | origins = CURLH_HEADER | CURLH_TRAILER | CURLH_CONNECT | CURLH_1XX | |
| + | CURLH_PSEUDO; |
| do { | |
| h = curl_easy_nextheader(curl, origins, count, NULL); | |
| if(h) | |
| @@ -23,15 +23,14 @@ | |
| ***************************************************************************/ | |
| #include "first.h" | |
| - | typedef struct |
| - | { |
| + | struct put_buffer { |
| const char *buf; | |
| size_t len; | |
| - | } put_buffer; |
| + | }; |
| static size_t put_callback(char *ptr, size_t size, size_t nmemb, void *stream) | |
| { | |
| - | put_buffer *putdata = (put_buffer *)stream; |
| + | struct put_buffer *putdata = (struct put_buffer *)stream; |
| size_t totalsize = size * nmemb; | |
| size_t tocopy = (putdata->len < totalsize) ? putdata->len : totalsize; | |
| memcpy(ptr, putdata->buf, tocopy); | |
| @@ -45,7 +44,7 @@ static CURLcode test_lib1948(const char *URL) | |
| CURL *curl; | |
| CURLcode res = CURLE_OK; | |
| static const char *testput = "This is test PUT data\n"; | |
| - | put_buffer pbuf; |
| + | struct put_buffer pbuf; |
| curl_global_init(CURL_GLOBAL_DEFAULT); | |
| @@ -63,12 +63,11 @@ static int sockopt_cb(void *clientp, | |
| } | |
| #ifdef __AMIGA__ | |
| - | #define my_inet_pton(x,y,z) inet_pton(x,(unsigned char *)y,z) |
| + | #define my_inet_pton(x, y, z) inet_pton(x, (unsigned char *)y, z) |
| #else | |
| - | #define my_inet_pton(x,y,z) inet_pton(x,y,z) |
| + | #define my_inet_pton(x, y, z) inet_pton(x, y, z) |
| #endif | |
| - | |
| /* Expected args: URL IP PORT */ | |
| static CURLcode test_lib1960(const char *URL) | |
| { | |
| @@ -109,7 +108,8 @@ static CURLcode test_lib1960(const char *URL) | |
| goto test_cleanup; | |
| } | |
| - | status = connect(client_fd, (struct sockaddr*)&serv_addr, sizeof(serv_addr)); |
| + | status = connect(client_fd, (struct sockaddr *)&serv_addr, |
| + | sizeof(serv_addr)); |
| if(status < 0) { | |
| curl_mfprintf(stderr, "connection failed\n"); | |
| goto test_cleanup; | |
| @@ -48,7 +48,6 @@ static CURLcode test_lib1977(const char *URL) | |
| goto test_cleanup; | |
| curl_mprintf("effective URL: %s\n", effective); | |
| - | |
| /* second transfer: set URL + query in the second CURLU handle */ | |
| curl_url_set(curlu_2, CURLUPART_URL, URL, CURLU_DEFAULT_SCHEME); | |
| curl_url_set(curlu_2, CURLUPART_QUERY, "foo", 0); | |
| @@ -64,7 +63,6 @@ static CURLcode test_lib1977(const char *URL) | |
| goto test_cleanup; | |
| curl_mprintf("effective URL: %s\n", effective); | |
| - | |
| /* third transfer: append extra query in the second CURLU handle, but do not | |
| set CURLOPT_CURLU again. this is to test that the contents of the handle | |
| is allowed to change between transfers and is used without having to set | |
| @@ -81,7 +79,6 @@ static CURLcode test_lib1977(const char *URL) | |
| goto test_cleanup; | |
| curl_mprintf("effective URL: %s\n", effective); | |
| - | |
| test_cleanup: | |
| curl_easy_cleanup(curl); | |
| curl_url_cleanup(curlu); | |
| @@ -90,7 +90,7 @@ static CURLcode test_lib2023(const char *URL) /* libauthretry */ | |
| long fallback_auth_scheme = parse_auth_name(libtest_arg3); | |
| if(main_auth_scheme == CURLAUTH_NONE || | |
| - | fallback_auth_scheme == CURLAUTH_NONE) { |
| + | fallback_auth_scheme == CURLAUTH_NONE) { |
| curl_mfprintf(stderr, "auth schemes not found on commandline\n"); | |
| return TEST_ERR_MAJOR_BAD; | |
| } | |
| @@ -32,7 +32,7 @@ static CURLcode ntlmcb_res = CURLE_OK; | |
| static size_t callback(char *ptr, size_t size, size_t nmemb, void *data) | |
| { | |
| - | ssize_t idx = ((CURL **) data) - ntlm_curls; |
| + | ssize_t idx = ((CURL **)data) - ntlm_curls; |
| curl_socket_t sock; | |
| long longdata; | |
| CURLcode code; | |
| @@ -195,8 +195,8 @@ static CURLcode test_lib2032(const char *URL) /* libntlmconnect */ | |
| #else | |
| itimeout = (int)timeout; | |
| #endif | |
| - | interval.tv_sec = itimeout/1000; |
| - | interval.tv_usec = (itimeout%1000)*1000; |
| + | interval.tv_sec = itimeout / 1000; |
| + | interval.tv_usec = (itimeout % 1000) * 1000; |
| } | |
| else { | |
| interval.tv_sec = 0; | |
| @@ -38,8 +38,7 @@ static CURLcode test_lib2402(const char *URL) | |
| (void)URL; | |
| - | curl_msnprintf(dnsentry, sizeof(dnsentry), "localhost:%s:%s", |
| - | port, address); |
| + | curl_msnprintf(dnsentry, sizeof(dnsentry), "localhost:%s:%s", port, address); |
| curl_mprintf("%s\n", dnsentry); | |
| slist = curl_slist_append(slist, dnsentry); | |
| if(!slist) { | |
| @@ -61,8 +60,7 @@ static CURLcode test_lib2402(const char *URL) | |
| easy_init(curl[i]); | |
| /* specify target */ | |
| curl_msnprintf(target_url, sizeof(target_url), | |
| - | "https://localhost:%s/path/2402%04zu", |
| - | port, i + 1); |
| + | "https://localhost:%s/path/2402%04zu", port, i + 1); |
| target_url[sizeof(target_url) - 1] = '\0'; | |
| easy_setopt(curl[i], CURLOPT_URL, target_url); | |
| /* go http2 */ | |
| @@ -38,8 +38,7 @@ static CURLcode test_lib2404(const char *URL) | |
| (void)URL; | |
| - | curl_msnprintf(dnsentry, sizeof(dnsentry), "localhost:%s:%s", |
| - | port, address); |
| + | curl_msnprintf(dnsentry, sizeof(dnsentry), "localhost:%s:%s", port, address); |
| curl_mprintf("%s\n", dnsentry); | |
| slist = curl_slist_append(slist, dnsentry); | |
| if(!slist) { | |
| @@ -61,8 +60,7 @@ static CURLcode test_lib2404(const char *URL) | |
| easy_init(curl[i]); | |
| /* specify target */ | |
| curl_msnprintf(target_url, sizeof(target_url), | |
| - | "https://localhost:%s/path/2404%04zu", |
| - | port, i + 1); |
| + | "https://localhost:%s/path/2404%04zu", port, i + 1); |
| target_url[sizeof(target_url) - 1] = '\0'; | |
| easy_setopt(curl[i], CURLOPT_URL, target_url); | |
| /* go http2 */ | |
| @@ -66,9 +66,10 @@ enum { | |
| TEST_USE_HTTP2_MPLEX | |
| }; | |
| - | static size_t emptyWriteFunc(char *ptr, size_t size, size_t nmemb, |
| - | void *data) { |
| - | (void)ptr; (void)data; |
| + | static size_t emptyWriteFunc(char *ptr, size_t size, size_t nmemb, void *data) |
| + | { |
| + | (void)ptr; |
| + | (void)data; |
| return size * nmemb; | |
| } | |
| @@ -40,8 +40,7 @@ static CURLcode test_lib2502(const char *URL) | |
| (void)URL; | |
| - | curl_msnprintf(dnsentry, sizeof(dnsentry), "localhost:%s:%s", |
| - | port, address); |
| + | curl_msnprintf(dnsentry, sizeof(dnsentry), "localhost:%s:%s", port, address); |
| curl_mprintf("%s\n", dnsentry); | |
| slist = curl_slist_append(slist, dnsentry); | |
| if(!slist) { | |
| @@ -63,8 +62,7 @@ static CURLcode test_lib2502(const char *URL) | |
| easy_init(curl[i]); | |
| /* specify target */ | |
| curl_msnprintf(target_url, sizeof(target_url), | |
| - | "https://localhost:%s/path/2502%04zu", |
| - | port, i + 1); |
| + | "https://localhost:%s/path/2502%04zu", port, i + 1); |
| target_url[sizeof(target_url) - 1] = '\0'; | |
| easy_setopt(curl[i], CURLOPT_URL, target_url); | |
| /* go http2 */ | |
| @@ -120,8 +120,7 @@ static CURLcode send_chunk(CURL *curl, int flags, const char *buffer, | |
| size_t nsent; | |
| retry: | |
| - | res = curl_ws_send(curl, buffer + *offset, size - *offset, &nsent, 0, |
| - | flags); |
| + | res = curl_ws_send(curl, buffer + *offset, size - *offset, &nsent, 0, flags); |
| if(res == CURLE_AGAIN) { | |
| assert(nsent == 0); | |
| goto retry; | |
| @@ -33,8 +33,7 @@ static CURLcode t3033_req_test(CURLM *multi, CURL *curl, | |
| int still_running = 0; | |
| if(index == 1) { | |
| - | curl_multi_setopt(multi, CURLMOPT_NETWORK_CHANGED, |
| - | CURLMNWC_CLEAR_CONNS); |
| + | curl_multi_setopt(multi, CURLMOPT_NETWORK_CHANGED, CURLMNWC_CLEAR_CONNS); |
| curl_mprintf("[1] signal network change\n"); | |
| } | |
| else { | |
| @@ -47,11 +47,11 @@ static bool is_chain_in_order(struct curl_certinfo *cert_info) | |
| static const char issuer_prefix[] = "Issuer:"; | |
| static const char subject_prefix[] = "Subject:"; | |
| - | if(!strncmp(slist->data, issuer_prefix, sizeof(issuer_prefix)-1)) { |
| - | issuer = slist->data + sizeof(issuer_prefix)-1; |
| + | if(!strncmp(slist->data, issuer_prefix, sizeof(issuer_prefix) - 1)) { |
| + | issuer = slist->data + sizeof(issuer_prefix) - 1; |
| } | |
| - | if(!strncmp(slist->data, subject_prefix, sizeof(subject_prefix)-1)) { |
| - | subject = slist->data + sizeof(subject_prefix)-1; |
| + | if(!strncmp(slist->data, subject_prefix, sizeof(subject_prefix) - 1)) { |
| + | subject = slist->data + sizeof(subject_prefix) - 1; |
| } | |
| } | |
| @@ -80,7 +80,7 @@ static bool is_chain_in_order(struct curl_certinfo *cert_info) | |
| return true; | |
| } | |
| - | static size_t wrfu(void *ptr, size_t size, size_t nmemb, void *stream) |
| + | static size_t wrfu(void *ptr, size_t size, size_t nmemb, void *stream) |
| { | |
| (void)stream; | |
| (void)ptr; | |
| @@ -116,7 +116,7 @@ test_cleanup: | |
| static void t3207_test_lock(CURL *curl, curl_lock_data data, | |
| curl_lock_access laccess, void *useptr) | |
| { | |
| - | curl_mutex_t *mutexes = (curl_mutex_t*) useptr; |
| + | curl_mutex_t *mutexes = (curl_mutex_t *)useptr; |
| (void)curl; | |
| (void)laccess; | |
| Curl_mutex_acquire(&mutexes[data]); | |
| @@ -124,7 +124,7 @@ static void t3207_test_lock(CURL *curl, curl_lock_data data, | |
| static void t3207_test_unlock(CURL *curl, curl_lock_data data, void *useptr) | |
| { | |
| - | curl_mutex_t *mutexes = (curl_mutex_t*) useptr; |
| + | curl_mutex_t *mutexes = (curl_mutex_t *)useptr; |
| (void)curl; | |
| Curl_mutex_release(&mutexes[data]); | |
| } | |
| @@ -175,7 +175,7 @@ static CURLcode test_lib3207(const char *URL) | |
| { | |
| CURLcode res = CURLE_OK; | |
| size_t i; | |
| - | CURLSH* share; |
| + | CURLSH *share; |
| struct Ctx ctx[THREAD_SIZE]; | |
| curl_global_init(CURL_GLOBAL_ALL); | |
| @@ -127,8 +127,7 @@ static CURLcode test_lib505(const char *URL) | |
| test_setopt(curl, CURLOPT_READDATA, hd_src); | |
| /* and give the size of the upload (optional) */ | |
| - | test_setopt(curl, CURLOPT_INFILESIZE_LARGE, |
| - | (curl_off_t)file_info.st_size); |
| + | test_setopt(curl, CURLOPT_INFILESIZE_LARGE, (curl_off_t)file_info.st_size); |
| /* Now run off and do what you have been told! */ | |
| res = curl_easy_perform(curl); | |
| @@ -52,21 +52,21 @@ static void t506_test_lock(CURL *curl, curl_lock_data data, | |
| (void)laccess; | |
| switch(data) { | |
| - | case CURL_LOCK_DATA_SHARE: |
| - | what = "share"; |
| - | locknum = 0; |
| - | break; |
| - | case CURL_LOCK_DATA_DNS: |
| - | what = "dns"; |
| - | locknum = 1; |
| - | break; |
| - | case CURL_LOCK_DATA_COOKIE: |
| - | what = "cookie"; |
| - | locknum = 2; |
| - | break; |
| - | default: |
| - | curl_mfprintf(stderr, "lock: no such data: %d\n", data); |
| - | return; |
| + | case CURL_LOCK_DATA_SHARE: |
| + | what = "share"; |
| + | locknum = 0; |
| + | break; |
| + | case CURL_LOCK_DATA_DNS: |
| + | what = "dns"; |
| + | locknum = 1; |
| + | break; |
| + | case CURL_LOCK_DATA_COOKIE: |
| + | what = "cookie"; |
| + | locknum = 2; |
| + | break; |
| + | default: |
| + | curl_mfprintf(stderr, "lock: no such data: %d\n", data); |
| + | return; |
| } | |
| /* detect locking of locked locks */ | |
| @@ -88,21 +88,21 @@ static void t506_test_unlock(CURL *curl, curl_lock_data data, void *useptr) | |
| int locknum; | |
| (void)curl; | |
| switch(data) { | |
| - | case CURL_LOCK_DATA_SHARE: |
| - | what = "share"; |
| - | locknum = 0; |
| - | break; |
| - | case CURL_LOCK_DATA_DNS: |
| - | what = "dns"; |
| - | locknum = 1; |
| - | break; |
| - | case CURL_LOCK_DATA_COOKIE: |
| - | what = "cookie"; |
| - | locknum = 2; |
| - | break; |
| - | default: |
| - | curl_mfprintf(stderr, "unlock: no such data: %d\n", data); |
| - | return; |
| + | case CURL_LOCK_DATA_SHARE: |
| + | what = "share"; |
| + | locknum = 0; |
| + | break; |
| + | case CURL_LOCK_DATA_DNS: |
| + | what = "dns"; |
| + | locknum = 1; |
| + | break; |
| + | case CURL_LOCK_DATA_COOKIE: |
| + | what = "cookie"; |
| + | locknum = 2; |
| + | break; |
| + | default: |
| + | curl_mfprintf(stderr, "unlock: no such data: %d\n", data); |
| + | return; |
| } | |
| /* detect unlocking of unlocked locks */ | |
| @@ -128,7 +128,7 @@ static void *t506_test_fire(void *ptr) | |
| { | |
| CURLcode code; | |
| struct curl_slist *headers; | |
| - | struct t506_Tdata *tdata = (struct t506_Tdata*)ptr; |
| + | struct t506_Tdata *tdata = (struct t506_Tdata *)ptr; |
| CURL *curl; | |
| curl = curl_easy_init(); | |
| @@ -138,9 +138,9 @@ static void *t506_test_fire(void *ptr) | |
| } | |
| headers = sethost(NULL); | |
| - | curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); |
| + | curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); |
| curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers); | |
| - | curl_easy_setopt(curl, CURLOPT_URL, tdata->url); |
| + | curl_easy_setopt(curl, CURLOPT_URL, tdata->url); |
| curl_easy_setopt(curl, CURLOPT_COOKIEFILE, ""); | |
| curl_mprintf("CURLOPT_SHARE\n"); | |
| curl_easy_setopt(curl, CURLOPT_SHARE, tdata->share); | |
| @@ -233,40 +233,38 @@ static CURLcode test_lib506(const char *URL) | |
| return TEST_ERR_MAJOR_BAD; | |
| } | |
| curl_mprintf("CURLOPT_SHARE\n"); | |
| - | test_setopt(curl, CURLOPT_SHARE, share); |
| + | test_setopt(curl, CURLOPT_SHARE, share); |
| curl_mprintf("CURLOPT_COOKIELIST injected_and_clobbered\n"); | |
| test_setopt(curl, CURLOPT_COOKIELIST, | |
| - | "Set-Cookie: injected_and_clobbered=yes; " |
| - | "domain=host.foo.com; expires=Sat Feb 2 11:56:27 GMT 2030"); |
| + | "Set-Cookie: injected_and_clobbered=yes; " |
| + | "domain=host.foo.com; expires=Sat Feb 2 11:56:27 GMT 2030"); |
| curl_mprintf("CURLOPT_COOKIELIST ALL\n"); | |
| test_setopt(curl, CURLOPT_COOKIELIST, "ALL"); | |
| curl_mprintf("CURLOPT_COOKIELIST session\n"); | |
| test_setopt(curl, CURLOPT_COOKIELIST, "Set-Cookie: session=elephants"); | |
| curl_mprintf("CURLOPT_COOKIELIST injected\n"); | |
| test_setopt(curl, CURLOPT_COOKIELIST, | |
| - | "Set-Cookie: injected=yes; domain=host.foo.com; " |
| - | "expires=Sat Feb 2 11:56:27 GMT 2030"); |
| + | "Set-Cookie: injected=yes; domain=host.foo.com; " |
| + | "expires=Sat Feb 2 11:56:27 GMT 2030"); |
| curl_mprintf("CURLOPT_COOKIELIST SESS\n"); | |
| test_setopt(curl, CURLOPT_COOKIELIST, "SESS"); | |
| curl_mprintf("CLEANUP\n"); | |
| curl_easy_cleanup(curl); | |
| - | |
| /* start treads */ | |
| for(i = 1; i <= THREADS; i++) { | |
| /* set thread data */ | |
| - | tdata.url = tutil_suburl(URL, i); /* must be curl_free()d */ |
| + | tdata.url = tutil_suburl(URL, i); /* must be curl_free()d */ |
| tdata.share = share; | |
| /* simulate thread, direct call of "thread" function */ | |
| - | curl_mprintf("*** run %d\n",i); |
| + | curl_mprintf("*** run %d\n", i); |
| t506_test_fire(&tdata); | |
| curl_free(tdata.url); | |
| } | |
| - | |
| /* fetch another one and save cookies */ | |
| curl_mprintf("*** run %d\n", i); | |
| curl = curl_easy_init(); | |
| @@ -280,11 +278,11 @@ static CURLcode test_lib506(const char *URL) | |
| url = tutil_suburl(URL, i); | |
| headers = sethost(NULL); | |
| test_setopt(curl, CURLOPT_HTTPHEADER, headers); | |
| - | test_setopt(curl, CURLOPT_URL, url); |
| + | test_setopt(curl, CURLOPT_URL, url); |
| curl_mprintf("CURLOPT_SHARE\n"); | |
| - | test_setopt(curl, CURLOPT_SHARE, share); |
| + | test_setopt(curl, CURLOPT_SHARE, share); |
| curl_mprintf("CURLOPT_COOKIEJAR\n"); | |
| - | test_setopt(curl, CURLOPT_COOKIEJAR, jar); |
| + | test_setopt(curl, CURLOPT_COOKIEJAR, jar); |
| curl_mprintf("CURLOPT_COOKIELIST FLUSH\n"); | |
| test_setopt(curl, CURLOPT_COOKIELIST, "FLUSH"); | |
| @@ -307,9 +305,9 @@ static CURLcode test_lib506(const char *URL) | |
| url = tutil_suburl(URL, i); | |
| headers = sethost(NULL); | |
| test_setopt(curl, CURLOPT_HTTPHEADER, headers); | |
| - | test_setopt(curl, CURLOPT_URL, url); |
| + | test_setopt(curl, CURLOPT_URL, url); |
| curl_mprintf("CURLOPT_SHARE\n"); | |
| - | test_setopt(curl, CURLOPT_SHARE, share); |
| + | test_setopt(curl, CURLOPT_SHARE, share); |
| curl_mprintf("CURLOPT_COOKIELIST ALL\n"); | |
| test_setopt(curl, CURLOPT_COOKIELIST, "ALL"); | |
| curl_mprintf("CURLOPT_COOKIEJAR\n"); | |
| @@ -32,7 +32,7 @@ static size_t t508_read_cb(char *ptr, size_t size, size_t nmemb, void *userp) | |
| { | |
| struct t508_WriteThis *pooh = (struct t508_WriteThis *)userp; | |
| - | if(size*nmemb < 1) |
| + | if(size * nmemb < 1) |
| return 0; | |
| if(pooh->sizeleft) { | |
| @@ -74,7 +74,6 @@ static void custom_free(void *ptr) | |
| free(ptr); | |
| } | |
| - | |
| static CURLcode test_lib509(const char *URL) | |
| { | |
| static const unsigned char a[] = {0x2f, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, | |
| @@ -40,14 +40,14 @@ static size_t t510_read_cb(char *ptr, size_t size, size_t nmemb, void *userp) | |
| struct t510_WriteThis *pooh = (struct t510_WriteThis *)userp; | |
| const char *data; | |
| - | if(size*nmemb < 1) |
| + | if(size * nmemb < 1) |
| return 0; | |
| data = testpost[pooh->counter]; | |
| if(data) { | |
| size_t len = strlen(data); | |
| - | if(size*nmemb < len) { |
| + | if(size * nmemb < len) { |
| curl_mfprintf(stderr, "read buffer is too small to run test\n"); | |
| return 0; | |
| } | |
| @@ -155,7 +155,6 @@ test_cleanup: | |
| curl_multi_cleanup(multi); | |
| curl_global_cleanup(); | |
| - | |
| } | |
| else if(testnum == 532) { | |
| /* undocumented cleanup sequence - type UB */ | |
| @@ -229,7 +229,7 @@ static ssize_t t530_getMicroSecondTimeout(struct curltime *timeout) | |
| /** | |
| * Update a fd_set with all of the sockets in use. | |
| */ | |
| - | static void t530_updateFdSet(struct t530_Sockets *sockets, fd_set* fdset, |
| + | static void t530_updateFdSet(struct t530_Sockets *sockets, fd_set *fdset, |
| curl_socket_t *maxFd) | |
| { | |
| int i; | |
| @@ -27,8 +27,7 @@ static void proxystat(CURL *curl) | |
| { | |
| long wasproxy; | |
| if(!curl_easy_getinfo(curl, CURLINFO_USED_PROXY, &wasproxy)) { | |
| - | curl_mprintf("This %sthe proxy\n", wasproxy ? "used ": |
| - | "DID NOT use "); |
| + | curl_mprintf("This %sthe proxy\n", wasproxy ? "used " : "DID NOT use "); |
| } | |
| } | |
| @@ -118,7 +118,7 @@ static int t537_test_rlimit(int keep_open) | |
| /* If the OS allows a HUGE number of open files, we do not run. | |
| * Modern debian sid reports a limit of 134217724 and this tests | |
| * takes minutes. */ | |
| - | #define LIMIT_CAP (256*1024) |
| + | #define LIMIT_CAP (256 * 1024) |
| if(rl.rlim_cur > LIMIT_CAP) { | |
| curl_mfprintf(stderr, "soft limit above %ld, not running\n", | |
| (long)LIMIT_CAP); | |
| @@ -138,8 +138,8 @@ static CURLcode loop(int num, CURLM *multi, const char *url, | |
| #else | |
| itimeout = (int)L; | |
| #endif | |
| - | T.tv_sec = itimeout/1000; |
| - | T.tv_usec = (itimeout%1000)*1000; |
| + | T.tv_sec = itimeout / 1000; |
| + | T.tv_usec = (itimeout % 1000) * 1000; |
| } | |
| else { | |
| T.tv_sec = 5; | |
| @@ -29,7 +29,7 @@ | |
| #include "first.h" | |
| static const char t547_uploadthis[] = "this is the blurb we want to upload\n"; | |
| - | #define T547_DATALEN (sizeof(t547_uploadthis)-1) |
| + | #define T547_DATALEN (sizeof(t547_uploadthis) - 1) |
| static size_t t547_read_cb(char *ptr, size_t size, size_t nmemb, void *clientp) | |
| { | |
| @@ -35,10 +35,10 @@ static char databuf[70000]; /* MUST be more than 64k OR | |
| static size_t t552_read_cb(char *ptr, size_t size, size_t nmemb, void *stream) | |
| { | |
| - | size_t amount = nmemb * size; /* Total bytes curl wants */ |
| - | size_t available = sizeof(databuf) - current_offset; /* What we have to |
| - | give */ |
| - | size_t given = amount < available ? amount : available; /* What is given */ |
| + | size_t amount = nmemb * size; /* Total bytes curl wants */ |
| + | size_t available = sizeof(databuf) - current_offset; /* What we have to |
| + | give */ |
| + | size_t given = amount < available ? amount : available; /* What is given */ |
| (void)stream; | |
| memcpy(ptr, databuf + current_offset, given); | |
| current_offset += given; | |
| @@ -32,7 +32,7 @@ static size_t t554_read_cb(char *ptr, size_t size, size_t nmemb, void *userp) | |
| { | |
| struct t554_WriteThis *pooh = (struct t554_WriteThis *)userp; | |
| - | if(size*nmemb < 1) |
| + | if(size * nmemb < 1) |
| return 0; | |
| if(pooh->sizeleft) { | |
| @@ -33,7 +33,7 @@ | |
| #include "first.h" | |
| static const char t555_uploadthis[] = "this is the blurb we want to upload\n"; | |
| - | #define T555_DATALEN (sizeof(t555_uploadthis)-1) |
| + | #define T555_DATALEN (sizeof(t555_uploadthis) - 1) |
| static size_t t555_read_cb(char *ptr, size_t size, size_t nmemb, void *clientp) | |
| { | |
| @@ -48,56 +48,48 @@ | |
| #define BUFSZ 256 | |
| - | |
| struct unsshort_st { | |
| unsigned short num; /* unsigned short */ | |
| const char *expected; /* expected string */ | |
| char result[BUFSZ]; /* result string */ | |
| }; | |
| - | |
| struct sigshort_st { | |
| short num; /* signed short */ | |
| const char *expected; /* expected string */ | |
| char result[BUFSZ]; /* result string */ | |
| }; | |
| - | |
| struct unsint_st { | |
| unsigned int num; /* unsigned int */ | |
| const char *expected; /* expected string */ | |
| char result[BUFSZ]; /* result string */ | |
| }; | |
| - | |
| struct sigint_st { | |
| int num; /* signed int */ | |
| const char *expected; /* expected string */ | |
| char result[BUFSZ]; /* result string */ | |
| }; | |
| - | |
| struct unslong_st { | |
| unsigned long num; /* unsigned long */ | |
| const char *expected; /* expected string */ | |
| char result[BUFSZ]; /* result string */ | |
| }; | |
| - | |
| struct siglong_st { | |
| long num; /* signed long */ | |
| const char *expected; /* expected string */ | |
| char result[BUFSZ]; /* result string */ | |
| }; | |
| - | |
| struct curloff_st { | |
| curl_off_t num; /* curl_off_t */ | |
| const char *expected; /* expected string */ | |
| char result[BUFSZ]; /* result string */ | |
| }; | |
| - | |
| static struct unsshort_st us_test[1 + 100]; | |
| static struct sigshort_st ss_test[1 + 100]; | |
| static struct unsint_st ui_test[1 + 100]; | |
| @@ -106,7 +98,6 @@ static struct unslong_st ul_test[1 + 100]; | |
| static struct siglong_st sl_test[1 + 100]; | |
| static struct curloff_st co_test[1 + 100]; | |
| - | |
| static int test_unsigned_short_formatting(void) | |
| { | |
| int i, j; | |
| @@ -136,7 +127,7 @@ static int test_unsigned_short_formatting(void) | |
| for(j = 0; j < BUFSZ; j++) | |
| us_test[i].result[j] = 'X'; | |
| - | us_test[i].result[BUFSZ-1] = '\0'; |
| + | us_test[i].result[BUFSZ - 1] = '\0'; |
| (void)curl_msprintf(us_test[i].result, "%hu", us_test[i].num); | |
| @@ -148,7 +139,6 @@ static int test_unsigned_short_formatting(void) | |
| i, us_test[i].expected, us_test[i].result); | |
| failed++; | |
| } | |
| - | |
| } | |
| if(!failed) | |
| @@ -159,7 +149,6 @@ static int test_unsigned_short_formatting(void) | |
| return failed; | |
| } | |
| - | |
| static int test_signed_short_formatting(void) | |
| { | |
| int i, j; | |
| @@ -211,7 +200,7 @@ static int test_signed_short_formatting(void) | |
| for(j = 0; j < BUFSZ; j++) | |
| ss_test[i].result[j] = 'X'; | |
| - | ss_test[i].result[BUFSZ-1] = '\0'; |
| + | ss_test[i].result[BUFSZ - 1] = '\0'; |
| (void)curl_msprintf(ss_test[i].result, "%hd", ss_test[i].num); | |
| @@ -222,7 +211,6 @@ static int test_signed_short_formatting(void) | |
| i, ss_test[i].expected, ss_test[i].result); | |
| failed++; | |
| } | |
| - | |
| } | |
| if(!failed) | |
| @@ -233,7 +221,6 @@ static int test_signed_short_formatting(void) | |
| return failed; | |
| } | |
| - | |
| static int test_unsigned_int_formatting(void) | |
| { | |
| int i, j; | |
| @@ -361,7 +348,7 @@ static int test_unsigned_int_formatting(void) | |
| for(j = 0; j < BUFSZ; j++) | |
| ui_test[i].result[j] = 'X'; | |
| - | ui_test[i].result[BUFSZ-1] = '\0'; |
| + | ui_test[i].result[BUFSZ - 1] = '\0'; |
| (void)curl_msprintf(ui_test[i].result, "%u", ui_test[i].num); | |
| @@ -372,7 +359,6 @@ static int test_unsigned_int_formatting(void) | |
| i, ui_test[i].expected, ui_test[i].result); | |
| failed++; | |
| } | |
| - | |
| } | |
| if(!failed) | |
| @@ -383,7 +369,6 @@ static int test_unsigned_int_formatting(void) | |
| return failed; | |
| } | |
| - | |
| static int test_signed_int_formatting(void) | |
| { | |
| int i, j; | |
| @@ -589,7 +574,7 @@ static int test_signed_int_formatting(void) | |
| for(j = 0; j < BUFSZ; j++) | |
| si_test[i].result[j] = 'X'; | |
| - | si_test[i].result[BUFSZ-1] = '\0'; |
| + | si_test[i].result[BUFSZ - 1] = '\0'; |
| (void)curl_msprintf(si_test[i].result, "%d", si_test[i].num); | |
| @@ -600,7 +585,6 @@ static int test_signed_int_formatting(void) | |
| i, si_test[i].expected, si_test[i].result); | |
| failed++; | |
| } | |
| - | |
| } | |
| if(!failed) | |
| @@ -611,7 +595,6 @@ static int test_signed_int_formatting(void) | |
| return failed; | |
| } | |
| - | |
| static int test_unsigned_long_formatting(void) | |
| { | |
| int i, j; | |
| @@ -738,7 +721,7 @@ static int test_unsigned_long_formatting(void) | |
| for(j = 0; j < BUFSZ; j++) | |
| ul_test[i].result[j] = 'X'; | |
| - | ul_test[i].result[BUFSZ-1] = '\0'; |
| + | ul_test[i].result[BUFSZ - 1] = '\0'; |
| (void)curl_msprintf(ul_test[i].result, "%lu", ul_test[i].num); | |
| @@ -749,7 +732,6 @@ static int test_unsigned_long_formatting(void) | |
| i, ul_test[i].expected, ul_test[i].result); | |
| failed++; | |
| } | |
| - | |
| } | |
| if(!failed) | |
| @@ -760,7 +742,6 @@ static int test_unsigned_long_formatting(void) | |
| return failed; | |
| } | |
| - | |
| static int test_signed_long_formatting(void) | |
| { | |
| int i, j; | |
| @@ -966,7 +947,7 @@ static int test_signed_long_formatting(void) | |
| for(j = 0; j < BUFSZ; j++) | |
| sl_test[i].result[j] = 'X'; | |
| - | sl_test[i].result[BUFSZ-1] = '\0'; |
| + | sl_test[i].result[BUFSZ - 1] = '\0'; |
| (void)curl_msprintf(sl_test[i].result, "%ld", sl_test[i].num); | |
| @@ -977,7 +958,6 @@ static int test_signed_long_formatting(void) | |
| i, sl_test[i].expected, sl_test[i].result); | |
| failed++; | |
| } | |
| - | |
| } | |
| if(!failed) | |
| @@ -988,7 +968,6 @@ static int test_signed_long_formatting(void) | |
| return failed; | |
| } | |
| - | |
| static int test_curl_off_t_formatting(void) | |
| { | |
| int i, j; | |
| @@ -1080,7 +1059,7 @@ static int test_curl_off_t_formatting(void) | |
| for(j = 0; j < BUFSZ; j++) | |
| co_test[i].result[j] = 'X'; | |
| - | co_test[i].result[BUFSZ-1] = '\0'; |
| + | co_test[i].result[BUFSZ - 1] = '\0'; |
| (void)curl_msprintf(co_test[i].result, "%" CURL_FORMAT_CURL_OFF_T, | |
| co_test[i].num); | |
| @@ -1092,7 +1071,6 @@ static int test_curl_off_t_formatting(void) | |
| i, co_test[i].expected, co_test[i].result); | |
| failed++; | |
| } | |
| - | |
| } | |
| if(!failed) | |
| @@ -1113,7 +1091,7 @@ static int string_check_low(int linenumber, char *buf, const char *buf2) | |
| } | |
| return 0; | |
| } | |
| - | #define string_check(x,y) string_check_low(__LINE__, x, y) |
| + | #define string_check(x, y) string_check_low(__LINE__, x, y) |
| static int strlen_check_low(int linenumber, char *buf, size_t len) | |
| { | |
| @@ -1126,7 +1104,7 @@ static int strlen_check_low(int linenumber, char *buf, size_t len) | |
| } | |
| return 0; | |
| } | |
| - | #define strlen_check(x,y) strlen_check_low(__LINE__, x, y) |
| + | #define strlen_check(x, y) strlen_check_low(__LINE__, x, y) |
| /* | |
| * The output strings in this test need to have been verified with a system | |
| @@ -1222,7 +1200,6 @@ static int test_width_precision(void) | |
| return errors; | |
| } | |
| - | |
| static int test_weird_arguments(void) | |
| { | |
| int errors = 0; | |
| @@ -1275,7 +1252,7 @@ static int test_weird_arguments(void) | |
| 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, /* 10 9 */ | |
| 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, /* 10 10 */ | |
| 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, /* 10 11 */ | |
| - | 0, 1, 2, 3, 4, 5, 6, 7); /* 8 */ |
| + | 0, 1, 2, 3, 4, 5, 6, 7); /* 8 */ |
| if(rc != 128) { | |
| curl_mprintf("curl_mprintf() returned %d and not 128!\n", rc); | |
| @@ -84,7 +84,7 @@ static CURLcode test_lib568(const char *URL) | |
| test_setopt(curl, CURLOPT_READDATA, sdpf); | |
| test_setopt(curl, CURLOPT_UPLOAD, 1L); | |
| - | test_setopt(curl, CURLOPT_INFILESIZE_LARGE, (curl_off_t) file_info.st_size); |
| + | test_setopt(curl, CURLOPT_INFILESIZE_LARGE, (curl_off_t)file_info.st_size); |
| test_setopt(curl, CURLOPT_VERBOSE, 1L); | |
| /* Do the ANNOUNCE */ | |
| @@ -70,7 +70,7 @@ static CURLcode test_lib570(const char *URL) | |
| test_setopt(curl, CURLOPT_RTSP_CLIENT_CSEQ, 999L); | |
| test_setopt(curl, CURLOPT_RTSP_TRANSPORT, | |
| - | "RAW/RAW/UDP;unicast;client_port=3056-3057"); |
| + | "RAW/RAW/UDP;unicast;client_port=3056-3057"); |
| test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_SETUP); | |
| stream_uri = tutil_suburl(URL, request++); | |
| @@ -102,7 +102,7 @@ static CURLcode test_lib572(const char *URL) | |
| test_setopt(curl, CURLOPT_READDATA, paramsf); | |
| test_setopt(curl, CURLOPT_UPLOAD, 1L); | |
| - | test_setopt(curl, CURLOPT_INFILESIZE_LARGE, (curl_off_t) file_info.st_size); |
| + | test_setopt(curl, CURLOPT_INFILESIZE_LARGE, (curl_off_t)file_info.st_size); |
| res = curl_easy_perform(curl); | |
| if(res) | |
| @@ -41,7 +41,7 @@ static CURLcode test_lib573(const char *URL) | |
| dbl_epsilon = 1.0; | |
| do { | |
| dbl_epsilon /= 2.0; | |
| - | } while((double)(1.0 + (dbl_epsilon/2.0)) > (double)1.0); |
| + | } while((double)(1.0 + (dbl_epsilon / 2.0)) > (double)1.0); |
| start_test_timing(); | |
| @@ -23,8 +23,7 @@ | |
| ***************************************************************************/ | |
| #include "first.h" | |
| - | static int new_fnmatch(void *ptr, |
| - | const char *pattern, const char *string) |
| + | static int new_fnmatch(void *ptr, const char *pattern, const char *string) |
| { | |
| (void)ptr; | |
| curl_mfprintf(stderr, "lib574: match string '%s' against pattern '%s'\n", | |
| @@ -84,7 +84,7 @@ static size_t t579_read_cb(char *ptr, size_t size, size_t nmemb, void *userp) | |
| struct t579_WriteThis *pooh = (struct t579_WriteThis *)userp; | |
| const char *data; | |
| - | if(size*nmemb < 1) |
| + | if(size * nmemb < 1) |
| return 0; | |
| data = testpost[pooh->counter]; | |
| @@ -175,7 +175,7 @@ static ssize_t t582_getMicroSecondTimeout(struct curltime *timeout) | |
| /** | |
| * Update a fd_set with all of the sockets in use. | |
| */ | |
| - | static void t582_updateFdSet(struct t582_Sockets *sockets, fd_set* fdset, |
| + | static void t582_updateFdSet(struct t582_Sockets *sockets, fd_set *fdset, |
| curl_socket_t *maxFd) | |
| { | |
| int i; | |
| @@ -47,21 +47,21 @@ static void t586_test_lock(CURL *curl, curl_lock_data data, | |
| (void)laccess; | |
| switch(data) { | |
| - | case CURL_LOCK_DATA_SHARE: |
| - | what = "share"; |
| - | break; |
| - | case CURL_LOCK_DATA_DNS: |
| - | what = "dns"; |
| - | break; |
| - | case CURL_LOCK_DATA_COOKIE: |
| - | what = "cookie"; |
| - | break; |
| - | case CURL_LOCK_DATA_SSL_SESSION: |
| - | what = "ssl_session"; |
| - | break; |
| - | default: |
| - | curl_mfprintf(stderr, "lock: no such data: %d\n", data); |
| - | return; |
| + | case CURL_LOCK_DATA_SHARE: |
| + | what = "share"; |
| + | break; |
| + | case CURL_LOCK_DATA_DNS: |
| + | what = "dns"; |
| + | break; |
| + | case CURL_LOCK_DATA_COOKIE: |
| + | what = "cookie"; |
| + | break; |
| + | case CURL_LOCK_DATA_SSL_SESSION: |
| + | what = "ssl_session"; |
| + | break; |
| + | default: |
| + | curl_mfprintf(stderr, "lock: no such data: %d\n", data); |
| + | return; |
| } | |
| curl_mprintf("lock: %-6s [%s]: %d\n", what, user->text, user->counter); | |
| user->counter++; | |
| @@ -74,21 +74,21 @@ static void t586_test_unlock(CURL *curl, curl_lock_data data, void *useptr) | |
| struct t586_userdata *user = (struct t586_userdata *)useptr; | |
| (void)curl; | |
| switch(data) { | |
| - | case CURL_LOCK_DATA_SHARE: |
| - | what = "share"; |
| - | break; |
| - | case CURL_LOCK_DATA_DNS: |
| - | what = "dns"; |
| - | break; |
| - | case CURL_LOCK_DATA_COOKIE: |
| - | what = "cookie"; |
| - | break; |
| - | case CURL_LOCK_DATA_SSL_SESSION: |
| - | what = "ssl_session"; |
| - | break; |
| - | default: |
| - | curl_mfprintf(stderr, "unlock: no such data: %d\n", data); |
| - | return; |
| + | case CURL_LOCK_DATA_SHARE: |
| + | what = "share"; |
| + | break; |
| + | case CURL_LOCK_DATA_DNS: |
| + | what = "dns"; |
| + | break; |
| + | case CURL_LOCK_DATA_COOKIE: |
| + | what = "cookie"; |
| + | break; |
| + | case CURL_LOCK_DATA_SSL_SESSION: |
| + | what = "ssl_session"; |
| + | break; |
| + | default: |
| + | curl_mfprintf(stderr, "unlock: no such data: %d\n", data); |
| + | return; |
| } | |
| curl_mprintf("unlock: %-6s [%s]: %d\n", what, user->text, user->counter); | |
| user->counter++; | |
| @@ -98,7 +98,7 @@ static void t586_test_unlock(CURL *curl, curl_lock_data data, void *useptr) | |
| static void *t586_test_fire(void *ptr) | |
| { | |
| CURLcode code; | |
| - | struct t586_Tdata *tdata = (struct t586_Tdata*)ptr; |
| + | struct t586_Tdata *tdata = (struct t586_Tdata *)ptr; |
| CURL *curl; | |
| curl = curl_easy_init(); | |
| @@ -108,8 +108,8 @@ static void *t586_test_fire(void *ptr) | |
| } | |
| curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L); | |
| - | curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); |
| - | curl_easy_setopt(curl, CURLOPT_URL, tdata->url); |
| + | curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); |
| + | curl_easy_setopt(curl, CURLOPT_URL, tdata->url); |
| curl_mprintf("CURLOPT_SHARE\n"); | |
| curl_easy_setopt(curl, CURLOPT_SHARE, tdata->share); | |
| @@ -181,20 +181,18 @@ static CURLcode test_lib586(const char *URL) | |
| return TEST_ERR_MAJOR_BAD; | |
| } | |
| - | |
| /* start treads */ | |
| for(i = 1; i <= THREADS; i++) { | |
| /* set thread data */ | |
| - | tdata.url = URL; |
| + | tdata.url = URL; |
| tdata.share = share; | |
| /* simulate thread, direct call of "thread" function */ | |
| - | curl_mprintf("*** run %d\n",i); |
| + | curl_mprintf("*** run %d\n", i); |
| t586_test_fire(&tdata); | |
| } | |
| - | |
| /* fetch another one */ | |
| curl_mprintf("*** run %d\n", i); | |
| curl = curl_easy_init(); | |
| @@ -233,8 +231,7 @@ test_cleanup: | |
| curl_mprintf("SHARE_CLEANUP\n"); | |
| scode = curl_share_cleanup(share); | |
| if(scode != CURLSHE_OK) | |
| - | curl_mfprintf(stderr, "curl_share_cleanup failed, code errno %d\n", |
| - | scode); |
| + | curl_mfprintf(stderr, "curl_share_cleanup failed, code errno %d\n", scode); |
| curl_mprintf("GLOBAL_CLEANUP\n"); | |
| curl_global_cleanup(); | |
| @@ -114,8 +114,8 @@ static CURLcode test_lib591(const char *URL) | |
| #else | |
| itimeout = (int)timeout; | |
| #endif | |
| - | interval.tv_sec = itimeout/1000; |
| - | interval.tv_usec = (itimeout%1000)*1000; |
| + | interval.tv_sec = itimeout / 1000; |
| + | interval.tv_usec = (itimeout % 1000) * 1000; |
| } | |
| else { | |
| interval.tv_sec = 0; | |
| @@ -94,11 +94,11 @@ static CURLcode test_lib597(const char *URL) | |
| #else | |
| itimeout = (int)timeout; | |
| #endif | |
| - | interval.tv_sec = itimeout/1000; |
| - | interval.tv_usec = (itimeout%1000)*1000; |
| + | interval.tv_sec = itimeout / 1000; |
| + | interval.tv_usec = (itimeout % 1000) * 1000; |
| } | |
| else { | |
| - | interval.tv_sec = TEST_HANG_TIMEOUT/1000 - 1; |
| + | interval.tv_sec = TEST_HANG_TIMEOUT / 1000 - 1; |
| interval.tv_usec = 0; | |
| } | |
| @@ -33,7 +33,7 @@ static size_t t643_read_cb(char *ptr, size_t size, size_t nmemb, void *userp) | |
| struct t643_WriteThis *pooh = (struct t643_WriteThis *)userp; | |
| int eof; | |
| - | if(size*nmemb < 1) |
| + | if(size * nmemb < 1) |
| return 0; | |
| if(testnum == 643) { | |
| @@ -100,8 +100,7 @@ static CURLcode t643_test_once(const char *URL, bool oldstyle) | |
| if(oldstyle) { | |
| res = curl_mime_name(part, "sendfile"); | |
| if(!res) | |
| - | res = curl_mime_data_cb(part, datasize, t643_read_cb, |
| - | NULL, NULL, &pooh); |
| + | res = curl_mime_data_cb(part, datasize, t643_read_cb, NULL, NULL, &pooh); |
| if(!res) | |
| res = curl_mime_filename(part, "postit2.c"); | |
| } | |
| @@ -109,8 +108,7 @@ static CURLcode t643_test_once(const char *URL, bool oldstyle) | |
| /* new style */ | |
| res = curl_mime_name(part, "sendfile alternative"); | |
| if(!res) | |
| - | res = curl_mime_data_cb(part, datasize, t643_read_cb, |
| - | NULL, NULL, &pooh); |
| + | res = curl_mime_data_cb(part, datasize, t643_read_cb, NULL, NULL, &pooh); |
| if(!res) | |
| res = curl_mime_filename(part, "filename 2 "); | |
| } | |
| @@ -137,8 +135,7 @@ static CURLcode t643_test_once(const char *URL, bool oldstyle) | |
| /* Fill in the file upload part */ | |
| res = curl_mime_name(part, "callbackdata"); | |
| if(!res) | |
| - | res = curl_mime_data_cb(part, datasize, t643_read_cb, |
| - | NULL, NULL, &pooh2); |
| + | res = curl_mime_data_cb(part, datasize, t643_read_cb, NULL, NULL, &pooh2); |
| if(res) | |
| curl_mprintf("curl_mime_xxx(2) = %s\n", curl_easy_strerror(res)); | |
| @@ -155,8 +152,7 @@ static CURLcode t643_test_once(const char *URL, bool oldstyle) | |
| /* Fill in the filename field */ | |
| res = curl_mime_name(part, "filename"); | |
| if(!res) | |
| - | res = curl_mime_data(part, "postit2.c", |
| - | CURL_ZERO_TERMINATED); |
| + | res = curl_mime_data(part, "postit2.c", CURL_ZERO_TERMINATED); |
| if(res) | |
| curl_mprintf("curl_mime_xxx(3) = %s\n", curl_easy_strerror(res)); | |
| @@ -172,8 +168,7 @@ static CURLcode t643_test_once(const char *URL, bool oldstyle) | |
| } | |
| res = curl_mime_name(part, "submit"); | |
| if(!res) | |
| - | res = curl_mime_data(part, "send", |
| - | CURL_ZERO_TERMINATED); |
| + | res = curl_mime_data(part, "send", CURL_ZERO_TERMINATED); |
| if(res) | |
| curl_mprintf("curl_mime_xxx(4) = %s\n", curl_easy_strerror(res)); | |
| @@ -30,7 +30,7 @@ | |
| /* curl_formget callback to count characters. */ | |
| static size_t count_chars(void *userp, const char *buf, size_t len) | |
| { | |
| - | size_t *pcounter = (size_t *) userp; |
| + | size_t *pcounter = (size_t *)userp; |
| (void)buf; | |
| *pcounter += len; | |
| @@ -51,8 +51,7 @@ static CURLcode test_lib650(const char *URL) | |
| long contentlength = 0; | |
| static const char testname[] = "fieldname"; | |
| - | static char testdata[] = |
| - | "this is what we post to the silly web server"; |
| + | static char testdata[] = "this is what we post to the silly web server"; |
| if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { | |
| curl_mfprintf(stderr, "curl_global_init() failed\n"); | |
| @@ -141,7 +140,7 @@ static CURLcode test_lib650(const char *URL) | |
| * This is done before including stdin data because we want to reuse it | |
| * and stdin cannot be rewound. | |
| */ | |
| - | curl_formget(formpost, (void *) &formlength, count_chars); |
| + | curl_formget(formpost, (void *)&formlength, count_chars); |
| /* Include length in data for external check. */ | |
| curl_msnprintf(flbuf, sizeof(flbuf), "%zu", formlength); | |
| @@ -35,12 +35,12 @@ static CURLcode test_lib651(const char *URL) | |
| /* create a buffer with AAAA...BBBBB...CCCC...etc */ | |
| int i; | |
| - | int size = (int)sizeof(testbuf)/1000; |
| + | int size = (int)sizeof(testbuf) / 1000; |
| - | for(i = 0; i < size ; i++) |
| + | for(i = 0; i < size; i++) |
| memset(&testbuf[i * 1000], 65 + i, 1000); | |
| - | testbuf[sizeof(testbuf)-1] = 0; /* null-terminate */ |
| + | testbuf[sizeof(testbuf) - 1] = 0; /* null-terminate */ |
| if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { | |
| curl_mfprintf(stderr, "curl_global_init() failed\n"); | |
| @@ -37,7 +37,7 @@ static CURLcode test_lib652(const char *URL) | |
| int i; | |
| int size = (int)sizeof(testbuf) / 10; | |
| - | for(i = 0; i < size ; i++) |
| + | for(i = 0; i < size; i++) |
| memset(&testbuf[i * 10], 65 + (i % 26), 10); | |
| if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { | |
| @@ -31,7 +31,7 @@ struct t654_WriteThis { | |
| static void free_callback(void *userp) | |
| { | |
| - | struct t654_WriteThis *pooh = (struct t654_WriteThis *) userp; |
| + | struct t654_WriteThis *pooh = (struct t654_WriteThis *)userp; |
| pooh->freecount++; | |
| } | |
| @@ -41,7 +41,7 @@ static size_t t654_read_cb(char *ptr, size_t size, size_t nmemb, void *userp) | |
| struct t654_WriteThis *pooh = (struct t654_WriteThis *)userp; | |
| int eof; | |
| - | if(size*nmemb < 1) |
| + | if(size * nmemb < 1) |
| return 0; | |
| eof = pooh->sizeleft <= 0; | |
| @@ -92,7 +92,7 @@ static CURLcode test_lib654(const char *URL) | |
| /* Prepare the callback structure. */ | |
| pooh.readptr = testdata; | |
| - | pooh.sizeleft = (curl_off_t) strlen(testdata); |
| + | pooh.sizeleft = (curl_off_t)strlen(testdata); |
| pooh.freecount = 0; | |
| /* Build the mime tree. */ | |
| @@ -40,7 +40,7 @@ static CURLcode test_lib666(const char *URL) | |
| if(i % 77 == 76) | |
| testbuf[i] = '\n'; | |
| else | |
| - | testbuf[i] = (char) (0x41 + i % 26); /* A...Z */ |
| + | testbuf[i] = (char)(0x41 + i % 26); /* A...Z */ |
| if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { | |
| curl_mfprintf(stderr, "curl_global_init() failed\n"); | |
| @@ -33,7 +33,7 @@ static size_t t667_read_cb(char *ptr, size_t size, size_t nmemb, void *userp) | |
| struct t667_WriteThis *pooh = (struct t667_WriteThis *)userp; | |
| int eof; | |
| - | if(size*nmemb < 1) |
| + | if(size * nmemb < 1) |
| return 0; | |
| eof = pooh->sizeleft <= 0; | |
| @@ -82,7 +82,7 @@ static CURLcode test_lib667(const char *URL) | |
| /* Prepare the callback structure. */ | |
| pooh.readptr = testdata; | |
| - | pooh.sizeleft = (curl_off_t) strlen(testdata); |
| + | pooh.sizeleft = (curl_off_t)strlen(testdata); |
| /* Build the mime tree. */ | |
| mime = curl_mime_init(curl); | |
| @@ -90,8 +90,7 @@ static CURLcode test_lib667(const char *URL) | |
| curl_mime_name(part, "field"); | |
| curl_mime_encoder(part, "base64"); | |
| /* Using an undefined length forces chunked transfer. */ | |
| - | curl_mime_data_cb(part, (curl_off_t) -1, t667_read_cb, |
| - | NULL, NULL, &pooh); |
| + | curl_mime_data_cb(part, (curl_off_t)-1, t667_read_cb, NULL, NULL, &pooh); |
| /* Bind mime data to its easy handle. */ | |
| test_setopt(curl, CURLOPT_MIMEPOST, mime); | |
| @@ -76,7 +76,7 @@ static CURLcode test_lib668(const char *URL) | |
| /* Prepare the callback structures. */ | |
| pooh1.readptr = testdata; | |
| - | pooh1.sizeleft = (curl_off_t) strlen(testdata); |
| + | pooh1.sizeleft = (curl_off_t)strlen(testdata); |
| pooh2 = pooh1; | |
| /* Build the mime tree. */ | |
| @@ -84,14 +84,14 @@ static CURLcode test_lib668(const char *URL) | |
| part = curl_mime_addpart(mime); | |
| curl_mime_name(part, "field1"); | |
| /* Early end of data detection can be done because the data size is known. */ | |
| - | curl_mime_data_cb(part, (curl_off_t) strlen(testdata), |
| + | curl_mime_data_cb(part, (curl_off_t)strlen(testdata), |
| t668_read_cb, NULL, NULL, &pooh1); | |
| part = curl_mime_addpart(mime); | |
| curl_mime_name(part, "field2"); | |
| /* Using an undefined length forces chunked transfer and disables early | |
| end of data detection for this part. */ | |
| - | curl_mime_data_cb(part, (curl_off_t) -1, t668_read_cb, |
| - | NULL, NULL, &pooh2); |
| + | curl_mime_data_cb(part, (curl_off_t)-1, |
| + | t668_read_cb, NULL, NULL, &pooh2); |
| part = curl_mime_addpart(mime); | |
| curl_mime_name(part, "field3"); | |
| /* Regular file part sources early end of data can be detected because | |
| @@ -33,7 +33,7 @@ struct t670_ReadThis { | |
| static size_t t670_read_cb(char *ptr, size_t size, size_t nmemb, void *userp) | |
| { | |
| - | struct t670_ReadThis *pooh = (struct t670_ReadThis *) userp; |
| + | struct t670_ReadThis *pooh = (struct t670_ReadThis *)userp; |
| time_t delta; | |
| if(size * nmemb < 1) | |
| @@ -61,7 +61,7 @@ static int t670_xferinfo(void *clientp, | |
| curl_off_t dltotal, curl_off_t dlnow, | |
| curl_off_t ultotal, curl_off_t ulnow) | |
| { | |
| - | struct t670_ReadThis *pooh = (struct t670_ReadThis *) clientp; |
| + | struct t670_ReadThis *pooh = (struct t670_ReadThis *)clientp; |
| (void)dltotal; | |
| (void)dlnow; | |
| @@ -102,7 +102,7 @@ static CURLcode test_lib670(const char *URL) | |
| return TEST_ERR_MAJOR_BAD; | |
| } | |
| - | pooh.origin = (time_t) 0; |
| + | pooh.origin = (time_t)0; |
| pooh.count = 0; | |
| pooh.curl = curl_easy_init(); | |
| @@ -128,7 +128,7 @@ static CURLcode test_lib670(const char *URL) | |
| goto test_cleanup; | |
| } | |
| - | res = curl_mime_data_cb(part, (curl_off_t) 2, t670_read_cb, |
| + | res = curl_mime_data_cb(part, (curl_off_t)2, t670_read_cb, |
| NULL, NULL, &pooh); | |
| /* Bind mime data to its easy handle. */ | |
| @@ -43,8 +43,7 @@ static int loadfile(const char *filename, void **filedata, size_t *filesize) | |
| continue_reading = fseek(fInCert, 0, SEEK_SET) == 0; | |
| if(continue_reading) | |
| data = curlx_malloc(datasize + 1); | |
| - | if((!data) || |
| - | ((int)fread(data, datasize, 1, fInCert) != 1)) |
| + | if((!data) || ((int)fread(data, datasize, 1, fInCert) != 1)) |
| continue_reading = FALSE; | |
| curlx_fclose(fInCert); | |
| if(!continue_reading) { | |
| @@ -52,7 +51,7 @@ static int loadfile(const char *filename, void **filedata, size_t *filesize) | |
| datasize = 0; | |
| data = NULL; | |
| } | |
| - | } |
| + | } |
| } | |
| *filesize = datasize; | |
| *filedata = data; | |
| @@ -69,7 +69,6 @@ static void t758_msg(const char *msg) | |
| curl_mfprintf(stderr, "%s %s\n", t758_tag(), msg); | |
| } | |
| - | |
| struct t758_Sockets { | |
| curl_socket_t *sockets; | |
| int count; /* number of sockets actually stored in array */ | |
| @@ -203,7 +202,7 @@ static int t758_curlTimerCallback(CURLM *multi, long timeout_ms, void *userp) | |
| static int t758_cert_verify_callback(X509_STORE_CTX *ctx, void *arg) | |
| { | |
| - | SSL * ssl; |
| + | SSL *ssl; |
| (void)arg; | |
| ssl = (SSL *)X509_STORE_CTX_get_ex_data(ctx, | |
| SSL_get_ex_data_X509_STORE_CTX_idx()); | |
| @@ -226,7 +225,7 @@ static int t758_cert_verify_callback(X509_STORE_CTX *ctx, void *arg) | |
| static CURLcode | |
| t758_set_ssl_ctx_callback(CURL *curl, void *ssl_ctx, void *clientp) | |
| { | |
| - | SSL_CTX *ctx = (SSL_CTX *) ssl_ctx; |
| + | SSL_CTX *ctx = (SSL_CTX *)ssl_ctx; |
| (void)curl; | |
| SSL_CTX_set_cert_verify_callback(ctx, t758_cert_verify_callback, clientp); | |
| return CURLE_OK; | |
| @@ -277,7 +276,7 @@ static ssize_t t758_getMicroSecondTimeout(struct curltime *timeout) | |
| /** | |
| * Update a fd_set with all of the sockets in use. | |
| */ | |
| - | static void t758_updateFdSet(struct t758_Sockets *sockets, fd_set* fdset, |
| + | static void t758_updateFdSet(struct t758_Sockets *sockets, fd_set *fdset, |
| curl_socket_t *maxFd) | |
| { | |
| int i; | |
| @@ -359,7 +358,6 @@ static CURLcode t758_one(const char *URL, int timer_fail_at, | |
| curl_global_trace("all"); | |
| - | |
| easy_init(curl); | |
| debug_config.nohex = TRUE; | |
| debug_config.tracetime = TRUE; | |
| @@ -26,8 +26,7 @@ | |
| static int dnsd_wrotepidfile = 0; | |
| static int dnsd_wroteportfile = 0; | |
| - | static unsigned short get16bit(const unsigned char **pkt, |
| - | size_t *size) |
| + | static unsigned short get16bit(const unsigned char **pkt, size_t *size) |
| { | |
| const unsigned char *p = *pkt; | |
| (*pkt) += 2; | |
| @@ -140,7 +139,7 @@ static int store_incoming(const unsigned char *data, size_t size, | |
| fprintf(server, "Z: %x\n", (id & 0x70) >> 4); | |
| fprintf(server, "RCODE: %x\n", (id & 0x0f)); | |
| #endif | |
| - | (void) get16bit(&data, &size); |
| + | (void)get16bit(&data, &size); |
| data += 6; /* skip ANCOUNT, NSCOUNT and ARCOUNT */ | |
| size -= 6; | |
| @@ -153,10 +152,9 @@ static int store_incoming(const unsigned char *data, size_t size, | |
| qd = get16bit(&data, &size); | |
| fprintf(server, "QNAME %s QTYPE %s\n", name, type2string(qd)); | |
| *qtype = qd; | |
| - | logmsg("Question for '%s' type %x / %s", name, qd, |
| - | type2string(qd)); |
| + | logmsg("Question for '%s' type %x / %s", name, qd, type2string(qd)); |
| - | (void) get16bit(&data, &size); |
| + | (void)get16bit(&data, &size); |
| *qlen = qsize - size; /* total size of the query */ | |
| if(*qlen > qbuflen) { | |
| @@ -311,7 +309,7 @@ static int send_response(curl_socket_t sock, | |
| fprintf(stderr, "Not working\n"); | |
| return -1; | |
| #else | |
| - | rc = sendto(sock, (const void *)bytes, (SENDTO3) i, 0, addr, addrlen); |
| + | rc = sendto(sock, (const void *)bytes, (SENDTO3)i, 0, addr, addrlen); |
| if(rc != (ssize_t)i) { | |
| fprintf(stderr, "failed sending %d bytes\n", (int)i); | |
| } | |
| @@ -319,7 +317,6 @@ static int send_response(curl_socket_t sock, | |
| return 0; | |
| } | |
| - | |
| static void read_instructions(void) | |
| { | |
| char file[256]; | |
| @@ -412,7 +409,7 @@ static int test_dnsd(int argc, char **argv) | |
| #else | |
| "" | |
| #endif | |
| - | ); |
| + | ); |
| return 0; | |
| } | |
| else if(!strcmp("--pidfile", argv[arg])) { | |
| @@ -475,7 +472,7 @@ static int test_dnsd(int argc, char **argv) | |
| } | |
| snprintf(loglockfile, sizeof(loglockfile), "%s/%s/dnsd-%s.lock", | |
| - | logdir, SERVERLOGS_LOCKDIR, ipv_inuse); |
| + | logdir, SERVERLOGS_LOCKDIR, ipv_inuse); |
| #ifdef _WIN32 | |
| if(win32_init()) | |
| @@ -182,8 +182,8 @@ static int appenddata(char **dst_buf, /* dest buffer */ | |
| return GPE_OK; | |
| } | |
| - | static int decodedata(char **buf, /* dest buffer */ |
| - | size_t *len) /* dest buffer data length */ |
| + | static int decodedata(char **buf, /* dest buffer */ |
| + | size_t *len) /* dest buffer data length */ |
| { | |
| CURLcode error = CURLE_OK; | |
| unsigned char *buf64 = NULL; | |
| @@ -254,7 +254,7 @@ int getpart(char **outbuf, size_t *outlen, | |
| char *end; | |
| union { | |
| ssize_t sig; | |
| - | size_t uns; |
| + | size_t uns; |
| } len; | |
| size_t bufsize = 0; | |
| size_t outalloc = 256; | |
| @@ -288,8 +288,7 @@ int getpart(char **outbuf, size_t *outlen, | |
| if('<' != *ptr) { | |
| if(in_wanted_part) { | |
| show(("=> %s", buffer)); | |
| - | error = appenddata(outbuf, outlen, &outalloc, buffer, datalen, |
| - | base64); |
| + | error = appenddata(outbuf, outlen, &outalloc, buffer, datalen, base64); |
| if(error) | |
| break; | |
| } | |
| @@ -353,7 +352,6 @@ int getpart(char **outbuf, size_t *outlen, | |
| if(in_wanted_part) | |
| break; | |
| } | |
| - | |
| } | |
| else if(!in_wanted_part) { | |
| /* | |
| @@ -411,9 +409,9 @@ int getpart(char **outbuf, size_t *outlen, | |
| /* start of wanted part */ | |
| in_wanted_part = 1; | |
| if(strstr(patt, "base64=")) | |
| - | /* bit rough test, but "mostly" functional, */ |
| - | /* treat wanted part data as base64 encoded */ |
| - | base64 = 1; |
| + | /* bit rough test, but "mostly" functional, */ |
| + | /* treat wanted part data as base64 encoded */ |
| + | base64 = 1; |
| if(strstr(patt, "nonewline=")) { | |
| show(("* setting nonewline\n")); | |
| nonewline = 1; | |
| @@ -421,7 +419,6 @@ int getpart(char **outbuf, size_t *outlen, | |
| } | |
| continue; | |
| } | |
| - | |
| } | |
| if(in_wanted_part) { | |
| @@ -156,7 +156,7 @@ static void logprotocol(mqttdir dir, | |
| /* return 0 on success */ | |
| static int connack(FILE *dump, curl_socket_t fd) | |
| { | |
| - | unsigned char packet[]={ |
| + | unsigned char packet[] = { |
| MQTT_MSG_CONNACK, 0x02, | |
| 0x00, 0x00 | |
| }; | |
| @@ -283,7 +283,6 @@ static size_t encode_length(size_t packetlen, | |
| return bytes; | |
| } | |
| - | |
| static size_t decode_length(unsigned char *buffer, | |
| size_t buflen, size_t *lenbytes) | |
| { | |
| @@ -304,7 +303,6 @@ static size_t decode_length(unsigned char *buffer, | |
| return len; | |
| } | |
| - | |
| /* return 0 on success */ | |
| static int publish(FILE *dump, | |
| curl_socket_t fd, unsigned short packetid, | |
| @@ -408,7 +406,7 @@ static int fixedheader(curl_socket_t fd, | |
| static curl_socket_t mqttit(curl_socket_t fd) | |
| { | |
| - | size_t buff_size = 10*1024; |
| + | size_t buff_size = 10 * 1024; |
| unsigned char *buffer = NULL; | |
| ssize_t rc; | |
| unsigned char byte; | |
| @@ -482,8 +480,7 @@ static curl_socket_t mqttit(curl_socket_t fd) | |
| } | |
| if(byte == MQTT_MSG_CONNECT) { | |
| - | logprotocol(FROM_CLIENT, "CONNECT", remaining_length, |
| - | dump, buffer, rc); |
| + | logprotocol(FROM_CLIENT, "CONNECT", remaining_length, dump, buffer, rc); |
| if(memcmp(protocol, buffer, sizeof(protocol))) { | |
| logmsg("Protocol preamble mismatch"); | |
| @@ -607,8 +604,7 @@ static curl_socket_t mqttit(curl_socket_t fd) | |
| size_t topiclen; | |
| logmsg("Incoming PUBLISH"); | |
| - | logprotocol(FROM_CLIENT, "PUBLISH", remaining_length, |
| - | dump, buffer, rc); |
| + | logprotocol(FROM_CLIENT, "PUBLISH", remaining_length, dump, buffer, rc); |
| topiclen = (size_t)(buffer[1 + bytes] << 8) | buffer[2 + bytes]; | |
| logmsg("Got %zu bytes topic", topiclen); | |
| @@ -754,7 +750,7 @@ static int test_mqttd(int argc, char *argv[]) | |
| #else | |
| "" | |
| #endif | |
| - | ); |
| + | ); |
| return 0; | |
| } | |
| else if(!strcmp("--pidfile", argv[arg])) { | |
| @@ -802,8 +798,7 @@ static int test_mqttd(int argc, char *argv[]) | |
| if(argc > arg) { | |
| opt = argv[arg]; | |
| if(curlx_str_number(&opt, &num, 0xffff)) { | |
| - | fprintf(stderr, "mqttd: invalid --port argument (%s)\n", |
| - | argv[arg]); |
| + | fprintf(stderr, "mqttd: invalid --port argument (%s)\n", argv[arg]); |
| return 0; | |
| } | |
| server_port = (unsigned short)num; | |
| @@ -47,7 +47,7 @@ static int test_resolve(int argc, char *argv[]) | |
| #else | |
| "" | |
| #endif | |
| - | ); |
| + | ); |
| return 0; | |
| } | |
| else if(!strcmp("--ipv6", argv[arg])) { | |
| @@ -79,7 +79,7 @@ static int test_resolve(int argc, char *argv[]) | |
| #ifdef CURLRES_IPV6 | |
| "\n --ipv6" | |
| #endif | |
| - | ); |
| + | ); |
| return 1; | |
| } | |
| @@ -50,10 +50,10 @@ typedef enum { | |
| RPROT_HTTP = 2 | |
| } reqprot_t; | |
| - | #define SET_RTP_PKT_CHN(p,c) ((p)[1] = (char)((c) & 0xFF)) |
| + | #define SET_RTP_PKT_CHN(p, c) ((p)[1] = (char)((c) & 0xFF)) |
| - | #define SET_RTP_PKT_LEN(p,l) (((p)[2] = (char)(((l) >> 8) & 0xFF)), \ |
| - | ((p)[3] = (char)((l) & 0xFF))) |
| + | #define SET_RTP_PKT_LEN(p, l) (((p)[2] = (char)(((l) >> 8) & 0xFF)), \ |
| + | ((p)[3] = (char)((l) & 0xFF))) |
| struct rtspd_httprequest { | |
| char reqbuf[150000]; /* buffer area for the incoming request */ | |
| @@ -105,10 +105,8 @@ struct rtspd_httprequest { | |
| #define END_OF_HEADERS "\r\n\r\n" | |
| - | |
| /* sent as reply to a QUIT */ | |
| - | static const char *docquit_rtsp = |
| - | "HTTP/1.1 200 Goodbye" END_OF_HEADERS; |
| + | static const char *docquit_rtsp = "HTTP/1.1 200 Goodbye" END_OF_HEADERS; |
| /* sent as reply to a CONNECT */ | |
| static const char *docconnect = | |
| @@ -180,7 +178,7 @@ static int rtspd_ProcessRequest(struct rtspd_httprequest *req) | |
| return 1; | |
| } | |
| - | req->prot_version = prot_major*10 + prot_minor; |
| + | req->prot_version = prot_major * 10 + prot_minor; |
| /* find the last slash */ | |
| ptr = strrchr(doc, '/'); | |
| @@ -285,8 +283,8 @@ static int rtspd_ProcessRequest(struct rtspd_httprequest *req) | |
| if(num < 0) | |
| logmsg("negative pipe size ignored"); | |
| else if(num > 0) | |
| - | req->pipe = num-1; /* decrease by one since we do not count the |
| - | first request in this number */ |
| + | req->pipe = num - 1; /* decrease by one since we do not count |
| + | the first request in this number */ |
| } | |
| else if(sscanf(ptr, "skip: %d", &num) == 1) { | |
| logmsg("instructed to skip this number of bytes %d", num); | |
| @@ -569,7 +567,7 @@ static void rtspd_storerequest(char *reqbuf, size_t totalsize) | |
| writeleft = totalsize; | |
| do { | |
| - | written = fwrite(&reqbuf[totalsize-writeleft], 1, writeleft, dump); |
| + | written = fwrite(&reqbuf[totalsize - writeleft], 1, writeleft, dump); |
| if(got_exit_signal) | |
| goto storerequest_cleanup; | |
| if(written > 0) | |
| @@ -584,7 +582,7 @@ static void rtspd_storerequest(char *reqbuf, size_t totalsize) | |
| logmsg("Error writing file %s error (%d) %s", dumpfile, | |
| error, curlx_strerror(error, errbuf, sizeof(errbuf))); | |
| logmsg("Wrote only (%zu bytes) of (%zu bytes) request input to %s", | |
| - | totalsize-writeleft, totalsize, dumpfile); |
| + | totalsize - writeleft, totalsize, dumpfile); |
| } | |
| storerequest_cleanup: | |
| @@ -636,7 +634,7 @@ static int rtspd_get_request(curl_socket_t sock, struct rtspd_httprequest *req) | |
| /*** end of httprequest init ***/ | |
| - | while(!done_processing && (req->offset < sizeof(req->reqbuf)-1)) { |
| + | while(!done_processing && (req->offset < sizeof(req->reqbuf) - 1)) { |
| if(pipereq_length && pipereq) { | |
| memmove(reqbuf, pipereq, pipereq_length); | |
| got = curlx_uztosz(pipereq_length); | |
| @@ -650,7 +648,7 @@ static int rtspd_get_request(curl_socket_t sock, struct rtspd_httprequest *req) | |
| got = sread(sock, reqbuf + req->offset, req->cl); | |
| else | |
| got = sread(sock, reqbuf + req->offset, | |
| - | sizeof(req->reqbuf)-1 - req->offset); |
| + | sizeof(req->reqbuf) - 1 - req->offset); |
| } | |
| if(got_exit_signal) | |
| return 1; | |
| @@ -686,16 +684,16 @@ static int rtspd_get_request(curl_socket_t sock, struct rtspd_httprequest *req) | |
| } | |
| } | |
| - | if((req->offset == sizeof(req->reqbuf)-1) && (got > 0)) { |
| + | if((req->offset == sizeof(req->reqbuf) - 1) && (got > 0)) { |
| logmsg("Request would overflow buffer, closing connection"); | |
| /* dump request received so far to external file anyway */ | |
| - | reqbuf[sizeof(req->reqbuf)-1] = '\0'; |
| + | reqbuf[sizeof(req->reqbuf) - 1] = '\0'; |
| fail = 1; | |
| } | |
| - | else if(req->offset > sizeof(req->reqbuf)-1) { |
| + | else if(req->offset > sizeof(req->reqbuf) - 1) { |
| logmsg("Request buffer overflow, closing connection"); | |
| /* dump request received so far to external file anyway */ | |
| - | reqbuf[sizeof(req->reqbuf)-1] = '\0'; |
| + | reqbuf[sizeof(req->reqbuf) - 1] = '\0'; |
| fail = 1; | |
| } | |
| else | |
| @@ -739,10 +737,10 @@ static int rtspd_send_doc(curl_socket_t sock, struct rtspd_httprequest *req) | |
| case RCMD_STREAM: { | |
| static const char streamthis[] = "a string to stream 01234567890\n"; | |
| for(;;) { | |
| - | written = swrite(sock, streamthis, sizeof(streamthis)-1); |
| + | written = swrite(sock, streamthis, sizeof(streamthis) - 1); |
| if(got_exit_signal) | |
| return -1; | |
| - | if(written != (ssize_t)(sizeof(streamthis)-1)) { |
| + | if(written != (ssize_t)(sizeof(streamthis) - 1)) { |
| logmsg("Stopped streaming"); | |
| break; | |
| } | |
| @@ -803,7 +801,7 @@ static int rtspd_send_doc(curl_socket_t sock, struct rtspd_httprequest *req) | |
| } | |
| else { | |
| FILE *stream = test2fopen(req->testno, logdir); | |
| - | char partbuf[80]="data"; |
| + | char partbuf[80] = "data"; |
| if(req->partno) | |
| snprintf(partbuf, sizeof(partbuf), "data%ld", req->partno); | |
| if(!stream) { | |
| @@ -942,7 +940,7 @@ static int rtspd_send_doc(curl_socket_t sock, struct rtspd_httprequest *req) | |
| if(sendfailure) { | |
| logmsg("Sending response failed. Only (%zu bytes) of " | |
| "(%zu bytes) were sent", | |
| - | responsesize-count, responsesize); |
| + | responsesize - count, responsesize); |
| free(ptr); | |
| free(cmd); | |
| return -1; | |
| @@ -997,7 +995,6 @@ static int rtspd_send_doc(curl_socket_t sock, struct rtspd_httprequest *req) | |
| return 0; | |
| } | |
| - | |
| static int test_rtspd(int argc, char *argv[]) | |
| { | |
| srvr_sockaddr_union_t me; | |
| @@ -1031,7 +1028,7 @@ static int test_rtspd(int argc, char *argv[]) | |
| #else | |
| "" | |
| #endif | |
| - | ); |
| + | ); |
| return 0; | |
| } | |
| else if(!strcmp("--pidfile", argv[arg])) { | |
| @@ -1126,8 +1123,7 @@ static int test_rtspd(int argc, char *argv[]) | |
| } | |
| flag = 1; | |
| - | if(setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, |
| - | (void *)&flag, sizeof(flag))) { |
| + | if(setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void *)&flag, sizeof(flag))) { |
| error = SOCKERRNO; | |
| logmsg("setsockopt(SO_REUSEADDR) failed with error (%d) %s", | |
| error, curlx_strerror(error, errbuf, sizeof(errbuf))); | |
| @@ -420,7 +420,7 @@ static DWORD WINAPI select_ws_wait_thread(void *lpParameter) | |
| DWORD type, length, ret; | |
| /* retrieve handles from internal structure */ | |
| - | data = (struct select_ws_wait_data *) lpParameter; |
| + | data = (struct select_ws_wait_data *)lpParameter; |
| if(data) { | |
| handle = data->handle; | |
| handles[0] = data->abort; | |
| @@ -434,120 +434,120 @@ static DWORD WINAPI select_ws_wait_thread(void *lpParameter) | |
| /* retrieve the type of file to wait on */ | |
| type = GetFileType(handle); | |
| switch(type) { | |
| - | case FILE_TYPE_DISK: |
| - | /* The handle represents a file on disk, this means: |
| - | * - WaitForMultipleObjectsEx will always be signalled for it. |
| - | * - comparison of current position in file and total size of |
| - | * the file can be used to check if we reached the end yet. |
| - | * |
| - | * Approach: Loop till either the internal event is signalled |
| - | * or if the end of the file has already been reached. |
| - | */ |
| - | while(WaitForMultipleObjectsEx(1, handles, FALSE, 0, FALSE) |
| - | == WAIT_TIMEOUT) { |
| - | /* get total size of file */ |
| - | length = 0; |
| - | size.QuadPart = 0; |
| - | size.LowPart = GetFileSize(handle, &length); |
| - | if((size.LowPart != INVALID_FILE_SIZE) || |
| + | case FILE_TYPE_DISK: |
| + | /* The handle represents a file on disk, this means: |
| + | * - WaitForMultipleObjectsEx will always be signalled for it. |
| + | * - comparison of current position in file and total size of |
| + | * the file can be used to check if we reached the end yet. |
| + | * |
| + | * Approach: Loop till either the internal event is signalled |
| + | * or if the end of the file has already been reached. |
| + | */ |
| + | while(WaitForMultipleObjectsEx(1, handles, FALSE, 0, FALSE) |
| + | == WAIT_TIMEOUT) { |
| + | /* get total size of file */ |
| + | length = 0; |
| + | size.QuadPart = 0; |
| + | size.LowPart = GetFileSize(handle, &length); |
| + | if((size.LowPart != INVALID_FILE_SIZE) || |
| + | (GetLastError() == NO_ERROR)) { |
| + | size.HighPart = (LONG)length; |
| + | /* get the current position within the file */ |
| + | pos.QuadPart = 0; |
| + | pos.LowPart = SetFilePointer(handle, 0, &pos.HighPart, FILE_CURRENT); |
| + | if((pos.LowPart != INVALID_SET_FILE_POINTER) || |
| (GetLastError() == NO_ERROR)) { | |
| - | size.HighPart = (LONG)length; |
| - | /* get the current position within the file */ |
| - | pos.QuadPart = 0; |
| - | pos.LowPart = SetFilePointer(handle, 0, &pos.HighPart, FILE_CURRENT); |
| - | if((pos.LowPart != INVALID_SET_FILE_POINTER) || |
| - | (GetLastError() == NO_ERROR)) { |
| - | /* compare position with size, abort if not equal */ |
| - | if(size.QuadPart == pos.QuadPart) { |
| - | /* sleep and continue waiting */ |
| - | SleepEx(0, FALSE); |
| - | continue; |
| - | } |
| + | /* compare position with size, abort if not equal */ |
| + | if(size.QuadPart == pos.QuadPart) { |
| + | /* sleep and continue waiting */ |
| + | SleepEx(0, FALSE); |
| + | continue; |
| } | |
| } | |
| - | /* there is some data available, stop waiting */ |
| - | logmsg("[select_ws_wait_thread] data available, DISK: %p", handle); |
| - | SetEvent(signal); |
| } | |
| - | break; |
| + | /* there is some data available, stop waiting */ |
| + | logmsg("[select_ws_wait_thread] data available, DISK: %p", handle); |
| + | SetEvent(signal); |
| + | } |
| + | break; |
| - | case FILE_TYPE_CHAR: |
| - | /* The handle represents a character input, this means: |
| - | * - WaitForMultipleObjectsEx will be signalled on any kind of input, |
| - | * including mouse and window size events we do not care about. |
| - | * |
| - | * Approach: Loop till either the internal event is signalled |
| - | * or we get signalled for an actual key-event. |
| - | */ |
| - | while(WaitForMultipleObjectsEx(2, handles, FALSE, INFINITE, FALSE) |
| - | == WAIT_OBJECT_0 + 1) { |
| - | /* check if this is an actual console handle */ |
| - | if(GetConsoleMode(handle, &ret)) { |
| - | /* retrieve an event from the console buffer */ |
| - | length = 0; |
| - | if(PeekConsoleInput(handle, &inputrecord, 1, &length)) { |
| - | /* check if the event is not an actual key-event */ |
| - | if(length == 1 && inputrecord.EventType != KEY_EVENT) { |
| - | /* purge the non-key-event and continue waiting */ |
| - | ReadConsoleInput(handle, &inputrecord, 1, &length); |
| - | continue; |
| - | } |
| + | case FILE_TYPE_CHAR: |
| + | /* The handle represents a character input, this means: |
| + | * - WaitForMultipleObjectsEx will be signalled on any kind of input, |
| + | * including mouse and window size events we do not care about. |
| + | * |
| + | * Approach: Loop till either the internal event is signalled |
| + | * or we get signalled for an actual key-event. |
| + | */ |
| + | while(WaitForMultipleObjectsEx(2, handles, FALSE, INFINITE, FALSE) |
| + | == WAIT_OBJECT_0 + 1) { |
| + | /* check if this is an actual console handle */ |
| + | if(GetConsoleMode(handle, &ret)) { |
| + | /* retrieve an event from the console buffer */ |
| + | length = 0; |
| + | if(PeekConsoleInput(handle, &inputrecord, 1, &length)) { |
| + | /* check if the event is not an actual key-event */ |
| + | if(length == 1 && inputrecord.EventType != KEY_EVENT) { |
| + | /* purge the non-key-event and continue waiting */ |
| + | ReadConsoleInput(handle, &inputrecord, 1, &length); |
| + | continue; |
| } | |
| } | |
| - | /* there is some data available, stop waiting */ |
| - | logmsg("[select_ws_wait_thread] data available, CHAR: %p", handle); |
| - | SetEvent(signal); |
| } | |
| - | break; |
| + | /* there is some data available, stop waiting */ |
| + | logmsg("[select_ws_wait_thread] data available, CHAR: %p", handle); |
| + | SetEvent(signal); |
| + | } |
| + | break; |
| - | case FILE_TYPE_PIPE: |
| - | /* The handle represents an anonymous or named pipe, this means: |
| - | * - WaitForMultipleObjectsEx will always be signalled for it. |
| - | * - peek into the pipe and retrieve the amount of data available. |
| - | * |
| - | * Approach: Loop till either the internal event is signalled |
| - | * or there is data in the pipe available for reading. |
| - | */ |
| - | while(WaitForMultipleObjectsEx(1, handles, FALSE, 0, FALSE) |
| - | == WAIT_TIMEOUT) { |
| - | /* peek into the pipe and retrieve the amount of data available */ |
| - | length = 0; |
| - | if(PeekNamedPipe(handle, NULL, 0, NULL, &length, NULL)) { |
| - | /* if there is no data available, sleep and continue waiting */ |
| - | if(length == 0) { |
| - | SleepEx(0, FALSE); |
| - | continue; |
| - | } |
| - | else { |
| - | logmsg("[select_ws_wait_thread] PeekNamedPipe len: %lu", length); |
| - | } |
| + | case FILE_TYPE_PIPE: |
| + | /* The handle represents an anonymous or named pipe, this means: |
| + | * - WaitForMultipleObjectsEx will always be signalled for it. |
| + | * - peek into the pipe and retrieve the amount of data available. |
| + | * |
| + | * Approach: Loop till either the internal event is signalled |
| + | * or there is data in the pipe available for reading. |
| + | */ |
| + | while(WaitForMultipleObjectsEx(1, handles, FALSE, 0, FALSE) |
| + | == WAIT_TIMEOUT) { |
| + | /* peek into the pipe and retrieve the amount of data available */ |
| + | length = 0; |
| + | if(PeekNamedPipe(handle, NULL, 0, NULL, &length, NULL)) { |
| + | /* if there is no data available, sleep and continue waiting */ |
| + | if(length == 0) { |
| + | SleepEx(0, FALSE); |
| + | continue; |
| } | |
| else { | |
| - | /* if the pipe has NOT been closed, sleep and continue waiting */ |
| - | ret = GetLastError(); |
| - | if(ret != ERROR_BROKEN_PIPE) { |
| - | logmsg("[select_ws_wait_thread] PeekNamedPipe error (%lu)", ret); |
| - | SleepEx(0, FALSE); |
| - | continue; |
| - | } |
| - | else { |
| - | logmsg("[select_ws_wait_thread] pipe closed, PIPE: %p", handle); |
| - | } |
| + | logmsg("[select_ws_wait_thread] PeekNamedPipe len: %lu", length); |
| } | |
| - | /* there is some data available, stop waiting */ |
| - | logmsg("[select_ws_wait_thread] data available, PIPE: %p", handle); |
| - | SetEvent(signal); |
| } | |
| - | break; |
| - | |
| - | default: |
| - | /* The handle has an unknown type, try to wait on it */ |
| - | if(WaitForMultipleObjectsEx(2, handles, FALSE, INFINITE, FALSE) |
| - | == WAIT_OBJECT_0 + 1) { |
| - | logmsg("[select_ws_wait_thread] data available, HANDLE: %p", handle); |
| - | SetEvent(signal); |
| + | else { |
| + | /* if the pipe has NOT been closed, sleep and continue waiting */ |
| + | ret = GetLastError(); |
| + | if(ret != ERROR_BROKEN_PIPE) { |
| + | logmsg("[select_ws_wait_thread] PeekNamedPipe error (%lu)", ret); |
| + | SleepEx(0, FALSE); |
| + | continue; |
| + | } |
| + | else { |
| + | logmsg("[select_ws_wait_thread] pipe closed, PIPE: %p", handle); |
| + | } |
| } | |
| - | break; |
| + | /* there is some data available, stop waiting */ |
| + | logmsg("[select_ws_wait_thread] data available, PIPE: %p", handle); |
| + | SetEvent(signal); |
| + | } |
| + | break; |
| + | |
| + | default: |
| + | /* The handle has an unknown type, try to wait on it */ |
| + | if(WaitForMultipleObjectsEx(2, handles, FALSE, INFINITE, FALSE) |
| + | == WAIT_OBJECT_0 + 1) { |
| + | logmsg("[select_ws_wait_thread] data available, HANDLE: %p", handle); |
| + | SetEvent(signal); |
| + | } |
| + | break; |
| } | |
| return 0; | |
| @@ -658,12 +658,12 @@ static int select_ws(int nfds, fd_set *readfds, fd_set *writefds, | |
| if(FD_ISSET(wsasock, readfds)) { | |
| FD_SET(wsasock, &readsock); | |
| - | wsaevents.lNetworkEvents |= FD_READ|FD_ACCEPT|FD_CLOSE; |
| + | wsaevents.lNetworkEvents |= FD_READ | FD_ACCEPT | FD_CLOSE; |
| } | |
| if(FD_ISSET(wsasock, writefds)) { | |
| FD_SET(wsasock, &writesock); | |
| - | wsaevents.lNetworkEvents |= FD_WRITE|FD_CONNECT|FD_CLOSE; |
| + | wsaevents.lNetworkEvents |= FD_WRITE | FD_CONNECT | FD_CLOSE; |
| } | |
| if(FD_ISSET(wsasock, exceptfds)) { | |
| @@ -800,11 +800,11 @@ static int select_ws(int nfds, fd_set *readfds, fd_set *writefds, | |
| wsaevents.lNetworkEvents |= data[i].wsastate; | |
| /* remove from descriptor set if not ready for read/accept/close */ | |
| - | if(!(wsaevents.lNetworkEvents & (FD_READ|FD_ACCEPT|FD_CLOSE))) |
| + | if(!(wsaevents.lNetworkEvents & (FD_READ | FD_ACCEPT | FD_CLOSE))) |
| FD_CLR(wsasock, readfds); | |
| /* remove from descriptor set if not ready for write/connect */ | |
| - | if(!(wsaevents.lNetworkEvents & (FD_WRITE|FD_CONNECT|FD_CLOSE))) |
| + | if(!(wsaevents.lNetworkEvents & (FD_WRITE | FD_CONNECT | FD_CLOSE))) |
| FD_CLR(wsasock, writefds); | |
| /* remove from descriptor set if not exceptional */ | |
| @@ -851,10 +851,10 @@ static int select_ws(int nfds, fd_set *readfds, fd_set *writefds, | |
| return ret; | |
| } | |
| - | #define SOCKFILT_select(a,b,c,d,e) select_ws(a,b,c,d,e) |
| + | #define SOCKFILT_select(a, b, c, d, e) select_ws(a, b, c, d, e) |
| #else | |
| - | #define SOCKFILT_select(a,b,c,d,e) select(a,b,c,d,e) |
| - | #endif /* USE_WINSOCK */ |
| + | #define SOCKFILT_select(a, b, c, d, e) select(a, b, c, d, e) |
| + | #endif /* USE_WINSOCK */ |
| /* Perform the disconnect handshake with sockfilt | |
| * This involves waiting for the disconnect acknowledgment after the DISC | |
| @@ -867,46 +867,45 @@ static bool disc_handshake(void) | |
| return FALSE; | |
| do { | |
| - | unsigned char buffer[BUFFER_SIZE]; |
| - | ssize_t buffer_len; |
| - | if(!read_stdin(buffer, 5)) |
| - | return FALSE; |
| - | logmsg("Received %c%c%c%c (on stdin)", |
| - | buffer[0], buffer[1], buffer[2], buffer[3]); |
| - | |
| - | if(!memcmp("ACKD", buffer, 4)) { |
| - | /* got the ack we were waiting for */ |
| - | break; |
| - | } |
| - | else if(!memcmp("DISC", buffer, 4)) { |
| - | logmsg("Crikey! Client also wants to disconnect"); |
| - | if(!write_stdout("ACKD\n", 5)) |
| - | return FALSE; |
| - | } |
| - | else if(!memcmp("DATA", buffer, 4)) { |
| - | /* We must read more data to stay in sync */ |
| - | logmsg("Throwing away data bytes"); |
| - | if(!read_data_block(buffer, sizeof(buffer), &buffer_len)) |
| - | return FALSE; |
| + | unsigned char buffer[BUFFER_SIZE]; |
| + | ssize_t buffer_len; |
| + | if(!read_stdin(buffer, 5)) |
| + | return FALSE; |
| + | logmsg("Received %c%c%c%c (on stdin)", |
| + | buffer[0], buffer[1], buffer[2], buffer[3]); |
| - | } |
| - | else if(!memcmp("QUIT", buffer, 4)) { |
| - | /* just die */ |
| - | logmsg("quits"); |
| + | if(!memcmp("ACKD", buffer, 4)) { |
| + | /* got the ack we were waiting for */ |
| + | break; |
| + | } |
| + | else if(!memcmp("DISC", buffer, 4)) { |
| + | logmsg("Crikey! Client also wants to disconnect"); |
| + | if(!write_stdout("ACKD\n", 5)) |
| return FALSE; | |
| - | } |
| - | else { |
| - | logmsg("Unexpected message error; aborting"); |
| - | /* |
| - | * The only other messages that could occur here are PING and PORT, |
| - | * and both of them occur at the start of a test when nothing should be |
| - | * trying to DISC. Therefore, we should not ever get here, but if we |
| - | * do, it is probably due to some kind of unclean shutdown situation so |
| - | * us shutting down is what we probably ought to be doing, anyway. |
| - | */ |
| + | } |
| + | else if(!memcmp("DATA", buffer, 4)) { |
| + | /* We must read more data to stay in sync */ |
| + | logmsg("Throwing away data bytes"); |
| + | if(!read_data_block(buffer, sizeof(buffer), &buffer_len)) |
| return FALSE; | |
| - | } |
| + | } |
| + | else if(!memcmp("QUIT", buffer, 4)) { |
| + | /* just die */ |
| + | logmsg("quits"); |
| + | return FALSE; |
| + | } |
| + | else { |
| + | logmsg("Unexpected message error; aborting"); |
| + | /* |
| + | * The only other messages that could occur here are PING and PORT, |
| + | * and both of them occur at the start of a test when nothing should be |
| + | * trying to DISC. Therefore, we should not ever get here, but if we |
| + | * do, it is probably due to some kind of unclean shutdown situation so |
| + | * us shutting down is what we probably ought to be doing, anyway. |
| + | */ |
| + | return FALSE; |
| + | } |
| } while(TRUE); | |
| return TRUE; | |
| } | |
| @@ -1034,7 +1033,6 @@ static bool juggle(curl_socket_t *sockfdp, | |
| } /* switch(*mode) */ | |
| - | |
| do { | |
| /* select() blocking behavior call on blocking descriptors please */ | |
| @@ -1058,7 +1056,6 @@ static bool juggle(curl_socket_t *sockfdp, | |
| /* timeout */ | |
| return TRUE; | |
| - | |
| if(FD_ISSET(fileno(stdin), &fds_read)) { | |
| ssize_t buffer_len; | |
| /* read from stdin, commands/data to be dealt with and possibly passed on | |
| @@ -1146,8 +1143,7 @@ static bool juggle(curl_socket_t *sockfdp, | |
| } | |
| } | |
| - | |
| - | if((sockfd != CURL_SOCKET_BAD) && (FD_ISSET(sockfd, &fds_read)) ) { |
| + | if((sockfd != CURL_SOCKET_BAD) && (FD_ISSET(sockfd, &fds_read))) { |
| ssize_t nread_socket; | |
| if(*mode == PASSIVE_LISTEN) { | |
| /* there is no stream set up yet, this is an indication that there is a | |
| @@ -1228,7 +1224,7 @@ static int test_sockfilt(int argc, char *argv[]) | |
| #else | |
| "" | |
| #endif | |
| - | ); |
| + | ); |
| return 0; | |
| } | |
| else if(!strcmp("--verbose", argv[arg])) { | |
| @@ -289,8 +289,8 @@ static curl_socket_t socks4(curl_socket_t fd, | |
| static curl_socket_t sockit(curl_socket_t fd) | |
| { | |
| - | unsigned char buffer[2*256 + 16]; |
| - | unsigned char response[2*256 + 16]; |
| + | unsigned char buffer[2 * 256 + 16]; |
| + | unsigned char response[2 * 256 + 16]; |
| ssize_t rc; | |
| unsigned char len; | |
| unsigned char type; | |
| @@ -483,7 +483,7 @@ static curl_socket_t sockit(curl_socket_t fd) | |
| case 3: | |
| /* The first octet of the address field contains the number of octets | |
| of name that follow */ | |
| - | fprintf(dump, " %.*s\n", len-1, &address[1]); |
| + | fprintf(dump, " %.*s\n", len - 1, &address[1]); |
| break; | |
| case 4: | |
| /* 16 bytes IPv6 address */ | |
| @@ -579,8 +579,7 @@ static int tunnel(struct perclient *cp, fd_set *fds) | |
| /* read from client, send to remote */ | |
| nread = recv(cp->clientfd, buffer, sizeof(buffer), 0); | |
| if(nread > 0) { | |
| - | nwrite = send(cp->remotefd, (char *)buffer, |
| - | (SEND_TYPE_ARG3)nread, 0); |
| + | nwrite = send(cp->remotefd, (char *)buffer, (SEND_TYPE_ARG3)nread, 0); |
| if(nwrite != nread) | |
| return 1; | |
| cp->fromclient += nwrite; | |
| @@ -592,8 +591,7 @@ static int tunnel(struct perclient *cp, fd_set *fds) | |
| /* read from remote, send to client */ | |
| nread = recv(cp->remotefd, buffer, sizeof(buffer), 0); | |
| if(nread > 0) { | |
| - | nwrite = send(cp->clientfd, (char *)buffer, |
| - | (SEND_TYPE_ARG3)nread, 0); |
| + | nwrite = send(cp->clientfd, (char *)buffer, (SEND_TYPE_ARG3)nread, 0); |
| if(nwrite != nread) | |
| return 1; | |
| cp->fromremote += nwrite; | |
| @@ -725,7 +723,6 @@ static bool socksd_incoming(curl_socket_t listenfd) | |
| cp->used = TRUE; | |
| clients++; | |
| } | |
| - | |
| } | |
| } | |
| for(i = 0; i < 2; i++) { | |
| @@ -777,7 +774,7 @@ static int test_socksd(int argc, char *argv[]) | |
| #else | |
| "" | |
| #endif | |
| - | ); |
| + | ); |
| return 0; | |
| } | |
| else if(!strcmp("--pidfile", argv[arg])) { | |
| @@ -51,7 +51,7 @@ static bool sws_prevbounce = FALSE; /* instructs the server to override the | |
| #define RCMD_STREAM 2 /* told to stream */ | |
| struct sws_httprequest { | |
| - | char reqbuf[2*1024*1024]; /* buffer area for the incoming request */ |
| + | char reqbuf[2 * 1024 * 1024]; /* buffer area for the incoming request */ |
| bool connect_request; /* if a CONNECT */ | |
| unsigned short connect_port; /* the port number CONNECT used */ | |
| size_t checkindex; /* where to start checking of the request */ | |
| @@ -138,8 +138,7 @@ static const char *cmdfile = "log/server.cmd"; | |
| static const char *end_of_headers = END_OF_HEADERS; | |
| /* sent as reply to a QUIT */ | |
| - | static const char *docquit_sws = |
| - | "HTTP/1.1 200 Goodbye" END_OF_HEADERS; |
| + | static const char *docquit_sws = "HTTP/1.1 200 Goodbye" END_OF_HEADERS; |
| /* send back this on 404 file not found */ | |
| static const char *doc404 = "HTTP/1.1 404 Not Found\r\n" | |
| @@ -169,7 +168,7 @@ static bool socket_domain_is_ip(void) | |
| #endif | |
| return true; | |
| default: | |
| - | /* case AF_UNIX: */ |
| + | /* case AF_UNIX: */ |
| return false; | |
| } | |
| } | |
| @@ -334,12 +333,10 @@ static int sws_ProcessRequest(struct sws_httprequest *req) | |
| size_t npath = 0; /* httppath length */ | |
| if(sscanf(line, | |
| - | "%" REQUEST_KEYWORD_SIZE_TXT"s ", request) == 1) { |
| + | "%" REQUEST_KEYWORD_SIZE_TXT "s ", request) == 1) { |
| http = strstr(line + strlen(request), "HTTP/"); | |
| - | if(http && sscanf(http, "HTTP/%d.%d", |
| - | &prot_major, |
| - | &prot_minor) == 2) { |
| + | if(http && sscanf(http, "HTTP/%d.%d", &prot_major, &prot_minor) == 2) { |
| /* between the request keyword and HTTP/ there is a path */ | |
| httppath = line + strlen(request); | |
| npath = http - httppath; | |
| @@ -361,7 +358,7 @@ static int sws_ProcessRequest(struct sws_httprequest *req) | |
| if(fine) { | |
| char *ptr; | |
| - | req->prot_version = prot_major*10 + prot_minor; |
| + | req->prot_version = prot_major * 10 + prot_minor; |
| /* find the last slash */ | |
| ptr = &httppath[npath]; | |
| @@ -746,7 +743,7 @@ static void sws_storerequest(const char *reqbuf, size_t totalsize) | |
| writeleft = totalsize; | |
| do { | |
| - | written = fwrite(&reqbuf[totalsize-writeleft], 1, writeleft, dump); |
| + | written = fwrite(&reqbuf[totalsize - writeleft], 1, writeleft, dump); |
| if(got_exit_signal) | |
| goto storerequest_cleanup; | |
| if(written > 0) | |
| @@ -761,7 +758,7 @@ static void sws_storerequest(const char *reqbuf, size_t totalsize) | |
| logmsg("Error writing file %s error (%d) %s", dumpfile, | |
| error, curlx_strerror(error, errbuf, sizeof(errbuf))); | |
| logmsg("Wrote only (%zu bytes) of (%zu bytes) request input to %s", | |
| - | totalsize-writeleft, totalsize, dumpfile); |
| + | totalsize - writeleft, totalsize, dumpfile); |
| } | |
| storerequest_cleanup: | |
| @@ -876,7 +873,7 @@ static int sws_get_request(curl_socket_t sock, struct sws_httprequest *req) | |
| return -1; | |
| } | |
| - | if(req->offset >= sizeof(req->reqbuf)-1) { |
| + | if(req->offset >= sizeof(req->reqbuf) - 1) { |
| /* buffer is already full; do nothing */ | |
| overflow = 1; | |
| } | |
| @@ -888,7 +885,7 @@ static int sws_get_request(curl_socket_t sock, struct sws_httprequest *req) | |
| got = sread(sock, reqbuf + req->offset, req->cl); | |
| else | |
| got = sread(sock, reqbuf + req->offset, | |
| - | sizeof(req->reqbuf)-1 - req->offset); |
| + | sizeof(req->reqbuf) - 1 - req->offset); |
| if(got_exit_signal) | |
| return -1; | |
| @@ -924,16 +921,16 @@ static int sws_get_request(curl_socket_t sock, struct sws_httprequest *req) | |
| return -1; | |
| } | |
| - | if(overflow || (req->offset == sizeof(req->reqbuf)-1 && got > 0)) { |
| + | if(overflow || (req->offset == sizeof(req->reqbuf) - 1 && got > 0)) { |
| logmsg("Request would overflow buffer, closing connection"); | |
| /* dump request received so far to external file anyway */ | |
| - | reqbuf[sizeof(req->reqbuf)-1] = '\0'; |
| + | reqbuf[sizeof(req->reqbuf) - 1] = '\0'; |
| fail = 1; | |
| } | |
| - | else if(req->offset > sizeof(req->reqbuf)-1) { |
| + | else if(req->offset > sizeof(req->reqbuf) - 1) { |
| logmsg("Request buffer overflow, closing connection"); | |
| /* dump request received so far to external file anyway */ | |
| - | reqbuf[sizeof(req->reqbuf)-1] = '\0'; |
| + | reqbuf[sizeof(req->reqbuf) - 1] = '\0'; |
| fail = 1; | |
| } | |
| else | |
| @@ -978,10 +975,10 @@ static int sws_send_doc(curl_socket_t sock, struct sws_httprequest *req) | |
| case RCMD_STREAM: { | |
| static const char streamthis[] = "a string to stream 01234567890\n"; | |
| for(;;) { | |
| - | written = swrite(sock, streamthis, sizeof(streamthis)-1); |
| + | written = swrite(sock, streamthis, sizeof(streamthis) - 1); |
| if(got_exit_signal) | |
| return -1; | |
| - | if(written != (ssize_t)(sizeof(streamthis)-1)) { |
| + | if(written != (ssize_t)(sizeof(streamthis) - 1)) { |
| logmsg("Stopped streaming"); | |
| break; | |
| } | |
| @@ -1144,7 +1141,7 @@ retry: | |
| if(req->writedelay) { | |
| int msecs_left = req->writedelay; | |
| int intervals = msecs_left / MAX_SLEEP_TIME_MS; | |
| - | if(msecs_left%MAX_SLEEP_TIME_MS) |
| + | if(msecs_left % MAX_SLEEP_TIME_MS) |
| intervals++; | |
| logmsg("Pausing %d milliseconds after writing %zd bytes", | |
| msecs_left, written); | |
| @@ -1172,7 +1169,7 @@ retry: | |
| if(sendfailure) { | |
| logmsg("Sending response failed. Only (%zu bytes) of (%zu bytes) " | |
| "were sent", | |
| - | responsesize-count, responsesize); |
| + | responsesize - count, responsesize); |
| sws_prevtestno = req->testno; | |
| sws_prevpartno = req->partno; | |
| free(ptr); | |
| @@ -1247,9 +1244,7 @@ static curl_socket_t connect_to(const char *ipaddr, unsigned short port) | |
| if(!ipaddr) | |
| return CURL_SOCKET_BAD; | |
| - | logmsg("about to connect to %s%s%s:%hu", |
| - | op_br, ipaddr, cl_br, port); |
| - | |
| + | logmsg("about to connect to %s%s%s:%hu", op_br, ipaddr, cl_br, port); |
| serverfd = socket(socket_domain, SOCK_STREAM, 0); | |
| if(CURL_SOCKET_BAD == serverfd) { | |
| @@ -1389,7 +1384,7 @@ success: | |
| * must accept a new connection and deal with it appropriately. | |
| */ | |
| - | #define data_or_ctrl(x) ((x)?"DATA":"CTRL") |
| + | #define data_or_ctrl(x) ((x) ? "DATA" : "CTRL") |
| #define SWS_CTRL 0 | |
| #define SWS_DATA 1 | |
| @@ -1644,7 +1639,7 @@ static void http_connect(curl_socket_t *infdp, | |
| } | |
| } | |
| if(serverfd[i] != CURL_SOCKET_BAD) { | |
| - | len = sizeof(readserver[i])-toc[i]; |
| + | len = sizeof(readserver[i]) - toc[i]; |
| if(len && FD_ISSET(serverfd[i], &input)) { | |
| /* read from server */ | |
| rc = sread(serverfd[i], &readserver[i][toc[i]], len); | |
| @@ -1676,7 +1671,7 @@ static void http_connect(curl_socket_t *infdp, | |
| logmsg("[%s] SENT \"%s\"", data_or_ctrl(i), | |
| data_to_hex(readserver[i], rc)); | |
| if(toc[i] - rc) | |
| - | memmove(&readserver[i][0], &readserver[i][rc], toc[i]-rc); |
| + | memmove(&readserver[i][0], &readserver[i][rc], toc[i] - rc); |
| toc[i] -= rc; | |
| } | |
| } | |
| @@ -1696,7 +1691,7 @@ static void http_connect(curl_socket_t *infdp, | |
| logmsg("[%s] SENT \"%s\"", data_or_ctrl(i), | |
| data_to_hex(readclient[i], rc)); | |
| if(tos[i] - rc) | |
| - | memmove(&readclient[i][0], &readclient[i][rc], tos[i]-rc); |
| + | memmove(&readclient[i][0], &readclient[i][rc], tos[i] - rc); |
| tos[i] -= rc; | |
| } | |
| } | |
| @@ -1826,7 +1821,6 @@ static void http_upgrade(struct sws_httprequest *req) | |
| /* left to implement */ | |
| } | |
| - | |
| /* returns a socket handle, or 0 if there are no more waiting sockets, | |
| or < 0 if there was an error */ | |
| static curl_socket_t accept_connection(curl_socket_t sock) | |
| @@ -2021,12 +2015,12 @@ static int test_sws(int argc, char *argv[]) | |
| if(!strcmp("--version", argv[arg])) { | |
| puts("sws IPv4" | |
| #ifdef USE_IPV6 | |
| - | "/IPv6" |
| + | "/IPv6" |
| #endif | |
| #ifdef USE_UNIX_SOCKETS | |
| - | "/unix" |
| + | "/unix" |
| #endif | |
| - | ); |
| + | ); |
| return 0; | |
| } | |
| else if(!strcmp("--pidfile", argv[arg])) { | |
| @@ -2097,8 +2091,7 @@ static int test_sws(int argc, char *argv[]) | |
| if(argc > arg) { | |
| opt = argv[arg]; | |
| if(curlx_str_number(&opt, &num, 0xffff)) { | |
| - | fprintf(stderr, "sws: invalid --port argument (%s)\n", |
| - | argv[arg]); |
| + | fprintf(stderr, "sws: invalid --port argument (%s)\n", argv[arg]); |
| return 0; | |
| } | |
| port = (unsigned short)num; | |
| @@ -2327,9 +2320,9 @@ static int test_sws(int argc, char *argv[]) | |
| /* Clear out closed sockets */ | |
| for(socket_idx = num_sockets - 1; socket_idx >= 1; --socket_idx) { | |
| if(CURL_SOCKET_BAD == all_sockets[socket_idx]) { | |
| - | char *dst = (char *) (all_sockets + socket_idx); |
| - | char *src = (char *) (all_sockets + socket_idx + 1); |
| - | char *end = (char *) (all_sockets + num_sockets); |
| + | char *dst = (char *)(all_sockets + socket_idx); |
| + | char *src = (char *)(all_sockets + socket_idx + 1); |
| + | char *end = (char *)(all_sockets + num_sockets); |
| memmove(dst, src, end - src); | |
| num_sockets -= 1; | |
| } | |
| @@ -380,7 +380,7 @@ static void read_ahead(struct testcase *test, | |
| } | |
| p = dp->th_data; | |
| - | for(i = 0 ; i < SEGSIZE; i++) { |
| + | for(i = 0; i < SEGSIZE; i++) { |
| if(newline) { | |
| if(prevchar == '\n') | |
| c = '\n'; /* lf to cr,lf */ | |
| @@ -536,8 +536,7 @@ static int synchnet(curl_socket_t f /* socket to flush */) | |
| else | |
| fromaddrlen = sizeof(fromaddr.sa6); | |
| #endif | |
| - | (void)recvfrom(f, rbuf, sizeof(rbuf), 0, |
| - | &fromaddr.sa, &fromaddrlen); |
| + | (void)recvfrom(f, rbuf, sizeof(rbuf), 0, &fromaddr.sa, &fromaddrlen); |
| } | |
| else | |
| break; | |
| @@ -578,7 +577,7 @@ static int test_tftpd(int argc, char **argv) | |
| #else | |
| "" | |
| #endif | |
| - | ); |
| + | ); |
| return 0; | |
| } | |
| else if(!strcmp("--pidfile", argv[arg])) { | |
| @@ -674,8 +673,7 @@ static int test_tftpd(int argc, char **argv) | |
| } | |
| flag = 1; | |
| - | if(setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, |
| - | (void *)&flag, sizeof(flag))) { |
| + | if(setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void *)&flag, sizeof(flag))) { |
| error = SOCKERRNO; | |
| logmsg("setsockopt(SO_REUSEADDR) failed with error (%d) %s", | |
| error, curlx_strerror(error, errbuf, sizeof(errbuf))); | |
| @@ -825,7 +823,7 @@ static int test_tftpd(int argc, char **argv) | |
| } | |
| #endif | |
| - | maxtimeout = 5*TIMEOUT; |
| + | maxtimeout = 5 * TIMEOUT; |
| tp = &trsbuf.hdr; | |
| tp->th_opcode = ntohs(tp->th_opcode); | |
| @@ -1076,7 +1074,6 @@ static int tftpd_parse_servercmd(struct testcase *req) | |
| return 0; /* OK! */ | |
| } | |
| - | |
| /* | |
| * Validate file access. | |
| */ | |
| @@ -1104,7 +1101,7 @@ static int validate_access(struct testcase *test, | |
| ptr = strrchr(filename, '/'); | |
| if(ptr) { | |
| - | char partbuf[80]="data"; |
| + | char partbuf[80] = "data"; |
| long partno; | |
| long testno; | |
| const char *pval; | |
| @@ -1209,7 +1206,7 @@ static void sendtftp(struct testcase *test, const struct formats *pf) | |
| if(test->writedelay) { | |
| logmsg("Pausing %d seconds before %d bytes", test->writedelay, | |
| size); | |
| - | curlx_wait_ms(1000*test->writedelay); |
| + | curlx_wait_ms(1000 * test->writedelay); |
| } | |
| send_data: | |
| @@ -1249,11 +1246,10 @@ send_data: | |
| } | |
| /* Re-synchronize with the other side */ | |
| (void)synchnet(peer); | |
| - | if(sap->th_block == (sendblock-1)) { |
| + | if(sap->th_block == (sendblock - 1)) { |
| goto send_data; | |
| } | |
| } | |
| - | |
| } | |
| sendblock++; | |
| } while(size == SEGSIZE); | |
| @@ -37,7 +37,7 @@ | |
| */ | |
| char *data_to_hex(char *data, size_t len) | |
| { | |
| - | static char buf[256*3]; |
| + | static char buf[256 * 3]; |
| size_t i; | |
| char *optr = buf; | |
| char *iptr = data; | |
| @@ -177,18 +177,18 @@ int win32_init(void) | |
| } | |
| if(LOBYTE(wsaData.wVersion) != LOBYTE(wVersionRequested) || | |
| - | HIBYTE(wsaData.wVersion) != HIBYTE(wVersionRequested) ) { |
| + | HIBYTE(wsaData.wVersion) != HIBYTE(wVersionRequested)) { |
| WSACleanup(); | |
| win32_perror("Winsock init failed"); | |
| logmsg("No suitable winsock.dll found -- aborting"); | |
| return 1; | |
| } | |
| } | |
| - | #endif /* USE_WINSOCK */ |
| + | #endif /* USE_WINSOCK */ |
| atexit(win32_cleanup); | |
| return 0; | |
| } | |
| - | #endif /* _WIN32 */ |
| + | #endif /* _WIN32 */ |
| /* fopens the test case file */ | |
| FILE *test2fopen(long testno, const char *logdir2) | |
| @@ -370,8 +370,7 @@ static void exit_signal_handler(int signum) | |
| fd != -1) { | |
| #else | |
| /* !checksrc! disable BANNEDFUNC 1 */ | |
| - | fd = open(serverlogfile, |
| - | O_WRONLY | O_CREAT | O_APPEND, S_IRUSR | S_IWUSR); |
| + | fd = open(serverlogfile, O_WRONLY | O_CREAT | O_APPEND, S_IRUSR | S_IWUSR); |
| if(fd != -1) { | |
| #endif | |
| static const char msg[] = "exit_signal_handler: called\n"; | |
| @@ -546,7 +545,7 @@ static SIGHANDLER_T set_signal(int signum, SIGHANDLER_T handler, | |
| #ifdef HAVE_SIGINTERRUPT | |
| if(oldhdlr != SIG_ERR) | |
| - | siginterrupt(signum, (int) restartable); |
| + | siginterrupt(signum, (int)restartable); |
| #else | |
| (void)restartable; | |
| #endif | |
| @@ -693,7 +692,7 @@ int bind_unix_socket(curl_socket_t sock, const char *unix_socket, | |
| return -1; | |
| } | |
| strcpy(sau->sun_path, unix_socket); | |
| - | rc = bind(sock, (struct sockaddr*)sau, sizeof(struct sockaddr_un)); |
| + | rc = bind(sock, (struct sockaddr *)sau, sizeof(struct sockaddr_un)); |
| if(rc && SOCKERRNO == SOCKEADDRINUSE) { | |
| struct_stat statbuf; | |
| /* socket already exists. Perhaps it is stale? */ | |
| @@ -738,7 +737,7 @@ int bind_unix_socket(curl_socket_t sock, const char *unix_socket, | |
| return rc; | |
| } | |
| /* stale socket is gone, retry bind */ | |
| - | rc = bind(sock, (struct sockaddr*)sau, sizeof(struct sockaddr_un)); |
| + | rc = bind(sock, (struct sockaddr *)sau, sizeof(struct sockaddr_un)); |
| } | |
| return rc; | |
| } | |
| @@ -805,29 +804,29 @@ curl_socket_t sockdaemon(curl_socket_t sock, | |
| request to let the system choose a non-zero available port. */ | |
| switch(socket_domain) { | |
| - | case AF_INET: |
| - | memset(&listener.sa4, 0, sizeof(listener.sa4)); |
| - | listener.sa4.sin_family = AF_INET; |
| - | listener.sa4.sin_addr.s_addr = INADDR_ANY; |
| - | listener.sa4.sin_port = htons(*listenport); |
| - | rc = bind(sock, &listener.sa, sizeof(listener.sa4)); |
| - | break; |
| + | case AF_INET: |
| + | memset(&listener.sa4, 0, sizeof(listener.sa4)); |
| + | listener.sa4.sin_family = AF_INET; |
| + | listener.sa4.sin_addr.s_addr = INADDR_ANY; |
| + | listener.sa4.sin_port = htons(*listenport); |
| + | rc = bind(sock, &listener.sa, sizeof(listener.sa4)); |
| + | break; |
| #ifdef USE_IPV6 | |
| - | case AF_INET6: |
| - | memset(&listener.sa6, 0, sizeof(listener.sa6)); |
| - | listener.sa6.sin6_family = AF_INET6; |
| - | listener.sa6.sin6_addr = in6addr_any; |
| - | listener.sa6.sin6_port = htons(*listenport); |
| - | rc = bind(sock, &listener.sa, sizeof(listener.sa6)); |
| - | break; |
| + | case AF_INET6: |
| + | memset(&listener.sa6, 0, sizeof(listener.sa6)); |
| + | listener.sa6.sin6_family = AF_INET6; |
| + | listener.sa6.sin6_addr = in6addr_any; |
| + | listener.sa6.sin6_port = htons(*listenport); |
| + | rc = bind(sock, &listener.sa, sizeof(listener.sa6)); |
| + | break; |
| #endif /* USE_IPV6 */ | |
| #ifdef USE_UNIX_SOCKETS | |
| - | case AF_UNIX: |
| - | rc = bind_unix_socket(sock, unix_socket, &listener.sau); |
| - | break; |
| + | case AF_UNIX: |
| + | rc = bind_unix_socket(sock, unix_socket, &listener.sau); |
| + | break; |
| #endif | |
| - | default: |
| - | rc = 1; |
| + | default: |
| + | rc = 1; |
| } | |
| if(rc) { | |
| @@ -65,7 +65,7 @@ static CURLcode test_unit1300(const char *arg) | |
| * 2: list head will be NULL | |
| * 3: list tail will be NULL | |
| * 4: list dtor will be NULL | |
| - | */ |
| + | */ |
| fail_unless(Curl_llist_count(&llist) == 0, | |
| "list initial size should be zero"); | |
| @@ -124,7 +124,7 @@ static CURLcode test_unit1302(const char *arg) | |
| {"", 0, "aWlpaWlpaQ=", 15} /* unaligned size, missing a padding char */ | |
| }; | |
| - | for(i = 0 ; i < CURL_ARRAYSIZE(encode); i++) { |
| + | for(i = 0; i < CURL_ARRAYSIZE(encode); i++) { |
| struct etest *e = &encode[i]; | |
| char *out; | |
| unsigned char *decoded; | |
| @@ -180,7 +180,7 @@ static CURLcode test_unit1302(const char *arg) | |
| Curl_safefree(out); | |
| } | |
| - | for(i = 0 ; i < CURL_ARRAYSIZE(badecode); i++) { |
| + | for(i = 0; i < CURL_ARRAYSIZE(badecode); i++) { |
| struct etest *e = &badecode[i]; | |
| unsigned char *decoded; | |
| size_t dlen; | |
| @@ -46,8 +46,7 @@ static CURLcode test_unit1304(const char *arg) | |
| * Test a non existent host in our netrc file. | |
| */ | |
| Curl_netrc_init(&store); | |
| - | result = Curl_parsenetrc(&store, |
| - | "test.example.com", &login, &password, arg); |
| + | result = Curl_parsenetrc(&store, "test.example.com", &login, &password, arg); |
| fail_unless(result == 1, "Host not found should return 1"); | |
| abort_unless(password == NULL, "password did not return NULL!"); | |
| abort_unless(login == NULL, "user did not return NULL!"); | |
| @@ -58,8 +57,7 @@ static CURLcode test_unit1304(const char *arg) | |
| */ | |
| login = (char *)CURL_UNCONST("me"); | |
| Curl_netrc_init(&store); | |
| - | result = Curl_parsenetrc(&store, |
| - | "example.com", &login, &password, arg); |
| + | result = Curl_parsenetrc(&store, "example.com", &login, &password, arg); |
| fail_unless(result == 0, "Host should have been found"); | |
| abort_unless(password == NULL, "password is not NULL!"); | |
| Curl_netrc_cleanup(&store); | |
| @@ -69,8 +67,7 @@ static CURLcode test_unit1304(const char *arg) | |
| */ | |
| login = (char *)CURL_UNCONST("me"); | |
| Curl_netrc_init(&store); | |
| - | result = Curl_parsenetrc(&store, |
| - | "test.example.com", &login, &password, arg); |
| + | result = Curl_parsenetrc(&store, "test.example.com", &login, &password, arg); |
| fail_unless(result == 1, "Host not found should return 1"); | |
| abort_unless(password == NULL, "password is not NULL!"); | |
| Curl_netrc_cleanup(&store); | |
| @@ -81,8 +78,7 @@ static CURLcode test_unit1304(const char *arg) | |
| */ | |
| login = (char *)CURL_UNCONST("admi"); /* spellchecker:disable-line */ | |
| Curl_netrc_init(&store); | |
| - | result = Curl_parsenetrc(&store, |
| - | "example.com", &login, &password, arg); |
| + | result = Curl_parsenetrc(&store, "example.com", &login, &password, arg); |
| fail_unless(result == 0, "Host should have been found"); | |
| abort_unless(password == NULL, "password is not NULL!"); | |
| Curl_netrc_cleanup(&store); | |
| @@ -93,8 +89,7 @@ static CURLcode test_unit1304(const char *arg) | |
| */ | |
| login = (char *)CURL_UNCONST("adminn"); | |
| Curl_netrc_init(&store); | |
| - | result = Curl_parsenetrc(&store, |
| - | "example.com", &login, &password, arg); |
| + | result = Curl_parsenetrc(&store, "example.com", &login, &password, arg); |
| fail_unless(result == 0, "Host should have been found"); | |
| abort_unless(password == NULL, "password is not NULL!"); | |
| Curl_netrc_cleanup(&store); | |
| @@ -105,8 +100,7 @@ static CURLcode test_unit1304(const char *arg) | |
| */ | |
| login = NULL; | |
| Curl_netrc_init(&store); | |
| - | result = Curl_parsenetrc(&store, |
| - | "example.com", &login, &password, arg); |
| + | result = Curl_parsenetrc(&store, "example.com", &login, &password, arg); |
| fail_unless(result == 0, "Host should have been found"); | |
| abort_unless(password != NULL, "returned NULL!"); | |
| fail_unless(strncmp(password, "passwd", 6) == 0, | |
| @@ -124,8 +118,7 @@ static CURLcode test_unit1304(const char *arg) | |
| password = NULL; | |
| login = NULL; | |
| Curl_netrc_init(&store); | |
| - | result = Curl_parsenetrc(&store, |
| - | "example.com", &login, &password, arg); |
| + | result = Curl_parsenetrc(&store, "example.com", &login, &password, arg); |
| fail_unless(result == 0, "Host should have been found"); | |
| abort_unless(password != NULL, "returned NULL!"); | |
| fail_unless(strncmp(password, "passwd", 6) == 0, | |
| @@ -143,12 +136,10 @@ static CURLcode test_unit1304(const char *arg) | |
| curlx_free(login); | |
| login = NULL; | |
| Curl_netrc_init(&store); | |
| - | result = Curl_parsenetrc(&store, |
| - | "curl.example.com", &login, &password, arg); |
| + | result = Curl_parsenetrc(&store, "curl.example.com", &login, &password, arg); |
| fail_unless(result == 0, "Host should have been found"); | |
| abort_unless(password != NULL, "returned NULL!"); | |
| - | fail_unless(strncmp(password, "none", 4) == 0, |
| - | "password should be 'none'"); |
| + | fail_unless(strncmp(password, "none", 4) == 0, "password should be 'none'"); |
| abort_unless(login != NULL, "returned NULL!"); | |
| fail_unless(strncmp(login, "none", 4) == 0, "login should be 'none'"); | |
| Curl_netrc_cleanup(&store); | |
| @@ -162,12 +153,10 @@ static CURLcode test_unit1304(const char *arg) | |
| curlx_free(login); | |
| login = NULL; | |
| Curl_netrc_init(&store); | |
| - | result = Curl_parsenetrc(&store, |
| - | "curl.example.com", &login, &password, arg); |
| + | result = Curl_parsenetrc(&store, "curl.example.com", &login, &password, arg); |
| fail_unless(result == 0, "Host should have been found"); | |
| abort_unless(password != NULL, "returned NULL!"); | |
| - | fail_unless(strncmp(password, "none", 4) == 0, |
| - | "password should be 'none'"); |
| + | fail_unless(strncmp(password, "none", 4) == 0, "password should be 'none'"); |
| abort_unless(login != NULL, "returned NULL!"); | |
| fail_unless(strncmp(login, "none", 4) == 0, "login should be 'none'"); | |
| Curl_netrc_cleanup(&store); | |
| @@ -290,7 +290,7 @@ static CURLcode test_unit1307(const char *arg) | |
| for(i = 0; i < CURL_ARRAYSIZE(tests); i++) { | |
| int result = tests[i].result; | |
| int rc = Curl_fnmatch(NULL, tests[i].pattern, tests[i].string); | |
| - | if(result & (LINUX_DIFFER|MAC_DIFFER)) { |
| + | if(result & (LINUX_DIFFER | MAC_DIFFER)) { |
| if((result & LINUX_DIFFER) && (machine == SYSTEM_LINUX)) | |
| result >>= LINUX_SHIFT; | |
| else if((result & MAC_DIFFER) && (machine == SYSTEM_MACOS)) | |
| @@ -63,8 +63,8 @@ static CURLcode test_unit1309(const char *arg) | |
| #define NUM_NODES 50 | |
| struct Curl_tree *root, *removed; | |
| - | struct Curl_tree nodes[NUM_NODES*3]; |
| - | size_t storage[NUM_NODES*3]; |
| + | struct Curl_tree nodes[NUM_NODES * 3]; |
| + | size_t storage[NUM_NODES * 3]; |
| int rc; | |
| int i, j; | |
| struct curltime tv_now = {0, 0}; | |
| @@ -75,7 +75,7 @@ static CURLcode test_unit1309(const char *arg) | |
| struct curltime key; | |
| key.tv_sec = 0; | |
| - | key.tv_usec = (541*i)%1023; |
| + | key.tv_usec = (541 * i) % 1023; |
| storage[i] = key.tv_usec; | |
| Curl_splayset(&nodes[i], &storage[i]); | |
| root = Curl_splayinsert(key, root, &nodes[i]); | |
| @@ -85,7 +85,7 @@ static CURLcode test_unit1309(const char *arg) | |
| splayprint(root, 0, 1); | |
| for(i = 0; i < NUM_NODES; i++) { | |
| - | int rem = (i + 7)%NUM_NODES; |
| + | int rem = (i + 7) % NUM_NODES; |
| curl_mprintf("Tree look:\n"); | |
| splayprint(root, 0, 1); | |
| curl_mprintf("remove pointer %d, payload %zu\n", rem, | |
| @@ -105,11 +105,11 @@ static CURLcode test_unit1309(const char *arg) | |
| struct curltime key; | |
| key.tv_sec = 0; | |
| - | key.tv_usec = (541*i)%1023; |
| + | key.tv_usec = (541 * i) % 1023; |
| /* add some nodes with the same key */ | |
| for(j = 0; j <= i % 3; j++) { | |
| - | storage[i * 3 + j] = key.tv_usec*10 + j; |
| + | storage[i * 3 + j] = key.tv_usec * 10 + j; |
| Curl_splayset(&nodes[i * 3 + j], &storage[i * 3 + j]); | |
| root = Curl_splayinsert(key, root, &nodes[i * 3 + j]); | |
| } | |
| @@ -103,7 +103,7 @@ static CURLcode test_unit1397(const char *arg) | |
| "did %sMATCH\n", | |
| tests[i].host, | |
| tests[i].pattern, | |
| - | tests[i].match ? "NOT ": ""); |
| + | tests[i].match ? "NOT " : ""); |
| unitfail++; | |
| } | |
| } | |
| @@ -118,7 +118,7 @@ static CURLcode test_unit1398(const char *arg) | |
| "%s%s%s%s%s%s%s%s%s%s" /* 100 */ | |
| "%s%s%s%s%s%s%s%s%s%s" /* 110 */ | |
| "%s%s%s%s%s%s%s%s%s%s" /* 120 */ | |
| - | "%s%s%s%s%s%s%s%s%s", /* 129 */ |
| + | "%s%s%s%s%s%s%s%s%s", /* 129 */ |
| "a", "", "", "", "", "", "", "", "", "", /* 10 */ | |
| "b", "", "", "", "", "", "", "", "", "", /* 20 */ | |
| @@ -132,8 +132,8 @@ static CURLcode test_unit1398(const char *arg) | |
| "j", "", "", "", "", "", "", "", "", "", /* 100 */ | |
| "k", "", "", "", "", "", "", "", "", "", /* 110 */ | |
| "l", "", "", "", "", "", "", "", "", "", /* 120 */ | |
| - | "m", "", "", "", "", "", "", "", "" /* 129 */ |
| - | ); |
| + | "m", "", "", "", "", "", "", "", "" /* 129 */ |
| + | ); |
| fail_unless(rc == 0, "return code should be 0"); | |
| /* 128 input % flags */ | |
| @@ -150,7 +150,7 @@ static CURLcode test_unit1398(const char *arg) | |
| "%s%s%s%s%s%s%s%s%s%s" /* 100 */ | |
| "%s%s%s%s%s%s%s%s%s%s" /* 110 */ | |
| "%s%s%s%s%s%s%s%s%s%s" /* 120 */ | |
| - | "%s%s%s%s%s%s%s%s", /* 128 */ |
| + | "%s%s%s%s%s%s%s%s", /* 128 */ |
| "a", "", "", "", "", "", "", "", "", "", /* 10 */ | |
| "b", "", "", "", "", "", "", "", "", "", /* 20 */ | |
| @@ -164,8 +164,8 @@ static CURLcode test_unit1398(const char *arg) | |
| "j", "", "", "", "", "", "", "", "", "", /* 100 */ | |
| "k", "", "", "", "", "", "", "", "", "", /* 110 */ | |
| "l", "", "", "", "", "", "", "", "", "", /* 120 */ | |
| - | "m", "", "", "", "", "", "", "" /* 128 */ |
| - | ); |
| + | "m", "", "", "", "", "", "", "" /* 128 */ |
| + | ); |
| fail_unless(rc == 13, "return code should be 13"); | |
| /* 129 output segments */ | |
| @@ -176,8 +176,8 @@ static CURLcode test_unit1398(const char *arg) | |
| "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" /* 80 */ | |
| "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" /* 100 */ | |
| "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" /* 120 */ | |
| - | "%%%%%%%%%%%%%%%%%%" /* 129 */ |
| - | ); |
| + | "%%%%%%%%%%%%%%%%%%" /* 129 */ |
| + | ); |
| fail_unless(rc == 0, "return code should be 0"); | |
| /* 128 output segments */ | |
| @@ -188,8 +188,8 @@ static CURLcode test_unit1398(const char *arg) | |
| "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" /* 80 */ | |
| "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" /* 100 */ | |
| "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" /* 120 */ | |
| - | "%%%%%%%%%%%%%%%%" /* 128 */ |
| - | ); |
| + | "%%%%%%%%%%%%%%%%" /* 128 */ |
| + | ); |
| fail_unless(rc == 128, "return code should be 128"); | |
| UNITTEST_END_SIMPLE | |
| @@ -37,7 +37,7 @@ static CURLcode test_unit1601(const char *arg) | |
| unsigned char output[MD5_DIGEST_LEN]; | |
| unsigned char *testp = output; | |
| - | Curl_md5it(output, (const unsigned char *) string1, strlen(string1)); |
| + | Curl_md5it(output, (const unsigned char *)string1, strlen(string1)); |
| verify_memory(testp, "\xc4\xca\x42\x38\xa0\xb9\x23\x82\x0d\xcc\x50\x9a\x6f" | |
| "\x75\x84\x9b", MD5_DIGEST_LEN); | |
| @@ -82,18 +82,12 @@ static CURLcode test_unit1606(const char *arg) | |
| UNITTEST_BEGIN(t1606_setup(&easy)) | |
| - | fail_unless(runawhile(easy, 41, 41, 40, 0) == 41, |
| - | "wrong low speed timeout"); |
| - | fail_unless(runawhile(easy, 21, 21, 20, 0) == 21, |
| - | "wrong low speed timeout"); |
| - | fail_unless(runawhile(easy, 60, 60, 40, 0) == 60, |
| - | "wrong log speed timeout"); |
| - | fail_unless(runawhile(easy, 50, 50, 40, 0) == 50, |
| - | "wrong log speed timeout"); |
| - | fail_unless(runawhile(easy, 40, 40, 40, 0) == 99, |
| - | "should not time out"); |
| - | fail_unless(runawhile(easy, 10, 50, 100, 2) == 36, |
| - | "bad timeout"); |
| + | fail_unless(runawhile(easy, 41, 41, 40, 0) == 41, "wrong low speed timeout"); |
| + | fail_unless(runawhile(easy, 21, 21, 20, 0) == 21, "wrong low speed timeout"); |
| + | fail_unless(runawhile(easy, 60, 60, 40, 0) == 60, "wrong log speed timeout"); |
| + | fail_unless(runawhile(easy, 50, 50, 40, 0) == 50, "wrong log speed timeout"); |
| + | fail_unless(runawhile(easy, 40, 40, 40, 0) == 99, "should not time out"); |
| + | fail_unless(runawhile(easy, 10, 50, 100, 2) == 36, "bad timeout"); |
| UNITTEST_END(t1606_stop(easy)) | |
| } | |
| @@ -44,14 +44,14 @@ static CURLcode test_unit1610(const char *arg) | |
| unsigned char output[CURL_SHA256_DIGEST_LENGTH]; | |
| unsigned char *testp = output; | |
| - | Curl_sha256it(output, (const unsigned char *) string1, strlen(string1)); |
| + | Curl_sha256it(output, (const unsigned char *)string1, strlen(string1)); |
| verify_memory(testp, | |
| "\x6b\x86\xb2\x73\xff\x34\xfc\xe1\x9d\x6b\x80\x4e\xff\x5a\x3f" | |
| "\x57\x47\xad\xa4\xea\xa2\x2f\x1d\x49\xc0\x1e\x52\xdd\xb7\x87" | |
| "\x5b\x4b", CURL_SHA256_DIGEST_LENGTH); | |
| - | Curl_sha256it(output, (const unsigned char *) string2, strlen(string2)); |
| + | Curl_sha256it(output, (const unsigned char *)string2, strlen(string2)); |
| verify_memory(testp, | |
| "\xcb\xb1\x6a\x8a\xb9\xcb\xb9\x35\xa8\xcb\xa0\x2e\x28\xc0\x26" | |
| @@ -35,13 +35,13 @@ static CURLcode test_unit1611(const char *arg) | |
| unsigned char output[MD4_DIGEST_LENGTH]; | |
| unsigned char *testp = output; | |
| - | Curl_md4it(output, (const unsigned char *) string1, strlen(string1)); |
| + | Curl_md4it(output, (const unsigned char *)string1, strlen(string1)); |
| verify_memory(testp, | |
| "\x8b\xe1\xec\x69\x7b\x14\xad\x3a\x53\xb3\x71\x43\x61\x20\x64" | |
| "\x1d", MD4_DIGEST_LENGTH); | |
| - | Curl_md4it(output, (const unsigned char *) string2, strlen(string2)); |
| + | Curl_md4it(output, (const unsigned char *)string2, strlen(string2)); |
| verify_memory(testp, | |
| "\xa7\x16\x1c\xad\x7e\xbe\xdb\xbc\xf8\xc7\x23\x10\x2d\x2c\xe2" | |
| @@ -40,8 +40,8 @@ static CURLcode test_unit1612(const char *arg) | |
| unsigned char *testp = output; | |
| Curl_hmacit(&Curl_HMAC_MD5, | |
| - | (const unsigned char *) password, strlen(password), |
| - | (const unsigned char *) string1, strlen(string1), |
| + | (const unsigned char *)password, strlen(password), |
| + | (const unsigned char *)string1, strlen(string1), |
| output); | |
| verify_memory(testp, | |
| @@ -49,8 +49,8 @@ static CURLcode test_unit1612(const char *arg) | |
| "\x37", HMAC_MD5_LENGTH); | |
| Curl_hmacit(&Curl_HMAC_MD5, | |
| - | (const unsigned char *) password, strlen(password), |
| - | (const unsigned char *) string2, strlen(string2), |
| + | (const unsigned char *)password, strlen(password), |
| + | (const unsigned char *)string2, strlen(string2), |
| output); | |
| verify_memory(testp, | |
| @@ -34,12 +34,12 @@ static CURLcode test_unit1614(const char *arg) | |
| int err = 0; | |
| struct check { | |
| - | const char *a; |
| + | const char *a; |
| const char *n; | |
| unsigned int bits; | |
| bool match; | |
| }; | |
| - | struct check list4[]= { |
| + | struct check list4[] = { |
| { "192.160.0.1", "192.160.0.1", 33, FALSE}, | |
| { "192.160.0.1", "192.160.0.1", 32, TRUE}, | |
| { "192.160.0.1", "192.160.0.1", 0, TRUE}, | |
| @@ -55,7 +55,7 @@ static CURLcode test_unit1614(const char *arg) | |
| { NULL, NULL, 0, FALSE} /* end marker */ | |
| }; | |
| #ifdef USE_IPV6 | |
| - | struct check list6[]= { |
| + | struct check list6[] = { |
| { "::1", "::1", 0, TRUE}, | |
| { "::1", "::1", 128, TRUE}, | |
| { "::1", "0:0::1", 128, TRUE}, | |
| @@ -69,7 +69,7 @@ static CURLcode test_unit1614(const char *arg) | |
| const char *n; | |
| bool match; | |
| }; | |
| - | struct noproxy list[]= { |
| + | struct noproxy list[] = { |
| { "www.example.com", "localhost .example.com .example.de", FALSE}, | |
| { "www.example.com", "localhost,.example.com,.example.de", TRUE}, | |
| { "www.example.com.", "localhost,.example.com,.example.de", TRUE}, | |
| @@ -161,7 +161,7 @@ static CURLcode test_unit1614(const char *arg) | |
| if(match != list4[i].match) { | |
| curl_mfprintf(stderr, "%s in %s/%u should %smatch\n", | |
| list4[i].a, list4[i].n, list4[i].bits, | |
| - | list4[i].match ? "": "not "); |
| + | list4[i].match ? "" : "not "); |
| err++; | |
| } | |
| } | |
| @@ -171,7 +171,7 @@ static CURLcode test_unit1614(const char *arg) | |
| if(match != list6[i].match) { | |
| curl_mfprintf(stderr, "%s in %s/%u should %smatch\n", | |
| list6[i].a, list6[i].n, list6[i].bits, | |
| - | list6[i].match ? "": "not "); |
| + | list6[i].match ? "" : "not "); |
| err++; | |
| } | |
| } | |
| @@ -181,7 +181,7 @@ static CURLcode test_unit1614(const char *arg) | |
| if(match != list[i].match) { | |
| curl_mfprintf(stderr, "%s in %s should %smatch\n", | |
| list[i].a, list[i].n, | |
| - | list[i].match ? "": "not "); |
| + | list[i].match ? "" : "not "); |
| err++; | |
| } | |
| } | |
| @@ -113,31 +113,31 @@ static CURLcode test_unit1615(const char *arg) | |
| /* Mute compiler warnings in 'verify_memory' macros below */ | |
| computed_hash = output_buf; | |
| - | Curl_sha512_256it(output_buf, (const unsigned char *) test_str1, |
| + | Curl_sha512_256it(output_buf, (const unsigned char *)test_str1, |
| CURL_ARRAYSIZE(test_str1) - 1); | |
| verify_memory(computed_hash, precomp_hash1, CURL_SHA512_256_DIGEST_LENGTH); | |
| - | Curl_sha512_256it(output_buf, (const unsigned char *) test_str2, |
| + | Curl_sha512_256it(output_buf, (const unsigned char *)test_str2, |
| CURL_ARRAYSIZE(test_str2) - 1); | |
| verify_memory(computed_hash, precomp_hash2, CURL_SHA512_256_DIGEST_LENGTH); | |
| - | Curl_sha512_256it(output_buf, (const unsigned char *) test_str3, |
| + | Curl_sha512_256it(output_buf, (const unsigned char *)test_str3, |
| CURL_ARRAYSIZE(test_str3) - 1); | |
| verify_memory(computed_hash, precomp_hash3, CURL_SHA512_256_DIGEST_LENGTH); | |
| - | Curl_sha512_256it(output_buf, (const unsigned char *) test_str4, |
| + | Curl_sha512_256it(output_buf, (const unsigned char *)test_str4, |
| CURL_ARRAYSIZE(test_str4) - 1); | |
| verify_memory(computed_hash, precomp_hash4, CURL_SHA512_256_DIGEST_LENGTH); | |
| - | Curl_sha512_256it(output_buf, (const unsigned char *) test_str5, |
| + | Curl_sha512_256it(output_buf, (const unsigned char *)test_str5, |
| CURL_ARRAYSIZE(test_str5) - 1); | |
| verify_memory(computed_hash, precomp_hash5, CURL_SHA512_256_DIGEST_LENGTH); | |
| - | Curl_sha512_256it(output_buf, (const unsigned char *) test_str6, |
| + | Curl_sha512_256it(output_buf, (const unsigned char *)test_str6, |
| CURL_ARRAYSIZE(test_str6) - 1); | |
| verify_memory(computed_hash, precomp_hash6, CURL_SHA512_256_DIGEST_LENGTH); | |
| - | Curl_sha512_256it(output_buf, (const unsigned char *) test_str7, |
| + | Curl_sha512_256it(output_buf, (const unsigned char *)test_str7, |
| CURL_ARRAYSIZE(test_str7) - 1); | |
| verify_memory(computed_hash, precomp_hash7, CURL_SHA512_256_DIGEST_LENGTH); | |
| @@ -116,8 +116,7 @@ static CURLcode test_unit1620(const char *arg) | |
| Curl_freeset(empty); | |
| for(i = (enum dupstring)0; i < STRING_LAST; i++) { | |
| - | fail_unless(empty->set.str[i] == NULL, |
| - | "Curl_free() did not set to NULL"); |
| + | fail_unless(empty->set.str[i] == NULL, "Curl_free() did not set to NULL"); |
| } | |
| rc = Curl_close(&empty); | |
| @@ -205,7 +205,7 @@ static CURLcode test_unit1650(const char *arg) | |
| int j; | |
| for(j = 0; j < 16; j += 2) { | |
| size_t l; | |
| - | curl_msnprintf(ptr, len, "%s%02x%02x", j?":":"", a->ip.v6[j], |
| + | curl_msnprintf(ptr, len, "%s%02x%02x", j ? ":" : "", a->ip.v6[j], |
| a->ip.v6[j + 1]); | |
| l = strlen(ptr); | |
| len -= l; | |
| @@ -232,12 +232,12 @@ static CURLcode test_unit1650(const char *arg) | |
| } | |
| /* pass all sizes into the decoder until full */ | |
| - | for(i = 0; i < sizeof(full49)-1; i++) { |
| + | for(i = 0; i < sizeof(full49) - 1; i++) { |
| struct dohentry d; | |
| DOHcode rc; | |
| memset(&d, 0, sizeof(d)); | |
| - | rc = doh_resp_decode((const unsigned char *)full49, i, CURL_DNS_TYPE_A, |
| - | &d); |
| + | rc = doh_resp_decode((const unsigned char *)full49, |
| + | i, CURL_DNS_TYPE_A, &d); |
| if(!rc) { | |
| /* none of them should work */ | |
| curl_mfprintf(stderr, "%zu: %d\n", i, rc); | |
| @@ -250,8 +250,8 @@ static CURLcode test_unit1650(const char *arg) | |
| struct dohentry d; | |
| DOHcode rc; | |
| memset(&d, 0, sizeof(d)); | |
| - | rc = doh_resp_decode((const unsigned char *)&full49[i], sizeof(full49)-i-1, |
| - | CURL_DNS_TYPE_A, &d); |
| + | rc = doh_resp_decode((const unsigned char *)&full49[i], |
| + | sizeof(full49) - i - 1, CURL_DNS_TYPE_A, &d); |
| if(!rc) { | |
| /* none of them should work */ | |
| curl_mfprintf(stderr, "2 %zu: %d\n", i, rc); | |
| @@ -264,8 +264,8 @@ static CURLcode test_unit1650(const char *arg) | |
| struct dohentry d; | |
| struct dohaddr *a; | |
| memset(&d, 0, sizeof(d)); | |
| - | rc = doh_resp_decode((const unsigned char *)full49, sizeof(full49)-1, |
| - | CURL_DNS_TYPE_A, &d); |
| + | rc = doh_resp_decode((const unsigned char *)full49, |
| + | sizeof(full49) - 1, CURL_DNS_TYPE_A, &d); |
| fail_if(d.numaddr != 1, "missing address"); | |
| a = &d.addr[0]; | |
| p = &a->ip.v4[0]; | |
| @@ -360,10 +360,10 @@ static CURLcode test_unit1651(const char *arg) | |
| /* a poor man's fuzzing of some initial data to make sure nothing bad | |
| happens */ | |
| - | for(byte = 1 ; byte < 255; byte += 17) { |
| + | for(byte = 1; byte < 255; byte += 17) { |
| for(i = 0; i < 45; i++) { | |
| unsigned char backup = cert[i]; | |
| - | cert[i] = (unsigned char) (byte & 0xff); |
| + | cert[i] = (unsigned char)(byte & 0xff); |
| (void)Curl_extract_certinfo(data, 0, beg, end); | |
| cert[i] = backup; | |
| } | |
| @@ -121,7 +121,7 @@ static CURLcode test_unit1655(const char *arg) | |
| else { | |
| if(d == DOH_OK) { | |
| fail_unless(olen <= sizeof(victim.dohbuffer), | |
| - | "wrote outside bounds"); |
| + | "wrote outside bounds"); |
| fail_unless(olen > strlen(name), "unrealistic low size"); | |
| } | |
| } | |
| @@ -95,7 +95,7 @@ static CURLcode test_unit1656(const char *arg) | |
| struct dynbuf dbuf; | |
| bool all_ok = TRUE; | |
| - | curlx_dyn_init(&dbuf, 32*1024); |
| + | curlx_dyn_init(&dbuf, 32 * 1024); |
| if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { | |
| curl_mfprintf(stderr, "curl_global_init() failed\n"); | |
| @@ -93,7 +93,7 @@ static CURLcode test_unit1657(const char *arg) | |
| bool all_ok = TRUE; | |
| struct dynbuf dbuf; | |
| - | curlx_dyn_init(&dbuf, 32*1024); |
| + | curlx_dyn_init(&dbuf, 32 * 1024); |
| if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { | |
| curl_mfprintf(stderr, "curl_global_init() failed\n"); | |
| @@ -130,7 +130,7 @@ static CURLcode test_unit1660(const char *arg) | |
| Curl_hsts_loadfile(easy, h, arg); | |
| - | for(i = 0; headers[i].host ; i++) { |
| + | for(i = 0; headers[i].host; i++) { |
| if(headers[i].hdr) { | |
| res = Curl_hsts_parse(h, headers[i].host, headers[i].hdr); | |
| @@ -78,7 +78,7 @@ static CURLcode test_unit1661(const char *arg) | |
| /** | |
| * testing Curl_bufref_ptr | |
| */ | |
| - | fail_unless((const char *) Curl_bufref_ptr(&bufref) == buffer, |
| + | fail_unless((const char *)Curl_bufref_ptr(&bufref) == buffer, |
| "Wrong pointer value returned"); | |
| /** | |
| @@ -39,12 +39,11 @@ static CURLcode t1663_setup(void) | |
| return res; | |
| } | |
| - | static void t1663_parse( |
| - | const char *input_data, |
| - | const char *exp_dev, |
| - | const char *exp_iface, |
| - | const char *exp_host, |
| - | CURLcode exp_rc) |
| + | static void t1663_parse(const char *input_data, |
| + | const char *exp_dev, |
| + | const char *exp_iface, |
| + | const char *exp_host, |
| + | CURLcode exp_rc) |
| { | |
| char *dev = NULL; | |
| char *iface = NULL; | |
| @@ -238,8 +238,7 @@ out: | |
| return res; | |
| } | |
| - | static void check_result(const struct test_case *tc, |
| - | struct test_result *tr) |
| + | static void check_result(const struct test_case *tc, struct test_result *tr) |
| { | |
| char msg[256]; | |
| timediff_t duration_ms; | |
| @@ -247,8 +246,7 @@ static void check_result(const struct test_case *tc, | |
| duration_ms = curlx_timediff_ms(tr->ended, tr->started); | |
| curl_mfprintf(stderr, "%d: test case took %dms\n", tc->id, (int)duration_ms); | |
| - | if(tr->res != tc->exp_res |
| - | && CURLE_OPERATION_TIMEDOUT != tr->res) { |
| + | if(tr->res != tc->exp_res && CURLE_OPERATION_TIMEDOUT != tr->res) { |
| /* on CI we encounter the TIMEOUT result, since images get less CPU | |
| * and events are not as sharply timed. */ | |
| curl_msprintf(msg, "%d: expected result %d but got %d", | |
| @@ -80,7 +80,7 @@ static void check_bufq(size_t pool_spares, | |
| size_t chunk_size, size_t max_chunks, | |
| size_t wsize, size_t rsize, int opts) | |
| { | |
| - | static unsigned char test_data[32*1024]; |
| + | static unsigned char test_data[32 * 1024]; |
| struct bufq q; | |
| struct bufc_pool pool; | |
| @@ -167,7 +167,7 @@ static void check_bufq(size_t pool_spares, | |
| /* Test SOFT_LIMIT option */ | |
| Curl_bufq_free(&q); | |
| - | Curl_bufq_init2(&q, chunk_size, max_chunks, (opts|BUFQ_OPT_SOFT_LIMIT)); |
| + | Curl_bufq_init2(&q, chunk_size, max_chunks, (opts | BUFQ_OPT_SOFT_LIMIT)); |
| nwritten = 0; | |
| while(!Curl_bufq_is_full(&q)) { | |
| res = Curl_bufq_write(&q, test_data, wsize, &n2); | |
| @@ -212,9 +212,9 @@ static CURLcode test_unit2601(const char *arg) | |
| struct bufq q; | |
| size_t n; | |
| CURLcode res; | |
| - | unsigned char buf[16*1024]; |
| + | unsigned char buf[16 * 1024]; |
| - | Curl_bufq_init(&q, 8*1024, 12); |
| + | Curl_bufq_init(&q, 8 * 1024, 12); |
| res = Curl_bufq_read(&q, buf, 128, &n); | |
| fail_unless(res && res == CURLE_AGAIN, "read empty fail"); | |
| Curl_bufq_free(&q); | |
| @@ -225,7 +225,7 @@ static CURLcode test_unit2601(const char *arg) | |
| check_bufq(0, 1024, 4, 16000, 3000, BUFQ_OPT_NONE); | |
| check_bufq(0, 8000, 10, 1234, 1234, BUFQ_OPT_NONE); | |
| - | check_bufq(0, 8000, 10, 8*1024, 4*1024, BUFQ_OPT_NONE); |
| + | check_bufq(0, 8000, 10, 8 * 1024, 4 * 1024, BUFQ_OPT_NONE); |
| check_bufq(0, 1024, 4, 128, 128, BUFQ_OPT_NO_SPARES); | |
| check_bufq(0, 1024, 4, 129, 127, BUFQ_OPT_NO_SPARES); | |
| @@ -85,7 +85,7 @@ static CURLcode test_unit2602(const char *arg) | |
| Curl_dynhds_reset(&hds); | |
| Curl_dynhds_free(&hds); | |
| - | Curl_dynhds_init(&hds, 128, 4*1024); |
| + | Curl_dynhds_init(&hds, 128, 4 * 1024); |
| fail_if(Curl_dynhds_add(&hds, "test1", 5, "123", 3), "add failed"); | |
| fail_if(Curl_dynhds_add(&hds, "test1", 5, "123", 3), "add failed"); | |
| fail_if(Curl_dynhds_cadd(&hds, "blablabla", "thingies"), "add failed"); | |
| @@ -100,18 +100,18 @@ static CURLcode test_unit2602(const char *arg) | |
| fail_unless(Curl_dynhds_ccount_name(&hds, "bLABlaBlA") == 0, "should"); | |
| fail_if(Curl_dynhds_cadd(&hds, "Bla-Bla", "thingies"), "add failed"); | |
| - | curlx_dyn_init(&dbuf, 32*1024); |
| + | curlx_dyn_init(&dbuf, 32 * 1024); |
| fail_if(Curl_dynhds_h1_dprint(&hds, &dbuf), "h1 print failed"); | |
| if(curlx_dyn_ptr(&dbuf)) { | |
| fail_if(strcmp(curlx_dyn_ptr(&dbuf), | |
| "test1: 123\r\ntest1: 123\r\nBla-Bla: thingies\r\n"), | |
| - | "h1 format differs"); |
| + | "h1 format differs"); |
| } | |
| curlx_dyn_free(&dbuf); | |
| } | |
| Curl_dynhds_free(&hds); | |
| - | Curl_dynhds_init(&hds, 128, 4*1024); |
| + | Curl_dynhds_init(&hds, 128, 4 * 1024); |
| /* continuation without previous header fails */ | |
| res = Curl_dynhds_h1_cadd_line(&hds, " indented value"); | |
| fail_unless(res, "add should have failed"); | |
| @@ -124,13 +124,13 @@ static CURLcode test_unit2602(const char *arg) | |
| fail_if(Curl_dynhds_h1_cadd_line(&hds, "ti3: val1"), "add"); | |
| fail_if(Curl_dynhds_h1_cadd_line(&hds, " val2"), "add indent"); | |
| - | curlx_dyn_init(&dbuf, 32*1024); |
| + | curlx_dyn_init(&dbuf, 32 * 1024); |
| fail_if(Curl_dynhds_h1_dprint(&hds, &dbuf), "h1 print failed"); | |
| if(curlx_dyn_ptr(&dbuf)) { | |
| curl_mfprintf(stderr, "indent concat: %s\n", curlx_dyn_ptr(&dbuf)); | |
| fail_if(strcmp(curlx_dyn_ptr(&dbuf), | |
| "ti1: val1 val2\r\nti2: val1 val2\r\nti3: val1 val2\r\n"), | |
| - | "wrong format"); |
| + | "wrong format"); |
| } | |
| curlx_dyn_free(&dbuf); | |
| @@ -94,68 +94,68 @@ static CURLcode test_unit3200(const char *arg) | |
| curl_mfprintf(stderr, "Test %zd...", i); | |
| switch(i) { | |
| - | case 0: |
| - | res = Curl_get_line(&buf, fp, &eof); |
| - | line = curlx_dyn_ptr(&buf); |
| - | fail_unless(!res && line && !strcmp("LINE1\n", line), |
| - | "First line failed (1)"); |
| - | res = Curl_get_line(&buf, fp, &eof); |
| - | line = curlx_dyn_ptr(&buf); |
| - | fail_unless(!res && line && !strcmp("LINE2 NEWLINE\n", line), |
| - | "Second line failed (1)"); |
| - | res = Curl_get_line(&buf, fp, &eof); |
| - | abort_unless(eof, "Missed EOF (1)"); |
| - | break; |
| - | case 1: |
| - | res = Curl_get_line(&buf, fp, &eof); |
| - | line = curlx_dyn_ptr(&buf); |
| - | fail_unless(!res && line && !strcmp("LINE1\n", line), |
| - | "First line failed (2)"); |
| - | res = Curl_get_line(&buf, fp, &eof); |
| - | line = curlx_dyn_ptr(&buf); |
| - | fail_unless(!res && line && !strcmp("LINE2 NONEWLINE\n", line), |
| - | "Second line failed (2)"); |
| - | res = Curl_get_line(&buf, fp, &eof); |
| - | abort_unless(eof, "Missed EOF (2)"); |
| - | break; |
| - | case 2: |
| - | res = Curl_get_line(&buf, fp, &eof); |
| - | line = curlx_dyn_ptr(&buf); |
| - | fail_unless(!res && line && !strcmp("LINE1\n", line), |
| - | "First line failed (3)"); |
| - | res = Curl_get_line(&buf, fp, &eof); |
| - | fail_unless(!curlx_dyn_len(&buf), |
| - | "Did not detect max read on EOF (3)"); |
| - | break; |
| - | case 3: |
| - | res = Curl_get_line(&buf, fp, &eof); |
| - | line = curlx_dyn_ptr(&buf); |
| - | fail_unless(!res && line && !strcmp("LINE1\n", line), |
| - | "First line failed (4)"); |
| - | res = Curl_get_line(&buf, fp, &eof); |
| - | fail_unless(!curlx_dyn_len(&buf), |
| - | "Did not ignore partial on EOF (4)"); |
| - | break; |
| - | case 4: |
| - | res = Curl_get_line(&buf, fp, &eof); |
| - | line = curlx_dyn_ptr(&buf); |
| - | fail_unless(!res && line && !strcmp("LINE1\n", line), |
| - | "First line failed (5)"); |
| - | res = Curl_get_line(&buf, fp, &eof); |
| - | fail_unless(!curlx_dyn_len(&buf), |
| - | "Did not bail out on too long line"); |
| - | break; |
| - | case 5: |
| - | res = Curl_get_line(&buf, fp, &eof); |
| - | line = curlx_dyn_ptr(&buf); |
| - | fail_unless(!res && line && !strcmp("LINE1\x1aTEST\n", line), |
| - | "Missed/Misinterpreted ^Z (6)"); |
| - | res = Curl_get_line(&buf, fp, &eof); |
| - | abort_unless(eof, "Missed EOF (6)"); |
| - | break; |
| - | default: |
| - | abort_unless(1, "Unknown case"); |
| - | break; |
| + | case 0: |
| + | res = Curl_get_line(&buf, fp, &eof); |
| + | line = curlx_dyn_ptr(&buf); |
| + | fail_unless(!res && line && !strcmp("LINE1\n", line), |
| + | "First line failed (1)"); |
| + | res = Curl_get_line(&buf, fp, &eof); |
| + | line = curlx_dyn_ptr(&buf); |
| + | fail_unless(!res && line && !strcmp("LINE2 NEWLINE\n", line), |
| + | "Second line failed (1)"); |
| + | res = Curl_get_line(&buf, fp, &eof); |
| + | abort_unless(eof, "Missed EOF (1)"); |
| + | break; |
| + | case 1: |
| + | res = Curl_get_line(&buf, fp, &eof); |
| + | line = curlx_dyn_ptr(&buf); |
| + | fail_unless(!res && line && !strcmp("LINE1\n", line), |
| + | "First line failed (2)"); |
| + | res = Curl_get_line(&buf, fp, &eof); |
| + | line = curlx_dyn_ptr(&buf); |
| + | fail_unless(!res && line && !strcmp("LINE2 NONEWLINE\n", line), |
| + | "Second line failed (2)"); |
| + | res = Curl_get_line(&buf, fp, &eof); |
| + | abort_unless(eof, "Missed EOF (2)"); |
| + | break; |
| + | case 2: |
| + | res = Curl_get_line(&buf, fp, &eof); |
| + | line = curlx_dyn_ptr(&buf); |
| + | fail_unless(!res && line && !strcmp("LINE1\n", line), |
| + | "First line failed (3)"); |
| + | res = Curl_get_line(&buf, fp, &eof); |
| + | fail_unless(!curlx_dyn_len(&buf), |
| + | "Did not detect max read on EOF (3)"); |
| + | break; |
| + | case 3: |
| + | res = Curl_get_line(&buf, fp, &eof); |
| + | line = curlx_dyn_ptr(&buf); |
| + | fail_unless(!res && line && !strcmp("LINE1\n", line), |
| + | "First line failed (4)"); |
| + | res = Curl_get_line(&buf, fp, &eof); |
| + | fail_unless(!curlx_dyn_len(&buf), |
| + | "Did not ignore partial on EOF (4)"); |
| + | break; |
| + | case 4: |
| + | res = Curl_get_line(&buf, fp, &eof); |
| + | line = curlx_dyn_ptr(&buf); |
| + | fail_unless(!res && line && !strcmp("LINE1\n", line), |
| + | "First line failed (5)"); |
| + | res = Curl_get_line(&buf, fp, &eof); |
| + | fail_unless(!curlx_dyn_len(&buf), |
| + | "Did not bail out on too long line"); |
| + | break; |
| + | case 5: |
| + | res = Curl_get_line(&buf, fp, &eof); |
| + | line = curlx_dyn_ptr(&buf); |
| + | fail_unless(!res && line && !strcmp("LINE1\x1aTEST\n", line), |
| + | "Missed/Misinterpreted ^Z (6)"); |
| + | res = Curl_get_line(&buf, fp, &eof); |
| + | abort_unless(eof, "Missed EOF (6)"); |
| + | break; |
| + | default: |
| + | abort_unless(1, "Unknown case"); |
| + | break; |
| } | |
| curlx_dyn_free(&buf); | |
| curlx_fclose(fp); | |
| @@ -561,9 +561,9 @@ static CURLcode test_unit3205(const char *arg) | |
| /* suites matched by EDH alias will return the DHE name */ | |
| if(test->id >= 0x0011 && test->id < 0x0017) { | |
| if(expect && memcmp(expect, "EDH-", 4) == 0) | |
| - | expect = (char *) memcpy(strcpy(alt, expect), "DHE-", 4); |
| + | expect = (char *)memcpy(strcpy(alt, expect), "DHE-", 4); |
| if(expect && memcmp(expect + 4, "EDH-", 4) == 0) | |
| - | expect = (char *) memcpy(strcpy(alt, expect) + 4, "DHE-", 4) - 4; |
| + | expect = (char *)memcpy(strcpy(alt, expect) + 4, "DHE-", 4) - 4; |
| } | |
| if(expect && strcmp(buf, expect) != 0) { | |
| @@ -84,7 +84,7 @@ static void check_set(const char *name, unsigned int capacity, | |
| } | |
| /* The count is half */ | |
| c = Curl_uint32_bset_count(&bset); | |
| - | fail_unless(c == slen/2, "set count is wrong"); |
| + | fail_unless(c == slen / 2, "set count is wrong"); |
| Curl_uint32_bset_clear(&bset); | |
| c = Curl_uint32_bset_count(&bset); | |
| @@ -107,7 +107,7 @@ static void check_set(const char *name, unsigned int capacity, | |
| for(i = 0; i < slen; i++) /* all still present after resize back */ | |
| fail_unless(Curl_uint32_bset_contains(&bset, s[i]), "unexpectedly lost"); | |
| - | fail_unless(!Curl_uint32_bset_resize(&bset, capacity/2), |
| + | fail_unless(!Curl_uint32_bset_resize(&bset, capacity / 2), |
| "resize half failed"); | |
| /* halved the size, what numbers remain in set? */ | |
| c = Curl_uint32_bset_capacity(&bset); | |
| @@ -75,7 +75,7 @@ static void check_spbset(const char *name, const unsigned int *s, size_t slen) | |
| } | |
| /* The count is half */ | |
| c = Curl_uint32_spbset_count(&bset); | |
| - | fail_unless(c == slen/2, "set count is wrong"); |
| + | fail_unless(c == slen / 2, "set count is wrong"); |
| Curl_uint32_spbset_clear(&bset); | |
| c = Curl_uint32_spbset_count(&bset); | |
| @@ -45,7 +45,7 @@ static CURLcode test_unit3216(const char *arg) | |
| fail_unless(Curl_rlimit_avail(&r, ts) == 0, "blocked inf"); | |
| Curl_rlimit_block(&r, FALSE, ts); | |
| fail_unless(Curl_rlimit_avail(&r, ts) == CURL_OFF_T_MAX, | |
| - | "unblocked unlimited"); |
| + | "unblocked unlimited"); |
| /* A ratelimit that give 10 tokens per second */ | |
| ts = curlx_now(); | |