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) {
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)
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':
/* 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;
/* 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;
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);
}
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";
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;
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);
}
}
/* 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)
);
}
-struct handle
-{
+struct handle {
size_t idx;
int paused;
int resumed;
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;
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);
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 */
}
"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)
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",
#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",
"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)
}
}
-
/* nothing happening, maintenance */
if(abort_paused) {
/* abort paused transfers */
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",
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);
}
curl_share_setopt(share, CURLSHOPT_SHARE, CURL_LOCK_DATA_SSL_SESSION);
-
if(!tse_add_transfer(multi, share, resolve, URL, http_version))
goto cleanup;
++ongoing;
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 */
}
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);
#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;
r = CURLE_RECV_ERROR;
goto out;
}
-
}
curl_multi_remove_handle(multi, m1_ctx.curl);
return r;
}
-
static void test_ws_data_usage(const char *msg)
{
if(msg)
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;
}
#endif /* CURL_DISABLE_WEBSOCKETS */
-
int main(int argc, const char **argv)
{
const char *URL = "";
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);
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;
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;
}
{
struct t1514_WriteThis *pooh = (struct t1514_WriteThis *)userp;
- if(size*nmemb < 1)
+ if(size * nmemb < 1)
return 0;
if(pooh->sizeleft) {
/* 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);
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;
}
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 {
/* 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)
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);
}
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);
}
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);
}
return TEST_ERR_SUCCESS;
}
-
static CURLcode test_lib1533(const char *URL)
{
struct cb_data data;
easy_init(curl);
/* Test that a filetime is properly initialized on curl_easy_init.
- */
+ */
res = curl_easy_getinfo(curl, CURLINFO_FILETIME, &filetime);
if(res) {
}
/* Test that a filetime is properly set after receiving an HTTP resource.
- */
+ */
res = curl_easy_getinfo(curl, CURLINFO_FILETIME, &filetime);
if(res) {
}
/* Test that a filetime is properly initialized on curl_easy_duphandle.
- */
+ */
dupe = curl_easy_duphandle(curl);
if(!dupe) {
}
/* Test that a filetime is properly initialized on curl_easy_reset.
- */
+ */
curl_easy_reset(curl);
easy_init(curl);
/* Test that protocol is properly initialized on curl_easy_init.
- */
+ */
res = curl_easy_getinfo(curl, CURLINFO_PROTOCOL, &protocol);
}
/* Test that a protocol is properly set after receiving an HTTP resource.
- */
+ */
res = curl_easy_getinfo(curl, CURLINFO_PROTOCOL, &protocol);
}
/* Test that a protocol is properly initialized on curl_easy_duphandle.
- */
+ */
dupe = curl_easy_duphandle(curl);
if(!dupe) {
}
/* Test that a protocol is properly initialized on curl_easy_reset.
- */
+ */
curl_easy_reset(curl);
easy_init(curl);
/* Test that scheme is properly initialized on curl_easy_init.
- */
+ */
res = curl_easy_getinfo(curl, CURLINFO_SCHEME, &scheme);
if(res) {
}
/* Test that a scheme is properly set after receiving an HTTP resource.
- */
+ */
res = curl_easy_getinfo(curl, CURLINFO_SCHEME, &scheme);
if(res) {
}
/* Test that a scheme is properly initialized on curl_easy_duphandle.
- */
+ */
dupe = curl_easy_duphandle(curl);
if(!dupe) {
}
/* Test that a scheme is properly initialized on curl_easy_reset.
- */
+ */
curl_easy_reset(curl);
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;
}
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",
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;
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;
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) {
};
/* "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;
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++) {
/* 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)
/* 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)
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);
/* ignore the data */
(void)data;
(void)userp;
- return n*l;
+ return n * l;
}
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)
***************************************************************************/
#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);
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);
}
#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)
{
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;
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);
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
goto test_cleanup;
curl_mprintf("effective URL: %s\n", effective);
-
test_cleanup:
curl_easy_cleanup(curl);
curl_url_cleanup(curlu);
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;
}
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;
#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;
(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) {
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 */
(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) {
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 */
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;
}
(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) {
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 */
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;
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 {
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;
}
}
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;
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]);
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]);
}
{
CURLcode res = CURLE_OK;
size_t i;
- CURLSH* share;
+ CURLSH *share;
struct Ctx ctx[THREAD_SIZE];
curl_global_init(CURL_GLOBAL_ALL);
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);
(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 */
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 */
{
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();
}
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);
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();
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");
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");
{
struct t508_WriteThis *pooh = (struct t508_WriteThis *)userp;
- if(size*nmemb < 1)
+ if(size * nmemb < 1)
return 0;
if(pooh->sizeleft) {
free(ptr);
}
-
static CURLcode test_lib509(const char *URL)
{
static const unsigned char a[] = {0x2f, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
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;
}
curl_multi_cleanup(multi);
curl_global_cleanup();
-
}
else if(testnum == 532) {
/* undocumented cleanup sequence - type UB */
/**
* 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;
{
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 ");
}
}
/* 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);
#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;
#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)
{
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;
{
struct t554_WriteThis *pooh = (struct t554_WriteThis *)userp;
- if(size*nmemb < 1)
+ if(size * nmemb < 1)
return 0;
if(pooh->sizeleft) {
#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)
{
#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];
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;
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);
i, us_test[i].expected, us_test[i].result);
failed++;
}
-
}
if(!failed)
return failed;
}
-
static int test_signed_short_formatting(void)
{
int i, j;
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);
i, ss_test[i].expected, ss_test[i].result);
failed++;
}
-
}
if(!failed)
return failed;
}
-
static int test_unsigned_int_formatting(void)
{
int i, j;
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);
i, ui_test[i].expected, ui_test[i].result);
failed++;
}
-
}
if(!failed)
return failed;
}
-
static int test_signed_int_formatting(void)
{
int i, j;
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);
i, si_test[i].expected, si_test[i].result);
failed++;
}
-
}
if(!failed)
return failed;
}
-
static int test_unsigned_long_formatting(void)
{
int i, j;
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);
i, ul_test[i].expected, ul_test[i].result);
failed++;
}
-
}
if(!failed)
return failed;
}
-
static int test_signed_long_formatting(void)
{
int i, j;
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);
i, sl_test[i].expected, sl_test[i].result);
failed++;
}
-
}
if(!failed)
return failed;
}
-
static int test_curl_off_t_formatting(void)
{
int i, j;
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);
i, co_test[i].expected, co_test[i].result);
failed++;
}
-
}
if(!failed)
}
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)
{
}
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
return errors;
}
-
static int test_weird_arguments(void)
{
int errors = 0;
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);
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 */
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++);
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)
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();
***************************************************************************/
#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",
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];
/**
* 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;
(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++;
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++;
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();
}
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);
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();
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();
#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;
#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;
}
struct t643_WriteThis *pooh = (struct t643_WriteThis *)userp;
int eof;
- if(size*nmemb < 1)
+ if(size * nmemb < 1)
return 0;
if(testnum == 643) {
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");
}
/* 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 ");
}
/* 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));
/* 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));
}
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));
/* 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;
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");
* 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);
/* 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");
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) {
static void free_callback(void *userp)
{
- struct t654_WriteThis *pooh = (struct t654_WriteThis *) userp;
+ struct t654_WriteThis *pooh = (struct t654_WriteThis *)userp;
pooh->freecount++;
}
struct t654_WriteThis *pooh = (struct t654_WriteThis *)userp;
int eof;
- if(size*nmemb < 1)
+ if(size * nmemb < 1)
return 0;
eof = pooh->sizeleft <= 0;
/* 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. */
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");
struct t667_WriteThis *pooh = (struct t667_WriteThis *)userp;
int eof;
- if(size*nmemb < 1)
+ if(size * nmemb < 1)
return 0;
eof = pooh->sizeleft <= 0;
/* 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);
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);
/* 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. */
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
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)
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;
return TEST_ERR_MAJOR_BAD;
}
- pooh.origin = (time_t) 0;
+ pooh.origin = (time_t)0;
pooh.count = 0;
pooh.curl = curl_easy_init();
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. */
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) {
datasize = 0;
data = NULL;
}
- }
+ }
}
*filesize = datasize;
*filedata = data;
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 */
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());
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;
/**
* 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;
curl_global_trace("all");
-
easy_init(curl);
debug_config.nohex = TRUE;
debug_config.tracetime = TRUE;
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;
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;
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) {
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);
}
return 0;
}
-
static void read_instructions(void)
{
char file[256];
#else
""
#endif
- );
+ );
return 0;
}
else if(!strcmp("--pidfile", argv[arg])) {
}
snprintf(loglockfile, sizeof(loglockfile), "%s/%s/dnsd-%s.lock",
- logdir, SERVERLOGS_LOCKDIR, ipv_inuse);
+ logdir, SERVERLOGS_LOCKDIR, ipv_inuse);
#ifdef _WIN32
if(win32_init())
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;
char *end;
union {
ssize_t sig;
- size_t uns;
+ size_t uns;
} len;
size_t bufsize = 0;
size_t outalloc = 256;
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;
}
if(in_wanted_part)
break;
}
-
}
else if(!in_wanted_part) {
/*
/* 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;
}
continue;
}
-
}
if(in_wanted_part) {
/* 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
};
return bytes;
}
-
static size_t decode_length(unsigned char *buffer,
size_t buflen, size_t *lenbytes)
{
return len;
}
-
/* return 0 on success */
static int publish(FILE *dump,
curl_socket_t fd, unsigned short packetid,
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;
}
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");
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);
#else
""
#endif
- );
+ );
return 0;
}
else if(!strcmp("--pidfile", argv[arg])) {
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;
#else
""
#endif
- );
+ );
return 0;
}
else if(!strcmp("--ipv6", argv[arg])) {
#ifdef CURLRES_IPV6
"\n --ipv6"
#endif
- );
+ );
return 1;
}
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 */
#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 =
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, '/');
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);
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)
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:
/*** 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);
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;
}
}
- 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
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;
}
}
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) {
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;
return 0;
}
-
static int test_rtspd(int argc, char *argv[])
{
srvr_sockaddr_union_t me;
#else
""
#endif
- );
+ );
return 0;
}
else if(!strcmp("--pidfile", argv[arg])) {
}
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)));
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;
/* 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;
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)) {
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 */
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
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;
}
} /* switch(*mode) */
-
do {
/* select() blocking behavior call on blocking descriptors please */
/* 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
}
}
-
- 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
#else
""
#endif
- );
+ );
return 0;
}
else if(!strcmp("--verbose", argv[arg])) {
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;
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 */
/* 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;
/* 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;
cp->used = TRUE;
clients++;
}
-
}
}
for(i = 0; i < 2; i++) {
#else
""
#endif
- );
+ );
return 0;
}
else if(!strcmp("--pidfile", argv[arg])) {
#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 */
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"
#endif
return true;
default:
- /* case AF_UNIX: */
+ /* case AF_UNIX: */
return false;
}
}
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;
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];
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)
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:
return -1;
}
- if(req->offset >= sizeof(req->reqbuf)-1) {
+ if(req->offset >= sizeof(req->reqbuf) - 1) {
/* buffer is already full; do nothing */
overflow = 1;
}
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;
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
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;
}
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);
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);
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) {
* 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
}
}
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);
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;
}
}
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;
}
}
/* 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)
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])) {
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;
/* 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;
}
}
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 */
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;
#else
""
#endif
- );
+ );
return 0;
}
else if(!strcmp("--pidfile", argv[arg])) {
}
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)));
}
#endif
- maxtimeout = 5*TIMEOUT;
+ maxtimeout = 5 * TIMEOUT;
tp = &trsbuf.hdr;
tp->th_opcode = ntohs(tp->th_opcode);
return 0; /* OK! */
}
-
/*
* Validate file access.
*/
ptr = strrchr(filename, '/');
if(ptr) {
- char partbuf[80]="data";
+ char partbuf[80] = "data";
long partno;
long testno;
const char *pval;
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:
}
/* 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);
*/
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;
}
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)
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";
#ifdef HAVE_SIGINTERRUPT
if(oldhdlr != SIG_ERR)
- siginterrupt(signum, (int) restartable);
+ siginterrupt(signum, (int)restartable);
#else
(void)restartable;
#endif
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? */
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;
}
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) {
* 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");
{"", 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;
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;
* 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!");
*/
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);
*/
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);
*/
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);
*/
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);
*/
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,
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,
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);
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);
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))
#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};
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]);
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,
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]);
}
"did %sMATCH\n",
tests[i].host,
tests[i].pattern,
- tests[i].match ? "NOT ": "");
+ tests[i].match ? "NOT " : "");
unitfail++;
}
}
"%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 */
"j", "", "", "", "", "", "", "", "", "", /* 100 */
"k", "", "", "", "", "", "", "", "", "", /* 110 */
"l", "", "", "", "", "", "", "", "", "", /* 120 */
- "m", "", "", "", "", "", "", "", "" /* 129 */
- );
+ "m", "", "", "", "", "", "", "", "" /* 129 */
+ );
fail_unless(rc == 0, "return code should be 0");
/* 128 input % flags */
"%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 */
"j", "", "", "", "", "", "", "", "", "", /* 100 */
"k", "", "", "", "", "", "", "", "", "", /* 110 */
"l", "", "", "", "", "", "", "", "", "", /* 120 */
- "m", "", "", "", "", "", "", "" /* 128 */
- );
+ "m", "", "", "", "", "", "", "" /* 128 */
+ );
fail_unless(rc == 13, "return code should be 13");
/* 129 output segments */
"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" /* 80 */
"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" /* 100 */
"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" /* 120 */
- "%%%%%%%%%%%%%%%%%%" /* 129 */
- );
+ "%%%%%%%%%%%%%%%%%%" /* 129 */
+ );
fail_unless(rc == 0, "return code should be 0");
/* 128 output segments */
"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" /* 80 */
"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" /* 100 */
"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" /* 120 */
- "%%%%%%%%%%%%%%%%" /* 128 */
- );
+ "%%%%%%%%%%%%%%%%" /* 128 */
+ );
fail_unless(rc == 128, "return code should be 128");
UNITTEST_END_SIMPLE
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);
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))
}
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"
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"
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,
"\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,
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},
{ 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},
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},
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++;
}
}
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++;
}
}
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++;
}
}
/* 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);
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);
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;
}
/* 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);
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);
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];
/* 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;
}
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");
}
}
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");
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");
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);
/**
* 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");
/**
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;
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;
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",
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;
/* 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);
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);
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);
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");
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");
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);
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);
/* 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) {
}
/* 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);
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);
}
/* 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);
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();