#if 0 /* useful function for debugging hashes and their contents */
-void Curl_hash_print(struct Curl_hash *h,
- void (*func)(void *))
+void Curl_hash_print(struct Curl_hash *h, void (*func)(void *))
{
struct Curl_hash_iterator iter;
struct Curl_hash_element *he;
* @unittest: 1602
* @unittest: 1603
*/
-void
-Curl_hash_init(struct Curl_hash *h,
- size_t slots,
- hash_function hfunc,
- comp_function comparator,
- Curl_hash_dtor dtor)
+void Curl_hash_init(struct Curl_hash *h,
+ size_t slots,
+ hash_function hfunc,
+ comp_function comparator,
+ Curl_hash_dtor dtor)
{
DEBUGASSERT(h);
DEBUGASSERT(slots);
#endif
}
-static struct Curl_hash_element *
-hash_elem_create(const void *key, size_t key_len, const void *p,
- Curl_hash_elem_dtor dtor)
+static struct Curl_hash_element *hash_elem_create(const void *key,
+ size_t key_len,
+ const void *p,
+ Curl_hash_elem_dtor dtor)
{
struct Curl_hash_element *he;
++h->size;
}
-#define CURL_HASH_SLOT(x,y,z) x->table[x->hash_func(y, z, x->slots)]
-#define CURL_HASH_SLOT_ADDR(x,y,z) &CURL_HASH_SLOT(x,y,z)
+#define CURL_HASH_SLOT(x, y, z) x->table[x->hash_func(y, z, x->slots)]
+#define CURL_HASH_SLOT_ADDR(x, y, z) &CURL_HASH_SLOT(x, y, z)
void *Curl_hash_add2(struct Curl_hash *h, void *key, size_t key_len, void *p,
Curl_hash_elem_dtor dtor)
* @unittest: 1602
* @unittest: 1603
*/
-void *
-Curl_hash_add(struct Curl_hash *h, void *key, size_t key_len, void *p)
+void *Curl_hash_add(struct Curl_hash *h, void *key, size_t key_len, void *p)
{
return Curl_hash_add2(h, key, key_len, p, NULL);
}
*
* @unittest: 1603
*/
-void *
-Curl_hash_pick(struct Curl_hash *h, void *key, size_t key_len)
+void *Curl_hash_pick(struct Curl_hash *h, void *key, size_t key_len)
{
DEBUGASSERT(h);
DEBUGASSERT(h->init == HASHINIT);
* @unittest: 1602
* @unittest: 1603
*/
-void
-Curl_hash_destroy(struct Curl_hash *h)
+void Curl_hash_destroy(struct Curl_hash *h)
{
DEBUGASSERT(h->init == HASHINIT);
if(h->table) {
}
/* Cleans all entries that pass the comp function criteria. */
-void
-Curl_hash_clean_with_criterium(struct Curl_hash *h, void *user,
- int (*comp)(void *, void *))
+void Curl_hash_clean_with_criterium(struct Curl_hash *h, void *user,
+ int (*comp)(void *, void *))
{
size_t i;
size_t Curl_hash_str(void *key, size_t key_length, size_t slots_num)
{
- const char *key_str = (const char *) key;
+ const char *key_str = (const char *)key;
const char *end = key_str + key_length;
size_t h = 5381;
#include "llist.h"
/* Hash function prototype */
-typedef size_t (*hash_function) (void *key,
- size_t key_length,
- size_t slots_num);
+typedef size_t (*hash_function)(void *key,
+ size_t key_length,
+ size_t slots_num);
/*
Comparator function prototype. Compares two keys.
*/
-typedef size_t (*comp_function) (void *key1,
- size_t key1_len,
- void *key2,
- size_t key2_len);
+typedef size_t (*comp_function)(void *key1,
+ size_t key1_len,
+ void *key2,
+ size_t key2_len);
typedef void (*Curl_hash_dtor)(void *);
struct Curl_hash_element {
struct Curl_hash_element *next;
- void *ptr;
+ void *ptr;
Curl_hash_elem_dtor dtor;
size_t key_len;
- char key[1]; /* allocated memory following the struct */
+ char key[1]; /* allocated memory following the struct */
};
struct Curl_hash {
/* Comparator function to compare keys */
comp_function comp_func;
/* General element construct, unless element itself carries one */
- Curl_hash_dtor dtor;
+ Curl_hash_dtor dtor;
size_t slots;
size_t size;
#ifdef DEBUGBUILD
struct Curl_hash_element *
Curl_hash_next_element(struct Curl_hash_iterator *iter);
-void Curl_hash_print(struct Curl_hash *h,
- void (*func)(void *));
+void Curl_hash_print(struct Curl_hash *h, void (*func)(void *));
#endif /* HEADER_CURL_HASH_H */
struct Curl_header_store *hs = NULL;
struct Curl_header_store *pick = NULL;
if(!name || !hout || !data ||
- (type > (CURLH_HEADER|CURLH_TRAILER|CURLH_CONNECT|CURLH_1XX|
+ (type > (CURLH_HEADER | CURLH_TRAILER | CURLH_CONNECT | CURLH_1XX |
CURLH_PSEUDO)) || !type || (request < -1))
return CURLHE_BAD_ARGUMENT;
if(!Curl_llist_count(&data->state.httphdrs))
return CURLE_OK;
}
-
/*
* Curl_headers_push() gets passed a full HTTP header to store. It gets called
* immediately before the header callback. The header is CRLF terminated.
CURLcode Curl_headers_cleanup(struct Curl_easy *data);
#else
-#define Curl_headers_init(x) CURLE_OK
-#define Curl_headers_push(x,y,z) CURLE_OK
-#define Curl_headers_cleanup(x) Curl_nop_stmt
+#define Curl_headers_init(x) CURLE_OK
+#define Curl_headers_push(x, y, z) CURLE_OK
+#define Curl_headers_cleanup(x) Curl_nop_stmt
#endif
#endif /* HEADER_CURL_HEADER_H */
static const unsigned char hmac_ipad = 0x36;
static const unsigned char hmac_opad = 0x5C;
-struct HMAC_context *
-Curl_HMAC_init(const struct HMAC_params *hashparams,
- const unsigned char *key,
- unsigned int keylen)
+struct HMAC_context *Curl_HMAC_init(const struct HMAC_params *hashparams,
+ const unsigned char *key,
+ unsigned int keylen)
{
size_t i;
struct HMAC_context *ctxt;
return ctxt;
ctxt->hash = hashparams;
- ctxt->hashctxt1 = (void *) (ctxt + 1);
- ctxt->hashctxt2 = (void *) ((char *) ctxt->hashctxt1 + hashparams->ctxtsize);
+ ctxt->hashctxt1 = (void *)(ctxt + 1);
+ ctxt->hashctxt2 = (void *)((char *)ctxt->hashctxt1 + hashparams->ctxtsize);
/* If the key is too long, replace it by its hash digest. */
if(keylen > hashparams->maxkeylen) {
if(hashparams->hinit(ctxt->hashctxt1))
goto fail;
hashparams->hupdate(ctxt->hashctxt1, key, keylen);
- hkey = (unsigned char *) ctxt->hashctxt2 + hashparams->ctxtsize;
+ hkey = (unsigned char *)ctxt->hashctxt2 + hashparams->ctxtsize;
hashparams->hfinal(hkey, ctxt->hashctxt1);
key = hkey;
keylen = hashparams->resultlen;
return 0;
}
-
int Curl_HMAC_final(struct HMAC_context *ctxt, unsigned char *output)
{
const struct HMAC_params *hashparams = ctxt->hash;
storage. */
if(!output)
- output = (unsigned char *) ctxt->hashctxt2 + ctxt->hash->ctxtsize;
+ output = (unsigned char *)ctxt->hashctxt2 + ctxt->hash->ctxtsize;
hashparams->hfinal(output, ctxt->hashctxt1);
hashparams->hupdate(ctxt->hashctxt2, output, hashparams->resultlen);
static void show_resolve_info(struct Curl_easy *data,
struct Curl_dns_entry *dns);
#else
-#define show_resolve_info(x,y) Curl_nop_stmt
+#define show_resolve_info(x, y) Curl_nop_stmt
#endif
/*
* Create a hostcache id string for the provided host + port, to be used by
* the DNS caching. Without alloc. Return length of the id string.
*/
-static size_t
-create_dnscache_id(const char *name,
- size_t nlen, /* 0 or actual name length */
- int port, char *ptr, size_t buflen)
+static size_t create_dnscache_id(const char *name,
+ size_t nlen, /* 0 or actual name length */
+ int port, char *ptr, size_t buflen)
{
size_t len = nlen ? nlen : strlen(name);
DEBUGASSERT(buflen >= MAX_HOSTCACHE_LEN);
* Returning non-zero means remove the entry, return 0 to keep it in the
* cache.
*/
-static int
-dnscache_entry_is_stale(void *datap, void *hc)
+static int dnscache_entry_is_stale(void *datap, void *hc)
{
- struct dnscache_prune_data *prune =
- (struct dnscache_prune_data *) datap;
- struct Curl_dns_entry *dns = (struct Curl_dns_entry *) hc;
+ struct dnscache_prune_data *prune = (struct dnscache_prune_data *)datap;
+ struct Curl_dns_entry *dns = (struct Curl_dns_entry *)hc;
if(dns->timestamp.tv_sec || dns->timestamp.tv_usec) {
/* get age in milliseconds */
* Prune the DNS cache. This assumes that a lock has already been taken.
* Returns the 'age' of the oldest still kept entry - in milliseconds.
*/
-static timediff_t
-dnscache_prune(struct Curl_hash *hostcache, timediff_t cache_timeout_ms,
- struct curltime now)
+static timediff_t dnscache_prune(struct Curl_hash *hostcache,
+ timediff_t cache_timeout_ms,
+ struct curltime now)
{
struct dnscache_prune_data user;
* The returned data *MUST* be "released" with Curl_resolv_unlink() after
* use, or we will leak memory!
*/
-struct Curl_dns_entry *
-Curl_dnscache_get(struct Curl_easy *data,
- const char *hostname,
- int port,
- int ip_version)
+struct Curl_dns_entry *Curl_dnscache_get(struct Curl_easy *data,
+ const char *hostname,
+ int port,
+ int ip_version)
{
struct Curl_dnscache *dnscache = dnscache_get(data);
struct Curl_dns_entry *dns = NULL;
struct Curl_addrinfo **nodes;
infof(data, "Shuffling %i addresses", num_addrs);
- nodes = curlx_malloc(num_addrs*sizeof(*nodes));
+ nodes = curlx_malloc(num_addrs * sizeof(*nodes));
if(nodes) {
int i;
unsigned int *rnd;
/* build a plain array of Curl_addrinfo pointers */
nodes[0] = *addr;
for(i = 1; i < num_addrs; i++) {
- nodes[i] = nodes[i-1]->ai_next;
+ nodes[i] = nodes[i - 1]->ai_next;
}
rnd = curlx_malloc(rnd_size);
/* relink list in the new order */
for(i = 1; i < num_addrs; i++) {
- nodes[i-1]->ai_next = nodes[i];
+ nodes[i - 1]->ai_next = nodes[i];
}
- nodes[num_addrs-1]->ai_next = NULL;
+ nodes[num_addrs - 1]->ai_next = NULL;
*addr = nodes[0];
}
curlx_free(rnd);
return ca;
}
#else
-#define get_localhost6(x,y) NULL
+#define get_localhost6(x, y) NULL
#endif
/* return a static IPv4 127.0.0.1 for the given name */
return FALSE;
}
-
/* return TRUE if 'part' is a case insensitive tail of 'full' */
static bool tailmatch(const char *full, size_t flen,
const char *part, size_t plen)
* execution. This effectively causes the remainder of the application to run
* within a signal handler which is nonportable and could lead to problems.
*/
-CURL_NORETURN static
-void alarmfunc(int sig)
+CURL_NORETURN static void alarmfunc(int sig)
{
(void)sig;
siglongjmp(curl_jmpenv, 1);
{
#ifdef USE_ALARM_TIMEOUT
#ifdef HAVE_SIGACTION
- struct sigaction keep_sigact; /* store the old struct here */
+ struct sigaction keep_sigact; /* store the old struct here */
volatile bool keep_copysig = FALSE; /* whether old sigact has been saved */
struct sigaction sigact;
#else
/* The alarm() function only provides integer second resolution, so if
we want to wait less than one second we must bail out already now. */
failf(data,
- "remaining timeout of %ld too small to resolve via SIGALRM method",
- timeout);
+ "remaining timeout of %ld too small to resolve via SIGALRM method",
+ timeout);
return CURLE_OPERATION_TIMEDOUT;
}
/* This allows us to time-out from the name resolver, as the timeout
/* alarm() makes a signal get sent when the timeout fires off, and that
will abort system calls */
- prev_alarm = alarm(curlx_sltoui(timeout/1000L));
+ prev_alarm = alarm(curlx_sltoui(timeout / 1000L));
}
#else /* !USE_ALARM_TIMEOUT */
unsigned long alarm_set = (unsigned long)(prev_alarm - elapsed_secs);
if(!alarm_set ||
- ((alarm_set >= 0x80000000) && (prev_alarm < 0x80000000)) ) {
+ ((alarm_set >= 0x80000000) && (prev_alarm < 0x80000000))) {
/* if the alarm time-left reached zero or turned "negative" (counted
with unsigned values), we should fire off a SIGALRM here, but we
will not, and zero would be to switch it off so we never set it to
static void dnscache_entry_dtor(void *entry)
{
- struct Curl_dns_entry *dns = (struct Curl_dns_entry *) entry;
+ struct Curl_dns_entry *dns = (struct Curl_dns_entry *)entry;
DEBUGASSERT(dns && (dns->refcount > 0));
dns->refcount--;
if(dns->refcount == 0)
error = FALSE;
err:
if(error) {
- failf(data, "Could not parse CURLOPT_RESOLVE entry '%s'",
- hostp->data);
+ failf(data, "Could not parse CURLOPT_RESOLVE entry '%s'", hostp->data);
Curl_freeaddrinfo(head);
return CURLE_SETOPT_OPTION_SYNTAX;
}
* The returned data *MUST* be "released" with Curl_resolv_unlink() after
* use, or we will leak memory!
*/
-struct Curl_dns_entry *
-Curl_dnscache_get(struct Curl_easy *data,
- const char *hostname,
- int port, int ip_version);
+struct Curl_dns_entry *Curl_dnscache_get(struct Curl_easy *data,
+ const char *hostname, int port,
+ int ip_version);
/*
* Curl_dnscache_addr() adds `entry` to the cache, increasing its
CURLcode Curl_resolv_check(struct Curl_easy *data,
struct Curl_dns_entry **dns);
#else
-#define Curl_resolv_check(x,y) CURLE_NOT_BUILT_IN
+#define Curl_resolv_check(x, y) CURLE_NOT_BUILT_IN
#endif
CURLcode Curl_resolv_pollset(struct Curl_easy *data,
struct easy_pollset *ps);
/* Linux */
(void)gethostbyname_r(hostname,
- (struct hostent *)buf,
- (char *)buf + sizeof(struct hostent),
- CURL_HOSTENT_SIZE - sizeof(struct hostent),
- &h, /* DIFFERENCE */
- &h_errnop);
+ (struct hostent *)buf,
+ (char *)buf + sizeof(struct hostent),
+ CURL_HOSTENT_SIZE - sizeof(struct hostent),
+ &h, /* DIFFERENCE */
+ &h_errnop);
/* Redhat 8, using glibc 2.2.93 changed the behavior. Now all of a
* sudden this function returns EAGAIN if the given buffer size is too
* small. Previous versions are known to return ERANGE for the same
#include "strdup.h"
#include "curlx/strparse.h"
-#define MAX_HSTS_LINE 4095
+#define MAX_HSTS_LINE 4095
#define MAX_HSTS_HOSTLEN 2048
#define MAX_HSTS_DATELEN 256
-#define UNLIMITED "unlimited"
+#define UNLIMITED "unlimited"
#if defined(DEBUGBUILD) || defined(UNITTESTS)
/* to play well with debug builds, we can *set* a fixed time this will
if((hlen > MAX_HSTS_HOSTLEN) || !hlen)
return NULL;
- if(hostname[hlen-1] == '.')
+ if(hostname[hlen - 1] == '.')
/* remove the trailing dot */
--hlen;
ntail = strlen(sts->host);
if((subdomain && sts->includeSubDomains) && (ntail < hlen)) {
size_t offs = hlen - ntail;
- if((hostname[offs-1] == '.') &&
+ if((hostname[offs - 1] == '.') &&
curl_strnequal(&hostname[offs], sts->host, ntail) &&
(ntail > blen)) {
/* save the tail match with the longest tail */
else
strcpy(e.expire, UNLIMITED);
- sc = data->set.hsts_write(data, &e, i,
- data->set.hsts_write_userp);
+ sc = data->set.hsts_write(data, &e, i, data->set.hsts_write_userp);
*stop = (sc != CURLSTS_OK);
return sc == CURLSTS_FAIL ? CURLE_BAD_FUNCTION_ARGUMENT : CURLE_OK;
}
if(result)
return result;
curl_mfprintf(fp, "%s%s \"%d%02d%02d %02d:%02d:%02d\"\n",
- sts->includeSubDomains ? ".": "", sts->host,
+ sts->includeSubDomains ? "." : "", sts->host,
stamp.tm_year + 1900, stamp.tm_mon + 1, stamp.tm_mday,
stamp.tm_hour, stamp.tm_min, stamp.tm_sec);
}
return CURLE_OK;
}
-
/*
* Curl_https_save() writes the HSTS cache to file and callback.
*/
char buffer[MAX_HSTS_HOSTLEN + 1];
struct curl_hstsentry e;
e.name = buffer;
- e.namelen = sizeof(buffer)-1;
+ e.namelen = sizeof(buffer) - 1;
e.includeSubDomains = FALSE; /* default */
e.expire[0] = 0;
e.name[0] = 0; /* just to make it clean */
CURLcode Curl_hsts_loadfiles(struct Curl_easy *data);
#else
#define Curl_hsts_cleanup(x)
-#define Curl_hsts_loadcb(x,y) CURLE_OK
-#define Curl_hsts_save(x,y,z)
+#define Curl_hsts_loadcb(x, y) CURLE_OK
+#define Curl_hsts_save(x, y, z)
#define Curl_hsts_loadfiles(x) CURLE_OK
#endif /* CURL_DISABLE_HTTP || CURL_DISABLE_HSTS */
#endif /* HEADER_CURL_HSTS_H */
static CURLcode http_target(struct Curl_easy *data, struct dynbuf *req);
static CURLcode http_useragent(struct Curl_easy *data);
-
/*
* HTTP handler interface.
*/
CURLPROTO_HTTP, /* protocol */
CURLPROTO_HTTP, /* family */
PROTOPT_CREDSPERREQUEST | /* flags */
- PROTOPT_USERPWDCTRL | PROTOPT_CONN_REUSE
+ PROTOPT_USERPWDCTRL | PROTOPT_CONN_REUSE
};
CURLPROTO_HTTPS, /* protocol */
CURLPROTO_HTTP, /* family */
PROTOPT_SSL | PROTOPT_CREDSPERREQUEST | PROTOPT_ALPN | /* flags */
- PROTOPT_USERPWDCTRL | PROTOPT_CONN_REUSE
+ PROTOPT_USERPWDCTRL | PROTOPT_CONN_REUSE
};
#endif
}
#else
/* disabled */
-#define Curl_checkProxyheaders(x,y,z,a) NULL
+#define Curl_checkProxyheaders(x, y, z, a) NULL
#endif
static bool http_header_is_empty(const char *header)
data->state.authproblem = TRUE;
else
data->info.proxyauthpicked = data->state.authproxy.picked;
-
}
#endif
return CURLE_OUT_OF_MEMORY;
}
else if((data->req.httpcode < 300) &&
- (!data->state.authhost.done) &&
+ !data->state.authhost.done &&
data->req.authneg) {
/* no (known) authentication available,
authentication is not "done" yet and
* Output the correct authentication header depending on the auth type
* and whether or not it is to a proxy.
*/
-static CURLcode
-output_auth_headers(struct Curl_easy *data,
- struct connectdata *conn,
- struct auth *authstatus,
- const char *request,
- const char *path,
- bool proxy)
+static CURLcode output_auth_headers(struct Curl_easy *data,
+ struct connectdata *conn,
+ struct auth *authstatus,
+ const char *request,
+ const char *path,
+ bool proxy)
{
const char *auth = NULL;
CURLcode result = CURLE_OK;
#else
/* when disabled */
-CURLcode
-Curl_http_output_auth(struct Curl_easy *data,
- struct connectdata *conn,
- const char *request,
- Curl_HttpReq httpreq,
- const char *path,
- bool proxytunnel)
+CURLcode Curl_http_output_auth(struct Curl_easy *data,
+ struct connectdata *conn,
+ const char *request,
+ Curl_HttpReq httpreq,
+ const char *path,
+ bool proxytunnel)
{
(void)data;
(void)conn;
/* 300 - Multiple Choices */
/* 306 - Not used */
/* 307 - Temporary Redirect */
- default: /* for all above (and the unknown ones) */
+ default: /* for all above (and the unknown ones) */
/* Some codes are explicitly mentioned since I have checked RFC2616 and
* they seem to be OK to POST to.
*/
* This behavior is forbidden by RFC1945 and the obsolete RFC2616, and
* can be overridden with CURLOPT_POSTREDIR.
*/
- if((data->state.httpreq == HTTPREQ_POST
- || data->state.httpreq == HTTPREQ_POST_FORM
- || data->state.httpreq == HTTPREQ_POST_MIME)
- && !(data->set.keep_post & CURL_REDIR_POST_301)) {
+ if((data->state.httpreq == HTTPREQ_POST ||
+ data->state.httpreq == HTTPREQ_POST_FORM ||
+ data->state.httpreq == HTTPREQ_POST_MIME) &&
+ !(data->set.keep_post & CURL_REDIR_POST_301)) {
http_switch_to_get(data, 301);
switch_to_get = TRUE;
}
* This behavior is forbidden by RFC1945 and the obsolete RFC2616, and
* can be overridden with CURLOPT_POSTREDIR.
*/
- if((data->state.httpreq == HTTPREQ_POST
- || data->state.httpreq == HTTPREQ_POST_FORM
- || data->state.httpreq == HTTPREQ_POST_MIME)
- && !(data->set.keep_post & CURL_REDIR_POST_302)) {
+ if((data->state.httpreq == HTTPREQ_POST ||
+ data->state.httpreq == HTTPREQ_POST_FORM ||
+ data->state.httpreq == HTTPREQ_POST_MIME) &&
+ !(data->set.keep_post & CURL_REDIR_POST_302)) {
http_switch_to_get(data, 302);
switch_to_get = TRUE;
}
* Returns TRUE if 'headerline' contains the 'header' with given 'content'.
* Pass headers WITH the colon.
*/
-bool
-Curl_compareheader(const char *headerline, /* line to check */
- const char *header, /* header keyword _with_ colon */
- const size_t hlen, /* len of the keyword in bytes */
- const char *content, /* content string to find */
- const size_t clen) /* len of the content in bytes */
+bool Curl_compareheader(const char *headerline, /* line to check */
+ const char *header, /* header keyword _with_ colon */
+ const size_t hlen, /* len of the keyword in bytes */
+ const char *content, /* content string to find */
+ const size_t clen) /* len of the content in bytes */
{
/* RFC2616, section 4.2 says: "Each header field consists of a name followed
* by a colon (":") and the field value. Field names are case-insensitive.
static const char *get_http_string(int httpversion)
{
switch(httpversion) {
- case 30:
- return "3";
- case 20:
- return "2";
- case 11:
- return "1.1";
- default:
- return "1.0";
+ case 30:
+ return "3";
+ case 20:
+ return "2";
+ case 11:
+ return "1.1";
+ default:
+ return "1.0";
}
}
curl_msnprintf(datestr, sizeof(datestr),
"%s: %s, %02d %s %4d %02d:%02d:%02d GMT\r\n",
condp,
- Curl_wkday[tm->tm_wday ? tm->tm_wday-1 : 6],
+ Curl_wkday[tm->tm_wday ? tm->tm_wday - 1 : 6],
tm->tm_mday,
Curl_month[tm->tm_mon],
tm->tm_year + 1900,
Curl_HttpReq httpreq = (Curl_HttpReq)data->state.httpreq;
const char *request;
#ifndef CURL_DISABLE_WEBSOCKETS
- if(data->conn->handler->protocol&(CURLPROTO_WS|CURLPROTO_WSS))
+ if(data->conn->handler->protocol & (CURLPROTO_WS | CURLPROTO_WSS))
httpreq = HTTPREQ_GET;
else
#endif
- if((data->conn->handler->protocol&(PROTO_FAMILY_HTTP|CURLPROTO_FTP)) &&
+ if((data->conn->handler->protocol & (PROTO_FAMILY_HTTP | CURLPROTO_FTP)) &&
data->state.upload)
httpreq = HTTPREQ_PUT;
return CURLE_OK;
}
-
static CURLcode http_set_aptr_host(struct Curl_easy *data)
{
struct connectdata *conn = data->conn;
[brackets] if the hostname is a plain IPv6-address. RFC2732-style. */
const char *host = conn->host.name;
- if(((conn->given->protocol&(CURLPROTO_HTTPS|CURLPROTO_WSS)) &&
+ if(((conn->given->protocol & (CURLPROTO_HTTPS | CURLPROTO_WSS)) &&
(conn->remote_port == PORT_HTTPS)) ||
- ((conn->given->protocol&(CURLPROTO_HTTP|CURLPROTO_WS)) &&
- (conn->remote_port == PORT_HTTP)) )
+ ((conn->given->protocol & (CURLPROTO_HTTP | CURLPROTO_WS)) &&
+ (conn->remote_port == PORT_HTTP)))
/* if(HTTPS on port 443) OR (HTTP on port 80) then do not include
the port number in the host string */
aptr->host = curl_maprintf("Host: %s%s%s\r\n",
return result;
}
#else
-#define http_cookies(a,b) CURLE_OK
+#define http_cookies(a, b) CURLE_OK
#endif
static CURLcode http_range(struct Curl_easy *data,
data->state.aptr.rangeline =
curl_maprintf("Content-Range: bytes %s%" FMT_OFF_T "/"
"%" FMT_OFF_T "\r\n",
- data->state.range, total_len-1, total_len);
+ data->state.range, total_len - 1, total_len);
}
else {
/* Range was selected and then we just pass the incoming range and
result = Curl_http2_request_upgrade(req, data);
}
#ifndef CURL_DISABLE_WEBSOCKETS
- if(!result && conn->handler->protocol&(CURLPROTO_WS|CURLPROTO_WSS))
+ if(!result && conn->handler->protocol & (CURLPROTO_WS | CURLPROTO_WSS))
result = Curl_ws_request(data, req);
#endif
break;
STATUS_BAD /* not a status line */
} statusline;
-
/* Check a string for a prefix. Check no more than 'len' bytes */
static bool checkprefixmax(const char *prefix, const char *buffer, size_t len)
{
*
* Returns TRUE if member of the list matches prefix of string
*/
-static statusline
-checkhttpprefix(struct Curl_easy *data,
- const char *s, size_t len)
+static statusline checkhttpprefix(struct Curl_easy *data,
+ const char *s, size_t len)
{
struct curl_slist *head = data->set.http200aliases;
statusline rc = STATUS_BAD;
}
#ifndef CURL_DISABLE_RTSP
-static statusline
-checkrtspprefix(struct Curl_easy *data,
- const char *s, size_t len)
+static statusline checkrtspprefix(struct Curl_easy *data,
+ const char *s, size_t len)
{
statusline result = STATUS_BAD;
statusline onmatch = len >= 5 ? STATUS_DONE : STATUS_UNKNOWN;
}
#endif /* CURL_DISABLE_RTSP */
-static statusline
-checkprotoprefix(struct Curl_easy *data, struct connectdata *conn,
- const char *s, size_t len)
+static statusline checkprotoprefix(struct Curl_easy *data,
+ struct connectdata *conn,
+ const char *s, size_t len)
{
#ifndef CURL_DISABLE_RTSP
if(conn->handler->protocol & CURLPROTO_RTSP)
/* HTTP header has field name `n` (a string constant) */
#define HD_IS(hd, hdlen, n) \
- (((hdlen) >= (sizeof(n)-1)) && curl_strnequal((n), (hd), (sizeof(n)-1)))
+ (((hdlen) >= (sizeof(n) - 1)) && curl_strnequal((n), (hd), (sizeof(n) - 1)))
#define HD_VAL(hd, hdlen, n) \
- ((((hdlen) >= (sizeof(n)-1)) && \
- curl_strnequal((n), (hd), (sizeof(n)-1)))? (hd + (sizeof(n)-1)) : NULL)
+ ((((hdlen) >= (sizeof(n) - 1)) && \
+ curl_strnequal((n), (hd), (sizeof(n) - 1)))? (hd + (sizeof(n) - 1)) : NULL)
/* HTTP header has field name `n` (a string constant) and contains `v`
* (a string constant) in its value(s) */
#define HD_IS_AND_SAYS(hd, hdlen, n, v) \
(HD_IS(hd, hdlen, n) && \
- ((hdlen) > ((sizeof(n)-1) + (sizeof(v)-1))) && \
+ ((hdlen) > ((sizeof(n) - 1) + (sizeof(v) - 1))) && \
Curl_compareheader(hd, STRCONST(n), STRCONST(v)))
/*
#endif
/* no major version switch mid-connection */
if(k->httpversion_sent &&
- (k->httpversion/10 != k->httpversion_sent/10)) {
+ (k->httpversion / 10 != k->httpversion_sent / 10)) {
failf(data, "Version mismatch (from HTTP/%u to HTTP/%u)",
- k->httpversion_sent/10, k->httpversion/10);
+ k->httpversion_sent / 10, k->httpversion / 10);
return CURLE_WEIRD_SERVER_REPLY;
}
break;
default:
failf(data, "Unsupported HTTP version (%u.%d) in response",
- k->httpversion/10, k->httpversion%10);
+ k->httpversion / 10, k->httpversion % 10);
return CURLE_UNSUPPORTED_PROTOCOL;
}
Curl_debug(data, CURLINFO_HEADER_IN, hd, hdlen);
writetype = CLIENTWRITE_HEADER |
- ((data->req.httpcode/100 == 1) ? CLIENTWRITE_1XX : 0);
+ ((data->req.httpcode / 100 == 1) ? CLIENTWRITE_1XX : 0);
result = Curl_client_write(data, writetype, hd, hdlen);
if(result)
/* Check if this response means the transfer errored. */
if(http_should_fail(data, data->req.httpcode)) {
- failf(data, "The requested URL returned error: %d",
- k->httpcode);
+ failf(data, "The requested URL returned error: %d", k->httpcode);
result = CURLE_HTTP_RETURNED_ERROR;
goto out;
}
}
else {
infof(data, "Got HTTP failure 417 while sending data");
- streamclose(conn,
- "Stop sending data before everything sent");
+ streamclose(conn, "Stop sending data before everything sent");
result = http_perhapsrewind(data, conn);
if(result)
goto out;
infof(data, "Keep sending data to get tossed away");
k->keepon |= KEEP_SEND;
}
-
}
/* If we requested a "no body", this is a good time to get
*/
Curl_debug(data, CURLINFO_HEADER_IN, hd, hdlen);
- if(k->httpcode/100 == 1)
+ if(k->httpcode / 100 == 1)
writetype |= CLIENTWRITE_1XX;
result = Curl_client_write(data, writetype, hd, hdlen);
if(result)
infof(data, "set pseudo header %s to %s", HTTP_PSEUDO_SCHEME, scheme);
}
else {
- scheme = Curl_conn_is_ssl(data->conn, FIRSTSOCKET) ?
- "https" : "http";
+ scheme = Curl_conn_is_ssl(data->conn, FIRSTSOCKET) ? "https" : "http";
}
}
struct Curl_creader *reader = NULL;
CURLcode result;
- result = Curl_creader_create(&reader, data, &cr_exp100,
- CURL_CR_PROTOCOL);
+ result = Curl_creader_create(&reader, data, &cr_exp100, CURL_CR_PROTOCOL);
if(!result)
result = Curl_creader_add(data, reader);
if(!result) {
HTTPREQ_HEAD
} Curl_HttpReq;
-
/* When redirecting transfers. */
typedef enum {
FOLLOW_NONE, /* not used within the function, just a placeholder to
/* bitmask of CURL_HTTP_V* values */
typedef unsigned char http_majors;
-
#ifndef CURL_DISABLE_HTTP
#ifdef USE_HTTP3
selected to use no auth at all. Ie, we actively select no auth, as opposed
to not having one selected. The other CURLAUTH_* defines are present in the
public curl/curl.h header. */
-#define CURLAUTH_PICKNONE (1<<30) /* do not use auth */
+#define CURLAUTH_PICKNONE (1 << 30) /* do not use auth */
/* MAX_INITIAL_POST_SIZE indicates the number of bytes that will make the POST
data get included in the initial data chunk sent to the server. If the
It must not be greater than 64K to work on VMS.
*/
#ifndef MAX_INITIAL_POST_SIZE
-#define MAX_INITIAL_POST_SIZE (64*1024)
+#define MAX_INITIAL_POST_SIZE (64 * 1024)
#endif
/* EXPECT_100_THRESHOLD is the request body size limit for when libcurl will
*
*/
#ifndef EXPECT_100_THRESHOLD
-#define EXPECT_100_THRESHOLD (1024*1024)
+#define EXPECT_100_THRESHOLD (1024 * 1024)
#endif
/* MAX_HTTP_RESP_HEADER_SIZE is the maximum size of all response headers
combined that libcurl allows for a single HTTP response, any HTTP
version. This count includes CONNECT response headers. */
-#define MAX_HTTP_RESP_HEADER_SIZE (300*1024)
+#define MAX_HTTP_RESP_HEADER_SIZE (300 * 1024)
/* MAX_HTTP_RESP_HEADER_COUNT is the maximum number of response headers that
libcurl allows for a single HTTP response, including CONNECT and
void Curl_http_req_free(struct httpreq *req);
-#define HTTP_PSEUDO_METHOD ":method"
-#define HTTP_PSEUDO_SCHEME ":scheme"
+#define HTTP_PSEUDO_METHOD ":method"
+#define HTTP_PSEUDO_SCHEME ":scheme"
#define HTTP_PSEUDO_AUTHORITY ":authority"
-#define HTTP_PSEUDO_PATH ":path"
-#define HTTP_PSEUDO_STATUS ":status"
+#define HTTP_PSEUDO_PATH ":path"
+#define HTTP_PSEUDO_STATUS ":status"
/**
* Create the list of HTTP/2 headers which represent the request,
#include "urlapi-int.h"
-#define H1_MAX_URL_LEN (8*1024)
+#define H1_MAX_URL_LEN (8 * 1024)
void Curl_h1_req_parse_init(struct h1_req_parser *parser, size_t max_line_len)
{
result = CURLE_OUT_OF_MEMORY;
goto out;
}
- url_options = (CURLU_NON_SUPPORT_SCHEME|
- CURLU_PATH_AS_IS|
+ url_options = (CURLU_NON_SUPPORT_SCHEME |
+ CURLU_PATH_AS_IS |
CURLU_NO_DEFAULT_PORT);
if(!(options & H1_PARSE_OPT_STRICT))
url_options |= CURLU_ALLOW_SPACE;
#endif
#ifdef CURL_DISABLE_VERBOSE_STRINGS
-#define nghttp2_session_callbacks_set_error_callback(x,y)
+#define nghttp2_session_callbacks_set_error_callback(x, y)
#endif
#if (NGHTTP2_VERSION_NUM >= 0x010c00)
* is blocked from sending us any data. See #10988 for an issue with this. */
#define HTTP2_HUGE_WINDOW_SIZE (100 * H2_STREAM_WINDOW_SIZE_MAX)
-#define H2_SETTINGS_IV_LEN 3
+#define H2_SETTINGS_IV_LEN 3
#define H2_BINSETTINGS_LEN 80
struct cf_h2_ctx {
/* How to access `call_data` from a cf_h2 filter */
#undef CF_CTX_CALL_DATA
-#define CF_CTX_CALL_DATA(cf) \
- ((struct cf_h2_ctx *)(cf)->ctx)->call_data
+#define CF_CTX_CALL_DATA(cf) ((struct cf_h2_ctx *)(cf)->ctx)->call_data
static void h2_stream_hash_free(unsigned int id, void *stream);
BIT(write_paused); /* stream write is paused */
};
-#define H2_STREAM_CTX(ctx,data) \
+#define H2_STREAM_CTX(ctx, data) \
((struct h2_stream_ctx *)( \
data? Curl_uint32_hash_get(&(ctx)->streams, (data)->mid) : NULL))
static int32_t cf_h2_get_desired_local_win(struct Curl_cfilter *cf,
struct Curl_easy *data)
{
- curl_off_t avail = Curl_rlimit_avail(&data->progress.dl.rlimit,
- curlx_now());
+ curl_off_t avail = Curl_rlimit_avail(&data->progress.dl.rlimit, curlx_now());
(void)cf;
if(avail < CURL_OFF_T_MAX) { /* limit in place */
}
#endif /* !NGHTTP2_HAS_SET_LOCAL_WINDOW_SIZE */
-
static CURLcode http2_data_setup(struct Curl_cfilter *cf,
struct Curl_easy *data,
struct h2_stream_ctx **pstream)
{
struct cf_h2_ctx *ctx = cf->ctx;
nghttp2_option *o;
- nghttp2_mem mem = {NULL, Curl_nghttp2_malloc, Curl_nghttp2_free,
- Curl_nghttp2_calloc, Curl_nghttp2_realloc};
+ nghttp2_mem mem = { NULL, Curl_nghttp2_malloc, Curl_nghttp2_free,
+ Curl_nghttp2_calloc, Curl_nghttp2_realloc };
int rc = nghttp2_option_new(&o);
if(rc)
NGHTTP2_ERR_CALLBACK_FAILURE : (ssize_t)nwritten;
}
-
/* We pass a pointer to this struct in the push callback, but the contents of
the struct are hidden from the user. */
struct curl_pushheaders {
static int fr_print(const nghttp2_frame *frame, char *buffer, size_t blen)
{
switch(frame->hd.type) {
- case NGHTTP2_DATA: {
- return curl_msnprintf(buffer, blen,
- "FRAME[DATA, len=%d, eos=%d, padlen=%d]",
- (int)frame->hd.length,
- !!(frame->hd.flags & NGHTTP2_FLAG_END_STREAM),
- (int)frame->data.padlen);
- }
- case NGHTTP2_HEADERS: {
- return curl_msnprintf(buffer, blen,
- "FRAME[HEADERS, len=%d, hend=%d, eos=%d]",
- (int)frame->hd.length,
- !!(frame->hd.flags & NGHTTP2_FLAG_END_HEADERS),
- !!(frame->hd.flags & NGHTTP2_FLAG_END_STREAM));
- }
- case NGHTTP2_PRIORITY: {
- return curl_msnprintf(buffer, blen,
- "FRAME[PRIORITY, len=%d, flags=%d]",
- (int)frame->hd.length, frame->hd.flags);
- }
- case NGHTTP2_RST_STREAM: {
- return curl_msnprintf(buffer, blen,
- "FRAME[RST_STREAM, len=%d, flags=%d, error=%u]",
- (int)frame->hd.length, frame->hd.flags,
- frame->rst_stream.error_code);
- }
- case NGHTTP2_SETTINGS: {
- if(frame->hd.flags & NGHTTP2_FLAG_ACK) {
- return curl_msnprintf(buffer, blen, "FRAME[SETTINGS, ack=1]");
- }
- return curl_msnprintf(buffer, blen,
- "FRAME[SETTINGS, len=%d]", (int)frame->hd.length);
- }
- case NGHTTP2_PUSH_PROMISE: {
- return curl_msnprintf(buffer, blen,
- "FRAME[PUSH_PROMISE, len=%d, hend=%d]",
- (int)frame->hd.length,
- !!(frame->hd.flags & NGHTTP2_FLAG_END_HEADERS));
- }
- case NGHTTP2_PING: {
- return curl_msnprintf(buffer, blen,
- "FRAME[PING, len=%d, ack=%d]",
- (int)frame->hd.length,
- frame->hd.flags&NGHTTP2_FLAG_ACK);
- }
- case NGHTTP2_GOAWAY: {
- char scratch[128];
- size_t s_len = CURL_ARRAYSIZE(scratch);
- size_t len = (frame->goaway.opaque_data_len < s_len) ?
- frame->goaway.opaque_data_len : s_len-1;
- if(len)
- memcpy(scratch, frame->goaway.opaque_data, len);
- scratch[len] = '\0';
- return curl_msnprintf(buffer, blen,
- "FRAME[GOAWAY, error=%d, reason='%s', "
- "last_stream=%d]", frame->goaway.error_code,
- scratch, frame->goaway.last_stream_id);
- }
- case NGHTTP2_WINDOW_UPDATE: {
- return curl_msnprintf(buffer, blen,
- "FRAME[WINDOW_UPDATE, incr=%d]",
- frame->window_update.window_size_increment);
- }
- default:
- return curl_msnprintf(buffer, blen, "FRAME[%d, len=%d, flags=%d]",
- frame->hd.type, (int)frame->hd.length,
- frame->hd.flags);
+ case NGHTTP2_DATA: {
+ return curl_msnprintf(buffer, blen,
+ "FRAME[DATA, len=%d, eos=%d, padlen=%d]",
+ (int)frame->hd.length,
+ !!(frame->hd.flags & NGHTTP2_FLAG_END_STREAM),
+ (int)frame->data.padlen);
+ }
+ case NGHTTP2_HEADERS: {
+ return curl_msnprintf(buffer, blen,
+ "FRAME[HEADERS, len=%d, hend=%d, eos=%d]",
+ (int)frame->hd.length,
+ !!(frame->hd.flags & NGHTTP2_FLAG_END_HEADERS),
+ !!(frame->hd.flags & NGHTTP2_FLAG_END_STREAM));
+ }
+ case NGHTTP2_PRIORITY: {
+ return curl_msnprintf(buffer, blen,
+ "FRAME[PRIORITY, len=%d, flags=%d]",
+ (int)frame->hd.length, frame->hd.flags);
+ }
+ case NGHTTP2_RST_STREAM: {
+ return curl_msnprintf(buffer, blen,
+ "FRAME[RST_STREAM, len=%d, flags=%d, error=%u]",
+ (int)frame->hd.length, frame->hd.flags,
+ frame->rst_stream.error_code);
+ }
+ case NGHTTP2_SETTINGS: {
+ if(frame->hd.flags & NGHTTP2_FLAG_ACK) {
+ return curl_msnprintf(buffer, blen, "FRAME[SETTINGS, ack=1]");
+ }
+ return curl_msnprintf(buffer, blen,
+ "FRAME[SETTINGS, len=%d]", (int)frame->hd.length);
+ }
+ case NGHTTP2_PUSH_PROMISE: {
+ return curl_msnprintf(buffer, blen,
+ "FRAME[PUSH_PROMISE, len=%d, hend=%d]",
+ (int)frame->hd.length,
+ !!(frame->hd.flags & NGHTTP2_FLAG_END_HEADERS));
+ }
+ case NGHTTP2_PING: {
+ return curl_msnprintf(buffer, blen,
+ "FRAME[PING, len=%d, ack=%d]",
+ (int)frame->hd.length,
+ frame->hd.flags & NGHTTP2_FLAG_ACK);
+ }
+ case NGHTTP2_GOAWAY: {
+ char scratch[128];
+ size_t s_len = CURL_ARRAYSIZE(scratch);
+ size_t len = (frame->goaway.opaque_data_len < s_len) ?
+ frame->goaway.opaque_data_len : s_len - 1;
+ if(len)
+ memcpy(scratch, frame->goaway.opaque_data, len);
+ scratch[len] = '\0';
+ return curl_msnprintf(buffer, blen,
+ "FRAME[GOAWAY, error=%d, reason='%s', "
+ "last_stream=%d]", frame->goaway.error_code,
+ scratch, frame->goaway.last_stream_id);
+ }
+ case NGHTTP2_WINDOW_UPDATE: {
+ return curl_msnprintf(buffer, blen,
+ "FRAME[WINDOW_UPDATE, incr=%d]",
+ frame->window_update.window_size_increment);
+ }
+ default:
+ return curl_msnprintf(buffer, blen, "FRAME[%d, len=%d, flags=%d]",
+ frame->hd.type, (int)frame->hd.length,
+ frame->hd.flags);
}
}
if(data && Curl_trc_cf_is_verbose(cf, data)) {
char buffer[256];
int len;
- len = fr_print(frame, buffer, sizeof(buffer)-1);
+ len = fr_print(frame, buffer, sizeof(buffer) - 1);
buffer[len] = 0;
CURL_TRC_CF(data, cf, "[%d] -> %s", frame->hd.stream_id, buffer);
}
if(Curl_trc_cf_is_verbose(cf, data)) {
char buffer[256];
int len;
- len = fr_print(frame, buffer, sizeof(buffer)-1);
+ len = fr_print(frame, buffer, sizeof(buffer) - 1);
buffer[len] = 0;
- CURL_TRC_CF(data, cf, "[%d] <- %s",frame->hd.stream_id, buffer);
+ CURL_TRC_CF(data, cf, "[%d] <- %s", frame->hd.stream_id, buffer);
}
#endif /* !CURL_DISABLE_VERBOSE_STRINGS */
if(!(frame->hd.flags & NGHTTP2_FLAG_ACK)) {
uint32_t max_conn = ctx->max_concurrent_streams;
ctx->max_concurrent_streams = nghttp2_session_get_remote_settings(
- session, NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS);
+ session, NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS);
ctx->enable_push = nghttp2_session_get_remote_settings(
- session, NGHTTP2_SETTINGS_ENABLE_PUSH) != 0;
+ session, NGHTTP2_SETTINGS_ENABLE_PUSH) != 0;
CURL_TRC_CF(data, cf, "[0] MAX_CONCURRENT_STREAMS: %d",
ctx->max_concurrent_streams);
CURL_TRC_CF(data, cf, "[0] ENABLE_PUSH: %s",
ctx->remote_max_sid = frame->goaway.last_stream_id;
if(data) {
infof(data, "received GOAWAY, error=%u, last_stream=%u",
- ctx->goaway_error, ctx->remote_max_sid);
+ ctx->goaway_error, ctx->remote_max_sid);
Curl_multi_connchanged(data->multi);
}
break;
#ifndef CURL_DISABLE_VERBOSE_STRINGS
char buffer[256];
int len;
- len = fr_print(frame, buffer, sizeof(buffer)-1);
+ len = fr_print(frame, buffer, sizeof(buffer) - 1);
buffer[len] = 0;
failf(data, "[HTTP2] [%d] received invalid frame: %s, error %d: %s",
stream_id, buffer, ngerr, nghttp2_strerror(ngerr));
/* Receiving a Stream ID not in the hash should not happen - unless
we have aborted a transfer artificially and there were more data
in the pipeline. Silently ignore. */
- CURL_TRC_CF(CF_DATA_CURRENT(cf), cf, "[%d] Data for unknown",
- stream_id);
+ CURL_TRC_CF(CF_DATA_CURRENT(cf), cf, "[%d] Data for unknown", stream_id);
/* consumed explicitly as no one will read it */
nghttp2_session_consume(session, stream_id, len);
return 0;
if(frame->hd.type == NGHTTP2_PUSH_PROMISE) {
char *h;
- if((namelen == (sizeof(HTTP_PSEUDO_AUTHORITY)-1)) &&
+ if((namelen == (sizeof(HTTP_PSEUDO_AUTHORITY) - 1)) &&
!strncmp(HTTP_PSEUDO_AUTHORITY, (const char *)name, namelen)) {
/* pseudo headers are lower case */
int rc = 0;
break;
Curl_debug(data, CURLINFO_HEADER_IN, curlx_dyn_ptr(&dbuf),
curlx_dyn_len(&dbuf));
- result = Curl_client_write(data, CLIENTWRITE_HEADER|CLIENTWRITE_TRAILER,
+ result = Curl_client_write(data,
+ CLIENTWRITE_HEADER | CLIENTWRITE_TRAILER,
curlx_dyn_ptr(&dbuf), curlx_dyn_len(&dbuf));
if(result)
break;
if(stream && stream->id > 0 &&
((sweight_wanted(data) != sweight_in_effect(data)) ||
(data->set.priority.exclusive != data->state.priority.exclusive) ||
- (data->set.priority.parent != data->state.priority.parent)) ) {
+ (data->set.priority.parent != data->state.priority.parent))) {
/* send new weight and/or dependency */
nghttp2_priority_spec pri_spec;
#define Curl_http2_may_switch(a) FALSE
-#define Curl_http2_request_upgrade(x,y) CURLE_UNSUPPORTED_PROTOCOL
-#define Curl_http2_switch(a) CURLE_UNSUPPORTED_PROTOCOL
-#define Curl_http2_upgrade(a,b,c,d,e) CURLE_UNSUPPORTED_PROTOCOL
-#define Curl_h2_http_1_1_error(x) 0
+#define Curl_http2_request_upgrade(x, y) CURLE_UNSUPPORTED_PROTOCOL
+#define Curl_http2_switch(a) CURLE_UNSUPPORTED_PROTOCOL
+#define Curl_http2_upgrade(a, b, c, d, e) CURLE_UNSUPPORTED_PROTOCOL
+#define Curl_h2_http_1_1_error(x) 0
#endif
#endif /* HEADER_CURL_HTTP2_H */
}
/* maximum length for the aws sivg4 parts */
-#define MAX_SIGV4_LEN 64
+#define MAX_SIGV4_LEN 64
#define DATE_HDR_KEY_LEN (MAX_SIGV4_LEN + sizeof("X--Date"))
/* string been x-PROVIDER-date:TIMESTAMP, I need +1 for ':' */
#define CONTENT_SHA256_KEY_LEN (MAX_SIGV4_LEN + sizeof("X--Content-Sha256"))
/* add 2 for ": " between header name and value */
-#define CONTENT_SHA256_HDR_LEN (CONTENT_SHA256_KEY_LEN + 2 + \
- SHA256_HEX_LENGTH)
+#define CONTENT_SHA256_HDR_LEN (CONTENT_SHA256_KEY_LEN + 2 + SHA256_HEX_LENGTH)
/* try to parse a payload hash from the content-sha256 header */
static const char *parse_content_sha_hdr(struct Curl_easy *data,
curlx_str_passblanks(&value);
len = strlen(value);
- while(len > 0 && ISBLANK(value[len-1]))
+ while(len > 0 && ISBLANK(value[len - 1]))
--len;
*value_len = len;
compare = strcmp(curlx_dyn_ptr(&aa->value), curlx_dyn_ptr(&bb->value));
return compare;
-
}
UNITTEST CURLcode canon_path(const char *q, size_t len,
if(!query)
return result;
- result = split_to_dyn_array(query, &query_array[0],
- &num_query_components);
+ result = split_to_dyn_array(query, &query_array[0], &num_query_components);
if(result) {
goto fail;
}
/* Create list of pairs, each pair containing an encoded query
- * component */
+ * component */
for(index = 0; index < num_query_components; index++) {
const char *in_key;
in_key_len = offset - in_key;
}
- curlx_dyn_init(&encoded_query_array[index].key, query_part_len*3 + 1);
- curlx_dyn_init(&encoded_query_array[index].value, query_part_len*3 + 1);
+ curlx_dyn_init(&encoded_query_array[index].key, query_part_len * 3 + 1);
+ curlx_dyn_init(&encoded_query_array[index].value, query_part_len * 3 + 1);
counted_query_components++;
/* Decode/encode the key */
const char *line;
struct Curl_str provider0;
struct Curl_str provider1;
- struct Curl_str region = { NULL, 0};
- struct Curl_str service = { NULL, 0};
+ struct Curl_str region = { NULL, 0 };
+ struct Curl_str service = { NULL, 0 };
const char *hostname = conn->host.name;
time_t clock;
struct tm tm;
char *str_to_sign = NULL;
const char *user = data->state.aptr.user ? data->state.aptr.user : "";
char *secret = NULL;
- unsigned char sign0[CURL_SHA256_DIGEST_LENGTH] = {0};
- unsigned char sign1[CURL_SHA256_DIGEST_LENGTH] = {0};
+ unsigned char sign0[CURL_SHA256_DIGEST_LENGTH] = { 0 };
+ unsigned char sign1[CURL_SHA256_DIGEST_LENGTH] = { 0 };
char *auth_headers = NULL;
if(data->set.path_as_is) {
/* AWS S3 requires a x-amz-content-sha256 header, and supports special
* values like UNSIGNED-PAYLOAD */
bool sign_as_s3 = curlx_str_casecompare(&provider0, "aws") &&
- curlx_str_casecompare(&service, "s3");
+ curlx_str_casecompare(&service, "s3");
if(sign_as_s3)
result = calc_s3_payload_hash(data, httpreq, curlx_str(&provider1),
goto fail;
infof(data, "aws_sigv4: Canonical request (enclosed in []) - [%s]",
- canonical_request);
+ canonical_request);
request_type = curl_maprintf("%.*s4_request",
(int)curlx_strlen(&provider0),
if(!credential_scope)
goto fail;
- if(Curl_sha256it(sha_hash, (unsigned char *) canonical_request,
+ if(Curl_sha256it(sha_hash, (unsigned char *)canonical_request,
strlen(canonical_request)))
goto fail;
curlx_strlen(&provider0));
infof(data, "aws_sigv4: String to sign (enclosed in []) - [%s]",
- str_to_sign);
+ str_to_sign);
secret = curl_maprintf("%.*s4%s", (int)curlx_strlen(&provider0),
curlx_str(&provider0), data->state.aptr.passwd ?
}
/*
-* Frees all allocated strings in a dynbuf pair array, and the dynbuf itself
-*/
+ * Frees all allocated strings in a dynbuf pair array, and the dynbuf itself
+ */
static void pair_array_free(struct pair *pair_array, size_t num_elements)
{
curlx_dyn_free(&pair_array[index].key);
curlx_dyn_free(&pair_array[index].value);
}
-
}
/*
-* Frees all allocated strings in a split dynbuf, and the dynbuf itself
-*/
+ * Frees all allocated strings in a split dynbuf, and the dynbuf itself
+ */
static void dyn_array_free(struct dynbuf *db, size_t num_elements)
{
}
/*
-* Splits source string by SPLIT_BY, and creates an array of dynbuf in db.
-* db is initialized by this function.
-* Caller is responsible for freeing the array elements with dyn_array_free
-*/
+ * Splits source string by SPLIT_BY, and creates an array of dynbuf in db.
+ * db is initialized by this function.
+ * Caller is responsible for freeing the array elements with dyn_array_free
+ */
#define SPLIT_BY '&'
if(source[pos] == SPLIT_BY) {
if(segment_length) {
curlx_dyn_init(&db[index], segment_length + 1);
- result = curlx_dyn_addn(&db[index], &source[start],
- segment_length);
+ result = curlx_dyn_addn(&db[index], &source[start], segment_length);
if(result)
goto fail;
return result;
}
-
static bool is_reserved_char(const char c)
{
return (ISALNUM(c) || ISURLPUNTCS(c));
return CURLE_OK;
}
-
static CURLcode encode_query_component(char *component, size_t len,
struct dynbuf *db)
{
}
/*
-* Populates a dynbuf containing url_encode(url_decode(in))
-*/
+ * Populates a dynbuf containing url_encode(url_decode(in))
+ */
static CURLcode http_aws_decode_encode(const char *in, size_t in_len,
struct dynbuf *out)
#ifdef UNITTESTS
UNITTEST CURLcode canon_path(const char *q, size_t len,
- struct dynbuf *new_path,
- bool normalize);
+ struct dynbuf *new_path, bool normalize);
UNITTEST CURLcode canon_query(const char *query, struct dynbuf *dq);
#endif
case CHUNK_FAILED:
return CURLE_RECV_ERROR;
}
-
}
return CURLE_OK;
}
continue;
}
- result = Curl_bufq_cwrite(&ctx->chunkbuf, tr->data,
- strlen(tr->data), &n);
+ result = Curl_bufq_cwrite(&ctx->chunkbuf, tr->data, strlen(tr->data), &n);
if(!result)
result = Curl_bufq_cwrite(&ctx->chunkbuf, STRCONST("\r\n"), &n);
if(result)
}
}
if(!tmp)
- path = (unsigned char *)curlx_strdup((const char *) uripath);
+ path = (unsigned char *)curlx_strdup((const char *)uripath);
if(!path)
return CURLE_OUT_OF_MEMORY;
Curl_auth_cleanup_spnego(neg_ctx);
}
-
CURLcode Curl_input_negotiate(struct Curl_easy *data, struct connectdata *conn,
bool proxy, const char *header)
{
#ifdef USE_SSL
curlx_dyn_init(&neg_ctx->channel_binding_data, SSL_CB_MAX_SIZE + 1);
if(Curl_conn_is_ssl(conn, FIRSTSOCKET)) {
- result = Curl_ssl_get_channel_binding(
- data, FIRSTSOCKET, &neg_ctx->channel_binding_data);
+ result = Curl_ssl_get_channel_binding(data, FIRSTSOCKET,
+ &neg_ctx->channel_binding_data);
if(result) {
http_auth_nego_reset(conn, neg_ctx, proxy);
return result;
userp = data->state.aptr.proxyuser;
passwdp = data->state.aptr.proxypasswd;
service = data->set.str[STRING_PROXY_SERVICE_NAME] ?
- data->set.str[STRING_PROXY_SERVICE_NAME] : "HTTP";
+ data->set.str[STRING_PROXY_SERVICE_NAME] : "HTTP";
hostname = conn->http_proxy.host.name;
state = &conn->proxy_ntlm_state;
authp = &data->state.authproxy;
userp = data->state.aptr.user;
passwdp = data->state.aptr.passwd;
service = data->set.str[STRING_SERVICE_NAME] ?
- data->set.str[STRING_SERVICE_NAME] : "HTTP";
+ data->set.str[STRING_SERVICE_NAME] : "HTTP";
hostname = conn->host.name;
state = &conn->http_ntlm_state;
authp = &data->state.authhost;
if(!result) {
DEBUGASSERT(Curl_bufref_len(&ntlmmsg) != 0);
result = curlx_base64_encode(Curl_bufref_ptr(&ntlmmsg),
- Curl_bufref_len(&ntlmmsg), &base64, &len);
+ Curl_bufref_len(&ntlmmsg), &base64, &len);
if(!result) {
curlx_free(*allocuserpwd);
*allocuserpwd = curl_maprintf("%sAuthorization: NTLM %s\r\n",
- proxy ? "Proxy-" : "",
- base64);
+ proxy ? "Proxy-" : "", base64);
curlx_free(base64);
if(!*allocuserpwd)
result = CURLE_OUT_OF_MEMORY;
if(!result) {
curlx_free(*allocuserpwd);
*allocuserpwd = curl_maprintf("%sAuthorization: NTLM %s\r\n",
- proxy ? "Proxy-" : "",
- base64);
+ proxy ? "Proxy-" : "", base64);
curlx_free(base64);
if(!*allocuserpwd)
result = CURLE_OUT_OF_MEMORY;
if(data->state.aptr.host &&
/* a Host: header was sent already, do not pass on any custom Host:
header as that will produce *two* in the same request! */
- curlx_str_casecompare(&name, "Host"));
+ curlx_str_casecompare(&name, "Host"))
+ ;
else if(data->state.httpreq == HTTPREQ_POST_FORM &&
/* this header (extended by formdata.c) is sent later */
- curlx_str_casecompare(&name, "Content-Type"));
+ curlx_str_casecompare(&name, "Content-Type"))
+ ;
else if(data->state.httpreq == HTTPREQ_POST_MIME &&
/* this header is sent later */
- curlx_str_casecompare(&name, "Content-Type"));
+ curlx_str_casecompare(&name, "Content-Type"))
+ ;
else if(data->req.authneg &&
/* while doing auth neg, do not allow the custom length since
we will force length zero then */
- curlx_str_casecompare(&name, "Content-Length"));
+ curlx_str_casecompare(&name, "Content-Length"))
+ ;
else if((httpversion >= 20) &&
- curlx_str_casecompare(&name, "Transfer-Encoding"));
+ curlx_str_casecompare(&name, "Transfer-Encoding"))
+ ;
/* HTTP/2 and HTTP/3 do not support chunked requests */
else if((curlx_str_casecompare(&name, "Authorization") ||
curlx_str_casecompare(&name, "Cookie")) &&
/* be careful of sending this potentially sensitive header to
other hosts */
- !Curl_auth_allowed_to_host(data));
+ !Curl_auth_allowed_to_host(data))
+ ;
else {
CURLcode result =
Curl_dynhds_add(hds, curlx_str(&name), curlx_strlen(&name),
Curl_http_proxy_get_destination(cf, &hostname, &port, &ipv6_ip);
authority = curl_maprintf("%s%s%s:%d", ipv6_ip ? "[" : "", hostname,
- ipv6_ip ?"]" : "", port);
+ ipv6_ip ? "]" : "", port);
if(!authority) {
result = CURLE_OUT_OF_MEMORY;
goto out;
}
- result = Curl_http_req_make(&req, "CONNECT", sizeof("CONNECT")-1,
+ result = Curl_http_req_make(&req, "CONNECT", sizeof("CONNECT") - 1,
NULL, 0, authority, strlen(authority),
NULL, 0);
if(result)
}
if(http_version_major == 1 &&
- !Curl_checkProxyheaders(data, cf->conn, STRCONST("Proxy-Connection"))) {
+ !Curl_checkProxyheaders(data, cf->conn, STRCONST("Proxy-Connection"))) {
result = Curl_dynhds_cadd(&req->headers, "Proxy-Connection", "Keep-Alive");
if(result)
goto out;
cf->next->cft->do_close(cf->next, data);
}
-
struct Curl_cftype Curl_cft_http_proxy = {
"HTTP-PROXY",
- CF_TYPE_IP_CONNECT|CF_TYPE_PROXY,
+ CF_TYPE_IP_CONNECT | CF_TYPE_PROXY,
0,
http_proxy_cf_destroy,
http_proxy_cf_connect,
int http_version_major);
/* Default proxy timeout in milliseconds */
-#define PROXY_TIMEOUT (3600*1000)
+#define PROXY_TIMEOUT (3600 * 1000)
CURLcode Curl_cf_http_proxy_query(struct Curl_cfilter *cf,
struct Curl_easy *data,
Curl_safefree(rrinfo->rrname);
}
-
#ifdef USE_ARES
static CURLcode httpsrr_opt(struct Curl_easy *data,
#ifdef USE_HTTPSRR
#define CURL_MAXLEN_host_name 253
-#define MAX_HTTPSRR_ALPNS 4
+#define MAX_HTTPSRR_ALPNS 4
struct Curl_easy;
*
***************************************************************************/
- /*
- * IDN conversions
- */
+/*
+ * IDN conversions
+ */
#include "curl_setup.h"
#include "urldata.h"
{
size_t inlen = strlen(in);
if(inlen < MAX_HOST_LENGTH) {
- char iconv_buffer[MAX_HOST_LENGTH] = {0};
+ char iconv_buffer[MAX_HOST_LENGTH] = { 0 };
char *iconv_outptr = iconv_buffer;
size_t iconv_outlen = sizeof(iconv_buffer);
CURLcode iconv_result = iconv_to_utf8(in, inlen,
&iconv_outptr, &iconv_outlen);
if(!iconv_result) {
UErrorCode err = U_ZERO_ERROR;
- UIDNA* idna = uidna_openUTS46(
- UIDNA_CHECK_BIDI|UIDNA_NONTRANSITIONAL_TO_ASCII, &err);
+ UIDNA *idna = uidna_openUTS46(
+ UIDNA_CHECK_BIDI | UIDNA_NONTRANSITIONAL_TO_ASCII, &err);
if(!U_FAILURE(err)) {
UIDNAInfo info = UIDNA_INFO_INITIALIZER;
- char buffer[MAX_HOST_LENGTH] = {0};
+ char buffer[MAX_HOST_LENGTH] = { 0 };
(void)uidna_nameToASCII_UTF8(idna, iconv_buffer, (int)iconv_outlen,
buffer, sizeof(buffer) - 1, &info, &err);
uidna_close(idna);
size_t inlen = strlen(in);
if(inlen < MAX_HOST_LENGTH) {
UErrorCode err = U_ZERO_ERROR;
- UIDNA* idna = uidna_openUTS46(
- UIDNA_CHECK_BIDI|UIDNA_NONTRANSITIONAL_TO_UNICODE, &err);
+ UIDNA *idna = uidna_openUTS46(
+ UIDNA_CHECK_BIDI | UIDNA_NONTRANSITIONAL_TO_UNICODE, &err);
if(!U_FAILURE(err)) {
UIDNAInfo info = UIDNA_INFO_INITIALIZER;
- char buffer[MAX_HOST_LENGTH] = {0};
+ char buffer[MAX_HOST_LENGTH] = { 0 };
(void)uidna_nameToUnicodeUTF8(idna, in, -1, buffer,
sizeof(buffer) - 1, &info, &err);
uidna_close(idna);
unsigned int Curl_ipv6_scope(const struct sockaddr *sa)
{
if(sa->sa_family == AF_INET6) {
- const struct sockaddr_in6 * sa6 =
- (const struct sockaddr_in6 *)(const void *) sa;
+ const struct sockaddr_in6 *sa6 =
+ (const struct sockaddr_in6 *)(const void *)sa;
const unsigned char *b = sa6->sin6_addr.s6_addr;
- unsigned short w = (unsigned short) ((b[0] << 8) | b[1]);
+ unsigned short w = (unsigned short)((b[0] << 8) | b[1]);
if((b[0] & 0xFE) == 0xFC) /* Handle ULAs */
return IPV6_SCOPE_UNIQUELOCAL;
struct ifaddrs *iface, *head;
if2ip_result_t res = IF2IP_NOT_FOUND;
-#if defined(USE_IPV6) && \
- !defined(HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID)
+#if defined(USE_IPV6) && !defined(HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID)
(void)local_scope_id;
#endif
#ifdef HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID
/* Include the scope of this interface as part of the address */
scopeid = ((struct sockaddr_in6 *)(void *)iface->ifa_addr)
- ->sin6_scope_id;
+ ->sin6_scope_id;
/* If given, scope id should match. */
if(local_scope_id && scopeid != local_scope_id) {
const char *interf,
char *buf, size_t buf_size)
{
- (void)af;
+ (void)af;
#ifdef USE_IPV6
- (void)remote_scope;
- (void)local_scope_id;
+ (void)remote_scope;
+ (void)local_scope_id;
#endif
- (void)interf;
- (void)buf;
- (void)buf_size;
- return IF2IP_NOT_FOUND;
+ (void)interf;
+ (void)buf;
+ (void)buf_size;
+ return IF2IP_NOT_FOUND;
}
#endif
/* Nedelcho Stanev's work-around for SFU 3.0 */
struct ifreq {
-#define IFNAMSIZ 16
+#define IFNAMSIZ 16
#define IFHWADDRLEN 6
union {
char ifrn_name[IFNAMSIZ]; /* if name, e.g. "en0" */
/* This define exists to avoid an extra #ifdef INTERIX in the C code. */
-#define ifr_name ifr_ifrn.ifrn_name /* interface name */
-#define ifr_addr ifr_ifru.ifru_addr /* address */
+#define ifr_name ifr_ifrn.ifrn_name /* interface name */
+#define ifr_addr ifr_ifru.ifru_addr /* address */
#define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */
-#define ifr_netmask ifr_ifru.ifru_netmask /* interface net mask */
-#define ifr_flags ifr_ifru.ifru_flags /* flags */
-#define ifr_hwaddr ifr_ifru.ifru_hwaddr /* MAC address */
-#define ifr_metric ifr_ifru.ifru_metric /* metric */
-#define ifr_mtu ifr_ifru.ifru_mtu /* mtu */
+#define ifr_netmask ifr_ifru.ifru_netmask /* interface net mask */
+#define ifr_flags ifr_ifru.ifru_flags /* flags */
+#define ifr_hwaddr ifr_ifru.ifru_hwaddr /* MAC address */
+#define ifr_metric ifr_ifru.ifru_metric /* metric */
+#define ifr_mtu ifr_ifru.ifru_mtu /* mtu */
#define SIOCGIFADDR _IOW('s', 102, struct ifreq) /* Get if addr */
/* Do we have an untagged command response? */
if(len >= 2 && !memcmp("* ", line, 2)) {
switch(imapc->state) {
- /* States which are interested in untagged responses */
- case IMAP_CAPABILITY:
- if(!imap_matchresp(line, len, "CAPABILITY"))
- return FALSE;
- break;
-
- case IMAP_LIST:
- if((!imap->custom && !imap_matchresp(line, len, "LIST")) ||
- (imap->custom && !imap_matchresp(line, len, imap->custom) &&
- (!curl_strequal(imap->custom, "STORE") ||
- !imap_matchresp(line, len, "FETCH")) &&
- !curl_strequal(imap->custom, "SELECT") &&
- !curl_strequal(imap->custom, "EXAMINE") &&
- !curl_strequal(imap->custom, "SEARCH") &&
- !curl_strequal(imap->custom, "EXPUNGE") &&
- !curl_strequal(imap->custom, "LSUB") &&
- !curl_strequal(imap->custom, "UID") &&
- !curl_strequal(imap->custom, "GETQUOTAROOT") &&
- !curl_strequal(imap->custom, "NOOP")))
- return FALSE;
- break;
+ /* States which are interested in untagged responses */
+ case IMAP_CAPABILITY:
+ if(!imap_matchresp(line, len, "CAPABILITY"))
+ return FALSE;
+ break;
- case IMAP_SELECT:
- /* SELECT is special in that its untagged responses do not have a
- common prefix so accept anything! */
- break;
+ case IMAP_LIST:
+ if((!imap->custom && !imap_matchresp(line, len, "LIST")) ||
+ (imap->custom && !imap_matchresp(line, len, imap->custom) &&
+ (!curl_strequal(imap->custom, "STORE") ||
+ !imap_matchresp(line, len, "FETCH")) &&
+ !curl_strequal(imap->custom, "SELECT") &&
+ !curl_strequal(imap->custom, "EXAMINE") &&
+ !curl_strequal(imap->custom, "SEARCH") &&
+ !curl_strequal(imap->custom, "EXPUNGE") &&
+ !curl_strequal(imap->custom, "LSUB") &&
+ !curl_strequal(imap->custom, "UID") &&
+ !curl_strequal(imap->custom, "GETQUOTAROOT") &&
+ !curl_strequal(imap->custom, "NOOP")))
+ return FALSE;
+ break;
- case IMAP_FETCH:
- if(!imap_matchresp(line, len, "FETCH"))
- return FALSE;
- break;
+ case IMAP_SELECT:
+ /* SELECT is special in that its untagged responses do not have a
+ common prefix so accept anything! */
+ break;
- case IMAP_SEARCH:
- if(!imap_matchresp(line, len, "SEARCH"))
- return FALSE;
- break;
+ case IMAP_FETCH:
+ if(!imap_matchresp(line, len, "FETCH"))
+ return FALSE;
+ break;
- /* Ignore other untagged responses */
- default:
+ case IMAP_SEARCH:
+ if(!imap_matchresp(line, len, "SEARCH"))
return FALSE;
+ break;
+
+ /* Ignore other untagged responses */
+ default:
+ return FALSE;
}
*resp = '*';
if(!imap->custom && ((len == 3 && line[0] == '+') ||
(len >= 2 && !memcmp("+ ", line, 2)))) {
switch(imapc->state) {
- /* States which are interested in continuation responses */
- case IMAP_AUTHENTICATE:
- case IMAP_APPEND:
- *resp = '+';
- break;
+ /* States which are interested in continuation responses */
+ case IMAP_AUTHENTICATE:
+ case IMAP_APPEND:
+ *resp = '+';
+ break;
- default:
- failf(data, "Unexpected continuation response");
- *resp = -1;
- break;
+ default:
+ failf(data, "Unexpected continuation response");
+ *resp = -1;
+ break;
}
return TRUE;
{
#if defined(DEBUGBUILD) && !defined(CURL_DISABLE_VERBOSE_STRINGS)
/* for debug purposes */
- static const char * const names[]={
+ static const char * const names[] = {
"STOP",
"SERVERGREET",
"CAPABILITY",
result, ssldone));
if(!result && ssldone) {
imapc->ssldone = ssldone;
- /* perform CAPA now, changes imapc->state out of IMAP_UPGRADETLS */
- result = imap_perform_capability(data, imapc);
+ /* perform CAPA now, changes imapc->state out of IMAP_UPGRADETLS */
+ result = imap_perform_capability(data, imapc);
}
out:
return result;
struct imap_conn *imapc =
Curl_conn_meta_get(data->conn, CURL_META_IMAP_CONN);
CURLcode result = CURLE_OK;
- const char *ir = (const char *) Curl_bufref_ptr(initresp);
+ const char *ir = (const char *)Curl_bufref_ptr(initresp);
if(!imapc)
return CURLE_FAILED_INIT;
if(!imapc)
return CURLE_FAILED_INIT;
return Curl_pp_sendf(data, &imapc->pp,
- "%s", (const char *) Curl_bufref_ptr(resp));
+ "%s", (const char *)Curl_bufref_ptr(resp));
}
/***********************************************************************
/* Extract the word */
for(wordlen = 0; line[wordlen] && line[wordlen] != ' ' &&
- line[wordlen] != '\t' && line[wordlen] != '\r' &&
- line[wordlen] != '\n';)
+ line[wordlen] != '\t' && line[wordlen] != '\r' &&
+ line[wordlen] != '\n';)
wordlen++;
/* Does the server support the STARTTLS capability? */
imapc->mb_uidvalidity = (unsigned int)value;
imapc->mb_uidvalidity_set = TRUE;
}
-
}
}
else if(imapcode == IMAP_RESP_OK) {
/* SEARCH the current mailbox */
result = imap_perform_search(data, imapc, imap);
else if(imap->mailbox && !selected &&
- (imap->custom || imap->uid || imap->mindex || imap->query))
+ (imap->custom || imap->uid || imap->mindex || imap->query))
/* SELECT the mailbox */
result = imap_perform_select(data, imapc, imap);
else
return TRUE;
switch(ch) {
- /* bchar */
- case ':': case '@': case '/':
- /* bchar -> achar */
- case '&': case '=':
- /* bchar -> achar -> uchar -> unreserved (without alphanumeric) */
- case '-': case '.': case '_': case '~':
- /* bchar -> achar -> uchar -> sub-delims-sh */
- case '!': case '$': case '\'': case '(': case ')': case '*':
- case '+': case ',':
- /* bchar -> achar -> uchar -> pct-encoded */
- case '%': /* HEXDIG chars are already included above */
- return TRUE;
+ /* bchar */
+ case ':':
+ case '@':
+ case '/':
+ /* bchar -> achar */
+ case '&':
+ case '=':
+ /* bchar -> achar -> uchar -> unreserved (without alphanumeric) */
+ case '-':
+ case '.':
+ case '_':
+ case '~':
+ /* bchar -> achar -> uchar -> sub-delims-sh */
+ case '!':
+ case '$':
+ case '\'':
+ case '(':
+ case ')':
+ case '*':
+ case '+':
+ case ',':
+ /* bchar -> achar -> uchar -> pct-encoded */
+ case '%': /* HEXDIG chars are already included above */
+ return TRUE;
- default:
- return FALSE;
+ default:
+ return FALSE;
}
}
#include "pingpong.h"
#include "curl_sasl.h"
-
extern const struct Curl_handler Curl_handler_imap;
extern const struct Curl_handler Curl_handler_imaps;
/* Authentication type values */
#define IMAP_TYPE_NONE 0
-#define IMAP_TYPE_ANY (IMAP_TYPE_CLEARTEXT|IMAP_TYPE_SASL)
+#define IMAP_TYPE_ANY (IMAP_TYPE_CLEARTEXT | IMAP_TYPE_SASL)
#endif /* HEADER_CURL_IMAP_H */
#ifdef USE_WIN32_LDAP
#define FREE_ON_WINLDAP(x) curlx_unicodefree(x)
-#define curl_ldap_num_t ULONG
+#define curl_ldap_num_t ULONG
#else
#define FREE_ON_WINLDAP(x)
#define curl_ldap_num_t int
#endif /* !HAVE_LDAP_URL_PARSE */
#ifdef DEBUG_LDAP
- #define LDAP_TRACE(x) do { \
- ldap_trace_low("%u: ", __LINE__); \
- ldap_trace_low x; \
- } while(0)
+#define LDAP_TRACE(x) \
+do { \
+ ldap_trace_low("%u: ", __LINE__); \
+ ldap_trace_low x; \
+} while(0)
- static void ldap_trace_low(const char *fmt, ...) CURL_PRINTF(1, 2);
+static void ldap_trace_low(const char *fmt, ...) CURL_PRINTF(1, 2);
#else
- #define LDAP_TRACE(x) Curl_nop_stmt
+#define LDAP_TRACE(x) Curl_nop_stmt
#endif
#if defined(USE_WIN32_LDAP) && defined(ldap_err2string)
/*
* LDAP protocol handler.
*/
-
const struct Curl_handler Curl_handler_ldap = {
"ldap", /* scheme */
ZERO_NULL, /* setup_connection */
/*
* LDAPS protocol handler.
*/
-
const struct Curl_handler Curl_handler_ldaps = {
"ldaps", /* scheme */
ZERO_NULL, /* setup_connection */
}
if((attr_len > 7) &&
- curl_strequal(";binary", attr + (attr_len - 7)) ) {
+ curl_strequal(";binary", attr + (attr_len - 7))) {
/* Binary attribute, encode to base64. */
if(vals[i]->bv_len) {
result = curlx_base64_encode((uint8_t *)vals[i]->bv_val,
LDAP_TRACE(("attr[%zu] '%.*s'\n", i, (int)out.len, out.str));
/* Unescape the attribute */
- result = Curl_urldecode(out.str, out.len, &unescaped, NULL,
- REJECT_ZERO);
+ result = Curl_urldecode(out.str, out.len, &unescaped, NULL, REJECT_ZERO);
if(result) {
rc = LDAP_NO_MEMORY;
goto quit;
/*
* @unittest: 1300
*/
-void
-Curl_llist_init(struct Curl_llist *l, Curl_llist_dtor dtor)
+void Curl_llist_init(struct Curl_llist *l, Curl_llist_dtor dtor)
{
l->_size = 0;
l->_dtor = dtor;
*
* @unittest: 1300
*/
-void
-Curl_llist_insert_next(struct Curl_llist *list,
- struct Curl_llist_node *e, /* may be NULL */
- const void *p,
- struct Curl_llist_node *ne)
+void Curl_llist_insert_next(struct Curl_llist *list,
+ struct Curl_llist_node *e, /* may be NULL */
+ const void *p,
+ struct Curl_llist_node *ne)
{
DEBUGASSERT(list);
DEBUGASSERT(list->_init == LLISTINIT);
*
* @unittest: 1300
*/
-void
-Curl_llist_append(struct Curl_llist *list, const void *p,
- struct Curl_llist_node *ne)
+void Curl_llist_append(struct Curl_llist *list, const void *p,
+ struct Curl_llist_node *ne)
{
DEBUGASSERT(list);
DEBUGASSERT(list->_init == LLISTINIT);
/*
* @unittest: 1300
*/
-UNITTEST void Curl_node_uremove(struct Curl_llist_node *, void *);
-UNITTEST void
-Curl_node_uremove(struct Curl_llist_node *e, void *user)
+UNITTEST void Curl_node_uremove(struct Curl_llist_node *e, void *user);
+UNITTEST void Curl_node_uremove(struct Curl_llist_node *e, void *user)
{
struct Curl_llist *list;
void *ptr;
Curl_node_uremove(e, NULL);
}
-void
-Curl_llist_destroy(struct Curl_llist *list, void *user)
+void Curl_llist_destroy(struct Curl_llist *list, void *user)
{
if(list) {
DEBUGASSERT(list->_init == LLISTINIT);
void Curl_llist_init(struct Curl_llist *, Curl_llist_dtor);
void Curl_llist_insert_next(struct Curl_llist *, struct Curl_llist_node *,
const void *, struct Curl_llist_node *node);
-void Curl_llist_append(struct Curl_llist *,
- const void *, struct Curl_llist_node *node);
+void Curl_llist_append(struct Curl_llist *, const void *,
+ struct Curl_llist_node *node);
void Curl_node_remove(struct Curl_llist_node *);
void Curl_llist_destroy(struct Curl_llist *, void *);
#include <nettle/md4.h>
#endif
-
#if defined(USE_WOLFSSL) && !defined(WOLFSSL_NO_MD4)
#ifdef OPENSSL_COEXIST
- #define MD4_CTX WOLFSSL_MD4_CTX
- #define MD4_Init wolfSSL_MD4_Init
+ #define MD4_CTX WOLFSSL_MD4_CTX
+ #define MD4_Init wolfSSL_MD4_Init
#define MD4_Update wolfSSL_MD4_Update
- #define MD4_Final wolfSSL_MD4_Final
+ #define MD4_Final wolfSSL_MD4_Final
#endif
#elif defined(USE_OPENSSL) && !defined(OPENSSL_NO_MD4)
static void MD4_Update(MD4_CTX *ctx, const void *data, unsigned long size)
{
- CryptHashData(ctx->hHash, (const BYTE *)data, (unsigned int) size, 0);
+ CryptHashData(ctx->hHash, (const BYTE *)data, (unsigned int)size, 0);
}
static void MD4_Final(unsigned char *result, MD4_CTX *ctx)
* The MD4 transformation for all three rounds.
*/
#define MD4_STEP(f, a, b, c, d, x, s) \
- (a) += f((b), (c), (d)) + (x); \
- (a) = (((a) << (s)) | (((a) & 0xffffffff) >> (32 - (s))));
+ (a) += f((b), (c), (d)) + (x); \
+ (a) = (((a) << (s)) | (((a) & 0xffffffff) >> (32 - (s))));
/*
* SET reads 4 input bytes in little-endian byte order and stores them
* does not work.
*/
#if defined(__i386__) || defined(__x86_64__) || defined(__vax__)
-#define MD4_SET(n) \
- (*(const MD4_u32plus *)(const void *)&ptr[(n) * 4])
-#define MD4_GET(n) \
- MD4_SET(n)
+#define MD4_SET(n) (*(const MD4_u32plus *)(const void *)&ptr[(n) * 4])
+#define MD4_GET(n) MD4_SET(n)
#else
-#define MD4_SET(n) \
- (ctx->block[(n)] = \
- (MD4_u32plus)ptr[(n) * 4] | \
- ((MD4_u32plus)ptr[(n) * 4 + 1] << 8) | \
- ((MD4_u32plus)ptr[(n) * 4 + 2] << 16) | \
- ((MD4_u32plus)ptr[(n) * 4 + 3] << 24))
-#define MD4_GET(n) \
- (ctx->block[(n)])
+#define MD4_SET(n) (ctx->block[(n)] = \
+ (MD4_u32plus)ptr[(n) * 4] | \
+ ((MD4_u32plus)ptr[(n) * 4 + 1] << 8) | \
+ ((MD4_u32plus)ptr[(n) * 4 + 2] << 16) | \
+ ((MD4_u32plus)ptr[(n) * 4 + 3] << 24))
+#define MD4_GET(n) (ctx->block[(n)])
#endif
/*
memset(&ctx->buffer[used], 0, available - 8);
ctx->lo <<= 3;
- ctx->buffer[56] = curlx_ultouc((ctx->lo)&0xff);
- ctx->buffer[57] = curlx_ultouc((ctx->lo >> 8)&0xff);
- ctx->buffer[58] = curlx_ultouc((ctx->lo >> 16)&0xff);
- ctx->buffer[59] = curlx_ultouc((ctx->lo >> 24)&0xff);
- ctx->buffer[60] = curlx_ultouc((ctx->hi)&0xff);
- ctx->buffer[61] = curlx_ultouc((ctx->hi >> 8)&0xff);
- ctx->buffer[62] = curlx_ultouc((ctx->hi >> 16)&0xff);
+ ctx->buffer[56] = curlx_ultouc((ctx->lo) & 0xff);
+ ctx->buffer[57] = curlx_ultouc((ctx->lo >> 8) & 0xff);
+ ctx->buffer[58] = curlx_ultouc((ctx->lo >> 16) & 0xff);
+ ctx->buffer[59] = curlx_ultouc((ctx->lo >> 24) & 0xff);
+ ctx->buffer[60] = curlx_ultouc((ctx->hi) & 0xff);
+ ctx->buffer[61] = curlx_ultouc((ctx->hi >> 8) & 0xff);
+ ctx->buffer[62] = curlx_ultouc((ctx->hi >> 16) & 0xff);
ctx->buffer[63] = curlx_ultouc(ctx->hi >> 24);
my_md4_body(ctx, ctx->buffer, 64);
- result[0] = curlx_ultouc((ctx->a)&0xff);
- result[1] = curlx_ultouc((ctx->a >> 8)&0xff);
- result[2] = curlx_ultouc((ctx->a >> 16)&0xff);
+ result[0] = curlx_ultouc((ctx->a) & 0xff);
+ result[1] = curlx_ultouc((ctx->a >> 8) & 0xff);
+ result[2] = curlx_ultouc((ctx->a >> 16) & 0xff);
result[3] = curlx_ultouc(ctx->a >> 24);
- result[4] = curlx_ultouc((ctx->b)&0xff);
- result[5] = curlx_ultouc((ctx->b >> 8)&0xff);
- result[6] = curlx_ultouc((ctx->b >> 16)&0xff);
+ result[4] = curlx_ultouc((ctx->b) & 0xff);
+ result[5] = curlx_ultouc((ctx->b >> 8) & 0xff);
+ result[6] = curlx_ultouc((ctx->b >> 16) & 0xff);
result[7] = curlx_ultouc(ctx->b >> 24);
- result[8] = curlx_ultouc((ctx->c)&0xff);
- result[9] = curlx_ultouc((ctx->c >> 8)&0xff);
- result[10] = curlx_ultouc((ctx->c >> 16)&0xff);
+ result[8] = curlx_ultouc((ctx->c) & 0xff);
+ result[9] = curlx_ultouc((ctx->c >> 8) & 0xff);
+ result[10] = curlx_ultouc((ctx->c >> 16) & 0xff);
result[11] = curlx_ultouc(ctx->c >> 24);
- result[12] = curlx_ultouc((ctx->d)&0xff);
- result[13] = curlx_ultouc((ctx->d >> 8)&0xff);
- result[14] = curlx_ultouc((ctx->d >> 16)&0xff);
+ result[12] = curlx_ultouc((ctx->d) & 0xff);
+ result[13] = curlx_ultouc((ctx->d >> 8) & 0xff);
+ result[14] = curlx_ultouc((ctx->d >> 16) & 0xff);
result[15] = curlx_ultouc(ctx->d >> 24);
memset(ctx, 0, sizeof(*ctx));
* The MD5 transformation for all four rounds.
*/
#define MD5_STEP(f, a, b, c, d, x, t, s) \
- (a) += f((b), (c), (d)) + (x) + (t); \
- (a) = (((a) << (s)) | (((a) & 0xffffffff) >> (32 - (s)))); \
- (a) += (b);
+ (a) += f((b), (c), (d)) + (x) + (t); \
+ (a) = (((a) << (s)) | (((a) & 0xffffffff) >> (32 - (s)))); \
+ (a) += (b);
/*
* SET reads 4 input bytes in little-endian byte order and stores them
* does not work.
*/
#if defined(__i386__) || defined(__x86_64__) || defined(__vax__)
-#define MD5_SET(n) \
- (*(const MD5_u32plus *)(const void *)&ptr[(n) * 4])
-#define MD5_GET(n) \
- MD5_SET(n)
+#define MD5_SET(n) (*(const MD5_u32plus *)(const void *)&ptr[(n) * 4])
+#define MD5_GET(n) MD5_SET(n)
#else
-#define MD5_SET(n) \
- (ctx->block[(n)] = \
- (MD5_u32plus)ptr[(n) * 4] | \
- ((MD5_u32plus)ptr[(n) * 4 + 1] << 8) | \
- ((MD5_u32plus)ptr[(n) * 4 + 2] << 16) | \
- ((MD5_u32plus)ptr[(n) * 4 + 3] << 24))
-#define MD5_GET(n) \
- (ctx->block[(n)])
+#define MD5_SET(n) (ctx->block[(n)] = \
+ (MD5_u32plus)ptr[(n) * 4] | \
+ ((MD5_u32plus)ptr[(n) * 4 + 1] << 8) | \
+ ((MD5_u32plus)ptr[(n) * 4 + 2] << 16) | \
+ ((MD5_u32plus)ptr[(n) * 4 + 3] << 24))
+#define MD5_GET(n) (ctx->block[(n)])
#endif
/*
memset(&ctx->buffer[used], 0, available - 8);
ctx->lo <<= 3;
- ctx->buffer[56] = curlx_ultouc((ctx->lo)&0xff);
- ctx->buffer[57] = curlx_ultouc((ctx->lo >> 8)&0xff);
- ctx->buffer[58] = curlx_ultouc((ctx->lo >> 16)&0xff);
+ ctx->buffer[56] = curlx_ultouc((ctx->lo) & 0xff);
+ ctx->buffer[57] = curlx_ultouc((ctx->lo >> 8) & 0xff);
+ ctx->buffer[58] = curlx_ultouc((ctx->lo >> 16) & 0xff);
ctx->buffer[59] = curlx_ultouc(ctx->lo >> 24);
- ctx->buffer[60] = curlx_ultouc((ctx->hi)&0xff);
- ctx->buffer[61] = curlx_ultouc((ctx->hi >> 8)&0xff);
- ctx->buffer[62] = curlx_ultouc((ctx->hi >> 16)&0xff);
+ ctx->buffer[60] = curlx_ultouc((ctx->hi) & 0xff);
+ ctx->buffer[61] = curlx_ultouc((ctx->hi >> 8) & 0xff);
+ ctx->buffer[62] = curlx_ultouc((ctx->hi >> 16) & 0xff);
ctx->buffer[63] = curlx_ultouc(ctx->hi >> 24);
my_md5_body(ctx, ctx->buffer, 64);
- result[0] = curlx_ultouc((ctx->a)&0xff);
- result[1] = curlx_ultouc((ctx->a >> 8)&0xff);
- result[2] = curlx_ultouc((ctx->a >> 16)&0xff);
+ result[0] = curlx_ultouc((ctx->a) & 0xff);
+ result[1] = curlx_ultouc((ctx->a >> 8) & 0xff);
+ result[2] = curlx_ultouc((ctx->a >> 16) & 0xff);
result[3] = curlx_ultouc(ctx->a >> 24);
- result[4] = curlx_ultouc((ctx->b)&0xff);
- result[5] = curlx_ultouc((ctx->b >> 8)&0xff);
- result[6] = curlx_ultouc((ctx->b >> 16)&0xff);
+ result[4] = curlx_ultouc((ctx->b) & 0xff);
+ result[5] = curlx_ultouc((ctx->b >> 8) & 0xff);
+ result[6] = curlx_ultouc((ctx->b >> 16) & 0xff);
result[7] = curlx_ultouc(ctx->b >> 24);
- result[8] = curlx_ultouc((ctx->c)&0xff);
- result[9] = curlx_ultouc((ctx->c >> 8)&0xff);
- result[10] = curlx_ultouc((ctx->c >> 16)&0xff);
+ result[8] = curlx_ultouc((ctx->c) & 0xff);
+ result[9] = curlx_ultouc((ctx->c >> 8) & 0xff);
+ result[10] = curlx_ultouc((ctx->c >> 16) & 0xff);
result[11] = curlx_ultouc(ctx->c >> 24);
- result[12] = curlx_ultouc((ctx->d)&0xff);
- result[13] = curlx_ultouc((ctx->d >> 8)&0xff);
- result[14] = curlx_ultouc((ctx->d >> 16)&0xff);
+ result[12] = curlx_ultouc((ctx->d) & 0xff);
+ result[13] = curlx_ultouc((ctx->d >> 8) & 0xff);
+ result[14] = curlx_ultouc((ctx->d >> 16) & 0xff);
result[15] = curlx_ultouc(ctx->d >> 24);
memset(ctx, 0, sizeof(*ctx));
if(memlimit && source) {
if(!memsize) {
/* log to file */
- curl_dbg_log("LIMIT %s:%d %s reached memlimit\n",
- source, line, func);
+ curl_dbg_log("LIMIT %s:%d %s reached memlimit\n", source, line, func);
/* log to stderr also */
curl_mfprintf(stderr, "LIMIT %s:%d %s reached memlimit\n",
source, line, func);
if(ptr) {
struct memdebug *mem;
- if(source)
- curl_dbg_log("MEM %s:%d free(%p)\n", source, line, (void *)ptr);
+ if(source)
+ curl_dbg_log("MEM %s:%d free(%p)\n", source, line, (void *)ptr);
#ifdef __INTEL_COMPILER
# pragma warning(push)
rc = send(sockfd, buf, len, flags);
if(source)
curl_dbg_log("SEND %s:%d send(%lu) = %ld\n",
- source, line, (unsigned long)len, (long)rc);
+ source, line, (unsigned long)len, (long)rc);
return rc;
}
rc = recv(sockfd, buf, len, flags);
if(source)
curl_dbg_log("RECV %s:%d recv(%lu) = %ld\n",
- source, line, (unsigned long)len, (long)rc);
+ source, line, (unsigned long)len, (long)rc);
return rc;
}
DEBUGASSERT(file != NULL);
if(source)
- curl_dbg_log("FILE %s:%d fclose(%p)\n",
- source, line, (void *)file);
+ curl_dbg_log("FILE %s:%d fclose(%p)\n", source, line, (void *)file);
/* !checksrc! disable BANNEDFUNC 1 */
res = fclose(file);
# endif
#endif
-#define READ_ERROR ((size_t) -1)
-#define STOP_FILLING ((size_t) -2)
+#define READ_ERROR ((size_t)-1)
+#define STOP_FILLING ((size_t)-2)
static size_t mime_subparts_read(char *buffer, size_t size, size_t nitems,
void *instream, bool *hasread);
static curl_off_t mime_size(curl_mimepart *part);
static const struct mime_encoder encoders[] = {
- {"binary", encoder_nop_read, encoder_nop_size},
- {"8bit", encoder_nop_read, encoder_nop_size},
- {"7bit", encoder_7bit_read, encoder_nop_size},
- {"base64", encoder_base64_read, encoder_base64_size},
- {"quoted-printable", encoder_qp_read, encoder_qp_size},
- {ZERO_NULL, ZERO_NULL, ZERO_NULL}
+ { "binary", encoder_nop_read, encoder_nop_size },
+ { "8bit", encoder_nop_read, encoder_nop_size },
+ { "7bit", encoder_7bit_read, encoder_nop_size },
+ { "base64", encoder_base64_read, encoder_base64_size },
+ { "quoted-printable", encoder_qp_read, encoder_qp_size },
+ { ZERO_NULL, ZERO_NULL, ZERO_NULL }
};
/* Quoted-printable character class table.
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 /* F0 - FF */
};
-
/* Binary --> hexadecimal ASCII table. */
static const char aschex[] =
"\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x41\x42\x43\x44\x45\x46";
-
#ifndef __VMS
#define filesize(name, stat_data) (stat_data.st_size)
-#define fopen_read curlx_fopen
+#define fopen_read curlx_fopen
#else
* and CD/DVD images should be either a STREAM_LF format or a fixed format.
*
*/
-curl_off_t VmsRealFileSize(const char *name,
- const struct_stat *stat_buf)
+curl_off_t VmsRealFileSize(const char *name, const struct_stat *stat_buf)
{
char buffer[8192];
curl_off_t count;
int ret_stat;
- FILE * file;
+ FILE *file;
file = curlx_fopen(name, FOPEN_READTEXT); /* VMS */
if(!file)
* if not to call a routine to get the correct size.
*
*/
-static curl_off_t VmsSpecialSize(const char *name,
- const struct_stat *stat_buf)
+static curl_off_t VmsSpecialSize(const char *name, const struct_stat *stat_buf)
{
switch(stat_buf->st_fab_rfm) {
case FAB$C_VAR:
* record format of the file.
*
*/
-static FILE * vmsfopenread(const char *file, const char *mode)
+static FILE *vmsfopenread(const char *file, const char *mode)
{
struct_stat statbuf;
int result;
#define fopen_read vmsfopenread
#endif
-
#ifndef HAVE_BASENAME
/*
(Quote from The Open Group Base Specifications Issue 6 IEEE Std 1003.1, 2004
return path;
}
-#define basename(x) Curl_basename((x))
+#define basename(x) Curl_basename(x)
#endif
p->bufend = 0;
}
-
/* Dummy encoder. This is used for 8bit and binary content encodings. */
static size_t encoder_nop_read(char *buffer, size_t size, bool ateof,
struct curl_mimepart *part)
return part->datasize;
}
-
/* 7bit encoder: the encoder is just a data validity check. */
static size_t encoder_7bit_read(char *buffer, size_t size, bool ateof,
curl_mimepart *part)
return cursize;
}
-
/* Base64 content encoder. */
static size_t encoder_base64_read(char *buffer, size_t size, bool ateof,
curl_mimepart *part)
return size + 2 * ((size - 1) / MAX_ENCODED_LINE_LENGTH);
}
-
/* Quoted-printable lookahead.
*
* Check if a CRLF or end of data is in input buffer at current position + n.
size_t len = 1;
size_t consumed = 1;
int i = st->buf[st->bufbeg];
- buf[0] = (char) i;
+ buf[0] = (char)i;
buf[1] = aschex[(i >> 4) & 0xF];
buf[2] = aschex[i & 0xF];
return part->datasize ? -1 : 0;
}
-
/* In-memory data callbacks. */
/* Argument is a pointer to the mime part. */
static size_t mime_mem_read(char *buffer, size_t size, size_t nitems,
void *instream)
{
- curl_mimepart *part = (curl_mimepart *) instream;
+ curl_mimepart *part = (curl_mimepart *)instream;
size_t sz = curlx_sotouz(part->datasize - part->state.offset);
(void)size; /* Always 1 */
static int mime_mem_seek(void *instream, curl_off_t offset, int whence)
{
- curl_mimepart *part = (curl_mimepart *) instream;
+ curl_mimepart *part = (curl_mimepart *)instream;
switch(whence) {
case SEEK_CUR:
static void mime_mem_free(void *ptr)
{
- Curl_safefree(((curl_mimepart *) ptr)->data);
+ Curl_safefree(((curl_mimepart *)ptr)->data);
}
-
/* Named file callbacks. */
/* Argument is a pointer to the mime part. */
static bool mime_open_file(curl_mimepart *part)
static size_t mime_file_read(char *buffer, size_t size, size_t nitems,
void *instream)
{
- curl_mimepart *part = (curl_mimepart *) instream;
+ curl_mimepart *part = (curl_mimepart *)instream;
if(!nitems)
return STOP_FILLING;
static int mime_file_seek(void *instream, curl_off_t offset, int whence)
{
- curl_mimepart *part = (curl_mimepart *) instream;
+ curl_mimepart *part = (curl_mimepart *)instream;
if(whence == SEEK_SET && !offset && !part->fp)
return CURL_SEEKFUNC_OK; /* Not open: implicitly already at BOF. */
static void mime_file_free(void *ptr)
{
- curl_mimepart *part = (curl_mimepart *) ptr;
+ curl_mimepart *part = (curl_mimepart *)ptr;
if(part->fp) {
curlx_fclose(part->fp);
Curl_safefree(part->data);
}
-
/* Subparts callbacks. */
/* Argument is a pointer to the mime structure. */
}
/* If we can determine we are at end of part data, spare a read. */
- if(part->datasize != (curl_off_t) -1 &&
+ if(part->datasize != (curl_off_t)-1 &&
part->state.offset >= part->datasize) {
/* sz is already zero. */
}
* Cannot be processed as other kinds since read function requires
* an additional parameter and is highly recursive.
*/
- sz = mime_subparts_read(buffer, 1, bufsize, part->arg, hasread);
- break;
+ sz = mime_subparts_read(buffer, 1, bufsize, part->arg, hasread);
+ break;
case MIMEKIND_FILE:
if(part->fp && feof(part->fp))
break; /* At EOF. */
while(bufsize) {
size_t sz = 0;
- struct curl_slist *hdr = (struct curl_slist *) part->state.ptr;
+ struct curl_slist *hdr = (struct curl_slist *)part->state.ptr;
switch(part->state.state) {
case MIMESTATE_BEGIN:
mimesetstate(&part->state,
static size_t mime_subparts_read(char *buffer, size_t size, size_t nitems,
void *instream, bool *hasread)
{
- curl_mime *mime = (curl_mime *) instream;
+ curl_mime *mime = (curl_mime *)instream;
size_t cursize = 0;
(void)size; /* Always 1 */
if(part->state.state > targetstate) {
res = CURL_SEEKFUNC_CANTSEEK;
if(part->seekfunc) {
- res = part->seekfunc(part->arg, (curl_off_t) 0, SEEK_SET);
+ res = part->seekfunc(part->arg, (curl_off_t)0, SEEK_SET);
switch(res) {
case CURL_SEEKFUNC_OK:
case CURL_SEEKFUNC_FAIL:
static int mime_subparts_seek(void *instream, curl_off_t offset, int whence)
{
- curl_mime *mime = (curl_mime *) instream;
+ curl_mime *mime = (curl_mime *)instream;
curl_mimepart *part;
int result = CURL_SEEKFUNC_OK;
part->readfunc = NULL;
part->seekfunc = NULL;
part->freefunc = NULL;
- part->arg = (void *) part; /* Defaults to part itself. */
+ part->arg = (void *)part; /* Defaults to part itself. */
part->data = NULL;
part->fp = NULL;
- part->datasize = (curl_off_t) 0; /* No size yet. */
+ part->datasize = (curl_off_t)0; /* No size yet. */
cleanup_encoder_state(&part->encstate);
part->kind = MIMEKIND_NONE;
part->flags &= ~(unsigned int)MIME_FAST_READ;
static void mime_subparts_free(void *ptr)
{
- curl_mime *mime = (curl_mime *) ptr;
+ curl_mime *mime = (curl_mime *)ptr;
if(mime && mime->parent) {
mime->parent->freefunc = NULL; /* Be sure we will not be called again. */
/* Do not free subparts: unbind them. This is used for the top level only. */
static void mime_subparts_unbind(void *ptr)
{
- curl_mime *mime = (curl_mime *) ptr;
+ curl_mime *mime = (curl_mime *)ptr;
if(mime && mime->parent) {
mime->parent->freefunc = NULL; /* Be sure we will not be called again. */
}
}
-
void Curl_mime_cleanpart(curl_mimepart *part)
{
if(part) {
case MIMEKIND_NONE:
break;
case MIMEKIND_DATA:
- res = curl_mime_data(dst, src->data, (size_t) src->datasize);
+ res = curl_mime_data(dst, src->data, (size_t)src->datasize);
break;
case MIMEKIND_FILE:
res = curl_mime_filedata(dst, src->data);
res = mime ? curl_mime_subparts(dst, mime) : CURLE_OUT_OF_MEMORY;
/* Duplicate subparts. */
- for(s = ((curl_mime *) src->arg)->firstpart; !res && s; s = s->nextpart) {
+ for(s = ((curl_mime *)src->arg)->firstpart; !res && s; s = s->nextpart) {
d = curl_mime_addpart(mime);
res = d ? Curl_mime_duppart(data, d, s) : CURLE_OUT_OF_MEMORY;
}
memset(mime->boundary, '-', MIME_BOUNDARY_DASHES);
if(Curl_rand_alnum(easy,
- (unsigned char *) &mime->boundary[MIME_BOUNDARY_DASHES],
+ (unsigned char *)&mime->boundary[MIME_BOUNDARY_DASHES],
MIME_RAND_BOUNDARY_CHARS + 1)) {
/* failed to get random separator, bail out */
curlx_free(mime);
/* Initialize a mime part. */
void Curl_mime_initpart(curl_mimepart *part)
{
- memset((char *) part, 0, sizeof(*part));
+ memset((char *)part, 0, sizeof(*part));
part->lastreadstatus = 1; /* Successful read status. */
mimesetstate(&part->state, MIMESTATE_BEGIN, NULL);
}
}
/* Set mime part content from memory data. */
-CURLcode curl_mime_data(curl_mimepart *part,
- const char *ptr, size_t datasize)
+CURLcode curl_mime_data(curl_mimepart *part, const char *ptr, size_t datasize)
{
if(!part)
return CURLE_BAD_FUNCTION_ARGUMENT;
they might not be positioned at start. Rewind them now, as
a future check while rewinding the parent may cause this
content to be skipped. */
- if(mime_subparts_seek(subparts, (curl_off_t) 0, SEEK_SET) !=
+ if(mime_subparts_seek(subparts, (curl_off_t)0, SEEK_SET) !=
CURL_SEEKFUNC_OK)
return CURLE_SEND_FAIL_REWIND;
return Curl_mime_set_subparts(part, subparts, TRUE);
}
-
/* Readback from top mime. */
/* Argument is the dummy top part. */
size_t Curl_mime_read(char *buffer, size_t size, size_t nitems, void *instream)
{
- curl_mimepart *part = (curl_mimepart *) instream;
+ curl_mimepart *part = (curl_mimepart *)instream;
size_t ret;
bool hasread;
if(size >= 0 && !(part->flags & MIME_BODY_ONLY)) {
/* Compute total part size. */
size += slist_size(part->curlheaders, 2, NULL, 0);
- size += slist_size(part->userheaders, 2,
- STRCONST("Content-Type"));
+ size += slist_size(part->userheaders, 2, STRCONST("Content-Type"));
size += 2; /* CRLF after headers. */
}
return size;
const char *type;
};
static const struct ContentType ctts[] = {
- {".gif", "image/gif"},
- {".jpg", "image/jpeg"},
- {".jpeg", "image/jpeg"},
- {".png", "image/png"},
- {".svg", "image/svg+xml"},
- {".txt", "text/plain"},
- {".htm", "text/html"},
- {".html", "text/html"},
- {".pdf", "application/pdf"},
- {".xml", "application/xml"}
+ { ".gif", "image/gif" },
+ { ".jpg", "image/jpeg" },
+ { ".jpeg", "image/jpeg" },
+ { ".png", "image/png" },
+ { ".svg", "image/svg+xml" },
+ { ".txt", "text/plain" },
+ { ".htm", "text/html" },
+ { ".html", "text/html" },
+ { ".pdf", "application/pdf" },
+ { ".xml", "application/xml" }
};
if(filename) {
}
if(part->kind == MIMEKIND_MULTIPART) {
- mime = (curl_mime *) part->arg;
+ mime = (curl_mime *)part->arg;
if(mime)
boundary = mime->boundary;
}
if(!search_header(part->userheaders, STRCONST("Content-Disposition"))) {
if(!disposition)
if(part->filename || part->name ||
- (contenttype && !curl_strnequal(contenttype, "multipart/", 10)))
- disposition = DISPOSITION_DEFAULT;
+ (contenttype && !curl_strnequal(contenttype, "multipart/", 10)))
+ disposition = DISPOSITION_DEFAULT;
if(disposition && curl_strequal(disposition, "attachment") &&
- !part->name && !part->filename)
+ !part->name && !part->filename)
disposition = NULL;
if(disposition) {
char *name = NULL;
Curl_safefree(filename);
if(ret)
return ret;
- }
}
+ }
/* Issue Content-Type header. */
if(contenttype) {
if(part->encoder)
cte = part->encoder->name;
else if(contenttype && strategy == MIMESTRATEGY_MAIL &&
- part->kind != MIMEKIND_MULTIPART)
+ part->kind != MIMEKIND_MULTIPART)
cte = "8bit";
if(cte) {
ret = Curl_mime_add_header(&part->curlheaders,
if(part->lastreadstatus == CURL_READFUNC_PAUSE)
part->lastreadstatus = 1; /* Successful read status. */
if(part->kind == MIMEKIND_MULTIPART) {
- curl_mime *mime = (curl_mime *) part->arg;
+ curl_mime *mime = (curl_mime *)part->arg;
if(mime) {
curl_mimepart *subpart;
curl_off_t passed = 0;
do {
- char scratch[4*1024];
+ char scratch[4 * 1024];
size_t readthisamountnow =
(offset - passed > (curl_off_t)sizeof(scratch)) ?
sizeof(scratch) :
return CURLE_NOT_BUILT_IN;
}
-CURLcode curl_mime_data(curl_mimepart *part,
- const char *data, size_t datasize)
+CURLcode curl_mime_data(curl_mimepart *part, const char *data, size_t datasize)
{
(void)part;
(void)data;
return CURLE_NOT_BUILT_IN;
}
-CURLcode curl_mime_data_cb(curl_mimepart *part,
- curl_off_t datasize,
+CURLcode curl_mime_data_cb(curl_mimepart *part, curl_off_t datasize,
curl_read_callback readfunc,
curl_seek_callback seekfunc,
curl_free_callback freefunc,
/* if disabled */
#define Curl_mime_initpart(x)
#define Curl_mime_cleanpart(x)
-#define Curl_mime_duppart(x,y,z) CURLE_OK /* Nothing to duplicate. Succeed */
-#define Curl_mime_set_subparts(a,b,c) CURLE_NOT_BUILT_IN
-#define Curl_mime_prepare_headers(a,b,c,d,e) CURLE_NOT_BUILT_IN
-#define Curl_mime_read NULL
-#define Curl_creader_set_mime(x,y) ((void)x, CURLE_NOT_BUILT_IN)
+#define Curl_mime_duppart(x, y, z) CURLE_OK /* Nothing to duplicate. Succeed */
+#define Curl_mime_set_subparts(a, b, c) CURLE_NOT_BUILT_IN
+#define Curl_mime_prepare_headers(a, b, c, d, e) CURLE_NOT_BUILT_IN
+#define Curl_mime_read NULL
+#define Curl_creader_set_mime(x, y) ((void)x, CURLE_NOT_BUILT_IN)
#endif
-
#endif /* HEADER_CURL_MIME_H */
return (int)num - 1;
}
-#define is_arg_used(x,y) ((x)[(y)/8] & (1 << ((y)&7)))
-#define mark_arg_used(x,y) ((x)[y/8] |= (unsigned char)(1 << ((y)&7)))
+#define is_arg_used(x, y) ((x)[(y) / 8] & (1 << ((y) & 7)))
+#define mark_arg_used(x, y) ((x)[y / 8] |= (unsigned char)(1 << ((y) & 7)))
/*
* Parse the format string.
int max_param = -1;
int i;
int ocount = 0;
- unsigned char usedinput[MAX_PARAMETERS/8];
+ unsigned char usedinput[MAX_PARAMETERS / 8];
size_t outlen = 0;
struct outsegment *optr;
int use_dollar = DOLLAR_UNKNOWN;
if(!(flags & FLAGS_LEFT))
flags |= FLAGS_PAD_NIL;
FALLTHROUGH();
- case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9': {
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': {
curl_off_t num;
flags |= FLAGS_WIDTH;
fmt--;
type = FORMAT_LONGU;
else
type = FORMAT_INTU;
- flags |= FLAGS_OCTAL|FLAGS_UNSIGNED;
+ flags |= FLAGS_OCTAL | FLAGS_UNSIGNED;
break;
case 'x':
if(flags & FLAGS_LONGLONG)
type = FORMAT_LONGU;
else
type = FORMAT_INTU;
- flags |= FLAGS_HEX|FLAGS_UNSIGNED;
+ flags |= FLAGS_HEX | FLAGS_UNSIGNED;
break;
case 'X':
if(flags & FLAGS_LONGLONG)
type = FORMAT_LONGU;
else
type = FORMAT_INTU;
- flags |= FLAGS_HEX|FLAGS_UPPER|FLAGS_UNSIGNED;
+ flags |= FLAGS_HEX | FLAGS_UPPER | FLAGS_UNSIGNED;
break;
case 'c':
type = FORMAT_INT;
break;
case 'E':
type = FORMAT_DOUBLE;
- flags |= FLAGS_FLOATE|FLAGS_UPPER;
+ flags |= FLAGS_FLOATE | FLAGS_UPPER;
break;
case 'g':
type = FORMAT_DOUBLE;
break;
case 'G':
type = FORMAT_DOUBLE;
- flags |= FLAGS_FLOATG|FLAGS_UPPER;
+ flags |= FLAGS_FLOATG | FLAGS_UPPER;
break;
default:
/* invalid instruction, disregard and continue */
double dnum,
char *work, int *donep)
{
- char formatbuf[32]="%";
+ char formatbuf[32] = "%";
char *fptr = &formatbuf[1];
- size_t left = sizeof(formatbuf)-strlen(formatbuf);
+ size_t left = sizeof(formatbuf) - strlen(formatbuf);
int flags = p->flags;
int width = p->width;
int prec = p->prec;
if(!(flags & FLAGS_LEFT))
while(--width > 0)
OUTCHAR(' ');
- OUTCHAR((char) num);
+ OUTCHAR((char)num);
if(flags & FLAGS_LEFT)
while(--width > 0)
OUTCHAR(' ');
if(!str) {
/* Write null string if there is space. */
- if(prec == -1 || prec >= (int) sizeof(nilstr) - 1) {
+ if(prec == -1 || prec >= (int)sizeof(nilstr) - 1) {
str = nilstr;
len = sizeof(nilstr) - 1;
/* Disable quotes around (nil) */
{
/* Generic pointer. */
if(ptr) {
- size_t num = (size_t) ptr;
+ size_t num = (size_t)ptr;
/* If the pointer is not NULL, write it as a %#x spec. */
- p->flags |= FLAGS_HEX|FLAGS_ALT;
+ p->flags |= FLAGS_HEX | FLAGS_ALT;
if(out_number(userp, stream, p, num, 0, work, donep))
return TRUE;
}
* All output is sent to the 'stream()' callback, one byte at a time.
*/
-static int formatf(
- void *userp, /* untouched by format(), just sent to the stream() function in
- the second argument */
- /* function pointer called for each output character */
- int (*stream)(unsigned char, void *),
- const char *format, /* %-formatted string */
- va_list ap_save) /* list of parameters */
+static int formatf(void *userp, /* untouched by format(), just sent to the
+ stream() function in the second argument */
+ /* function pointer called for each output character */
+ int (*stream)(unsigned char, void *),
+ const char *format, /* %-formatted string */
+ va_list ap_save) /* list of parameters */
{
int done = 0; /* number of characters written */
int i;
/* Answer the count of characters written. */
#ifdef HAVE_LONG_LONG_TYPE
if(p.flags & FLAGS_LONGLONG)
- *(LONG_LONG_TYPE *) iptr->val.ptr = (LONG_LONG_TYPE)done;
+ *(LONG_LONG_TYPE *)iptr->val.ptr = (LONG_LONG_TYPE)done;
else
#endif
if(p.flags & FLAGS_LONG)
- *(long *) iptr->val.ptr = (long)done;
+ *(long *)iptr->val.ptr = (long)done;
else if(!(p.flags & FLAGS_SHORT))
- *(int *) iptr->val.ptr = (int)done;
+ *(int *)iptr->val.ptr = (int)done;
else
- *(short *) iptr->val.ptr = (short)done;
+ *(short *)iptr->val.ptr = (short)done;
break;
default:
CURLcode result = curlx_dyn_addn(infop->b, &outc, 1);
if(result) {
infop->merr = result == CURLE_TOO_LARGE ? MERR_TOO_LARGE : MERR_MEM;
- return 1 ; /* fail */
+ return 1; /* fail */
}
return 0;
}
/* #define MQTT_MSG_PINGREQ 0xC0 */
#define MQTT_MSG_PINGRESP 0xD0
-#define MQTT_CONNACK_LEN 2
-#define MQTT_SUBACK_LEN 3
+#define MQTT_CONNACK_LEN 2
+#define MQTT_SUBACK_LEN 3
#define MQTT_CLIENTID_LEN 12 /* "curl0123abcd" */
/* meta key for storing protocol meta at easy handle */
BIT(pingsent); /* 1 while we wait for ping response */
};
-
/*
* Forward declarations.
*/
int rc = 0;
/* remain length */
int remain_pos = 0;
- char remain[4] = {0};
+ char remain[4] = { 0 };
size_t packetlen = 0;
size_t start_user = 0;
size_t start_pwd = 0;
char *packet = NULL;
/* extracting username from request */
- const char *username = data->state.aptr.user ?
- data->state.aptr.user : "";
+ const char *username = data->state.aptr.user ? data->state.aptr.user : "";
const size_t ulen = strlen(username);
/* extracting password from request */
- const char *passwd = data->state.aptr.passwd ?
- data->state.aptr.passwd : "";
+ const char *passwd = data->state.aptr.passwd ? data->state.aptr.passwd : "";
const size_t plen = strlen(passwd);
const size_t payloadlen = ulen + plen + MQTT_CLIENTID_LEN + 2 +
/* The plus 2s below are for the MSB and LSB describing the length of the
packet[1 + n] = (mqtt->packetid >> 8) & 0xff;
packet[2 + n] = mqtt->packetid & 0xff;
packet[3 + n] = (topiclen >> 8) & 0xff;
- packet[4 + n ] = topiclen & 0xff;
+ packet[4 + n] = topiclen & 0xff;
memcpy(&packet[5 + n], topic, topiclen);
packet[5 + n + topiclen] = 0; /* QoS zero */
}
#ifdef DEBUGBUILD
-static const char *statenames[]={
+static const char *statenames[] = {
"MQTT_FIRST",
"MQTT_REMAINING_LENGTH",
"MQTT_CONNACK",
mqtt->nextstate = nextstate;
}
-
static CURLcode mqtt_read_publish(struct Curl_easy *data, bool *done)
{
CURLcode result = CURLE_OK;
FALLTHROUGH();
case MQTT_PUB_REMAIN: {
/* read rest of packet, but no more. Cap to buffer size */
- char buffer[4*1024];
+ char buffer[4 * 1024];
size_t rest = mq->npacket;
if(rest > sizeof(buffer))
rest = sizeof(buffer);
if(result)
return result;
- infof(data, "mqtt_doing: state [%d]", (int) mqtt->state);
+ infof(data, "mqtt_doing: state [%d]", (int)mqtt->state);
switch(mqtt->state) {
case MQTT_FIRST:
/* Read the initial byte only */
#include "urlapi-int.h"
/* initial multi->xfers table size for a full multi */
-#define CURL_XFER_TABLE_SIZE 512
+#define CURL_XFER_TABLE_SIZE 512
/*
CURL_SOCKET_HASH_TABLE_SIZE should be a prime number. Increasing it from 97
}
#ifndef DEBUGBUILD
-#define multistate(x,y) mstate(x,y)
+#define multistate(x, y) mstate(x, y)
#else
-#define multistate(x,y) mstate(x,y, __LINE__)
+#define multistate(x, y) mstate(x, y, __LINE__)
#endif
-
/* multi->proto_hash destructor. Should never be called as elements
* MUST be added with their own destructor */
static void ph_freeentry(void *p)
if(!multi->warned) {
infof(data, "!!! WARNING !!!");
infof(data, "This is a debug build of libcurl, "
- "do not use in production.");
+ "do not use in production.");
multi->warned = TRUE;
}
}
#else
-#define multi_warn_debug(x,y) Curl_nop_stmt
+#define multi_warn_debug(x, y) Curl_nop_stmt
#endif
-
static CURLMcode multi_xfers_add(struct Curl_multi *multi,
struct Curl_easy *data)
{
new_size = max_capacity; /* can not be larger than this */
}
else {
- /* make it a 64 multiple, since our bitsets frow by that and
- * small (easy_multi) grows to at least 64 on first resize. */
+ /* make it a 64 multiple, since our bitsets frow by that and
+ * small (easy_multi) grows to at least 64 on first resize. */
new_size = (((used + min_unused) + 63) / 64) * 64;
}
}
&& !(conn->http_negotiate_state == GSS_AUTHRECV ||
conn->proxy_negotiate_state == GSS_AUTHRECV)
#endif
- )
+ )
return TRUE;
/* Unless this connection is for a "connect-only" transfer, it
if(data->state.lastconnect_id != -1) {
/* Mark any connect-only connection for closure */
Curl_cpool_do_by_id(data, data->state.lastconnect_id,
- close_connect_only, NULL);
+ close_connect_only, NULL);
}
#ifdef USE_LIBPSL
else {
/* Default is to obey the data->req.keepon flags for send/recv */
if(CURL_WANT_RECV(data) && CONN_SOCK_IDX_VALID(conn->recv_idx)) {
- result = Curl_pollset_add_in(
- data, ps, conn->sock[conn->recv_idx]);
+ result = Curl_pollset_add_in(data, ps, conn->sock[conn->recv_idx]);
}
if(!result && Curl_req_want_send(data) &&
CONN_SOCK_IDX_VALID(conn->send_idx)) {
- result = Curl_pollset_add_out(
- data, ps, conn->sock[conn->send_idx]);
+ result = Curl_pollset_add_out(data, ps, conn->sock[conn->send_idx]);
}
}
if(!result)
if(CURL_TRC_M_is_verbose(data)) {
size_t timeout_count = Curl_llist_count(&data->state.timeoutlist);
switch(ps->n) {
- case 0:
- CURL_TRC_M(data, "pollset[], timeouts=%zu, paused %d/%d (r/w)",
- timeout_count,
- Curl_xfer_send_is_paused(data),
- Curl_xfer_recv_is_paused(data));
- break;
- case 1:
- CURL_TRC_M(data, "pollset[fd=%" FMT_SOCKET_T " %s%s], timeouts=%zu",
- ps->sockets[0],
- (ps->actions[0] & CURL_POLL_IN) ? "IN" : "",
- (ps->actions[0] & CURL_POLL_OUT) ? "OUT" : "",
- timeout_count);
- break;
- case 2:
- CURL_TRC_M(data, "pollset[fd=%" FMT_SOCKET_T " %s%s, "
- "fd=%" FMT_SOCKET_T " %s%s], timeouts=%zu",
- ps->sockets[0],
- (ps->actions[0] & CURL_POLL_IN) ? "IN" : "",
- (ps->actions[0] & CURL_POLL_OUT) ? "OUT" : "",
- ps->sockets[1],
- (ps->actions[1] & CURL_POLL_IN) ? "IN" : "",
- (ps->actions[1] & CURL_POLL_OUT) ? "OUT" : "",
- timeout_count);
- break;
- default:
- CURL_TRC_M(data, "pollset[fds=%u], timeouts=%zu",
- ps->n, timeout_count);
- break;
+ case 0:
+ CURL_TRC_M(data, "pollset[], timeouts=%zu, paused %d/%d (r/w)",
+ timeout_count,
+ Curl_xfer_send_is_paused(data),
+ Curl_xfer_recv_is_paused(data));
+ break;
+ case 1:
+ CURL_TRC_M(data, "pollset[fd=%" FMT_SOCKET_T " %s%s], timeouts=%zu",
+ ps->sockets[0],
+ (ps->actions[0] & CURL_POLL_IN) ? "IN" : "",
+ (ps->actions[0] & CURL_POLL_OUT) ? "OUT" : "",
+ timeout_count);
+ break;
+ case 2:
+ CURL_TRC_M(data, "pollset[fd=%" FMT_SOCKET_T " %s%s, "
+ "fd=%" FMT_SOCKET_T " %s%s], timeouts=%zu",
+ ps->sockets[0],
+ (ps->actions[0] & CURL_POLL_IN) ? "IN" : "",
+ (ps->actions[0] & CURL_POLL_OUT) ? "OUT" : "",
+ ps->sockets[1],
+ (ps->actions[1] & CURL_POLL_IN) ? "IN" : "",
+ (ps->actions[1] & CURL_POLL_OUT) ? "OUT" : "",
+ timeout_count);
+ break;
+ default:
+ CURL_TRC_M(data, "pollset[fds=%u], timeouts=%zu", ps->n, timeout_count);
+ break;
}
CURL_TRC_EASY_TIMERS(data);
}
if((int)ps.sockets[i] > this_max_fd)
this_max_fd = (int)ps.sockets[i];
}
- }
- while(Curl_uint32_bset_next(&multi->process, mid, &mid));
+ } while(Curl_uint32_bset_next(&multi->process, mid, &mid));
}
Curl_cshutdn_setfds(&multi->cshutdn, multi->admin,
}
Curl_multi_pollset(data, &ps);
need += Curl_waitfds_add_ps(&cwfds, &ps);
- }
- while(Curl_uint32_bset_next(&multi->process, mid, &mid));
+ } while(Curl_uint32_bset_next(&multi->process, mid, &mid));
}
need += Curl_cshutdn_add_waitfds(&multi->cshutdn, multi->admin, &cwfds);
result = CURLM_OUT_OF_MEMORY;
goto out;
}
- }
- while(Curl_uint32_bset_next(&multi->process, mid, &mid));
+ } while(Curl_uint32_bset_next(&multi->process, mid, &mid));
}
if(Curl_cshutdn_add_pollfds(&multi->cshutdn, multi->admin, &cpfds)) {
for(i = 0; i < cpfds.n; i++) {
long mask = 0;
if(cpfds.pfds[i].events & POLLIN)
- mask |= FD_READ|FD_ACCEPT|FD_CLOSE;
+ mask |= FD_READ | FD_ACCEPT | FD_CLOSE;
if(cpfds.pfds[i].events & POLLPRI)
mask |= FD_OOB;
if(cpfds.pfds[i].events & POLLOUT) {
- mask |= FD_WRITE|FD_CONNECT|FD_CLOSE;
+ mask |= FD_WRITE | FD_CONNECT | FD_CLOSE;
reset_socket_fdwrite(cpfds.pfds[i].fd);
}
if(mask) {
curl_socket_t s = extra_fds[i].fd;
wsa_events.lNetworkEvents = 0;
if(WSAEnumNetworkEvents(s, NULL, &wsa_events) == 0) {
- if(wsa_events.lNetworkEvents & (FD_READ|FD_ACCEPT|FD_CLOSE))
+ if(wsa_events.lNetworkEvents & (FD_READ | FD_ACCEPT | FD_CLOSE))
mask |= CURL_WAIT_POLLIN;
- if(wsa_events.lNetworkEvents & (FD_WRITE|FD_CONNECT|FD_CLOSE))
+ if(wsa_events.lNetworkEvents & (FD_WRITE | FD_CONNECT | FD_CLOSE))
mask |= CURL_WAIT_POLLOUT;
if(wsa_events.lNetworkEvents & FD_OOB)
mask |= CURL_WAIT_POLLPRI;
int timeout_ms,
int *ret)
{
- return multi_wait(multi, extra_fds, extra_nfds, timeout_ms, ret, TRUE,
- TRUE);
+ return multi_wait(multi, extra_fds, extra_nfds, timeout_ms, ret, TRUE, TRUE);
}
CURLMcode curl_multi_wakeup(CURLM *m)
* proceed with some action.
*
*/
-static CURLcode protocol_connect(struct Curl_easy *data,
- bool *protocol_done)
+static CURLcode protocol_connect(struct Curl_easy *data, bool *protocol_done)
{
CURLcode result = CURLE_OK;
struct connectdata *conn = data->conn;
*protocol_done = FALSE;
- if(Curl_conn_is_connected(conn, FIRSTSOCKET)
- && conn->bits.protoconnstart) {
+ if(Curl_conn_is_connected(conn, FIRSTSOCKET) && conn->bits.protoconnstart) {
/* We already are connected, get back. This may happen when the connect
worked fine in the first call, like when we connect to a local server
or proxy. Note that we do not know if the protocol is actually done.
return CURLE_TOO_MANY_REDIRECTS;
}
-static CURLcode mspeed_check(struct Curl_easy *data,
- struct curltime now)
+static CURLcode mspeed_check(struct Curl_easy *data, struct curltime now)
{
timediff_t recv_wait_ms = 0;
timediff_t send_wait_ms = 0;
multi_done(data, CURLE_OK, FALSE);
/* if there is no connection left, skip the DONE state */
- multistate(data, data->conn ?
- MSTATE_DONE : MSTATE_COMPLETED);
+ multistate(data, data->conn ? MSTATE_DONE : MSTATE_COMPLETED);
rc = CURLM_CALL_MULTI_PERFORM;
goto end;
}
if(control) {
/* if positive, advance to DO_DONE
if negative, go back to DOING */
- multistate(data, control == 1 ?
- MSTATE_DID : MSTATE_DOING);
+ multistate(data, control == 1 ? MSTATE_DID : MSTATE_DOING);
rc = CURLM_CALL_MULTI_PERFORM;
}
/* else
return rc;
}
-
CURLMcode curl_multi_perform(CURLM *m, int *running_handles)
{
CURLMcode returncode = CURLM_OK;
result = multi_runsingle(multi, &now, data);
if(result)
returncode = result;
- }
- while(Curl_uint32_bset_next(&multi->process, mid, &mid));
+ } while(Curl_uint32_bset_next(&multi->process, mid, &mid));
}
sigpipe_restore(&pipe_st);
#endif
if(data->state.internal)
Curl_close(&data);
- }
- while(Curl_uint32_tbl_next(&multi->xfers, mid, &mid, &entry));
+ } while(Curl_uint32_tbl_next(&multi->xfers, mid, &mid, &entry));
}
Curl_cpool_destroy(&multi->cpool);
return NULL;
}
-
void Curl_multi_will_close(struct Curl_easy *data, curl_socket_t s)
{
if(data) {
CURL_TRC_M(multi->admin, "multi_run_dirty, %u no longer found", mid);
Curl_uint32_bset_remove(&multi->dirty, mid);
}
- }
- while(Curl_uint32_bset_next(&multi->dirty, mid, &mid));
+ } while(Curl_uint32_bset_next(&multi->dirty, mid, &mid));
}
out:
}
#undef curl_multi_setopt
-CURLMcode curl_multi_setopt(CURLM *m,
- CURLMoption option, ...)
+CURLMcode curl_multi_setopt(CURLM *m, CURLMoption option, ...)
{
CURLMcode res = CURLM_OK;
va_list param;
break;
case CURLMOPT_PIPELINING_SERVER_BL:
break;
- case CURLMOPT_MAX_CONCURRENT_STREAMS:
- {
- long streams = va_arg(param, long);
- if((streams < 1) || (streams > INT_MAX))
- streams = 100;
- multi->max_concurrent_streams = (unsigned int)streams;
- }
+ case CURLMOPT_MAX_CONCURRENT_STREAMS: {
+ long streams = va_arg(param, long);
+ if((streams < 1) || (streams > INT_MAX))
+ streams = 100;
+ multi->max_concurrent_streams = (unsigned int)streams;
break;
+ }
case CURLMOPT_NETWORK_CHANGED: {
long val = va_arg(param, long);
if(val & CURLMNWC_CLEAR_DNS) {
return multi_socket(multi, TRUE, CURL_SOCKET_BAD, 0, running_handles);
}
-
static bool multi_has_dirties(struct Curl_multi *multi)
{
uint32_t mid;
CURL_TRC_M(multi->admin, "dirty transfer %u no longer found", mid);
Curl_uint32_bset_remove(&multi->dirty, mid);
}
- }
- while(Curl_uint32_bset_next(&multi->dirty, mid, &mid));
+ } while(Curl_uint32_bset_next(&multi->dirty, mid, &mid));
}
return FALSE;
}
struct curltime *expire_time,
long *timeout_ms)
{
- static const struct curltime tv_zero = {0, 0};
+ static const struct curltime tv_zero = { 0, 0 };
#ifndef CURL_DISABLE_VERBOSE_STRINGS
struct Curl_easy *data = NULL;
#endif
#ifndef CURL_DISABLE_VERBOSE_STRINGS
if(data && CURL_TRC_TIMER_is_verbose(data)) {
- struct Curl_llist_node *e =
- Curl_llist_head(&data->state.timeoutlist);
+ struct Curl_llist_node *e = Curl_llist_head(&data->state.timeoutlist);
if(e) {
struct time_node *n = Curl_node_elem(e);
CURL_TRC_TIMER(data, n->eid, "gives multi timeout in %ldms",
set_value = TRUE;
}
else if(multi->last_timeout_ms < 0) {
- CURL_TRC_M(multi->admin, "[TIMER] set %ldms, none before",
- timeout_ms);
+ CURL_TRC_M(multi->admin, "[TIMER] set %ldms, none before", timeout_ms);
set_value = TRUE;
}
else if(curlx_timediff_us(multi->last_expire_ts, expire_ts)) {
*
* Remove a given timestamp from the list of timeouts.
*/
-static void
-multi_deltimeout(struct Curl_easy *data, expire_id eid)
+static void multi_deltimeout(struct Curl_easy *data, expire_id eid)
{
struct Curl_llist_node *e;
struct Curl_llist *timeoutlist = &data->state.timeoutlist;
* of list is always the timeout nearest in time.
*
*/
-static CURLMcode
-multi_addtimeout(struct Curl_easy *data,
- struct curltime *stamp,
- expire_id eid,
- const struct curltime *nowp)
+static CURLMcode multi_addtimeout(struct Curl_easy *data,
+ struct curltime *stamp,
+ expire_id eid,
+ const struct curltime *nowp)
{
struct Curl_llist_node *e;
struct time_node *node;
break;
prev = e;
}
-
}
/* else
this is the first timeout on the list */
DEBUGASSERT(id < EXPIRE_LAST);
set = *nowp;
- set.tv_sec += (time_t)(milli/1000); /* might be a 64 to 32 bits conversion */
- set.tv_usec += (int)(milli%1000)*1000;
+ set.tv_sec += (time_t)(milli / 1000); /* may be a 64 to 32-bit conversion */
+ set.tv_usec += (int)(milli % 1000) * 1000;
if(set.tv_usec >= 1000000) {
set.tv_sec++;
/* transfer no longer known, should not happen */
Curl_uint32_bset_remove(&multi->pending, mid);
DEBUGASSERT(0);
- }
- while(Curl_uint32_bset_next(&multi->pending, mid, &mid));
+ } while(Curl_uint32_bset_next(&multi->pending, mid, &mid));
}
}
DEBUGASSERT(i < count);
if(!data->state.internal)
a[i++] = data;
- }
- while(Curl_uint32_tbl_next(&multi->xfers, mid, &mid, &entry));
+ } while(Curl_uint32_tbl_next(&multi->xfers, mid, &mid, &entry));
}
a[i] = NULL; /* last entry is a NULL */
}
static size_t mev_sh_entry_hash(void *key, size_t key_length, size_t slots_num)
{
- curl_socket_t fd = *((curl_socket_t *) key);
+ curl_socket_t fd = *((curl_socket_t *)key);
(void)key_length;
return (fd % (curl_socket_t)slots_num);
}
static size_t mev_sh_entry_compare(void *k1, size_t k1_len,
void *k2, size_t k2_len)
{
- (void)k1_len; (void)k2_len;
- return (*((curl_socket_t *) k1)) == (*((curl_socket_t *) k2));
+ (void)k1_len;
+ (void)k2_len;
+ return (*((curl_socket_t *)k1)) == (*((curl_socket_t *)k2));
}
/* sockhash entry destructor callback */
}
/* look up a given socket in the socket hash, skip invalid sockets */
-static struct mev_sh_entry *
-mev_sh_entry_get(struct Curl_hash *sh, curl_socket_t s)
+static struct mev_sh_entry *mev_sh_entry_get(struct Curl_hash *sh,
+ curl_socket_t s)
{
if(s != CURL_SOCKET_BAD) {
/* only look for proper sockets */
}
/* make sure this socket is present in the hash for this handle */
-static struct mev_sh_entry *
-mev_sh_entry_add(struct Curl_hash *sh, curl_socket_t s)
+static struct mev_sh_entry *mev_sh_entry_add(struct Curl_hash *sh,
+ curl_socket_t s)
{
struct mev_sh_entry *there = mev_sh_entry_get(sh, s);
struct mev_sh_entry *check;
return TRUE;
}
-
static bool mev_sh_entry_xfer_remove(struct mev_sh_entry *e,
struct Curl_easy *data)
{
/* We managed this socket before, tell the socket callback to forget it. */
if(entry->announced && multi->socket_cb) {
- CURL_TRC_M(data, "ev %s, call(fd=%" FMT_SOCKET_T ", ev=REMOVE)",
- cause, s);
+ CURL_TRC_M(data, "ev %s, call(fd=%" FMT_SOCKET_T ", ev=REMOVE)", cause, s);
mev_in_callback(multi, TRUE);
rc = multi->socket_cb(data, s, CURL_POLL_REMOVE,
multi->socket_userp, entry->user_data);
}
}
-static struct easy_pollset*
-mev_add_new_conn_pollset(struct connectdata *conn)
+static struct easy_pollset *mev_add_new_conn_pollset(struct connectdata *conn)
{
struct easy_pollset *ps;
return ps;
}
-static struct easy_pollset*
-mev_add_new_xfer_pollset(struct Curl_easy *data)
+static struct easy_pollset *mev_add_new_xfer_pollset(struct Curl_easy *data)
{
struct easy_pollset *ps;
return ps;
}
-static struct easy_pollset *
-mev_get_last_pollset(struct Curl_easy *data,
- struct connectdata *conn)
+static struct easy_pollset *mev_get_last_pollset(struct Curl_easy *data,
+ struct connectdata *conn)
{
if(data) {
if(conn)
return NULL;
}
-static CURLMcode mev_assess(struct Curl_multi *multi,
- struct Curl_easy *data,
+static CURLMcode mev_assess(struct Curl_multi *multi, struct Curl_easy *data,
struct connectdata *conn)
{
struct easy_pollset ps, *last_ps;
struct Curl_easy *data = Curl_multi_get_easy(multi, mid);
if(data)
result = Curl_multi_ev_assess_xfer(multi, data);
- }
- while(!result && Curl_uint32_bset_next(set, mid, &mid));
+ } while(!result && Curl_uint32_bset_next(set, mid, &mid));
}
return result;
}
-
CURLMcode Curl_multi_ev_assign(struct Curl_multi *multi,
curl_socket_t s,
void *user_data)
CURL_TRC_M(multi->admin, "socket transfer %u no longer found", mid);
Curl_uint32_spbset_remove(&entry->xfers, mid);
}
- }
- while(Curl_uint32_spbset_next(&entry->xfers, mid, &mid));
+ } while(Curl_uint32_spbset_next(&entry->xfers, mid, &mid));
}
if(entry->conn)
uint32_t type;
};
-#define CURL_MNTFY_CHUNK_SIZE 128
+#define CURL_MNTFY_CHUNK_SIZE 128
struct mntfy_chunk {
struct mntfy_chunk *next;
Curl_uint32_bset_contains(&multi->ntfy.enabled, (uint32_t)type)) {
/* append to list of outstanding notifications */
struct mntfy_chunk *tail = mntfy_non_full_tail(&multi->ntfy);
- CURL_TRC_M(data, "[NTFY] add %d for xfer %u", type, data->mid);
+ CURL_TRC_M(data, "[NTFY] add %d for xfer %u", type, data->mid);
if(tail)
mntfy_chunk_append(tail, data, (uint32_t)type);
else
void Curl_mntfy_add(struct Curl_easy *data, unsigned int type);
-#define CURLM_NTFY(d,t) \
- do { if((d) && (d)->multi && (d)->multi->ntfy.ntfy_cb) \
- Curl_mntfy_add((d), (t)); } while(0)
+#define CURLM_NTFY(d, t) \
+ do { \
+ if((d) && (d)->multi && (d)->multi->ntfy.ntfy_cb) \
+ Curl_mntfy_add((d), (t)); \
+ } while(0)
CURLMcode Curl_mntfy_dispatch_all(struct Curl_multi *multi);
-
#endif /* HEADER_CURL_MULTI_NTFY_H */
struct Curl_easy *data,
struct connectdata *conn);
-
/* Return the value of the CURLMOPT_MAX_CONCURRENT_STREAMS option */
unsigned int Curl_multi_max_concurrent_streams(struct Curl_multi *multi);
#define FOUND_LOGIN 1
#define FOUND_PASSWORD 2
-#define MAX_NETRC_LINE 16384
-#define MAX_NETRC_FILE (128*1024)
+#define MAX_NETRC_LINE 16384
+#define MAX_NETRC_FILE (128 * 1024)
#define MAX_NETRC_TOKEN 4096
/* convert a dynbuf call CURLcode error to a NETRCcode error */
if(!specific_login)
Curl_safefree(login);
}
- if((found == (FOUND_PASSWORD|FOUND_LOGIN)) && our_login) {
+ if((found == (FOUND_PASSWORD | FOUND_LOGIN)) && our_login) {
done = TRUE;
break;
}
}
else {
struct passwd pw, *pw_res;
- if(!getpwuid_r(geteuid(), &pw, pwbuf, sizeof(pwbuf), &pw_res)
- && pw_res) {
+ if(!getpwuid_r(geteuid(), &pw, pwbuf, sizeof(pwbuf), &pw_res) &&
+ pw_res) {
home = pw.pw_dir;
}
#elif defined(HAVE_GETPWUID) && defined(HAVE_GETEUID)
NETRCcode Curl_parsenetrc(struct store_netrc *s, const char *host,
char **loginp, char **passwordp,
const char *filename);
- /* Assume: (*passwordp)[0]=0, host[0] != 0.
- * If (*loginp)[0] = 0, search for login and password within a machine
- * section in the netrc.
- * If (*loginp)[0] != 0, search for password within machine and login.
- */
+/* Assume: (*passwordp)[0]=0, host[0] != 0.
+ * If (*loginp)[0] = 0, search for login and password within a machine
+ * section in the netrc.
+ * If (*loginp)[0] != 0, search for password within machine and login.
+ */
#else
/* disabled */
-#define Curl_parsenetrc(a,b,c,d,e,f) 1
+#define Curl_parsenetrc(a, b, c, d, e, f) 1
#define Curl_netrc_init(x)
#define Curl_netrc_cleanup(x)
#endif
else if(tokenlen < namelen) {
/* case B, tailmatch domain */
match = (name[namelen - tokenlen - 1] == '.') &&
- curl_strnequal(token, name + (namelen - tokenlen),
- tokenlen);
+ curl_strnequal(token, name + (namelen - tokenlen), tokenlen);
}
/* case C passes through, not a match */
return match;
return Curl_cidr4_match(name, check, bits);
}
-
/****************************************************************
-* Checks if the host is in the noproxy list. returns TRUE if it matches and
-* therefore the proxy should NOT be used.
-****************************************************************/
+ * Checks if the host is in the noproxy list. returns TRUE if it matches and
+ * therefore the proxy should NOT be used.
+ ****************************************************************/
bool Curl_check_noproxy(const char *name, const char *no_proxy)
{
char hostip[128];
/*
* LDAP protocol handler.
*/
-
const struct Curl_handler Curl_handler_ldap = {
"ldap", /* scheme */
oldap_setup_connection, /* setup_connection */
CURLPROTO_LDAP, /* protocol */
CURLPROTO_LDAP, /* family */
PROTOPT_SSL_REUSE | /* flags */
- PROTOPT_CONN_REUSE
+ PROTOPT_CONN_REUSE
};
#ifdef USE_SSL
/*
* LDAPS protocol handler.
*/
-
const struct Curl_handler Curl_handler_ldaps = {
"ldaps", /* scheme */
oldap_setup_connection, /* setup_connection */
CURLPROTO_LDAPS, /* protocol */
CURLPROTO_LDAP, /* family */
PROTOPT_SSL | /* flags */
- PROTOPT_CONN_REUSE
+ PROTOPT_CONN_REUSE
};
#endif
result = rc == LDAP_URL_ERR_MEM ? CURLE_OUT_OF_MEMORY :
CURLE_URL_MALFORMAT;
rc -= LDAP_URL_SUCCESS;
- if((size_t) rc < CURL_ARRAYSIZE(url_errs))
+ if((size_t)rc < CURL_ARRAYSIZE(url_errs))
msg = url_errs[rc];
failf(data, "LDAP local: %s", msg);
}
ber_len_t len);
static int ldapsb_tls_close(Sockbuf_IO_Desc *sbiod);
-static Sockbuf_IO ldapsb_tls =
-{
+static Sockbuf_IO ldapsb_tls = {
ldapsb_tls_setup,
ldapsb_tls_remove,
ldapsb_tls_ctrl,
ldap_set_option(li->ld, LDAP_OPT_REFERRALS, LDAP_OPT_OFF);
{
- ber_len_t max = 256*1024;
+ ber_len_t max = 256 * 1024;
Sockbuf *sb;
if((ldap_get_option(li->ld, LDAP_OPT_SOCKBUF, &sb) != LDAP_OPT_SUCCESS) ||
/* Set the maximum allowed size of an incoming message, which to
if(bvals) {
for(i = 0; bvals[i].bv_val; i++) {
size_t llen;
- unsigned short mech = Curl_sasl_decode_mech((char *) bvals[i].bv_val,
+ unsigned short mech = Curl_sasl_decode_mech((char *)bvals[i].bv_val,
bvals[i].bv_len, &llen);
if(bvals[i].bv_len == llen)
li->sasl.authmechs |= mech;
struct connectdata *conn = data->conn;
struct ldapconninfo *li = Curl_conn_meta_get(conn, CURL_META_LDAP_CONN);
LDAPMessage *msg = NULL;
- struct timeval tv = {0, 0};
+ struct timeval tv = { 0, 0 };
int code = LDAP_SUCCESS;
int rc;
int rc;
LDAPMessage *msg = NULL;
BerElement *ber = NULL;
- struct timeval tv = {0, 0};
+ struct timeval tv = { 0, 0 };
struct berval bv, *bvals;
CURLcode result = CURLE_AGAIN;
int code;
}
#ifdef USE_SSL
-static int
-ldapsb_tls_setup(Sockbuf_IO_Desc *sbiod, void *arg)
+static int ldapsb_tls_setup(Sockbuf_IO_Desc *sbiod, void *arg)
{
sbiod->sbiod_pvt = arg;
return 0;
}
-static int
-ldapsb_tls_remove(Sockbuf_IO_Desc *sbiod)
+static int ldapsb_tls_remove(Sockbuf_IO_Desc *sbiod)
{
sbiod->sbiod_pvt = NULL;
return 0;
}
/* We do not need to do anything because libcurl does it already */
-static int
-ldapsb_tls_close(Sockbuf_IO_Desc *sbiod)
+static int ldapsb_tls_close(Sockbuf_IO_Desc *sbiod)
{
(void)sbiod;
return 0;
}
-static int
-ldapsb_tls_ctrl(Sockbuf_IO_Desc *sbiod, int opt, void *arg)
+static int ldapsb_tls_ctrl(Sockbuf_IO_Desc *sbiod, int opt, void *arg)
{
(void)arg;
if(opt == LBER_SB_OPT_DATA_READY) {
return 0;
}
-static ber_slen_t
-ldapsb_tls_read(Sockbuf_IO_Desc *sbiod, void *buf, ber_len_t len)
+static ber_slen_t ldapsb_tls_read(Sockbuf_IO_Desc *sbiod, void *buf,
+ ber_len_t len)
{
struct Curl_easy *data = sbiod->sbiod_pvt;
ber_slen_t ret = 0;
}
return ret;
}
-static ber_slen_t
-ldapsb_tls_write(Sockbuf_IO_Desc *sbiod, void *buf, ber_len_t len)
+static ber_slen_t ldapsb_tls_write(Sockbuf_IO_Desc *sbiod, void *buf,
+ ber_len_t len)
{
struct Curl_easy *data = sbiod->sbiod_pvt;
ber_slen_t ret = 0;
#if !defined(CURL_DISABLE_PARSEDATE) || !defined(CURL_DISABLE_FTP) || \
!defined(CURL_DISABLE_FILE) || defined(USE_GNUTLS)
/* These names are also used by FTP and FILE code */
-const char * const Curl_wkday[] =
-{"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"};
-const char * const Curl_month[]=
-{ "Jan", "Feb", "Mar", "Apr", "May", "Jun",
- "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
+const char * const Curl_wkday[] = {
+ "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"
+};
+const char * const Curl_month[] = {
+ "Jan", "Feb", "Mar", "Apr", "May", "Jun",
+ "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
+};
#endif
#ifndef CURL_DISABLE_PARSEDATE
-static const char * const weekday[] =
-{ "Monday", "Tuesday", "Wednesday", "Thursday",
- "Friday", "Saturday", "Sunday" };
+static const char * const weekday[] = {
+ "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"
+};
struct tzinfo {
char name[5];
/* Here's a bunch of frequently used time zone names. These were supported
by the old getdate parser. */
#define tDAYZONE -60 /* offset for daylight savings time */
-static const struct tzinfo tz[]= {
- {"GMT", 0}, /* Greenwich Mean */
- {"UT", 0}, /* Universal Time */
- {"UTC", 0}, /* Universal (Coordinated) */
- {"WET", 0}, /* Western European */
- {"BST", 0 tDAYZONE}, /* British Summer */
- {"WAT", 60}, /* West Africa */
- {"AST", 240}, /* Atlantic Standard */
- {"ADT", 240 tDAYZONE}, /* Atlantic Daylight */
- {"EST", 300}, /* Eastern Standard */
- {"EDT", 300 tDAYZONE}, /* Eastern Daylight */
- {"CST", 360}, /* Central Standard */
- {"CDT", 360 tDAYZONE}, /* Central Daylight */
- {"MST", 420}, /* Mountain Standard */
- {"MDT", 420 tDAYZONE}, /* Mountain Daylight */
- {"PST", 480}, /* Pacific Standard */
- {"PDT", 480 tDAYZONE}, /* Pacific Daylight */
- {"YST", 540}, /* Yukon Standard */
- {"YDT", 540 tDAYZONE}, /* Yukon Daylight */
- {"HST", 600}, /* Hawaii Standard */
- {"HDT", 600 tDAYZONE}, /* Hawaii Daylight */
- {"CAT", 600}, /* Central Alaska */
- {"AHST", 600}, /* Alaska-Hawaii Standard */
- {"NT", 660}, /* Nome */ /* spellchecker:disable-line */
- {"IDLW", 720}, /* International Date Line West */
- {"CET", -60}, /* Central European */
- {"MET", -60}, /* Middle European */
- {"MEWT", -60}, /* Middle European Winter */
- {"MEST", -60 tDAYZONE}, /* Middle European Summer */
- {"CEST", -60 tDAYZONE}, /* Central European Summer */
- {"MESZ", -60 tDAYZONE}, /* Middle European Summer */
- {"FWT", -60}, /* French Winter */
- {"FST", -60 tDAYZONE}, /* French Summer */
- {"EET", -120}, /* Eastern Europe, USSR Zone 1 */
- {"WAST", -420}, /* spellchecker:disable-line */
- /* West Australian Standard */
- {"WADT", -420 tDAYZONE}, /* West Australian Daylight */
- {"CCT", -480}, /* China Coast, USSR Zone 7 */
- {"JST", -540}, /* Japan Standard, USSR Zone 8 */
- {"EAST", -600}, /* Eastern Australian Standard */
- {"EADT", -600 tDAYZONE}, /* Eastern Australian Daylight */
- {"GST", -600}, /* Guam Standard, USSR Zone 9 */
- {"NZT", -720}, /* New Zealand */
- {"NZST", -720}, /* New Zealand Standard */
- {"NZDT", -720 tDAYZONE}, /* New Zealand Daylight */
- {"IDLE", -720}, /* International Date Line East */
+static const struct tzinfo tz[] = {
+ { "GMT", 0 }, /* Greenwich Mean */
+ { "UT", 0 }, /* Universal Time */
+ { "UTC", 0 }, /* Universal (Coordinated) */
+ { "WET", 0 }, /* Western European */
+ { "BST", 0 tDAYZONE }, /* British Summer */
+ { "WAT", 60 }, /* West Africa */
+ { "AST", 240 }, /* Atlantic Standard */
+ { "ADT", 240 tDAYZONE }, /* Atlantic Daylight */
+ { "EST", 300 }, /* Eastern Standard */
+ { "EDT", 300 tDAYZONE }, /* Eastern Daylight */
+ { "CST", 360 }, /* Central Standard */
+ { "CDT", 360 tDAYZONE }, /* Central Daylight */
+ { "MST", 420 }, /* Mountain Standard */
+ { "MDT", 420 tDAYZONE }, /* Mountain Daylight */
+ { "PST", 480 }, /* Pacific Standard */
+ { "PDT", 480 tDAYZONE }, /* Pacific Daylight */
+ { "YST", 540 }, /* Yukon Standard */
+ { "YDT", 540 tDAYZONE }, /* Yukon Daylight */
+ { "HST", 600 }, /* Hawaii Standard */
+ { "HDT", 600 tDAYZONE }, /* Hawaii Daylight */
+ { "CAT", 600 }, /* Central Alaska */
+ { "AHST", 600 }, /* Alaska-Hawaii Standard */
+ { "NT", 660 }, /* Nome */ /* spellchecker:disable-line */
+ { "IDLW", 720 }, /* International Date Line West */
+ { "CET", -60 }, /* Central European */
+ { "MET", -60 }, /* Middle European */
+ { "MEWT", -60 }, /* Middle European Winter */
+ { "MEST", -60 tDAYZONE }, /* Middle European Summer */
+ { "CEST", -60 tDAYZONE }, /* Central European Summer */
+ { "MESZ", -60 tDAYZONE }, /* Middle European Summer */
+ { "FWT", -60 }, /* French Winter */
+ { "FST", -60 tDAYZONE }, /* French Summer */
+ { "EET", -120 }, /* Eastern Europe, USSR Zone 1 */
+ { "WAST", -420 }, /* spellchecker:disable-line */
+ /* West Australian Standard */
+ { "WADT", -420 tDAYZONE }, /* West Australian Daylight */
+ { "CCT", -480 }, /* China Coast, USSR Zone 7 */
+ { "JST", -540 }, /* Japan Standard, USSR Zone 8 */
+ { "EAST", -600 }, /* Eastern Australian Standard */
+ { "EADT", -600 tDAYZONE }, /* Eastern Australian Daylight */
+ { "GST", -600 }, /* Guam Standard, USSR Zone 9 */
+ { "NZT", -720 }, /* New Zealand */
+ { "NZST", -720 }, /* New Zealand Standard */
+ { "NZDT", -720 tDAYZONE }, /* New Zealand Daylight */
+ { "IDLE", -720 }, /* International Date Line East */
/* Next up: Military timezone names. RFC822 allowed these, but (as noted in
RFC 1123) had their signs wrong. Here we use the correct signs to match
actual military usage.
*/
- {"A", 1 * 60}, /* Alpha */
- {"B", 2 * 60}, /* Bravo */
- {"C", 3 * 60}, /* Charlie */
- {"D", 4 * 60}, /* Delta */
- {"E", 5 * 60}, /* Echo */
- {"F", 6 * 60}, /* Foxtrot */
- {"G", 7 * 60}, /* Golf */
- {"H", 8 * 60}, /* Hotel */
- {"I", 9 * 60}, /* India */
+ { "A", 1 * 60 }, /* Alpha */
+ { "B", 2 * 60 }, /* Bravo */
+ { "C", 3 * 60 }, /* Charlie */
+ { "D", 4 * 60 }, /* Delta */
+ { "E", 5 * 60 }, /* Echo */
+ { "F", 6 * 60 }, /* Foxtrot */
+ { "G", 7 * 60 }, /* Golf */
+ { "H", 8 * 60 }, /* Hotel */
+ { "I", 9 * 60 }, /* India */
/* "J", Juliet is not used as a timezone, to indicate the observer's local
time */
- {"K", 10 * 60}, /* Kilo */
- {"L", 11 * 60}, /* Lima */
- {"M", 12 * 60}, /* Mike */
- {"N", -1 * 60}, /* November */
- {"O", -2 * 60}, /* Oscar */
- {"P", -3 * 60}, /* Papa */
- {"Q", -4 * 60}, /* Quebec */
- {"R", -5 * 60}, /* Romeo */
- {"S", -6 * 60}, /* Sierra */
- {"T", -7 * 60}, /* Tango */
- {"U", -8 * 60}, /* Uniform */
- {"V", -9 * 60}, /* Victor */
- {"W", -10 * 60}, /* Whiskey */
- {"X", -11 * 60}, /* X-ray */
- {"Y", -12 * 60}, /* Yankee */
- {"Z", 0}, /* Zulu, zero meridian, a.k.a. UTC */
+ { "K", 10 * 60 }, /* Kilo */
+ { "L", 11 * 60 }, /* Lima */
+ { "M", 12 * 60 }, /* Mike */
+ { "N", -1 * 60 }, /* November */
+ { "O", -2 * 60 }, /* Oscar */
+ { "P", -3 * 60 }, /* Papa */
+ { "Q", -4 * 60 }, /* Quebec */
+ { "R", -5 * 60 }, /* Romeo */
+ { "S", -6 * 60 }, /* Sierra */
+ { "T", -7 * 60 }, /* Tango */
+ { "U", -8 * 60 }, /* Uniform */
+ { "V", -9 * 60 }, /* Victor */
+ { "W", -10 * 60 }, /* Whiskey */
+ { "X", -11 * 60 }, /* X-ray */
+ { "Y", -12 * 60 }, /* Yankee */
+ { "Z", 0 }, /* Zulu, zero meridian, a.k.a. UTC */
};
/* returns:
size_t ilen = strlen(what->name);
if((ilen == len) &&
curl_strnequal(check, what->name, len))
- return what->offset*60;
+ return what->offset * 60;
what++;
}
return -1;
static time_t time2epoch(int sec, int min, int hour,
int mday, int mon, int year)
{
- static const int month_days_cumulative[12] =
- { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 };
+ static const int month_days_cumulative[12] = {
+ 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334
+ };
int leap_days = year - (mon <= 1);
leap_days = ((leap_days / 4) - (leap_days / 100) + (leap_days / 400)
- (1969 / 4) + (1969 / 100) - (1969 / 400));
- return ((((time_t) (year - 1970) * 365
+ return ((((time_t)(year - 1970) * 365
+ leap_days + month_days_cumulative[mon] + mday - 1) * 24
+ hour) * 60 + min) * 60 + sec;
}
int num = date[0] - '0';
if(ISDIGIT(date[1])) {
*endp = &date[2];
- return num*10 + (date[1] - '0');
+ return num * 10 + (date[1] - '0');
}
*endp = &date[1];
return num;
}
-
/* HH:MM:SS or HH:MM and accept single-digits too */
static bool match_time(const char *date,
int *h, int *m, int *s, char **endp)
anyone has a more authoritative source for the exact maximum time
zone offsets, please speak up! */
found = TRUE;
- tzoff = (val/100 * 60 + val%100)*60;
+ tzoff = (val / 100 * 60 + val % 100) * 60;
/* the + and - prefix indicates the local time compared to GMT,
this we need their reversed math to get what we want */
- tzoff = date[-1]=='+' ? -tzoff : tzoff;
+ tzoff = date[-1] == '+' ? -tzoff : tzoff;
}
else if((num_digits == 8) &&
(mdaynum == -1)) {
/* 8 digits, no year, month or day yet. This is YYYYMMDD */
found = TRUE;
- yearnum = val/10000;
- monnum = (val%10000)/100-1; /* month is 0 - 11 */
- mdaynum = val%100;
+ yearnum = val / 10000;
+ monnum = (val % 10000) / 100 - 1; /* month is 0 - 11 */
+ mdaynum = val % 100;
}
if(!found && (dignext == DATE_MDAY) && (mdaynum == -1)) {
return CURLE_OK;
}
-
/***********************************************************************
*
* Curl_pp_sendf()
read */
};
-#define PINGPONG_SETUP(pp,s,e) \
- do { \
- (pp)->statemachine = s; \
- (pp)->endofresp = e; \
+#define PINGPONG_SETUP(pp, s, e) \
+ do { \
+ (pp)->statemachine = s; \
+ (pp)->endofresp = e; \
} while(0)
/*
timediff_t Curl_pp_state_timeout(struct Curl_easy *data,
struct pingpong *pp, bool disconnecting);
-
/***********************************************************************
*
* Curl_pp_sendf()
struct pingpong *pp,
struct easy_pollset *ps);
-
/***********************************************************************
*
* Curl_pp_moredata()
#define POP3_TYPE_SASL (1 << 2)
/* Authentication type values */
-#define POP3_TYPE_NONE 0
-#define POP3_TYPE_ANY (POP3_TYPE_CLEARTEXT|POP3_TYPE_APOP|POP3_TYPE_SASL)
+#define POP3_TYPE_NONE 0
+#define POP3_TYPE_ANY (POP3_TYPE_CLEARTEXT | POP3_TYPE_APOP | POP3_TYPE_SASL)
/* This is the 5-bytes End-Of-Body marker for POP3 */
-#define POP3_EOB "\x0d\x0a\x2e\x0d\x0a"
+#define POP3_EOB "\x0d\x0a\x2e\x0d\x0a"
#define POP3_EOB_LEN 5
/* meta key for storing protocol meta at easy handle */
CURLPROTO_POP3, /* protocol */
CURLPROTO_POP3, /* family */
PROTOPT_CLOSEACTION | PROTOPT_NOURLQUERY | /* flags */
- PROTOPT_URLOPTIONS | PROTOPT_SSL_REUSE |
- PROTOPT_CONN_REUSE
+ PROTOPT_URLOPTIONS | PROTOPT_SSL_REUSE | PROTOPT_CONN_REUSE
};
#ifdef USE_SSL
CURLPROTO_POP3S, /* protocol */
CURLPROTO_POP3, /* family */
PROTOPT_CLOSEACTION | PROTOPT_SSL | /* flags */
- PROTOPT_NOURLQUERY | PROTOPT_URLOPTIONS |
- PROTOPT_CONN_REUSE
+ PROTOPT_NOURLQUERY | PROTOPT_URLOPTIONS | PROTOPT_CONN_REUSE
};
#endif
result, ssldone));
if(!result && ssldone) {
pop3c->ssldone = ssldone;
- /* perform CAPA now, changes pop3c->state out of POP3_UPGRADETLS */
+ /* perform CAPA now, changes pop3c->state out of POP3_UPGRADETLS */
result = pop3_perform_capa(data, conn);
}
out:
if(!ctxt)
return CURLE_OUT_OF_MEMORY;
- Curl_MD5_update(ctxt, (const unsigned char *) pop3c->apoptimestamp,
+ Curl_MD5_update(ctxt, (const unsigned char *)pop3c->apoptimestamp,
curlx_uztoui(strlen(pop3c->apoptimestamp)));
- Curl_MD5_update(ctxt, (const unsigned char *) conn->passwd,
+ Curl_MD5_update(ctxt, (const unsigned char *)conn->passwd,
curlx_uztoui(strlen(conn->passwd)));
/* Finalise the digest */
struct pop3_conn *pop3c =
Curl_conn_meta_get(data->conn, CURL_META_POP3_CONN);
CURLcode result = CURLE_OK;
- const char *ir = (const char *) Curl_bufref_ptr(initresp);
+ const char *ir = (const char *)Curl_bufref_ptr(initresp);
if(!pop3c)
return CURLE_FAILED_INIT;
/* xxx.yU */
curl_msnprintf(max6, 7, "%3" CURL_FORMAT_CURL_OFF_T
".%" CURL_FORMAT_CURL_OFF_T "%c", nbytes,
- (bytes%1024) / (1024/10), unit[k]);
+ (bytes % 1024) / (1024 / 10), unit[k]);
}
return max6;
}
void Curl_pgrsEarlyData(struct Curl_easy *data, curl_off_t sent)
{
- data->progress.earlydata_sent = sent;
+ data->progress.earlydata_sent = sent;
}
/* returns the average speed in bytes / second */
{
if(us < 1)
return size * 1000000;
- else if(size < CURL_OFF_T_MAX/1000000)
+ else if(size < CURL_OFF_T_MAX / 1000000)
return (size * 1000000) / us;
else if(us >= 1000000)
return size / (us / 1000000);
((i_latest + 1) % CURL_SPEED_RECORDS);
/* How much we transferred between oldest and current records */
- amount = p->speed_amount[i_latest]- p->speed_amount[i_oldest];
+ amount = p->speed_amount[i_latest] - p->speed_amount[i_oldest];
/* How long this took */
duration_ms = curlx_timediff_ms(p->speed_time[i_latest],
p->speed_time[i_oldest]);
if(duration_ms <= 0)
duration_ms = 1;
- if(amount > (CURL_OFF_T_MAX/1000)) {
+ if(amount > (CURL_OFF_T_MAX / 1000)) {
/* the 'amount' value is bigger than would fit in 64 bits if
multiplied with 1000, so we use the double math for this */
- p->current_speed = (curl_off_t)
- (((double)amount * 1000.0)/(double)duration_ms);
+ p->current_speed =
+ (curl_off_t)(((double)amount * 1000.0) / (double)duration_ms);
}
else {
/* the 'amount' value is small enough to fit within 32 bits even
if(total > 10000)
return cur / (total / 100);
else if(total > 0)
- return (cur*100) / total;
+ return (cur * 100) / total;
return 0;
}
char time_left[10];
char time_total[10];
char time_spent[10];
- curl_off_t cur_secs = (curl_off_t)p->timespent/1000000; /* seconds */
+ curl_off_t cur_secs = (curl_off_t)p->timespent / 1000000; /* seconds */
if(!p->headers_out) {
if(data->state.resume_from) {
time2str(time_spent, cur_secs);
/* Get the total amount of data expected to get transferred */
- total_expected_size =
- p->ul_size_known ? p->ul.total_size : p->ul.cur_size;
+ total_expected_size = p->ul_size_known ? p->ul.total_size : p->ul.cur_size;
- dl_size =
- p->dl_size_known ? p->dl.total_size : p->dl.cur_size;
+ dl_size = p->dl_size_known ? p->dl.total_size : p->dl.cur_size;
/* integer overflow check */
if((CURL_OFF_T_MAX - total_expected_size) < dl_size)
#define progress_meter(x) Curl_nop_stmt
#endif
-
/*
* Curl_pgrsUpdate() returns 0 for success or the value returned by the
* progress callback!
pslcache->expires = expires;
}
}
- Curl_share_unlock(easy, CURL_LOCK_DATA_PSL); /* Release exclusive lock. */
+ Curl_share_unlock(easy, CURL_LOCK_DATA_PSL); /* Release exclusive lock. */
Curl_share_lock(easy, CURL_LOCK_DATA_PSL, CURL_LOCK_ACCESS_SHARED);
}
psl = pslcache->psl;
* size.
*/
-CURLcode Curl_rand_hex(struct Curl_easy *data, unsigned char *rnd,
- size_t num)
+CURLcode Curl_rand_hex(struct Curl_easy *data, unsigned char *rnd, size_t num)
{
CURLcode result = CURLE_BAD_FUNCTION_ARGUMENT;
unsigned char buffer[128];
memset(buffer, 0, sizeof(buffer));
#endif
- if((num/2 >= sizeof(buffer)) || !(num&1)) {
+ if((num / 2 >= sizeof(buffer)) || !(num & 1)) {
/* make sure it fits in the local buffer and that it is an odd number! */
DEBUGF(infof(data, "invalid buffer size with Curl_rand_hex"));
return CURLE_BAD_FUNCTION_ARGUMENT;
num--; /* save one for null-termination */
- result = Curl_rand(data, buffer, num/2);
+ result = Curl_rand(data, buffer, num / 2);
if(result)
return result;
- Curl_hexencode(buffer, num/2, rnd, num + 1);
+ Curl_hexencode(buffer, num / 2, rnd, num + 1);
return result;
}
unsigned char *rnd, size_t num);
#ifdef DEBUGBUILD
-#define Curl_rand(a,b,c) Curl_rand_bytes((a), TRUE, (b), (c))
+#define Curl_rand(a, b, c) Curl_rand_bytes((a), TRUE, (b), (c))
#else
-#define Curl_rand(a,b,c) Curl_rand_bytes((a), (b), (c))
+#define Curl_rand(a, b, c) Curl_rand_bytes((a), (b), (c))
#endif
/*
* hexadecimal digits PLUS a null-terminating byte. It must be an odd number
* size.
*/
-CURLcode Curl_rand_hex(struct Curl_easy *data, unsigned char *rnd,
- size_t num);
+CURLcode Curl_rand_hex(struct Curl_easy *data, unsigned char *rnd, size_t num);
/*
* Curl_rand_alnum() fills the 'rnd' buffer with a given 'num' size with random
#include "ratelimit.h"
-#define CURL_US_PER_SEC 1000000
+#define CURL_US_PER_SEC 1000000
#define CURL_RLIMIT_MIN_CHUNK (16 * 1024)
#define CURL_RLIMIT_MAX_STEPS 2 /* 500ms interval */
void Curl_req_hard_reset(struct SingleRequest *req, struct Curl_easy *data)
{
- struct curltime t0 = {0, 0};
+ struct curltime t0 = { 0, 0 };
Curl_safefree(req->newurl);
Curl_client_reset(data);
CURLcode result = CURLE_OK;
if(data->req.keepon & KEEP_SEND)
result = Curl_req_abort_sending(data);
- data->req.keepon &= ~(KEEP_RECV|KEEP_SEND);
+ data->req.keepon &= ~(KEEP_RECV | KEEP_SEND);
return result;
}
UPGR101_RECEIVED /* 101 response received */
};
-
/*
* Request specific data in the easy handle (Curl_easy). Previously,
* these members were on the connectdata struct but since a conn struct may
return Curl_pollset_add_out(data, ps, data->conn->sock[FIRSTSOCKET]);
}
-static
-CURLcode rtp_client_write(struct Curl_easy *data, const char *ptr, size_t len);
-static
-CURLcode rtsp_parse_transport(struct Curl_easy *data, const char *transport);
-
+static CURLcode rtp_client_write(struct Curl_easy *data, const char *ptr,
+ size_t len);
+static CURLcode rtsp_parse_transport(struct Curl_easy *data,
+ const char *transport);
/*
* RTSP handler interface.
return CURLE_OK;
}
-
/*
* Function to check on various aspects of a connection.
*/
return ret_val;
}
-
static CURLcode rtsp_connect(struct Curl_easy *data, bool *done)
{
struct rtsp_conn *rtspc =
return httpStatus;
}
-
static CURLcode rtsp_setup_body(struct Curl_easy *data,
Curl_RtspReq rtspreq,
struct dynbuf *reqp)
if(rtspreq == RTSPREQ_SET_PARAMETER ||
rtspreq == RTSPREQ_GET_PARAMETER) {
if(!Curl_checkheaders(data, STRCONST("Content-Type"))) {
- result = curlx_dyn_addn(reqp,
- STRCONST("Content-Type: "
- "text/parameters\r\n"));
+ result = curlx_dyn_addn(reqp, STRCONST("Content-Type: "
+ "text/parameters\r\n"));
if(result)
return result;
}
if(rtspreq == RTSPREQ_ANNOUNCE) {
if(!Curl_checkheaders(data, STRCONST("Content-Type"))) {
- result = curlx_dyn_addn(reqp,
- STRCONST("Content-Type: "
- "application/sdp\r\n"));
+ result = curlx_dyn_addn(reqp, STRCONST("Content-Type: "
+ "application/sdp\r\n"));
if(result)
return result;
}
blen, rtspc->in_header, data->req.done, rtspc->state,
data->req.size));
if(!result && (is_eos || blen)) {
- result = Curl_client_write(data, CLIENTWRITE_BODY|
+ result = Curl_client_write(data, CLIENTWRITE_BODY |
(is_eos ? CLIENTWRITE_EOS : 0), buf, blen);
}
return rtsp_rtp_write_resp(data, buf, blen, is_eos);
}
-static
-CURLcode rtp_client_write(struct Curl_easy *data, const char *ptr, size_t len)
+static CURLcode rtp_client_write(struct Curl_easy *data, const char *ptr,
+ size_t len)
{
size_t wrote;
curl_write_callback writeit;
return CURLE_OK;
}
-static
-CURLcode rtsp_parse_transport(struct Curl_easy *data, const char *transport)
+static CURLcode rtsp_parse_transport(struct Curl_easy *data,
+ const char *transport)
{
/* If we receive multiple Transport response-headers, the linterleaved
channels of each response header is recorded and used together for
return CURLE_OK;
}
-
#endif /* CURL_DISABLE_RTSP */
#else
/* disabled */
-#define Curl_rtsp_parseheader(x,y) CURLE_NOT_BUILT_IN
+#define Curl_rtsp_parseheader(x, y) CURLE_NOT_BUILT_IN
#endif /* CURL_DISABLE_RTSP */
num = 0;
if(readfd0 != CURL_SOCKET_BAD) {
pfd[num].fd = readfd0;
- pfd[num].events = POLLRDNORM|POLLIN|POLLRDBAND|POLLPRI;
+ pfd[num].events = POLLRDNORM | POLLIN | POLLRDBAND | POLLPRI;
pfd[num].revents = 0;
num++;
}
if(readfd1 != CURL_SOCKET_BAD) {
pfd[num].fd = readfd1;
- pfd[num].events = POLLRDNORM|POLLIN|POLLRDBAND|POLLPRI;
+ pfd[num].events = POLLRDNORM | POLLIN | POLLRDBAND | POLLPRI;
pfd[num].revents = 0;
num++;
}
if(writefd != CURL_SOCKET_BAD) {
pfd[num].fd = writefd;
- pfd[num].events = POLLWRNORM|POLLOUT|POLLPRI;
+ pfd[num].events = POLLWRNORM | POLLOUT | POLLPRI;
pfd[num].revents = 0;
num++;
}
r = 0;
num = 0;
if(readfd0 != CURL_SOCKET_BAD) {
- if(pfd[num].revents & (POLLRDNORM|POLLIN|POLLERR|POLLHUP))
+ if(pfd[num].revents & (POLLRDNORM | POLLIN | POLLERR | POLLHUP))
r |= CURL_CSELECT_IN;
- if(pfd[num].revents & (POLLPRI|POLLNVAL))
+ if(pfd[num].revents & (POLLPRI | POLLNVAL))
r |= CURL_CSELECT_ERR;
num++;
}
if(readfd1 != CURL_SOCKET_BAD) {
- if(pfd[num].revents & (POLLRDNORM|POLLIN|POLLERR|POLLHUP))
+ if(pfd[num].revents & (POLLRDNORM | POLLIN | POLLERR | POLLHUP))
r |= CURL_CSELECT_IN2;
- if(pfd[num].revents & (POLLPRI|POLLNVAL))
+ if(pfd[num].revents & (POLLPRI | POLLNVAL))
r |= CURL_CSELECT_ERR;
num++;
}
if(writefd != CURL_SOCKET_BAD) {
- if(pfd[num].revents & (POLLWRNORM|POLLOUT))
+ if(pfd[num].revents & (POLLWRNORM | POLLOUT))
r |= CURL_CSELECT_OUT;
- if(pfd[num].revents & (POLLERR|POLLHUP|POLLPRI|POLLNVAL))
+ if(pfd[num].revents & (POLLERR | POLLHUP | POLLPRI | POLLNVAL))
r |= CURL_CSELECT_ERR;
}
if(ufds[i].revents & POLLHUP)
ufds[i].revents |= POLLIN;
if(ufds[i].revents & POLLERR)
- ufds[i].revents |= POLLIN|POLLOUT;
+ ufds[i].revents |= POLLIN | POLLOUT;
}
#else /* HAVE_POLL */
if(ufds[i].fd == CURL_SOCKET_BAD)
continue;
VERIFY_SOCK(ufds[i].fd);
- if(ufds[i].events & (POLLIN|POLLOUT|POLLPRI|
- POLLRDNORM|POLLWRNORM|POLLRDBAND)) {
+ if(ufds[i].events & (POLLIN |POLLOUT |POLLPRI |
+ POLLRDNORM | POLLWRNORM | POLLRDBAND)) {
if(ufds[i].fd > maxfd)
maxfd = ufds[i].fd;
- if(ufds[i].events & (POLLRDNORM|POLLIN))
+ if(ufds[i].events & (POLLRDNORM | POLLIN))
FD_SET(ufds[i].fd, &fds_read);
- if(ufds[i].events & (POLLWRNORM|POLLOUT))
+ if(ufds[i].events & (POLLWRNORM | POLLOUT))
FD_SET(ufds[i].fd, &fds_write);
- if(ufds[i].events & (POLLRDBAND|POLLPRI))
+ if(ufds[i].events & (POLLRDBAND | POLLPRI))
FD_SET(ufds[i].fd, &fds_err);
}
}
if(!VALID_SOCK(sock))
return CURLE_BAD_FUNCTION_ARGUMENT;
- DEBUGASSERT(add_flags <= (CURL_POLL_IN|CURL_POLL_OUT));
- DEBUGASSERT(remove_flags <= (CURL_POLL_IN|CURL_POLL_OUT));
- DEBUGASSERT((add_flags&remove_flags) == 0); /* no overlap */
+ DEBUGASSERT(add_flags <= (CURL_POLL_IN | CURL_POLL_OUT));
+ DEBUGASSERT(remove_flags <= (CURL_POLL_IN | CURL_POLL_OUT));
+ DEBUGASSERT((add_flags & remove_flags) == 0); /* no overlap */
for(i = 0; i < ps->n; ++i) {
if(ps->sockets[i] == sock) {
ps->actions[i] &= (unsigned char)(~remove_flags);
#define POLLHUP 0x10
#define POLLNVAL 0x20
-struct pollfd
-{
- curl_socket_t fd;
- short events;
- short revents;
+struct pollfd {
+ curl_socket_t fd;
+ short events;
+ short revents;
};
#endif
int Curl_socket_check(curl_socket_t readfd, curl_socket_t readfd2,
curl_socket_t writefd,
timediff_t timeout_ms);
-#define SOCKET_READABLE(x,z) \
+#define SOCKET_READABLE(x, z) \
Curl_socket_check(x, CURL_SOCKET_BAD, CURL_SOCKET_BAD, z)
-#define SOCKET_WRITABLE(x,z) \
+#define SOCKET_WRITABLE(x, z) \
Curl_socket_check(CURL_SOCKET_BAD, CURL_SOCKET_BAD, x, z)
int Curl_poll(struct pollfd ufds[], unsigned int nfds, timediff_t timeout_ms);
#ifdef USE_WINSOCK
#define VALID_SOCK(s) ((s) < INVALID_SOCKET)
#define FDSET_SOCK(x) 1
-#define VERIFY_SOCK(x) do { \
- if(!VALID_SOCK(x)) { \
- SET_SOCKERRNO(SOCKEINVAL); \
- return -1; \
- } \
-} while(0)
+#define VERIFY_SOCK(x) \
+ do { \
+ if(!VALID_SOCK(x)) { \
+ SET_SOCKERRNO(SOCKEINVAL); \
+ return -1; \
+ } \
+ } while(0)
#else
#define VALID_SOCK(s) ((s) >= 0)
/* If the socket is small enough to get set or read from an fdset */
#define FDSET_SOCK(s) ((s) < FD_SETSIZE)
-#define VERIFY_SOCK(x) do { \
- if(!VALID_SOCK(x) || !FDSET_SOCK(x)) { \
- SET_SOCKERRNO(SOCKEINVAL); \
- return -1; \
- } \
+#define VERIFY_SOCK(x) \
+ do { \
+ if(!VALID_SOCK(x) || !FDSET_SOCK(x)) { \
+ SET_SOCKERRNO(SOCKEINVAL); \
+ return -1; \
+ } \
} while(0)
#endif
-
/* Keep the sockets to poll for an easy handle.
* `actions` are bitmaps of CURL_POLL_IN and CURL_POLL_OUT.
* Starts with small capacity, grows on demand.
*/
-#define EZ_POLLSET_DEF_COUNT 2
+#define EZ_POLLSET_DEF_COUNT 2
struct easy_pollset {
curl_socket_t *sockets;
#define CURL_EASY_POLLSET_MAGIC 0x7a657370
#endif
-
/* allocate and initialise */
struct easy_pollset *Curl_pollset_create(void);
bool do_in, bool do_out) WARN_UNUSED_RESULT;
#define Curl_pollset_add_in(data, ps, sock) \
- Curl_pollset_change((data), (ps), (sock), CURL_POLL_IN, 0)
+ Curl_pollset_change((data), (ps), (sock), CURL_POLL_IN, 0)
#define Curl_pollset_remove_in(data, ps, sock) \
- Curl_pollset_change((data), (ps), (sock), 0, CURL_POLL_IN)
+ Curl_pollset_change((data), (ps), (sock), 0, CURL_POLL_IN)
#define Curl_pollset_add_out(data, ps, sock) \
- Curl_pollset_change((data), (ps), (sock), CURL_POLL_OUT, 0)
+ Curl_pollset_change((data), (ps), (sock), CURL_POLL_OUT, 0)
#define Curl_pollset_remove_out(data, ps, sock) \
- Curl_pollset_change((data), (ps), (sock), 0, CURL_POLL_OUT)
+ Curl_pollset_change((data), (ps), (sock), 0, CURL_POLL_OUT)
#define Curl_pollset_add_inout(data, ps, sock) \
- Curl_pollset_change((data), (ps), (sock), \
- CURL_POLL_IN|CURL_POLL_OUT, 0)
+ Curl_pollset_change((data), (ps), (sock), \
+ CURL_POLL_IN | CURL_POLL_OUT, 0)
#define Curl_pollset_set_in_only(data, ps, sock) \
- Curl_pollset_change((data), (ps), (sock), \
- CURL_POLL_IN, CURL_POLL_OUT)
+ Curl_pollset_change((data), (ps), (sock), \
+ CURL_POLL_IN, CURL_POLL_OUT)
#define Curl_pollset_set_out_only(data, ps, sock) \
- Curl_pollset_change((data), (ps), (sock), \
- CURL_POLL_OUT, CURL_POLL_IN)
+ Curl_pollset_change((data), (ps), (sock), \
+ CURL_POLL_OUT, CURL_POLL_IN)
/* return < = on error, 0 on timeout or how many sockets are ready */
int Curl_pollset_poll(struct Curl_easy *data,
CURLcode result;
/* it is one of those, at least */
- DEBUGASSERT(type & (CLIENTWRITE_BODY|CLIENTWRITE_HEADER|CLIENTWRITE_INFO));
+ DEBUGASSERT(type &
+ (CLIENTWRITE_BODY | CLIENTWRITE_HEADER | CLIENTWRITE_INFO));
/* BODY is only BODY (with optional EOS) */
DEBUGASSERT(!(type & CLIENTWRITE_BODY) ||
- ((type & ~(CLIENTWRITE_BODY|CLIENTWRITE_EOS)) == 0));
+ ((type & ~(CLIENTWRITE_BODY | CLIENTWRITE_EOS)) == 0));
/* INFO is only INFO (with optional EOS) */
DEBUGASSERT(!(type & CLIENTWRITE_INFO) ||
- ((type & ~(CLIENTWRITE_INFO|CLIENTWRITE_EOS)) == 0));
+ ((type & ~(CLIENTWRITE_INFO | CLIENTWRITE_EOS)) == 0));
if(!data->req.writer_stack) {
result = do_init_writer_stack(data);
bool is_connect = !!(type & CLIENTWRITE_CONNECT);
if(!ctx->started_response &&
- !(type & (CLIENTWRITE_INFO|CLIENTWRITE_CONNECT))) {
+ !(type & (CLIENTWRITE_INFO | CLIENTWRITE_CONNECT))) {
Curl_pgrsTime(data, TIMER_STARTTRANSFER);
Curl_rlimit_start(&data->progress.dl.rlimit, curlx_now());
ctx->started_response = TRUE;
}
/* when seekerr == CURL_SEEKFUNC_CANTSEEK (cannot seek to offset) */
do {
- char scratch[4*1024];
+ char scratch[4 * 1024];
size_t readthisamountnow =
(offset - passed > (curl_off_t)sizeof(scratch)) ?
sizeof(scratch) :
struct Curl_creader *reader = NULL;
CURLcode result;
- result = Curl_creader_create(&reader, data, &cr_lc,
- CURL_CR_CONTENT_ENCODE);
+ result = Curl_creader_create(&reader, data, &cr_lc, CURL_CR_CONTENT_ENCODE);
if(!result)
result = Curl_creader_add(data, reader);
return r;
}
return NULL;
-
}
* BODY, INFO and HEADER should not be mixed, as this would lead to
* confusion on how to interpret/format/convert the data.
*/
-#define CLIENTWRITE_BODY (1<<0) /* non-meta information, BODY */
-#define CLIENTWRITE_INFO (1<<1) /* meta information, not a HEADER */
-#define CLIENTWRITE_HEADER (1<<2) /* meta information, HEADER */
-#define CLIENTWRITE_STATUS (1<<3) /* a special status HEADER */
-#define CLIENTWRITE_CONNECT (1<<4) /* a CONNECT related HEADER */
-#define CLIENTWRITE_1XX (1<<5) /* a 1xx response related HEADER */
-#define CLIENTWRITE_TRAILER (1<<6) /* a trailer HEADER */
-#define CLIENTWRITE_EOS (1<<7) /* End Of transfer download Stream */
-#define CLIENTWRITE_0LEN (1<<8) /* write even 0-length buffers */
+#define CLIENTWRITE_BODY (1 << 0) /* non-meta information, BODY */
+#define CLIENTWRITE_INFO (1 << 1) /* meta information, not a HEADER */
+#define CLIENTWRITE_HEADER (1 << 2) /* meta information, HEADER */
+#define CLIENTWRITE_STATUS (1 << 3) /* a special status HEADER */
+#define CLIENTWRITE_CONNECT (1 << 4) /* a CONNECT related HEADER */
+#define CLIENTWRITE_1XX (1 << 5) /* a 1xx response related HEADER */
+#define CLIENTWRITE_TRAILER (1 << 6) /* a trailer HEADER */
+#define CLIENTWRITE_EOS (1 << 7) /* End Of transfer download Stream */
+#define CLIENTWRITE_0LEN (1 << 8) /* write even 0-length buffers */
/* Forward declarations */
struct Curl_creader;
void Curl_cwriter_def_close(struct Curl_easy *data,
struct Curl_cwriter *writer);
-
typedef enum {
CURL_CRCNTRL_REWIND,
CURL_CRCNTRL_UNPAUSE,
struct Curl_creader *Curl_creader_get_by_type(struct Curl_easy *data,
const struct Curl_crtype *crt);
-
/**
* Set the client reader to provide 0 bytes, immediate EOS.
*/
{
if(secs < 0)
return CURLE_BAD_FUNCTION_ARGUMENT;
-#if LONG_MAX > (TIMEDIFF_T_MAX/1000)
- if(secs > (TIMEDIFF_T_MAX/1000)) {
+#if LONG_MAX > (TIMEDIFF_T_MAX / 1000)
+ if(secs > (TIMEDIFF_T_MAX / 1000)) {
*ptimeout_ms = TIMEDIFF_T_MAX;
return CURLE_OK;
}
return CURLE_OK;
}
-#define C_SSLVERSION_VALUE(x) (x & 0xffff)
+#define C_SSLVERSION_VALUE(x) (x & 0xffff)
#define C_SSLVERSION_MAX_VALUE(x) ((unsigned long)x & 0xffff0000)
static CURLcode protocol2num(const char *str, curl_prot_t *val)
return CURLE_BAD_FUNCTION_ARGUMENT;
if(curl_strequal(str, "all")) {
- *val = ~(curl_prot_t) 0;
+ *val = ~(curl_prot_t)0;
return CURLE_OK;
}
size_t tlen;
str = strchr(str, ',');
- tlen = str ? (size_t) (str - token) : strlen(token);
+ tlen = str ? (size_t)(str - token) : strlen(token);
if(tlen) {
const struct Curl_handler *h = Curl_getn_scheme_handler(token, tlen);
/* switch off bits we cannot support */
#ifndef USE_NTLM
- auth &= ~CURLAUTH_NTLM; /* no NTLM support */
+ auth &= ~CURLAUTH_NTLM; /* no NTLM support */
#endif
#ifndef USE_SPNEGO
auth &= ~CURLAUTH_NEGOTIATE; /* no Negotiate (SPNEGO) auth without GSS-API
case CURLOPT_SSL_SESSIONID_CACHE:
s->ssl.primary.cache_session = enabled;
#ifndef CURL_DISABLE_PROXY
- s->proxy_ssl.primary.cache_session =
- s->ssl.primary.cache_session;
+ s->proxy_ssl.primary.cache_session = s->ssl.primary.cache_session;
#endif
break;
#ifdef USE_SSH
s->tcp_keepalive = enabled;
break;
case CURLOPT_TCP_FASTOPEN:
-#if defined(CONNECT_DATA_IDEMPOTENT) || defined(MSG_FASTOPEN) || \
+#if defined(CONNECT_DATA_IDEMPOTENT) || defined(MSG_FASTOPEN) || \
defined(TCP_FASTOPEN_CONNECT)
s->tcp_fastopen = enabled;
break;
#ifdef HAVE_GSSAPI
case CURLOPT_GSSAPI_DELEGATION:
s->gssapi_delegation = (unsigned char)uarg &
- (CURLGSSAPI_DELEGATION_POLICY_FLAG|CURLGSSAPI_DELEGATION_FLAG);
+ (CURLGSSAPI_DELEGATION_POLICY_FLAG | CURLGSSAPI_DELEGATION_FLAG);
break;
#endif
case CURLOPT_IPRESOLVE:
if((arg < CURL_IPRESOLVE_WHATEVER) || (arg > CURL_IPRESOLVE_V6))
return CURLE_BAD_FUNCTION_ARGUMENT;
- s->ipver = (unsigned char) arg;
+ s->ipver = (unsigned char)arg;
break;
case CURLOPT_CONNECT_ONLY:
break;
#endif /* ! CURL_DISABLE_FORM_API */
#endif /* ! CURL_DISABLE_HTTP */
-#if !defined(CURL_DISABLE_HTTP) || !defined(CURL_DISABLE_SMTP) || \
- !defined(CURL_DISABLE_IMAP)
+#if !defined(CURL_DISABLE_HTTP) || !defined(CURL_DISABLE_SMTP) || \
+ !defined(CURL_DISABLE_IMAP)
# ifndef CURL_DISABLE_MIME
case CURLOPT_MIMEPOST:
/*
if(!s->err)
s->err = stderr;
break;
- case CURLOPT_SHARE:
- {
+ case CURLOPT_SHARE: {
struct Curl_share *set = va_arg(param, struct Curl_share *);
/* disconnect from old share, if any */
/* enable cookies since we now use a share that uses cookies! */
data->cookies = data->share->cookies;
}
-#endif /* CURL_DISABLE_HTTP */
+#endif /* CURL_DISABLE_HTTP */
#ifndef CURL_DISABLE_HSTS
if(data->share->hsts) {
/* first free the private one if any */
}
/* check for host cache not needed,
* it will be done by curl_easy_perform */
+ break;
}
- break;
#ifdef USE_HTTP2
case CURLOPT_STREAM_DEPENDS:
}
#ifndef CURL_DISABLE_COOKIES
-static CURLcode cookielist(struct Curl_easy *data,
- const char *ptr)
+static CURLcode cookielist(struct Curl_easy *data, const char *ptr)
{
CURLcode result = CURLE_OK;
if(!ptr)
return result;
}
-static CURLcode cookiefile(struct Curl_easy *data,
- const char *ptr)
+static CURLcode cookiefile(struct Curl_easy *data, const char *ptr)
{
/*
* Set cookie file to read and parse. Can be used multiple times.
case CURLOPT_PROXY_SSL_CIPHER_LIST:
if(Curl_ssl_supports(data, SSLSUPP_CIPHER_LIST)) {
/* set a list of cipher we want to use in the SSL connection for proxy */
- return Curl_setstropt(&s->str[STRING_SSL_CIPHER_LIST_PROXY],
- ptr);
+ return Curl_setstropt(&s->str[STRING_SSL_CIPHER_LIST_PROXY], ptr);
}
else
return CURLE_NOT_BUILT_IN;
case CURLOPT_PROXY_TLS13_CIPHERS:
if(Curl_ssl_supports(data, SSLSUPP_TLS13_CIPHERSUITES))
/* set preferred list of TLS 1.3 cipher suites for proxy */
- return Curl_setstropt(&s->str[STRING_SSL_CIPHER13_LIST_PROXY],
- ptr);
+ return Curl_setstropt(&s->str[STRING_SSL_CIPHER13_LIST_PROXY], ptr);
else
return CURLE_NOT_BUILT_IN;
#endif
* to use the socks proxy.
*/
return Curl_setstropt(&s->str[STRING_PRE_PROXY], ptr);
-#endif /* CURL_DISABLE_PROXY */
+#endif /* CURL_DISABLE_PROXY */
#ifndef CURL_DISABLE_PROXY
case CURLOPT_SOCKS5_GSSAPI_SERVICE:
}
curlx_free(u);
curlx_free(p);
- }
break;
+ }
case CURLOPT_PROXYUSERNAME:
/*
* authentication username to use in the operation
*/
#ifdef USE_SSL
if(Curl_ssl_supports(data, SSLSUPP_PINNEDPUBKEY))
- return Curl_setstropt(&s->str[STRING_SSL_PINNEDPUBLICKEY_PROXY],
- ptr);
+ return Curl_setstropt(&s->str[STRING_SSL_PINNEDPUBLICKEY_PROXY], ptr);
#endif
return CURLE_NOT_BUILT_IN;
#endif
* Specify colon-delimited list of signature scheme names.
*/
if(Curl_ssl_supports(data, SSLSUPP_SIGNATURE_ALGORITHMS))
- return Curl_setstropt(&s->str[STRING_SSL_SIGNATURE_ALGORITHMS],
- ptr);
+ return Curl_setstropt(&s->str[STRING_SSL_SIGNATURE_ALGORITHMS], ptr);
return CURLE_NOT_BUILT_IN;
#endif
#ifdef USE_SSH
* Option to allow for the SHA256 of the host public key to be checked
* for validation purposes.
*/
- return Curl_setstropt(&s->str[STRING_SSH_HOST_PUBLIC_KEY_SHA256],
- ptr);
+ return Curl_setstropt(&s->str[STRING_SSH_HOST_PUBLIC_KEY_SHA256], ptr);
case CURLOPT_SSH_HOSTKEYDATA:
/*
}
else
/* make a NULL argument reset to default */
- s->allowed_protocols = (curl_prot_t) CURLPROTO_ALL;
+ s->allowed_protocols = (curl_prot_t)CURLPROTO_ALL;
break;
case CURLOPT_REDIR_PROTOCOLS_STR:
}
else
/* make a NULL argument reset to default */
- s->redir_protocols = (curl_prot_t) CURLPROTO_REDIR;
+ s->redir_protocols = (curl_prot_t)CURLPROTO_REDIR;
break;
case CURLOPT_DEFAULT_PROTOCOL:
}
/* set tls_ech flag value, preserving CLA_CFG bit */
if(!strcmp(ptr, "false"))
- s->tls_ech = CURLECH_DISABLE |
- (s->tls_ech & CURLECH_CLA_CFG);
+ s->tls_ech = (s->tls_ech & CURLECH_CLA_CFG) | CURLECH_DISABLE;
else if(!strcmp(ptr, "grease"))
- s->tls_ech = CURLECH_GREASE |
- (s->tls_ech & CURLECH_CLA_CFG);
+ s->tls_ech = (s->tls_ech & CURLECH_CLA_CFG) | CURLECH_GREASE;
else if(!strcmp(ptr, "true"))
- s->tls_ech = CURLECH_ENABLE |
- (s->tls_ech & CURLECH_CLA_CFG);
+ s->tls_ech = (s->tls_ech & CURLECH_CLA_CFG) | CURLECH_ENABLE;
else if(!strcmp(ptr, "hard"))
- s->tls_ech = CURLECH_HARD |
- (s->tls_ech & CURLECH_CLA_CFG);
+ s->tls_ech = (s->tls_ech & CURLECH_CLA_CFG) | CURLECH_HARD;
else if(plen > 5 && !strncmp(ptr, "ecl:", 4)) {
result = Curl_setstropt(&s->str[STRING_ECH_CONFIG], ptr + 4);
if(result)
/*
* Blob that holds Issuer certificate to check certificates issuer
*/
- return Curl_setblobopt(&s->blobs[BLOB_SSL_ISSUERCERT_PROXY],
- blob);
+ return Curl_setblobopt(&s->blobs[BLOB_SSL_ISSUERCERT_PROXY], blob);
#endif
case CURLOPT_SSLKEY_BLOB:
/*
CURLcode Curl_setopt_SSLVERSION(struct Curl_easy *data, CURLoption option,
long arg);
#else
-#define Curl_setopt_SSLVERSION(a,b,c) CURLE_NOT_BUILT_IN
+#define Curl_setopt_SSLVERSION(a, b, c) CURLE_NOT_BUILT_IN
#endif
CURLcode Curl_setstropt(char **charp, const char *s) WARN_UNUSED_RESULT;
*
***************************************************************************/
-
/* OS/400 netdb.h does not define NI_MAXHOST. */
#define NI_MAXHOST 1025
/* OS/400 has no idea of a tty! */
#define isatty(fd) 0
-
/* Workaround bug in IBM QADRT runtime library:
* function puts() does not output the implicit trailing newline.
*/
#include <stdio.h> /* Be sure it is loaded. */
#undef puts
-#define puts(s) (fputs((s), stdout) == EOF? EOF: putchar('\n'))
-
+#define puts(s) (fputs((s), stdout) == EOF ? EOF : putchar('\n'))
/* System API wrapper prototypes & definitions to support ASCII parameters. */
#define gss_init_sec_context Curl_gss_init_sec_context_a
-extern OM_uint32 Curl_gss_delete_sec_context_a(OM_uint32 * minor_status,
- gss_ctx_id_t * context_handle,
+extern OM_uint32 Curl_gss_delete_sec_context_a(OM_uint32 *minor_status,
+ gss_ctx_id_t *context_handle,
gss_buffer_t output_token);
#define gss_delete_sec_context Curl_gss_delete_sec_context_a
/* Hide the stuff we are overriding */
#define getenv decc_getenv
#ifdef __DECC
-# if __INITIAL_POINTER_SIZE != 64
-# define getpwuid decc_getpwuid
-# endif
+# if __INITIAL_POINTER_SIZE != 64
+# define getpwuid decc_getpwuid
+# endif
#endif
#include <stdlib.h>
char *decc$getenv(const char *__name);
#undef getenv
#undef getpwuid
-#define getenv vms_getenv
+#define getenv vms_getenv
#define getpwuid vms_getpwuid
/* VAX needs these in upper case when compiling exact case */
#define sys$assign SYS$ASSIGN
#define sys$dassgn SYS$DASSGN
-#define sys$qiow SYS$QIOW
+#define sys$qiow SYS$QIOW
#ifdef __DECC
-# if __INITIAL_POINTER_SIZE
-# pragma __pointer_size __save
-# endif
+# if __INITIAL_POINTER_SIZE
+# pragma __pointer_size __save
+# endif
#endif
#if __USE_LONG_GID_T
-# define decc_getpwuid DECC$__LONG_GID_GETPWUID
+# define decc_getpwuid DECC$__LONG_GID_GETPWUID
#else
-# if __INITIAL_POINTER_SIZE
-# define decc_getpwuid decc$__32_getpwuid
-# else
-# define decc_getpwuid decc$getpwuid
-# endif
+# if __INITIAL_POINTER_SIZE
+# define decc_getpwuid decc$__32_getpwuid
+# else
+# define decc_getpwuid decc$getpwuid
+# endif
#endif
- struct passwd *decc_getpwuid(uid_t uid);
+struct passwd *decc_getpwuid(uid_t uid);
#ifdef __DECC
-# if __INITIAL_POINTER_SIZE == 32
+# if __INITIAL_POINTER_SIZE == 32
/* Translate the path, but only if the path is a VMS file specification */
/* The translation is usually only needed for older versions of VMS */
static char *vms_translate_path(const char *path)
return (char *)path;
}
}
-# else
- /* VMS translate path is actually not needed on the current 64-bit */
- /* VMS platforms, so instead of figuring out the pointer settings */
- /* Change it to a noop */
-# define vms_translate_path(__path) __path
-# endif
+# else
+ /* VMS translate path is actually not needed on the current 64-bit */
+ /* VMS platforms, so instead of figuring out the pointer settings */
+ /* Change it to a noop */
+# define vms_translate_path(__path) __path
+# endif
#endif
#ifdef __DECC
-# if __INITIAL_POINTER_SIZE
-# pragma __pointer_size __restore
-# endif
+# if __INITIAL_POINTER_SIZE
+# pragma __pointer_size __restore
+# endif
#endif
static char *vms_getenv(const char *envvar)
return result;
}
-
static struct passwd vms_passwd_cache;
static struct passwd *vms_getpwuid(uid_t uid)
/* Hack needed to support 64-bit builds, decc_getpwnam is 32-bit only */
#ifdef __DECC
-# if __INITIAL_POINTER_SIZE
+# if __INITIAL_POINTER_SIZE
__char_ptr32 unix_path;
-# else
+# else
char *unix_path;
-# endif
+# endif
#else
char *unix_path;
#endif
/* Bug - VMS OpenSSL and Kerberos universal symbols are in uppercase only */
/* VMS libraries should have universal symbols in exact and uppercase */
-#define ASN1_INTEGER_get ASN1_INTEGER_GET
-#define ASN1_STRING_data ASN1_STRING_DATA
-#define ASN1_STRING_length ASN1_STRING_LENGTH
-#define ASN1_STRING_print ASN1_STRING_PRINT
-#define ASN1_STRING_to_UTF8 ASN1_STRING_TO_UTF8
-#define ASN1_STRING_type ASN1_STRING_TYPE
-#define BIO_ctrl BIO_CTRL
-#define BIO_free BIO_FREE
-#define BIO_new BIO_NEW
-#define BIO_s_mem BIO_S_MEM
-#define BN_bn2bin BN_BN2BIN
-#define BN_num_bits BN_NUM_BITS
+#define ASN1_INTEGER_get ASN1_INTEGER_GET
+#define ASN1_STRING_data ASN1_STRING_DATA
+#define ASN1_STRING_length ASN1_STRING_LENGTH
+#define ASN1_STRING_print ASN1_STRING_PRINT
+#define ASN1_STRING_to_UTF8 ASN1_STRING_TO_UTF8
+#define ASN1_STRING_type ASN1_STRING_TYPE
+#define BIO_ctrl BIO_CTRL
+#define BIO_free BIO_FREE
+#define BIO_new BIO_NEW
+#define BIO_s_mem BIO_S_MEM
+#define BN_bn2bin BN_BN2BIN
+#define BN_num_bits BN_NUM_BITS
#define CRYPTO_cleanup_all_ex_data CRYPTO_CLEANUP_ALL_EX_DATA
-#define CRYPTO_free CRYPTO_FREE
-#define CRYPTO_malloc CRYPTO_MALLOC
-#define CONF_modules_load_file CONF_MODULES_LOAD_FILE
+#define CRYPTO_free CRYPTO_FREE
+#define CRYPTO_malloc CRYPTO_MALLOC
+#define CONF_modules_load_file CONF_MODULES_LOAD_FILE
#ifdef __VAX
# ifdef VMS_OLD_SSL
/* Ancient OpenSSL on VAX/VMS missing this constant */
# define CONF_MFLAGS_IGNORE_MISSING_FILE 0x10
# undef CONF_modules_load_file
- static int CONF_modules_load_file(const char *filename,
- const char *appname,
- unsigned long flags) {
- return 1;
- }
+static int CONF_modules_load_file(const char *filename,
+ const char *appname,
+ unsigned long flags) {
+ return 1;
+}
# endif
#endif
-#define DES_ecb_encrypt DES_ECB_ENCRYPT
-#define DES_set_key DES_SET_KEY
-#define DES_set_odd_parity DES_SET_ODD_PARITY
-#define ENGINE_ctrl ENGINE_CTRL
-#define ENGINE_ctrl_cmd ENGINE_CTRL_CMD
-#define ENGINE_finish ENGINE_FINISH
-#define ENGINE_free ENGINE_FREE
-#define ENGINE_get_first ENGINE_GET_FIRST
-#define ENGINE_get_id ENGINE_GET_ID
-#define ENGINE_get_next ENGINE_GET_NEXT
-#define ENGINE_init ENGINE_INIT
+#define DES_ecb_encrypt DES_ECB_ENCRYPT
+#define DES_set_key DES_SET_KEY
+#define DES_set_odd_parity DES_SET_ODD_PARITY
+#define ENGINE_ctrl ENGINE_CTRL
+#define ENGINE_ctrl_cmd ENGINE_CTRL_CMD
+#define ENGINE_finish ENGINE_FINISH
+#define ENGINE_free ENGINE_FREE
+#define ENGINE_get_first ENGINE_GET_FIRST
+#define ENGINE_get_id ENGINE_GET_ID
+#define ENGINE_get_next ENGINE_GET_NEXT
+#define ENGINE_init ENGINE_INIT
#define ENGINE_load_builtin_engines ENGINE_LOAD_BUILTIN_ENGINES
-#define ENGINE_load_private_key ENGINE_LOAD_PRIVATE_KEY
-#define ENGINE_set_default ENGINE_SET_DEFAULT
-#define ERR_clear_error ERR_CLEAR_ERROR
-#define ERR_error_string ERR_ERROR_STRING
-#define ERR_error_string_n ERR_ERROR_STRING_N
-#define ERR_free_strings ERR_FREE_STRINGS
-#define ERR_get_error ERR_GET_ERROR
-#define ERR_peek_error ERR_PEEK_ERROR
-#define ERR_remove_state ERR_REMOVE_STATE
-#define EVP_PKEY_copy_parameters EVP_PKEY_COPY_PARAMETERS
-#define EVP_PKEY_free EVP_PKEY_FREE
-#define EVP_cleanup EVP_CLEANUP
-#define GENERAL_NAMES_free GENERAL_NAMES_FREE
-#define i2d_X509_PUBKEY I2D_X509_PUBKEY
-#define MD4_Final MD4_FINAL
-#define MD4_Init MD4_INIT
-#define MD4_Update MD4_UPDATE
-#define MD5_Final MD5_FINAL
-#define MD5_Init MD5_INIT
-#define MD5_Update MD5_UPDATE
+#define ENGINE_load_private_key ENGINE_LOAD_PRIVATE_KEY
+#define ENGINE_set_default ENGINE_SET_DEFAULT
+#define ERR_clear_error ERR_CLEAR_ERROR
+#define ERR_error_string ERR_ERROR_STRING
+#define ERR_error_string_n ERR_ERROR_STRING_N
+#define ERR_free_strings ERR_FREE_STRINGS
+#define ERR_get_error ERR_GET_ERROR
+#define ERR_peek_error ERR_PEEK_ERROR
+#define ERR_remove_state ERR_REMOVE_STATE
+#define EVP_PKEY_copy_parameters EVP_PKEY_COPY_PARAMETERS
+#define EVP_PKEY_free EVP_PKEY_FREE
+#define EVP_cleanup EVP_CLEANUP
+#define GENERAL_NAMES_free GENERAL_NAMES_FREE
+#define i2d_X509_PUBKEY I2D_X509_PUBKEY
+#define MD4_Final MD4_FINAL
+#define MD4_Init MD4_INIT
+#define MD4_Update MD4_UPDATE
+#define MD5_Final MD5_FINAL
+#define MD5_Init MD5_INIT
+#define MD5_Update MD5_UPDATE
#define OPENSSL_add_all_algo_noconf OPENSSL_ADD_ALL_ALGO_NOCONF
#ifndef __VAX
#define OPENSSL_load_builtin_modules OPENSSL_LOAD_BUILTIN_MODULES
#endif
-#define PEM_read_X509 PEM_READ_X509
-#define PEM_write_bio_X509 PEM_WRITE_BIO_X509
-#define PKCS12_free PKCS12_FREE
-#define PKCS12_parse PKCS12_PARSE
-#define RAND_add RAND_ADD
-#define RAND_bytes RAND_BYTES
-#define RAND_file_name RAND_FILE_NAME
-#define RAND_load_file RAND_LOAD_FILE
-#define RAND_status RAND_STATUS
-#define SSL_CIPHER_get_name SSL_CIPHER_GET_NAME
-#define SSL_CTX_add_client_CA SSL_CTX_ADD_CLIENT_CA
-#define SSL_CTX_callback_ctrl SSL_CTX_CALLBACK_CTRL
-#define SSL_CTX_check_private_key SSL_CTX_CHECK_PRIVATE_KEY
-#define SSL_CTX_ctrl SSL_CTX_CTRL
-#define SSL_CTX_free SSL_CTX_FREE
-#define SSL_CTX_get_cert_store SSL_CTX_GET_CERT_STORE
-#define SSL_CTX_load_verify_locations SSL_CTX_LOAD_VERIFY_LOCATIONS
-#define SSL_CTX_new SSL_CTX_NEW
-#define SSL_CTX_set_cipher_list SSL_CTX_SET_CIPHER_LIST
-#define SSL_CTX_set_def_passwd_cb_ud SSL_CTX_SET_DEF_PASSWD_CB_UD
-#define SSL_CTX_set_default_passwd_cb SSL_CTX_SET_DEFAULT_PASSWD_CB
-#define SSL_CTX_set_msg_callback SSL_CTX_SET_MSG_CALLBACK
-#define SSL_CTX_set_verify SSL_CTX_SET_VERIFY
-#define SSL_CTX_use_PrivateKey SSL_CTX_USE_PRIVATEKEY
-#define SSL_CTX_use_PrivateKey_file SSL_CTX_USE_PRIVATEKEY_FILE
-#define SSL_CTX_use_cert_chain_file SSL_CTX_USE_CERT_CHAIN_FILE
-#define SSL_CTX_use_certificate SSL_CTX_USE_CERTIFICATE
-#define SSL_CTX_use_certificate_file SSL_CTX_USE_CERTIFICATE_FILE
-#define SSL_SESSION_free SSL_SESSION_FREE
-#define SSL_connect SSL_CONNECT
-#define SSL_free SSL_FREE
-#define SSL_get1_session SSL_GET1_SESSION
-#define SSL_get_certificate SSL_GET_CERTIFICATE
-#define SSL_get_current_cipher SSL_GET_CURRENT_CIPHER
-#define SSL_get_error SSL_GET_ERROR
-#define SSL_get_peer_cert_chain SSL_GET_PEER_CERT_CHAIN
-#define SSL_get_peer_certificate SSL_GET_PEER_CERTIFICATE
-#define SSL_get_privatekey SSL_GET_PRIVATEKEY
-#define SSL_get_session SSL_GET_SESSION
-#define SSL_get_shutdown SSL_GET_SHUTDOWN
-#define SSL_get_verify_result SSL_GET_VERIFY_RESULT
-#define SSL_library_init SSL_LIBRARY_INIT
-#define SSL_load_error_strings SSL_LOAD_ERROR_STRINGS
-#define SSL_new SSL_NEW
-#define SSL_peek SSL_PEEK
-#define SSL_pending SSL_PENDING
-#define SSL_read SSL_READ
-#define SSL_set_connect_state SSL_SET_CONNECT_STATE
-#define SSL_set_fd SSL_SET_FD
-#define SSL_set_session SSL_SET_SESSION
-#define SSL_shutdown SSL_SHUTDOWN
-#define SSL_version SSL_VERSION
-#define SSL_write SSL_WRITE
-#define SSLeay SSLEAY
-#define SSLv23_client_method SSLV23_CLIENT_METHOD
-#define SSLv3_client_method SSLV3_CLIENT_METHOD
-#define TLSv1_client_method TLSV1_CLIENT_METHOD
-#define UI_create_method UI_CREATE_METHOD
-#define UI_destroy_method UI_DESTROY_METHOD
-#define UI_get0_user_data UI_GET0_USER_DATA
-#define UI_get_input_flags UI_GET_INPUT_FLAGS
-#define UI_get_string_type UI_GET_STRING_TYPE
-#define UI_create_method UI_CREATE_METHOD
-#define UI_destroy_method UI_DESTROY_METHOD
-#define UI_method_get_closer UI_METHOD_GET_CLOSER
-#define UI_method_get_opener UI_METHOD_GET_OPENER
-#define UI_method_get_reader UI_METHOD_GET_READER
-#define UI_method_get_writer UI_METHOD_GET_WRITER
-#define UI_method_set_closer UI_METHOD_SET_CLOSER
-#define UI_method_set_opener UI_METHOD_SET_OPENER
-#define UI_method_set_reader UI_METHOD_SET_READER
-#define UI_method_set_writer UI_METHOD_SET_WRITER
-#define UI_OpenSSL UI_OPENSSL
-#define UI_set_result UI_SET_RESULT
-#define X509V3_EXT_print X509V3_EXT_PRINT
-#define X509_EXTENSION_get_critical X509_EXTENSION_GET_CRITICAL
-#define X509_EXTENSION_get_data X509_EXTENSION_GET_DATA
-#define X509_EXTENSION_get_object X509_EXTENSION_GET_OBJECT
-#define X509_LOOKUP_file X509_LOOKUP_FILE
-#define X509_NAME_ENTRY_get_data X509_NAME_ENTRY_GET_DATA
-#define X509_NAME_get_entry X509_NAME_GET_ENTRY
-#define X509_NAME_get_index_by_NID X509_NAME_GET_INDEX_BY_NID
-#define X509_NAME_print_ex X509_NAME_PRINT_EX
+#define PEM_read_X509 PEM_READ_X509
+#define PEM_write_bio_X509 PEM_WRITE_BIO_X509
+#define PKCS12_free PKCS12_FREE
+#define PKCS12_parse PKCS12_PARSE
+#define RAND_add RAND_ADD
+#define RAND_bytes RAND_BYTES
+#define RAND_file_name RAND_FILE_NAME
+#define RAND_load_file RAND_LOAD_FILE
+#define RAND_status RAND_STATUS
+#define SSL_CIPHER_get_name SSL_CIPHER_GET_NAME
+#define SSL_CTX_add_client_CA SSL_CTX_ADD_CLIENT_CA
+#define SSL_CTX_callback_ctrl SSL_CTX_CALLBACK_CTRL
+#define SSL_CTX_check_private_key SSL_CTX_CHECK_PRIVATE_KEY
+#define SSL_CTX_ctrl SSL_CTX_CTRL
+#define SSL_CTX_free SSL_CTX_FREE
+#define SSL_CTX_get_cert_store SSL_CTX_GET_CERT_STORE
+#define SSL_CTX_load_verify_locations SSL_CTX_LOAD_VERIFY_LOCATIONS
+#define SSL_CTX_new SSL_CTX_NEW
+#define SSL_CTX_set_cipher_list SSL_CTX_SET_CIPHER_LIST
+#define SSL_CTX_set_def_passwd_cb_ud SSL_CTX_SET_DEF_PASSWD_CB_UD
+#define SSL_CTX_set_default_passwd_cb SSL_CTX_SET_DEFAULT_PASSWD_CB
+#define SSL_CTX_set_msg_callback SSL_CTX_SET_MSG_CALLBACK
+#define SSL_CTX_set_verify SSL_CTX_SET_VERIFY
+#define SSL_CTX_use_PrivateKey SSL_CTX_USE_PRIVATEKEY
+#define SSL_CTX_use_PrivateKey_file SSL_CTX_USE_PRIVATEKEY_FILE
+#define SSL_CTX_use_cert_chain_file SSL_CTX_USE_CERT_CHAIN_FILE
+#define SSL_CTX_use_certificate SSL_CTX_USE_CERTIFICATE
+#define SSL_CTX_use_certificate_file SSL_CTX_USE_CERTIFICATE_FILE
+#define SSL_SESSION_free SSL_SESSION_FREE
+#define SSL_connect SSL_CONNECT
+#define SSL_free SSL_FREE
+#define SSL_get1_session SSL_GET1_SESSION
+#define SSL_get_certificate SSL_GET_CERTIFICATE
+#define SSL_get_current_cipher SSL_GET_CURRENT_CIPHER
+#define SSL_get_error SSL_GET_ERROR
+#define SSL_get_peer_cert_chain SSL_GET_PEER_CERT_CHAIN
+#define SSL_get_peer_certificate SSL_GET_PEER_CERTIFICATE
+#define SSL_get_privatekey SSL_GET_PRIVATEKEY
+#define SSL_get_session SSL_GET_SESSION
+#define SSL_get_shutdown SSL_GET_SHUTDOWN
+#define SSL_get_verify_result SSL_GET_VERIFY_RESULT
+#define SSL_library_init SSL_LIBRARY_INIT
+#define SSL_load_error_strings SSL_LOAD_ERROR_STRINGS
+#define SSL_new SSL_NEW
+#define SSL_peek SSL_PEEK
+#define SSL_pending SSL_PENDING
+#define SSL_read SSL_READ
+#define SSL_set_connect_state SSL_SET_CONNECT_STATE
+#define SSL_set_fd SSL_SET_FD
+#define SSL_set_session SSL_SET_SESSION
+#define SSL_shutdown SSL_SHUTDOWN
+#define SSL_version SSL_VERSION
+#define SSL_write SSL_WRITE
+#define SSLeay SSLEAY
+#define SSLv23_client_method SSLV23_CLIENT_METHOD
+#define SSLv3_client_method SSLV3_CLIENT_METHOD
+#define TLSv1_client_method TLSV1_CLIENT_METHOD
+#define UI_create_method UI_CREATE_METHOD
+#define UI_destroy_method UI_DESTROY_METHOD
+#define UI_get0_user_data UI_GET0_USER_DATA
+#define UI_get_input_flags UI_GET_INPUT_FLAGS
+#define UI_get_string_type UI_GET_STRING_TYPE
+#define UI_create_method UI_CREATE_METHOD
+#define UI_destroy_method UI_DESTROY_METHOD
+#define UI_method_get_closer UI_METHOD_GET_CLOSER
+#define UI_method_get_opener UI_METHOD_GET_OPENER
+#define UI_method_get_reader UI_METHOD_GET_READER
+#define UI_method_get_writer UI_METHOD_GET_WRITER
+#define UI_method_set_closer UI_METHOD_SET_CLOSER
+#define UI_method_set_opener UI_METHOD_SET_OPENER
+#define UI_method_set_reader UI_METHOD_SET_READER
+#define UI_method_set_writer UI_METHOD_SET_WRITER
+#define UI_OpenSSL UI_OPENSSL
+#define UI_set_result UI_SET_RESULT
+#define X509V3_EXT_print X509V3_EXT_PRINT
+#define X509_EXTENSION_get_critical X509_EXTENSION_GET_CRITICAL
+#define X509_EXTENSION_get_data X509_EXTENSION_GET_DATA
+#define X509_EXTENSION_get_object X509_EXTENSION_GET_OBJECT
+#define X509_LOOKUP_file X509_LOOKUP_FILE
+#define X509_NAME_ENTRY_get_data X509_NAME_ENTRY_GET_DATA
+#define X509_NAME_get_entry X509_NAME_GET_ENTRY
+#define X509_NAME_get_index_by_NID X509_NAME_GET_INDEX_BY_NID
+#define X509_NAME_print_ex X509_NAME_PRINT_EX
#define X509_STORE_CTX_get_current_cert X509_STORE_CTX_GET_CURRENT_CERT
-#define X509_STORE_add_lookup X509_STORE_ADD_LOOKUP
-#define X509_STORE_set_flags X509_STORE_SET_FLAGS
-#define X509_check_issued X509_CHECK_ISSUED
-#define X509_free X509_FREE
-#define X509_get_ext_d2i X509_GET_EXT_D2I
-#define X509_get_issuer_name X509_GET_ISSUER_NAME
-#define X509_get_pubkey X509_GET_PUBKEY
-#define X509_get_serialNumber X509_GET_SERIALNUMBER
-#define X509_get_subject_name X509_GET_SUBJECT_NAME
-#define X509_load_crl_file X509_LOAD_CRL_FILE
-#define X509_verify_cert_error_string X509_VERIFY_CERT_ERROR_STRING
-#define d2i_PKCS12_fp D2I_PKCS12_FP
-#define i2t_ASN1_OBJECT I2T_ASN1_OBJECT
-#define sk_num SK_NUM
-#define sk_pop SK_POP
-#define sk_pop_free SK_POP_FREE
-#define sk_value SK_VALUE
+#define X509_STORE_add_lookup X509_STORE_ADD_LOOKUP
+#define X509_STORE_set_flags X509_STORE_SET_FLAGS
+#define X509_check_issued X509_CHECK_ISSUED
+#define X509_free X509_FREE
+#define X509_get_ext_d2i X509_GET_EXT_D2I
+#define X509_get_issuer_name X509_GET_ISSUER_NAME
+#define X509_get_pubkey X509_GET_PUBKEY
+#define X509_get_serialNumber X509_GET_SERIALNUMBER
+#define X509_get_subject_name X509_GET_SUBJECT_NAME
+#define X509_load_crl_file X509_LOAD_CRL_FILE
+#define X509_verify_cert_error_string X509_VERIFY_CERT_ERROR_STRING
+#define d2i_PKCS12_fp D2I_PKCS12_FP
+#define i2t_ASN1_OBJECT I2T_ASN1_OBJECT
+#define sk_num SK_NUM
+#define sk_pop SK_POP
+#define sk_pop_free SK_POP_FREE
+#define sk_value SK_VALUE
#ifdef __VAX
#define OPENSSL_NO_SHA256
#endif
-#define SHA256_Final SHA256_FINAL
-#define SHA256_Init SHA256_INIT
+#define SHA256_Final SHA256_FINAL
+#define SHA256_Init SHA256_INIT
#define SHA256_Update SHA256_UPDATE
#define USE_UPPERCASE_GSSAPI 1
-#define gss_seal GSS_SEAL
-#define gss_unseal GSS_UNSEAL
+#define gss_seal GSS_SEAL
+#define gss_unseal GSS_UNSEAL
#define USE_UPPERCASE_KRBAPI 1
/* VAX symbols are always in uppercase */
#ifdef __VAX
-#define inflate INFLATE
-#define inflateEnd INFLATEEND
+#define inflate INFLATE
+#define inflateEnd INFLATEEND
#define inflateInit2_ INFLATEINIT2_
-#define inflateInit_ INFLATEINIT_
-#define zlibVersion ZLIBVERSION
+#define inflateInit_ INFLATEINIT_
+#define zlibVersion ZLIBVERSION
#endif
/* Older VAX OpenSSL port defines these as Macros */
/* that way a newer port will also work if some one has one */
#ifdef __VAX
-# include <openssl/evp.h>
-# ifndef OpenSSL_add_all_algorithms
-# define OpenSSL_add_all_algorithms OPENSSL_ADD_ALL_ALGORITHMS
- void OPENSSL_ADD_ALL_ALGORITHMS(void);
-# endif
+# include <openssl/evp.h>
+# ifndef OpenSSL_add_all_algorithms
+# define OpenSSL_add_all_algorithms OPENSSL_ADD_ALL_ALGORITHMS
+ void OPENSSL_ADD_ALL_ALGORITHMS(void);
+# endif
#endif
#endif /* HEADER_CURL_SETUP_VMS_H */
{
my_sha256_ctx *ctx = (my_sha256_ctx *)in;
if(!CryptAcquireContext(&ctx->hCryptProv, NULL, NULL, PROV_RSA_AES,
- CRYPT_VERIFYCONTEXT | CRYPT_SILENT))
+ CRYPT_VERIFYCONTEXT | CRYPT_SILENT))
return CURLE_OUT_OF_MEMORY;
if(!CryptCreateHash(ctx->hCryptProv, CALG_SHA_256, 0, 0, &ctx->hHash)) {
/* This is based on the SHA256 implementation in LibTomCrypt that was released
* into public domain. */
-#define WPA_GET_BE32(a) ((((unsigned long)(a)[0]) << 24) | \
- (((unsigned long)(a)[1]) << 16) | \
- (((unsigned long)(a)[2]) << 8) | \
- ((unsigned long)(a)[3]))
-#define WPA_PUT_BE32(a, val) \
-do { \
- (a)[0] = (unsigned char)((((unsigned long) (val)) >> 24) & 0xff); \
- (a)[1] = (unsigned char)((((unsigned long) (val)) >> 16) & 0xff); \
- (a)[2] = (unsigned char)((((unsigned long) (val)) >> 8) & 0xff); \
- (a)[3] = (unsigned char)(((unsigned long) (val)) & 0xff); \
-} while(0)
+#define WPA_GET_BE32(a) \
+ ((((unsigned long)(a)[0]) << 24) | \
+ (((unsigned long)(a)[1]) << 16) | \
+ (((unsigned long)(a)[2]) << 8) | \
+ ((unsigned long)(a)[3]))
+#define WPA_PUT_BE32(a, val) \
+ do { \
+ (a)[0] = (unsigned char)((((unsigned long)(val)) >> 24) & 0xff); \
+ (a)[1] = (unsigned char)((((unsigned long)(val)) >> 16) & 0xff); \
+ (a)[2] = (unsigned char)((((unsigned long)(val)) >> 8) & 0xff); \
+ (a)[3] = (unsigned char) (((unsigned long)(val)) & 0xff); \
+ } while(0)
#ifdef HAVE_LONGLONG
-#define WPA_PUT_BE64(a, val) \
-do { \
- (a)[0] = (unsigned char)(((unsigned long long)(val)) >> 56); \
- (a)[1] = (unsigned char)(((unsigned long long)(val)) >> 48); \
- (a)[2] = (unsigned char)(((unsigned long long)(val)) >> 40); \
- (a)[3] = (unsigned char)(((unsigned long long)(val)) >> 32); \
- (a)[4] = (unsigned char)(((unsigned long long)(val)) >> 24); \
- (a)[5] = (unsigned char)(((unsigned long long)(val)) >> 16); \
- (a)[6] = (unsigned char)(((unsigned long long)(val)) >> 8); \
- (a)[7] = (unsigned char)(((unsigned long long)(val)) & 0xff); \
-} while(0)
+#define WPA_PUT_BE64(a, val) \
+ do { \
+ (a)[0] = (unsigned char)(((unsigned long long)(val)) >> 56); \
+ (a)[1] = (unsigned char)(((unsigned long long)(val)) >> 48); \
+ (a)[2] = (unsigned char)(((unsigned long long)(val)) >> 40); \
+ (a)[3] = (unsigned char)(((unsigned long long)(val)) >> 32); \
+ (a)[4] = (unsigned char)(((unsigned long long)(val)) >> 24); \
+ (a)[5] = (unsigned char)(((unsigned long long)(val)) >> 16); \
+ (a)[6] = (unsigned char)(((unsigned long long)(val)) >> 8); \
+ (a)[7] = (unsigned char)(((unsigned long long)(val)) & 0xff); \
+ } while(0)
#else
-#define WPA_PUT_BE64(a, val) \
-do { \
- (a)[0] = (unsigned char)(((unsigned __int64)(val)) >> 56); \
- (a)[1] = (unsigned char)(((unsigned __int64)(val)) >> 48); \
- (a)[2] = (unsigned char)(((unsigned __int64)(val)) >> 40); \
- (a)[3] = (unsigned char)(((unsigned __int64)(val)) >> 32); \
- (a)[4] = (unsigned char)(((unsigned __int64)(val)) >> 24); \
- (a)[5] = (unsigned char)(((unsigned __int64)(val)) >> 16); \
- (a)[6] = (unsigned char)(((unsigned __int64)(val)) >> 8); \
- (a)[7] = (unsigned char)(((unsigned __int64)(val)) & 0xff); \
-} while(0)
+#define WPA_PUT_BE64(a, val) \
+ do { \
+ (a)[0] = (unsigned char)(((unsigned __int64)(val)) >> 56); \
+ (a)[1] = (unsigned char)(((unsigned __int64)(val)) >> 48); \
+ (a)[2] = (unsigned char)(((unsigned __int64)(val)) >> 40); \
+ (a)[3] = (unsigned char)(((unsigned __int64)(val)) >> 32); \
+ (a)[4] = (unsigned char)(((unsigned __int64)(val)) >> 24); \
+ (a)[5] = (unsigned char)(((unsigned __int64)(val)) >> 16); \
+ (a)[6] = (unsigned char)(((unsigned __int64)(val)) >> 8); \
+ (a)[7] = (unsigned char)(((unsigned __int64)(val)) & 0xff); \
+ } while(0)
#endif
struct sha256_state {
/* Various logical functions */
#define RORc(x, y) \
-(((((unsigned long)(x) & 0xFFFFFFFFUL) >> (unsigned long)((y) & 31)) | \
- ((unsigned long)(x) << (unsigned long)(32 - ((y) & 31)))) & 0xFFFFFFFFUL)
-#define Sha256_Ch(x,y,z) (z ^ (x & (y ^ z)))
-#define Sha256_Maj(x,y,z) (((x | y) & z) | (x & y))
-#define Sha256_S(x, n) RORc((x), (n))
-#define Sha256_R(x, n) (((x)&0xFFFFFFFFUL)>>(n))
+ (((((unsigned long)(x) & 0xFFFFFFFFUL) >> (unsigned long)((y) & 31)) | \
+ ((unsigned long)(x) << (unsigned long)(32 - ((y) & 31)))) & 0xFFFFFFFFUL)
+
+#define Sha256_Ch(x, y, z) (z ^ (x & (y ^ z)))
+#define Sha256_Maj(x, y, z) (((x | y) & z) | (x & y))
+#define Sha256_S(x, n) RORc((x), (n))
+#define Sha256_R(x, n) (((x) & 0xFFFFFFFFUL) >> (n))
+
#define Sigma0(x) (Sha256_S(x, 2) ^ Sha256_S(x, 13) ^ Sha256_S(x, 22))
#define Sigma1(x) (Sha256_S(x, 6) ^ Sha256_S(x, 11) ^ Sha256_S(x, 25))
#define Gamma0(x) (Sha256_S(x, 7) ^ Sha256_S(x, 18) ^ Sha256_R(x, 3))
#define Gamma1(x) (Sha256_S(x, 17) ^ Sha256_S(x, 19) ^ Sha256_R(x, 10))
/* Compress 512-bits */
-static int sha256_compress(struct sha256_state *md,
- const unsigned char *buf)
+static int sha256_compress(struct sha256_state *md, const unsigned char *buf)
{
unsigned long S[8], W[64];
int i;
W[i] = WPA_GET_BE32(buf + (4 * i));
/* fill W[16..63] */
for(i = 16; i < 64; i++) {
- W[i] = Gamma1(W[i - 2]) + W[i - 7] + Gamma0(W[i - 15]) +
- W[i - 16];
+ W[i] = Gamma1(W[i - 2]) + W[i - 7] + Gamma0(W[i - 15]) + W[i - 16];
}
/* Compress */
-#define RND(a,b,c,d,e,f,g,h,i) \
+#define RND(a, b, c, d, e, f, g, h, i) \
do { \
unsigned long t0 = h + Sigma1(e) + Sha256_Ch(e, f, g) + K[i] + W[i]; \
unsigned long t1 = Sigma0(a) + Sha256_Maj(a, b, c); \
for(i = 0; i < 64; ++i) {
unsigned long t;
RND(S[0], S[1], S[2], S[3], S[4], S[5], S[6], S[7], i);
- t = S[7]; S[7] = S[6]; S[6] = S[5]; S[5] = S[4];
- S[4] = S[3]; S[3] = S[2]; S[2] = S[1]; S[1] = S[0]; S[0] = t;
+ t = S[7];
+ S[7] = S[6];
+ S[6] = S[5];
+ S[5] = S[4];
+ S[4] = S[3];
+ S[3] = S[2];
+ S[2] = S[1];
+ S[1] = S[0];
+ S[0] = t;
}
/* Feedback */
return result;
}
-
const struct HMAC_params Curl_HMAC_SHA256 = {
my_sha256_init, /* Hash initialization function. */
my_sha256_update, /* Hash update function. */
***************************************************************************/
#include "curl_setup.h"
-#if defined(HAVE_SIGACTION) && \
+#if defined(HAVE_SIGACTION) && \
(defined(USE_OPENSSL) || defined(USE_MBEDTLS) || defined(USE_WOLFSSL))
#include <signal.h>
#else
/* for systems without sigaction */
-#define sigpipe_ignore(x,y) Curl_nop_stmt
-#define sigpipe_apply(x,y) Curl_nop_stmt
-#define sigpipe_init(x) Curl_nop_stmt
-#define sigpipe_restore(x) Curl_nop_stmt
+#define sigpipe_ignore(x, y) Curl_nop_stmt
+#define sigpipe_apply(x, y) Curl_nop_stmt
+#define sigpipe_init(x) Curl_nop_stmt
+#define sigpipe_restore(x) Curl_nop_stmt
#define SIGPIPE_VARIABLE(x)
-#define SIGPIPE_MEMBER(x) bool x
+#define SIGPIPE_MEMBER(x) bool x
#endif
#endif /* HEADER_CURL_SIGPIPE_H */
/* returns last node in linked list */
static struct curl_slist *slist_get_last(struct curl_slist *list)
{
- struct curl_slist *item;
+ struct curl_slist *item;
/* if caller passed us a NULL, return now */
if(!list)
struct curl_slist *Curl_slist_append_nodup(struct curl_slist *list,
const char *data)
{
- struct curl_slist *last;
- struct curl_slist *new_item;
+ struct curl_slist *last;
+ struct curl_slist *new_item;
DEBUGASSERT(data);
* bothersome, then simply create a separate _init function and call it
* appropriately from within the program.
*/
-struct curl_slist *curl_slist_append(struct curl_slist *list,
- const char *data)
+struct curl_slist *curl_slist_append(struct curl_slist *list, const char *data)
{
char *dupdata = curlx_strdup(data);
/* be nice and clean up resources */
void curl_slist_free_all(struct curl_slist *list)
{
- struct curl_slist *next;
- struct curl_slist *item;
+ struct curl_slist *next;
+ struct curl_slist *item;
if(!list)
return;
defined(__OS400__)
static unsigned short smb_swap16(unsigned short x)
{
- return (unsigned short) ((x << 8) | ((x >> 8) & 0xff));
+ return (unsigned short)((x << 8) | ((x >> 8) & 0xff));
}
static unsigned int smb_swap32(unsigned int x)
static curl_off_t smb_swap64(curl_off_t x)
{
- return ((curl_off_t) smb_swap32((unsigned int) x) << 32) |
- smb_swap32((unsigned int) (x >> 32));
+ return ((curl_off_t)smb_swap32((unsigned int)x) << 32) |
+ smb_swap32((unsigned int)(x >> 32));
}
#else
if(nbt_size >= msg_size + 1) {
/* Add the word count */
- msg_size += 1 + ((unsigned char) buf[msg_size]) * sizeof(unsigned short);
+ msg_size += 1 + ((unsigned char)buf[msg_size]) * sizeof(unsigned short);
if(nbt_size >= msg_size + sizeof(unsigned short)) {
/* Add the byte count */
msg_size += sizeof(unsigned short) +
const unsigned int pid = 0xbad71d; /* made up */
memset(h, 0, sizeof(*h));
- h->nbt_length = htons((unsigned short) (sizeof(*h) - sizeof(unsigned int) +
- len));
+ h->nbt_length = htons((unsigned short)(sizeof(*h) - sizeof(unsigned int) +
+ len));
memcpy((char *)h->magic, "\xffSMB", 4);
h->command = cmd;
h->flags = SMB_FLAGS_CANONICAL_PATHNAMES | SMB_FLAGS_CASELESS_PATHNAMES;
h->uid = smb_swap16(smbc->uid);
h->tid = smb_swap16(req->tid);
h->pid_high = smb_swap16((unsigned short)(pid >> 16));
- h->pid = smb_swap16((unsigned short) pid);
+ h->pid = smb_swap16((unsigned short)pid);
}
static CURLcode smb_send(struct Curl_easy *data, struct smb_conn *smbc,
msg.access = smb_swap32(SMB_GENERIC_READ);
msg.create_disposition = smb_swap32(SMB_FILE_OPEN);
}
- msg.byte_count = smb_swap16((unsigned short) byte_count);
+ msg.byte_count = smb_swap16((unsigned short)byte_count);
strcpy(msg.bytes, req->path);
return smb_send_message(data, smbc, req, SMB_COM_NT_CREATE_ANDX, &msg,
msg.word_count = SMB_WC_READ_ANDX;
msg.andx.command = SMB_COM_NO_ANDX_COMMAND;
msg.fid = smb_swap16(req->fid);
- msg.offset = smb_swap32((unsigned int) offset);
- msg.offset_high = smb_swap32((unsigned int) (offset >> 32));
+ msg.offset = smb_swap32((unsigned int)offset);
+ msg.offset_high = smb_swap32((unsigned int)(offset >> 32));
msg.min_bytes = smb_swap16(MAX_PAYLOAD_SIZE);
msg.max_bytes = smb_swap16(MAX_PAYLOAD_SIZE);
msg->word_count = SMB_WC_WRITE_ANDX;
msg->andx.command = SMB_COM_NO_ANDX_COMMAND;
msg->fid = smb_swap16(req->fid);
- msg->offset = smb_swap32((unsigned int) offset);
- msg->offset_high = smb_swap32((unsigned int) (offset >> 32));
- msg->data_length = smb_swap16((unsigned short) upload_size);
+ msg->offset = smb_swap32((unsigned int)offset);
+ msg->offset_high = smb_swap32((unsigned int)(offset >> 32));
+ msg->data_length = smb_swap16((unsigned short)upload_size);
msg->data_offset = smb_swap16(sizeof(*msg) - sizeof(unsigned int));
- msg->byte_count = smb_swap16((unsigned short) (upload_size + 1));
+ msg->byte_count = smb_swap16((unsigned short)(upload_size + 1));
smb_format_message(smbc, req, &msg->h, SMB_COM_WRITE_ANDX,
- sizeof(*msg) - sizeof(msg->h) + (size_t) upload_size);
+ sizeof(*msg) - sizeof(msg->h) + (size_t)upload_size);
- return smb_send(data, smbc, sizeof(*msg), (size_t) upload_size);
+ return smb_send(data, smbc, sizeof(*msg), (size_t)upload_size);
}
static CURLcode smb_send_and_recv(struct Curl_easy *data,
*out = TIME_T_MIN;
else
#endif
- *out = (time_t) timestamp;
+ *out = (time_t)timestamp;
}
else
*out = 0;
next_state = SMB_TREE_DISCONNECT;
break;
}
- smb_m = (const struct smb_nt_create_response*) msg;
+ smb_m = (const struct smb_nt_create_response *)msg;
req->fid = smb_swap16(smb_m->fid);
data->req.offset = 0;
if(data->state.upload) {
next_state = SMB_CLOSE;
break;
}
- len = Curl_read16_le(((const unsigned char *) msg) +
+ len = Curl_read16_le(((const unsigned char *)msg) +
sizeof(struct smb_header) + 11);
- off = Curl_read16_le(((const unsigned char *) msg) +
+ off = Curl_read16_le(((const unsigned char *)msg) +
sizeof(struct smb_header) + 13);
if(len > 0) {
if(off + sizeof(unsigned int) + len > smbc->got) {
next_state = SMB_CLOSE;
break;
}
- len = Curl_read16_le(((const unsigned char *) msg) +
+ len = Curl_read16_le(((const unsigned char *)msg) +
sizeof(struct smb_header) + 5);
data->req.bytecount += len;
data->req.offset += len;
CURLPROTO_SMTP, /* protocol */
CURLPROTO_SMTP, /* family */
PROTOPT_CLOSEACTION | PROTOPT_NOURLQUERY | /* flags */
- PROTOPT_URLOPTIONS | PROTOPT_SSL_REUSE |
- PROTOPT_CONN_REUSE
+ PROTOPT_URLOPTIONS | PROTOPT_SSL_REUSE | PROTOPT_CONN_REUSE
};
#ifdef USE_SSL
CURLPROTO_SMTPS, /* protocol */
CURLPROTO_SMTP, /* family */
PROTOPT_CLOSEACTION | PROTOPT_SSL | /* flags */
- PROTOPT_NOURLQUERY | PROTOPT_URLOPTIONS |
- PROTOPT_CONN_REUSE
+ PROTOPT_NOURLQUERY | PROTOPT_URLOPTIONS | PROTOPT_CONN_REUSE
};
#endif
const char *p = tmpline;
result = TRUE;
memcpy(tmpline, line, (len == 5 ? 5 : 3));
- tmpline[len == 5 ? 5 : 3 ] = 0;
+ tmpline[len == 5 ? 5 : 3] = 0;
if(curlx_str_number(&p, &code, len == 5 ? 99999 : 999))
return FALSE;
- *resp = (int) code;
+ *resp = (int)code;
/* Make sure real server never sends internal value */
if(*resp == 1)
CURLcode result = CURLE_OK;
struct smtp_conn *smtpc =
Curl_conn_meta_get(data->conn, CURL_META_SMTP_CONN);
- const char *ir = (const char *) Curl_bufref_ptr(initresp);
+ const char *ir = (const char *)Curl_bufref_ptr(initresp);
if(!smtpc)
return CURLE_FAILED_INIT;
if(!smtpc)
return CURLE_FAILED_INIT;
return Curl_pp_sendf(data, &smtpc->pp,
- "%s", (const char *) Curl_bufref_ptr(resp));
+ "%s", (const char *)Curl_bufref_ptr(resp));
}
/***********************************************************************
CURLcode result = CURLE_OK;
(void)instate;
- if(smtpcode/100 != 2) {
+ if(smtpcode / 100 != 2) {
failf(data, "Got unexpected smtp-server response: %d", smtpcode);
result = CURLE_WEIRD_SERVER_REPLY;
}
(void)instate;
- if(smtpcode/100 != 2 && smtpcode != 1) {
- if(data->set.use_ssl <= CURLUSESSL_TRY
- || Curl_conn_is_ssl(data->conn, FIRSTSOCKET))
+ if(smtpcode / 100 != 2 && smtpcode != 1) {
+ if(data->set.use_ssl <= CURLUSESSL_TRY ||
+ Curl_conn_is_ssl(data->conn, FIRSTSOCKET))
result = smtp_perform_helo(data, smtpc);
else {
failf(data, "Remote access denied: %d", smtpcode);
CURLcode result = CURLE_OK;
(void)instate;
- if(smtpcode/100 != 2) {
+ if(smtpcode / 100 != 2) {
failf(data, "Remote access denied: %d", smtpcode);
result = CURLE_REMOTE_ACCESS_DENIED;
}
(void)instate;
- if((smtp->rcpt && smtpcode/100 != 2 && smtpcode != 553 && smtpcode != 1) ||
- (!smtp->rcpt && smtpcode/100 != 2 && smtpcode != 1)) {
+ if((smtp->rcpt && smtpcode / 100 != 2 && smtpcode != 553 && smtpcode != 1) ||
+ (!smtp->rcpt && smtpcode / 100 != 2 && smtpcode != 1)) {
failf(data, "Command failed: %d", smtpcode);
result = CURLE_WEIRD_SERVER_REPLY;
}
CURLcode result = CURLE_OK;
(void)instate;
- if(smtpcode/100 != 2) {
+ if(smtpcode / 100 != 2) {
failf(data, "MAIL failed: %d", smtpcode);
result = CURLE_SEND_ERROR;
}
(void)instate;
- is_smtp_err = (smtpcode/100 != 2);
+ is_smtp_err = (smtpcode / 100 != 2);
/* If there is multiple RCPT TO to be issued, it is possible to ignore errors
and proceed with only the valid addresses. */
smtpc = curlx_calloc(1, sizeof(*smtpc));
if(!smtpc ||
Curl_conn_meta_set(conn, CURL_META_SMTP_CONN, smtpc, smtp_conn_dtor)) {
- result = CURLE_OUT_OF_MEMORY;
- goto out;
+ result = CURLE_OUT_OF_MEMORY;
+ goto out;
}
smtp = curlx_calloc(1, sizeof(*smtp));
}
/* this is the 5-bytes End-Of-Body marker for SMTP */
-#define SMTP_EOB "\r\n.\r\n"
+#define SMTP_EOB "\r\n.\r\n"
#define SMTP_EOB_FIND_LEN 3
/* client reader doing SMTP End-Of-Body escaping. */
const char *eob = SMTP_EOB;
CURL_TRC_SMTP(data, "auto-ending mail body with '\\r\\n.\\r\\n'");
switch(ctx->n_eob) {
- case 2:
- /* seen a CRLF at the end, just add the remainder */
- eob = &SMTP_EOB[2];
- break;
- case 3:
- /* ended with '\r\n.', we should escape the last '.' */
- eob = "." SMTP_EOB;
- break;
- default:
- break;
+ case 2:
+ /* seen a CRLF at the end, just add the remainder */
+ eob = &SMTP_EOB[2];
+ break;
+ case 3:
+ /* ended with '\r\n.', we should escape the last '.' */
+ eob = "." SMTP_EOB;
+ break;
+ default:
+ break;
}
result = Curl_bufq_cwrite(&ctx->buf, eob, strlen(eob), &n);
if(result)
struct Curl_creader *reader = NULL;
CURLcode result;
- result = Curl_creader_create(&reader, data, &cr_eob,
- CURL_CR_CONTENT_ENCODE);
+ result = Curl_creader_create(&reader, data, &cr_eob, CURL_CR_CONTENT_ENCODE);
if(!result)
result = Curl_creader_add(data, reader);
#ifdef USE_EVENTFD
-#define wakeup_write write
-#define wakeup_read read
-#define wakeup_close close
-#define wakeup_create(p,nb) Curl_eventfd(p,nb)
+#define wakeup_write write
+#define wakeup_read read
+#define wakeup_close close
+#define wakeup_create(p, nb) Curl_eventfd(p, nb)
#include <curl/curl.h>
int Curl_eventfd(curl_socket_t socks[2], bool nonblocking);
#elif defined(HAVE_PIPE)
-#define wakeup_write write
-#define wakeup_read read
-#define wakeup_close close
-#define wakeup_create(p,nb) Curl_pipe(p,nb)
+#define wakeup_write write
+#define wakeup_read read
+#define wakeup_close close
+#define wakeup_create(p, nb) Curl_pipe(p, nb)
#include <curl/curl.h>
int Curl_pipe(curl_socket_t socks[2], bool nonblocking);
#endif
#define USE_SOCKETPAIR
-#define wakeup_create(p,nb) \
+#define wakeup_create(p, nb) \
Curl_socketpair(SOCKETPAIR_FAMILY, SOCKETPAIR_TYPE, 0, p, nb)
#endif /* USE_EVENTFD */
#if defined(DEBUGBUILD) && !defined(CURL_DISABLE_VERBOSE_STRINGS)
#define DEBUG_AND_VERBOSE
-#define sxstate(x,c,d,y) socksstate(x,c,d,y, __LINE__)
+#define sxstate(x, c, d, y) socksstate(x, c, d, y, __LINE__)
#else
-#define sxstate(x,c,d,y) socksstate(x,c,d,y)
+#define sxstate(x, c, d, y) socksstate(x, c, d, y)
#endif
/* always use this function to change state, to make debugging easier */
}
static CURLproxycode socks_flush(struct socks_state *sx,
- struct Curl_cfilter *cf,
- struct Curl_easy *data,
- bool *done)
+ struct Curl_cfilter *cf,
+ struct Curl_easy *data,
+ bool *done)
{
CURLcode result;
size_t nwritten;
result = Curl_resolv(data, sx->hostname, sx->remote_port,
cf->conn->ip_version, TRUE, &dns);
if(result == CURLE_AGAIN) {
- CURL_TRC_CF(data, cf, "SOCKS4 non-blocking resolve of %s",
- sx->hostname);
+ CURL_TRC_CF(data, cf, "SOCKS4 non-blocking resolve of %s", sx->hostname);
return CURLPX_OK;
}
else if(result)
}
if(result || !dns) {
- failf(data, "Failed to resolve \"%s\" for SOCKS4 connect.",
- sx->hostname);
+ failf(data, "Failed to resolve \"%s\" for SOCKS4 connect.", sx->hostname);
return CURLPX_RESOLVE_HOST;
}
}
/*
-* This function logs in to a SOCKS4 proxy and sends the specifics to the final
-* destination server.
-*
-* Reference :
-* https://www.openssh.com/txt/socks4.protocol
-*
-* Note :
-* Set protocol4a=true for "SOCKS 4A (Simple Extension to SOCKS 4 Protocol)"
-* Nonsupport "Identification Protocol (RFC1413)"
-*/
+ * This function logs in to a SOCKS4 proxy and sends the specifics to the final
+ * destination server.
+ *
+ * Reference :
+ * https://www.openssh.com/txt/socks4.protocol
+ *
+ * Note :
+ * Set protocol4a=true for "SOCKS 4A (Simple Extension to SOCKS 4 Protocol)"
+ * Nonsupport "Identification Protocol (RFC1413)"
+ */
static CURLproxycode socks4_connect(struct Curl_cfilter *cf,
struct socks_state *sx,
struct Curl_easy *data)
if(result || (nwritten != ulen))
return CURLPX_SEND_REQUEST;
}
- buf[0] = (unsigned char) plen;
+ buf[0] = (unsigned char)plen;
result = Curl_bufq_write(&sx->iobuf, buf, 1, &nwritten);
if(result || (nwritten != 1))
return CURLPX_SEND_REQUEST;
const size_t hostname_len = strlen(sx->hostname);
desttype = 3;
destination = (const unsigned char *)sx->hostname;
- destlen = (unsigned char) hostname_len; /* one byte length */
+ destlen = (unsigned char)hostname_len; /* one byte length */
}
req[3] = desttype;
result = Curl_resolv(data, sx->hostname, sx->remote_port,
cf->conn->ip_version, TRUE, &dns);
if(result == CURLE_AGAIN) {
- CURL_TRC_CF(data, cf, "SOCKS5 non-blocking resolve of %s",
- sx->hostname);
+ CURL_TRC_CF(data, cf, "SOCKS5 non-blocking resolve of %s", sx->hostname);
return CURLPX_OK;
}
else if(result)
}
if(result || !dns) {
- failf(data, "Failed to resolve \"%s\" for SOCKS5 connect.",
- sx->hostname);
+ failf(data, "Failed to resolve \"%s\" for SOCKS5 connect.", sx->hostname);
presult = CURLPX_RESOLVE_HOST;
goto out;
}
}
#endif
if(!hp) {
- failf(data, "Failed to resolve \"%s\" for SOCKS5 connect.",
- sx->hostname);
+ failf(data, "Failed to resolve \"%s\" for SOCKS5 connect.", sx->hostname);
presult = CURLPX_RESOLVE_HOST;
goto out;
}
struct Curl_cftype Curl_cft_socks_proxy = {
"SOCKS",
- CF_TYPE_IP_CONNECT|CF_TYPE_PROXY,
+ CF_TYPE_IP_CONNECT | CF_TYPE_PROXY,
0,
socks_proxy_cf_destroy,
socks_proxy_cf_connect,
#include "curl_setup.h"
#ifdef CURL_DISABLE_PROXY
-#define Curl_SOCKS4(a,b,c,d,e) CURLE_NOT_BUILT_IN
-#define Curl_SOCKS5(a,b,c,d,e,f) CURLE_NOT_BUILT_IN
-#define Curl_SOCKS_getsock(x,y,z) 0
+#define Curl_SOCKS4(a, b, c, d, e) CURLE_NOT_BUILT_IN
+#define Curl_SOCKS5(a, b, c, d, e, f) CURLE_NOT_BUILT_IN
+#define Curl_SOCKS_getsock(x, y, z) 0
#else
/*
* Helper read-from-socket functions. Does the same as Curl_read() but it
GSS_C_NULL_OID,
&msg_ctx, &status_string);
if(maj_stat == GSS_S_COMPLETE) {
- if(curlx_dyn_addn(&dbuf, status_string.value,
- status_string.length))
+ if(curlx_dyn_addn(&dbuf, status_string.value, status_string.length))
return 1; /* error */
gss_release_buffer(&min_stat, &status_string);
break;
GSS_C_NULL_OID,
&msg_ctx, &status_string);
if(maj_stat == GSS_S_COMPLETE) {
- if(curlx_dyn_addn(&dbuf, status_string.value,
- status_string.length))
+ if(curlx_dyn_addn(&dbuf, status_string.value, status_string.length))
return 1; /* error */
gss_release_buffer(&min_stat, &status_string);
break;
return CURLE_OUT_OF_MEMORY;
gss_major_status = gss_import_name(&gss_minor_status, &service,
- (gss_OID) GSS_C_NULL_OID, &server);
+ (gss_OID)GSS_C_NULL_OID, &server);
}
else {
service.value = curlx_malloc(serviceptr_length +
us_length = htons((unsigned short)gss_send_token.length);
memcpy(socksreq + 2, &us_length, sizeof(short));
- code = Curl_conn_cf_send(cf->next, data, socksreq, 4,
- FALSE, &nwritten);
+ code = Curl_conn_cf_send(cf->next, data, socksreq, 4, FALSE, &nwritten);
if(code || (nwritten != 4)) {
failf(data, "Failed to send GSS-API authentication request.");
gss_release_name(&gss_status, &server);
Curl_gss_delete_sec_context(&gss_status, &gss_context, NULL);
return CURLE_COULDNT_CONNECT;
}
-
}
gss_release_buffer(&gss_status, &gss_send_token);
}
if(sspi_send_token.cbBuffer) {
- socksreq[0] = 1; /* GSS-API subnegotiation version */
- socksreq[1] = 1; /* authentication message type */
+ socksreq[0] = 1; /* GSS-API subnegotiation version */
+ socksreq[1] = 1; /* authentication message type */
if(sspi_send_token.cbBuffer > 0xffff) {
/* needs to fit in an unsigned 16 bit field */
result = CURLE_COULDNT_CONNECT;
}
/* Do encryption */
- socksreq[0] = 1; /* GSS-API subnegotiation version */
- socksreq[1] = 2; /* encryption message type */
+ socksreq[0] = 1; /* GSS-API subnegotiation version */
+ socksreq[1] = 2; /* encryption message type */
gss_enc = 0; /* no data protection */
/* do confidentiality protection if supported */
infof(data, "SOCKS5 server supports GSS-API %s data protection.",
(gss_enc == 0) ? "no" :
- ((gss_enc == 1) ? "integrity":"confidentiality") );
+ ((gss_enc == 1) ? "integrity" : "confidentiality") );
/*
* Sending the encryption type in clear seems wrong. It should be
}
etbuf_size = sspi_w_token[0].cbBuffer + sspi_w_token[1].cbBuffer +
- sspi_w_token[2].cbBuffer;
+ sspi_w_token[2].cbBuffer;
if(etbuf_size > 0xffff) {
/* needs to fit in an unsigned 16 bit field */
result = CURLE_COULDNT_CONNECT;
* zero : when i is equal to j
* positive when : when i is larger than j
*/
-#define compare(i,j) curlx_timediff_us(i,j)
+#define compare(i, j) curlx_timediff_us(i, j)
/*
* Splay using the key i (which may or may not be in the tree.) The starting
node->smaller = t->smaller;
node->larger = t;
t->smaller = NULL;
-
}
else {
node->larger = t->larger;
struct Curl_tree *t,
struct Curl_tree **removed)
{
- static const struct curltime tv_zero = {0, 0};
+ static const struct curltime tv_zero = { 0, 0 };
struct Curl_tree *x;
if(!t) {
return x;
}
-
/* Deletes the node we point out from the tree if it is there. Stores a
* pointer to the new resulting tree in 'newroot'.
*
/* Mapping table to go from lowercase to uppercase for plain ASCII.*/
static const unsigned char touppermap[256] = {
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
- 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
- 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59,
- 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
- 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 65,
- 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
- 85, 86, 87, 88, 89, 90, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132,
- 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147,
- 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162,
- 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177,
- 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192,
- 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207,
- 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222,
- 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237,
- 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252,
- 253, 254, 255
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
+ 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
+ 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
+ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59,
+ 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
+ 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
+ 90, 91, 92, 93, 94, 95, 96, 65, 66, 67, 68, 69, 70, 71, 72,
+ 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87,
+ 88, 89, 90, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
+ 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149,
+ 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164,
+ 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179,
+ 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194,
+ 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209,
+ 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224,
+ 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239,
+ 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254,
+ 255
};
/* Mapping table to go from uppercase to lowercase for plain ASCII.*/
static const unsigned char tolowermap[256] = {
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
- 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
- 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59,
- 60, 61, 62, 63, 64, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108,
- 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 91, 92,
- 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
- 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
- 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139,
- 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154,
- 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169,
- 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184,
- 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199,
- 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214,
- 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229,
- 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244,
- 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
+ 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
+ 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
+ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59,
+ 60, 61, 62, 63, 64, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106,
+ 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121,
+ 122, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
+ 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119,
+ 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
+ 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149,
+ 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164,
+ 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179,
+ 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194,
+ 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209,
+ 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224,
+ 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239,
+ 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254,
+ 255
};
-
/* Portable, consistent toupper. Do not use toupper() because its behavior is
altered by the current locale. */
char Curl_raw_toupper(char in)
{
- return (char)touppermap[(unsigned char) in];
+ return (char)touppermap[(unsigned char)in];
}
-
/* Portable, consistent tolower. Do not use tolower() because its behavior is
altered by the current locale. */
char Curl_raw_tolower(char in)
{
- return (char)tolowermap[(unsigned char) in];
+ return (char)tolowermap[(unsigned char)in];
}
/* Copy an upper case version of the string from src to dest. The
if(a && b) {
while(1) {
- match |= a[i]^b[i];
+ match |= a[i] ^ b[i];
if(!a[i] || !b[i])
break;
i++;
/* checkprefix() is a shorter version of the above, used when the first
argument is the string literal */
-#define checkprefix(a,b) curl_strnequal(b, STRCONST(a))
+#define checkprefix(a, b) curl_strnequal(b, STRCONST(a))
void Curl_strntoupper(char *dest, const char *src, size_t n);
void Curl_strntolower(char *dest, const char *src, size_t n);
char *Curl_strdup(const char *str);
#endif
#ifdef _WIN32
-wchar_t* Curl_wcsdup(const wchar_t* src);
+wchar_t *Curl_wcsdup(const wchar_t *src);
#endif
void *Curl_memdup(const void *src, size_t buffer_length);
void *Curl_saferealloc(void *ptr, size_t size);
#include "curlx/winapi.h"
#include "strerror.h"
-const char *
-curl_easy_strerror(CURLcode error)
+const char *curl_easy_strerror(CURLcode error)
{
#ifndef CURL_DISABLE_VERBOSE_STRINGS
switch(error) {
case CURLE_NOT_BUILT_IN:
return "A requested feature, protocol or option was not found built-in in"
- " this libcurl due to a build-time decision.";
+ " this libcurl due to a build-time decision.";
case CURLE_COULDNT_RESOLVE_PROXY:
return "Could not resolve proxy name";
#endif
}
-const char *
-curl_multi_strerror(CURLMcode error)
+const char *curl_multi_strerror(CURLMcode error)
{
#ifndef CURL_DISABLE_VERBOSE_STRINGS
switch(error) {
#endif
}
-const char *
-curl_share_strerror(CURLSHcode error)
+const char *curl_share_strerror(CURLSHcode error)
{
#ifndef CURL_DISABLE_VERBOSE_STRINGS
switch(error) {
#endif
}
-const char *
-curl_url_strerror(CURLUcode error)
+const char *curl_url_strerror(CURLUcode error)
{
#ifndef CURL_DISABLE_VERBOSE_STRINGS
switch(error) {
#ifndef CURL_DISABLE_VERBOSE_STRINGS
switch(err) {
- case SEC_E_OK:
- txt = "No error";
- break;
+ case SEC_E_OK:
+ txt = "No error";
+ break;
#define SEC2TXT(sec) case sec: txt = #sec; break
- SEC2TXT(CRYPT_E_REVOKED);
- SEC2TXT(CRYPT_E_NO_REVOCATION_DLL);
- SEC2TXT(CRYPT_E_NO_REVOCATION_CHECK);
- SEC2TXT(CRYPT_E_REVOCATION_OFFLINE);
- SEC2TXT(CRYPT_E_NOT_IN_REVOCATION_DATABASE);
- SEC2TXT(SEC_E_ALGORITHM_MISMATCH);
- SEC2TXT(SEC_E_BAD_BINDINGS);
- SEC2TXT(SEC_E_BAD_PKGID);
- SEC2TXT(SEC_E_BUFFER_TOO_SMALL);
- SEC2TXT(SEC_E_CANNOT_INSTALL);
- SEC2TXT(SEC_E_CANNOT_PACK);
- SEC2TXT(SEC_E_CERT_EXPIRED);
- SEC2TXT(SEC_E_CERT_UNKNOWN);
- SEC2TXT(SEC_E_CERT_WRONG_USAGE);
- SEC2TXT(SEC_E_CONTEXT_EXPIRED);
- SEC2TXT(SEC_E_CROSSREALM_DELEGATION_FAILURE);
- SEC2TXT(SEC_E_CRYPTO_SYSTEM_INVALID);
- SEC2TXT(SEC_E_DECRYPT_FAILURE);
- SEC2TXT(SEC_E_DELEGATION_POLICY);
- SEC2TXT(SEC_E_DELEGATION_REQUIRED);
- SEC2TXT(SEC_E_DOWNGRADE_DETECTED);
- SEC2TXT(SEC_E_ENCRYPT_FAILURE);
- SEC2TXT(SEC_E_ILLEGAL_MESSAGE);
- SEC2TXT(SEC_E_INCOMPLETE_CREDENTIALS);
- SEC2TXT(SEC_E_INCOMPLETE_MESSAGE);
- SEC2TXT(SEC_E_INSUFFICIENT_MEMORY);
- SEC2TXT(SEC_E_INTERNAL_ERROR);
- SEC2TXT(SEC_E_INVALID_HANDLE);
- SEC2TXT(SEC_E_INVALID_PARAMETER);
- SEC2TXT(SEC_E_INVALID_TOKEN);
- SEC2TXT(SEC_E_ISSUING_CA_UNTRUSTED);
- SEC2TXT(SEC_E_ISSUING_CA_UNTRUSTED_KDC);
- SEC2TXT(SEC_E_KDC_CERT_EXPIRED);
- SEC2TXT(SEC_E_KDC_CERT_REVOKED);
- SEC2TXT(SEC_E_KDC_INVALID_REQUEST);
- SEC2TXT(SEC_E_KDC_UNABLE_TO_REFER);
- SEC2TXT(SEC_E_KDC_UNKNOWN_ETYPE);
- SEC2TXT(SEC_E_LOGON_DENIED);
- SEC2TXT(SEC_E_MAX_REFERRALS_EXCEEDED);
- SEC2TXT(SEC_E_MESSAGE_ALTERED);
- SEC2TXT(SEC_E_MULTIPLE_ACCOUNTS);
- SEC2TXT(SEC_E_MUST_BE_KDC);
- SEC2TXT(SEC_E_NOT_OWNER);
- SEC2TXT(SEC_E_NO_AUTHENTICATING_AUTHORITY);
- SEC2TXT(SEC_E_NO_CREDENTIALS);
- SEC2TXT(SEC_E_NO_IMPERSONATION);
- SEC2TXT(SEC_E_NO_IP_ADDRESSES);
- SEC2TXT(SEC_E_NO_KERB_KEY);
- SEC2TXT(SEC_E_NO_PA_DATA);
- SEC2TXT(SEC_E_NO_S4U_PROT_SUPPORT);
- SEC2TXT(SEC_E_NO_TGT_REPLY);
- SEC2TXT(SEC_E_OUT_OF_SEQUENCE);
- SEC2TXT(SEC_E_PKINIT_CLIENT_FAILURE);
- SEC2TXT(SEC_E_PKINIT_NAME_MISMATCH);
- SEC2TXT(SEC_E_POLICY_NLTM_ONLY);
- SEC2TXT(SEC_E_QOP_NOT_SUPPORTED);
- SEC2TXT(SEC_E_REVOCATION_OFFLINE_C);
- SEC2TXT(SEC_E_REVOCATION_OFFLINE_KDC);
- SEC2TXT(SEC_E_SECPKG_NOT_FOUND);
- SEC2TXT(SEC_E_SECURITY_QOS_FAILED);
- SEC2TXT(SEC_E_SHUTDOWN_IN_PROGRESS);
- SEC2TXT(SEC_E_SMARTCARD_CERT_EXPIRED);
- SEC2TXT(SEC_E_SMARTCARD_CERT_REVOKED);
- SEC2TXT(SEC_E_SMARTCARD_LOGON_REQUIRED);
- SEC2TXT(SEC_E_STRONG_CRYPTO_NOT_SUPPORTED);
- SEC2TXT(SEC_E_TARGET_UNKNOWN);
- SEC2TXT(SEC_E_TIME_SKEW);
- SEC2TXT(SEC_E_TOO_MANY_PRINCIPALS);
- SEC2TXT(SEC_E_UNFINISHED_CONTEXT_DELETED);
- SEC2TXT(SEC_E_UNKNOWN_CREDENTIALS);
- SEC2TXT(SEC_E_UNSUPPORTED_FUNCTION);
- SEC2TXT(SEC_E_UNSUPPORTED_PREAUTH);
- SEC2TXT(SEC_E_UNTRUSTED_ROOT);
- SEC2TXT(SEC_E_WRONG_CREDENTIAL_HANDLE);
- SEC2TXT(SEC_E_WRONG_PRINCIPAL);
- SEC2TXT(SEC_I_COMPLETE_AND_CONTINUE);
- SEC2TXT(SEC_I_COMPLETE_NEEDED);
- SEC2TXT(SEC_I_CONTEXT_EXPIRED);
- SEC2TXT(SEC_I_CONTINUE_NEEDED);
- SEC2TXT(SEC_I_INCOMPLETE_CREDENTIALS);
- SEC2TXT(SEC_I_LOCAL_LOGON);
- SEC2TXT(SEC_I_NO_LSA_CONTEXT);
- SEC2TXT(SEC_I_RENEGOTIATE);
- SEC2TXT(SEC_I_SIGNATURE_NEEDED);
- default:
- txt = "Unknown error";
+ SEC2TXT(CRYPT_E_REVOKED);
+ SEC2TXT(CRYPT_E_NO_REVOCATION_DLL);
+ SEC2TXT(CRYPT_E_NO_REVOCATION_CHECK);
+ SEC2TXT(CRYPT_E_REVOCATION_OFFLINE);
+ SEC2TXT(CRYPT_E_NOT_IN_REVOCATION_DATABASE);
+ SEC2TXT(SEC_E_ALGORITHM_MISMATCH);
+ SEC2TXT(SEC_E_BAD_BINDINGS);
+ SEC2TXT(SEC_E_BAD_PKGID);
+ SEC2TXT(SEC_E_BUFFER_TOO_SMALL);
+ SEC2TXT(SEC_E_CANNOT_INSTALL);
+ SEC2TXT(SEC_E_CANNOT_PACK);
+ SEC2TXT(SEC_E_CERT_EXPIRED);
+ SEC2TXT(SEC_E_CERT_UNKNOWN);
+ SEC2TXT(SEC_E_CERT_WRONG_USAGE);
+ SEC2TXT(SEC_E_CONTEXT_EXPIRED);
+ SEC2TXT(SEC_E_CROSSREALM_DELEGATION_FAILURE);
+ SEC2TXT(SEC_E_CRYPTO_SYSTEM_INVALID);
+ SEC2TXT(SEC_E_DECRYPT_FAILURE);
+ SEC2TXT(SEC_E_DELEGATION_POLICY);
+ SEC2TXT(SEC_E_DELEGATION_REQUIRED);
+ SEC2TXT(SEC_E_DOWNGRADE_DETECTED);
+ SEC2TXT(SEC_E_ENCRYPT_FAILURE);
+ SEC2TXT(SEC_E_ILLEGAL_MESSAGE);
+ SEC2TXT(SEC_E_INCOMPLETE_CREDENTIALS);
+ SEC2TXT(SEC_E_INCOMPLETE_MESSAGE);
+ SEC2TXT(SEC_E_INSUFFICIENT_MEMORY);
+ SEC2TXT(SEC_E_INTERNAL_ERROR);
+ SEC2TXT(SEC_E_INVALID_HANDLE);
+ SEC2TXT(SEC_E_INVALID_PARAMETER);
+ SEC2TXT(SEC_E_INVALID_TOKEN);
+ SEC2TXT(SEC_E_ISSUING_CA_UNTRUSTED);
+ SEC2TXT(SEC_E_ISSUING_CA_UNTRUSTED_KDC);
+ SEC2TXT(SEC_E_KDC_CERT_EXPIRED);
+ SEC2TXT(SEC_E_KDC_CERT_REVOKED);
+ SEC2TXT(SEC_E_KDC_INVALID_REQUEST);
+ SEC2TXT(SEC_E_KDC_UNABLE_TO_REFER);
+ SEC2TXT(SEC_E_KDC_UNKNOWN_ETYPE);
+ SEC2TXT(SEC_E_LOGON_DENIED);
+ SEC2TXT(SEC_E_MAX_REFERRALS_EXCEEDED);
+ SEC2TXT(SEC_E_MESSAGE_ALTERED);
+ SEC2TXT(SEC_E_MULTIPLE_ACCOUNTS);
+ SEC2TXT(SEC_E_MUST_BE_KDC);
+ SEC2TXT(SEC_E_NOT_OWNER);
+ SEC2TXT(SEC_E_NO_AUTHENTICATING_AUTHORITY);
+ SEC2TXT(SEC_E_NO_CREDENTIALS);
+ SEC2TXT(SEC_E_NO_IMPERSONATION);
+ SEC2TXT(SEC_E_NO_IP_ADDRESSES);
+ SEC2TXT(SEC_E_NO_KERB_KEY);
+ SEC2TXT(SEC_E_NO_PA_DATA);
+ SEC2TXT(SEC_E_NO_S4U_PROT_SUPPORT);
+ SEC2TXT(SEC_E_NO_TGT_REPLY);
+ SEC2TXT(SEC_E_OUT_OF_SEQUENCE);
+ SEC2TXT(SEC_E_PKINIT_CLIENT_FAILURE);
+ SEC2TXT(SEC_E_PKINIT_NAME_MISMATCH);
+ SEC2TXT(SEC_E_POLICY_NLTM_ONLY);
+ SEC2TXT(SEC_E_QOP_NOT_SUPPORTED);
+ SEC2TXT(SEC_E_REVOCATION_OFFLINE_C);
+ SEC2TXT(SEC_E_REVOCATION_OFFLINE_KDC);
+ SEC2TXT(SEC_E_SECPKG_NOT_FOUND);
+ SEC2TXT(SEC_E_SECURITY_QOS_FAILED);
+ SEC2TXT(SEC_E_SHUTDOWN_IN_PROGRESS);
+ SEC2TXT(SEC_E_SMARTCARD_CERT_EXPIRED);
+ SEC2TXT(SEC_E_SMARTCARD_CERT_REVOKED);
+ SEC2TXT(SEC_E_SMARTCARD_LOGON_REQUIRED);
+ SEC2TXT(SEC_E_STRONG_CRYPTO_NOT_SUPPORTED);
+ SEC2TXT(SEC_E_TARGET_UNKNOWN);
+ SEC2TXT(SEC_E_TIME_SKEW);
+ SEC2TXT(SEC_E_TOO_MANY_PRINCIPALS);
+ SEC2TXT(SEC_E_UNFINISHED_CONTEXT_DELETED);
+ SEC2TXT(SEC_E_UNKNOWN_CREDENTIALS);
+ SEC2TXT(SEC_E_UNSUPPORTED_FUNCTION);
+ SEC2TXT(SEC_E_UNSUPPORTED_PREAUTH);
+ SEC2TXT(SEC_E_UNTRUSTED_ROOT);
+ SEC2TXT(SEC_E_WRONG_CREDENTIAL_HANDLE);
+ SEC2TXT(SEC_E_WRONG_PRINCIPAL);
+ SEC2TXT(SEC_I_COMPLETE_AND_CONTINUE);
+ SEC2TXT(SEC_I_COMPLETE_NEEDED);
+ SEC2TXT(SEC_I_CONTEXT_EXPIRED);
+ SEC2TXT(SEC_I_CONTINUE_NEEDED);
+ SEC2TXT(SEC_I_INCOMPLETE_CREDENTIALS);
+ SEC2TXT(SEC_I_LOCAL_LOGON);
+ SEC2TXT(SEC_I_NO_LSA_CONTEXT);
+ SEC2TXT(SEC_I_RENEGOTIATE);
+ SEC2TXT(SEC_I_SIGNATURE_NEEDED);
+ default:
+ txt = "Unknown error";
}
if(err == SEC_E_ILLEGAL_MESSAGE) {
/* highest supported version. */
if(LOBYTE(wsaData.wVersion) != LOBYTE(wVersionRequested) ||
- HIBYTE(wsaData.wVersion) != HIBYTE(wVersionRequested) ) {
+ HIBYTE(wsaData.wVersion) != HIBYTE(wVersionRequested)) {
/* Tell the user that we could not find a usable */
/* winsock.dll. */
#define SUBBUFSIZE 512
-#define CURL_SB_CLEAR(x) x->subpointer = x->subbuffer
-#define CURL_SB_TERM(x) \
- do { \
- x->subend = x->subpointer; \
- CURL_SB_CLEAR(x); \
+#define CURL_SB_CLEAR(x) x->subpointer = x->subbuffer
+#define CURL_SB_TERM(x) \
+ do { \
+ x->subend = x->subpointer; \
+ CURL_SB_CLEAR(x); \
} while(0)
-#define CURL_SB_ACCUM(x,c) \
- do { \
- if(x->subpointer < (x->subbuffer + sizeof(x->subbuffer))) \
- *x->subpointer++ = (c); \
+#define CURL_SB_ACCUM(x, c) \
+ do { \
+ if(x->subpointer < (x->subbuffer + sizeof(x->subbuffer))) \
+ *x->subpointer++ = (c); \
} while(0)
-#define CURL_SB_GET(x) ((*x->subpointer++)&0xff)
-#define CURL_SB_LEN(x) (x->subend - x->subpointer)
+#define CURL_SB_GET(x) ((*x->subpointer++) & 0xff)
+#define CURL_SB_LEN(x) (x->subend - x->subpointer)
/* For posterity:
#define CURL_SB_PEEK(x) ((*x->subpointer)&0xff)
#define CURL_SB_EOF(x) (x->subpointer >= x->subend) */
#ifdef CURL_DISABLE_VERBOSE_STRINGS
-#define printoption(a,b,c,d) Curl_nop_stmt
+#define printoption(a, b, c, d) Curl_nop_stmt
#endif
/* For negotiation compliant to RFC 1143 */
/*
* Telnet receiver states for fsm
*/
-typedef enum
-{
+typedef enum {
CURL_TS_DATA = 0,
CURL_TS_IAC,
CURL_TS_WILL,
unsigned char *subpointer, *subend; /* buffer for sub-options */
};
-
-static
-CURLcode telrcv(struct Curl_easy *data,
- struct TELNET *tn,
- const unsigned char *inbuf, /* Data received from socket */
- ssize_t count); /* Number of bytes received */
+static CURLcode telrcv(struct Curl_easy *data,
+ struct TELNET *tn,
+ const unsigned char *inbuf, /* Data received from
+ socket */
+ ssize_t count); /* Number of bytes
+ received */
#ifndef CURL_DISABLE_VERBOSE_STRINGS
static void printoption(struct Curl_easy *data,
PROTOPT_NONE | PROTOPT_NOURLQUERY /* flags */
};
-
static void telnet_easy_dtor(void *key, size_t klen, void *entry)
{
struct TELNET *tn = entry;
curlx_free(tn);
}
-static
-CURLcode init_telnet(struct Curl_easy *data)
+static CURLcode init_telnet(struct Curl_easy *data)
{
struct TELNET *tn;
bytes_written = swrite(conn->sock[FIRSTSOCKET], buf, 3);
if(bytes_written < 0) {
int err = SOCKERRNO;
- failf(data,"Sending data failed (%d)",err);
+ failf(data, "Sending data failed (%d)", err);
}
printoption(data, "SENT", cmd, option);
}
-static
-void set_remote_option(struct Curl_easy *data, struct TELNET *tn,
- int option, int newstate)
+static void set_remote_option(struct Curl_easy *data, struct TELNET *tn,
+ int option, int newstate)
{
if(newstate == CURL_YES) {
switch(tn->him[option]) {
}
}
-static
-void rec_will(struct Curl_easy *data, struct TELNET *tn, int option)
+static void rec_will(struct Curl_easy *data, struct TELNET *tn, int option)
{
switch(tn->him[option]) {
case CURL_NO:
}
}
-static
-void rec_wont(struct Curl_easy *data, struct TELNET *tn, int option)
+static void rec_wont(struct Curl_easy *data, struct TELNET *tn, int option)
{
switch(tn->him[option]) {
case CURL_NO:
}
}
-static void
-set_local_option(struct Curl_easy *data, struct TELNET *tn,
- int option, int newstate)
+static void set_local_option(struct Curl_easy *data, struct TELNET *tn,
+ int option, int newstate)
{
if(newstate == CURL_YES) {
switch(tn->us[option]) {
}
}
-static
-void rec_do(struct Curl_easy *data, struct TELNET *tn, int option)
+static void rec_do(struct Curl_easy *data, struct TELNET *tn, int option)
{
switch(tn->us[option]) {
case CURL_NO:
}
}
-static
-void rec_dont(struct Curl_easy *data, struct TELNET *tn, int option)
+static void rec_dont(struct Curl_easy *data, struct TELNET *tn, int option)
{
switch(tn->us[option]) {
case CURL_NO:
}
}
-
static void printsub(struct Curl_easy *data,
int direction, /* '<' or '>' */
unsigned char *pointer, /* where suboption data is */
if(length >= 3) {
int j;
- i = pointer[length-2];
- j = pointer[length-1];
+ i = pointer[length - 2];
+ j = pointer[length - 1];
if(i != CURL_IAC || j != CURL_SE) {
infof(data, "(terminated by ");
printsub(data, '<', (unsigned char *)tn->subbuffer, CURL_SB_LEN(tn) + 2);
switch(CURL_SB_GET(tn)) {
- case CURL_TELOPT_TTYPE:
- if(bad_option(tn->subopt_ttype))
- return CURLE_BAD_FUNCTION_ARGUMENT;
- if(strlen(tn->subopt_ttype) > 1000) {
- failf(data, "Tool long telnet TTYPE");
- return CURLE_SEND_ERROR;
- }
- len = curl_msnprintf((char *)temp, sizeof(temp), "%c%c%c%c%s%c%c",
- CURL_IAC, CURL_SB, CURL_TELOPT_TTYPE,
- CURL_TELQUAL_IS, tn->subopt_ttype, CURL_IAC,
- CURL_SE);
- bytes_written = swrite(conn->sock[FIRSTSOCKET], temp, len);
+ case CURL_TELOPT_TTYPE:
+ if(bad_option(tn->subopt_ttype))
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+ if(strlen(tn->subopt_ttype) > 1000) {
+ failf(data, "Tool long telnet TTYPE");
+ return CURLE_SEND_ERROR;
+ }
+ len = curl_msnprintf((char *)temp, sizeof(temp), "%c%c%c%c%s%c%c",
+ CURL_IAC, CURL_SB, CURL_TELOPT_TTYPE,
+ CURL_TELQUAL_IS, tn->subopt_ttype, CURL_IAC,
+ CURL_SE);
+ bytes_written = swrite(conn->sock[FIRSTSOCKET], temp, len);
- if(bytes_written < 0) {
- err = SOCKERRNO;
- failf(data, "Sending data failed (%d)", err);
- return CURLE_SEND_ERROR;
- }
- printsub(data, '>', &temp[2], len-2);
- break;
- case CURL_TELOPT_XDISPLOC:
- if(bad_option(tn->subopt_xdisploc))
+ if(bytes_written < 0) {
+ err = SOCKERRNO;
+ failf(data, "Sending data failed (%d)", err);
+ return CURLE_SEND_ERROR;
+ }
+ printsub(data, '>', &temp[2], len-2);
+ break;
+ case CURL_TELOPT_XDISPLOC:
+ if(bad_option(tn->subopt_xdisploc))
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+ if(strlen(tn->subopt_xdisploc) > 1000) {
+ failf(data, "Tool long telnet XDISPLOC");
+ return CURLE_SEND_ERROR;
+ }
+ len = curl_msnprintf((char *)temp, sizeof(temp), "%c%c%c%c%s%c%c",
+ CURL_IAC, CURL_SB, CURL_TELOPT_XDISPLOC,
+ CURL_TELQUAL_IS, tn->subopt_xdisploc, CURL_IAC,
+ CURL_SE);
+ bytes_written = swrite(conn->sock[FIRSTSOCKET], temp, len);
+ if(bytes_written < 0) {
+ err = SOCKERRNO;
+ failf(data, "Sending data failed (%d)", err);
+ return CURLE_SEND_ERROR;
+ }
+ printsub(data, '>', &temp[2], len - 2);
+ break;
+ case CURL_TELOPT_NEW_ENVIRON:
+ len = curl_msnprintf((char *)temp, sizeof(temp), "%c%c%c%c",
+ CURL_IAC, CURL_SB, CURL_TELOPT_NEW_ENVIRON,
+ CURL_TELQUAL_IS);
+ for(v = tn->telnet_vars; v; v = v->next) {
+ size_t tmplen = (strlen(v->data) + 1);
+ if(bad_option(v->data))
return CURLE_BAD_FUNCTION_ARGUMENT;
- if(strlen(tn->subopt_xdisploc) > 1000) {
- failf(data, "Tool long telnet XDISPLOC");
- return CURLE_SEND_ERROR;
- }
- len = curl_msnprintf((char *)temp, sizeof(temp), "%c%c%c%c%s%c%c",
- CURL_IAC, CURL_SB, CURL_TELOPT_XDISPLOC,
- CURL_TELQUAL_IS, tn->subopt_xdisploc, CURL_IAC,
- CURL_SE);
- bytes_written = swrite(conn->sock[FIRSTSOCKET], temp, len);
- if(bytes_written < 0) {
- err = SOCKERRNO;
- failf(data,"Sending data failed (%d)",err);
- return CURLE_SEND_ERROR;
- }
- printsub(data, '>', &temp[2], len-2);
- break;
- case CURL_TELOPT_NEW_ENVIRON:
- len = curl_msnprintf((char *)temp, sizeof(temp), "%c%c%c%c",
- CURL_IAC, CURL_SB, CURL_TELOPT_NEW_ENVIRON,
- CURL_TELQUAL_IS);
- for(v = tn->telnet_vars; v; v = v->next) {
- size_t tmplen = (strlen(v->data) + 1);
- if(bad_option(v->data))
- return CURLE_BAD_FUNCTION_ARGUMENT;
- /* Add the variable if it fits */
- if(len + tmplen < (int)sizeof(temp)-6) {
- char *s = strchr(v->data, ',');
- if(!s)
- len += curl_msnprintf((char *)&temp[len], sizeof(temp) - len,
- "%c%s", CURL_NEW_ENV_VAR, v->data);
- else {
- size_t vlen = s - v->data;
- len += curl_msnprintf((char *)&temp[len], sizeof(temp) - len,
- "%c%.*s%c%s", CURL_NEW_ENV_VAR,
- (int)vlen, v->data, CURL_NEW_ENV_VALUE, ++s);
- }
+ /* Add the variable if it fits */
+ if(len + tmplen < (int)sizeof(temp) - 6) {
+ char *s = strchr(v->data, ',');
+ if(!s)
+ len += curl_msnprintf((char *)&temp[len], sizeof(temp) - len,
+ "%c%s", CURL_NEW_ENV_VAR, v->data);
+ else {
+ size_t vlen = s - v->data;
+ len += curl_msnprintf((char *)&temp[len], sizeof(temp) - len,
+ "%c%.*s%c%s", CURL_NEW_ENV_VAR,
+ (int)vlen, v->data, CURL_NEW_ENV_VALUE, ++s);
}
}
- curl_msnprintf((char *)&temp[len], sizeof(temp) - len,
- "%c%c", CURL_IAC, CURL_SE);
- len += 2;
- bytes_written = swrite(conn->sock[FIRSTSOCKET], temp, len);
- if(bytes_written < 0) {
- err = SOCKERRNO;
- failf(data,"Sending data failed (%d)",err);
- }
- printsub(data, '>', &temp[2], len-2);
- break;
+ }
+ curl_msnprintf((char *)&temp[len], sizeof(temp) - len,
+ "%c%c", CURL_IAC, CURL_SE);
+ len += 2;
+ bytes_written = swrite(conn->sock[FIRSTSOCKET], temp, len);
+ if(bytes_written < 0) {
+ err = SOCKERRNO;
+ failf(data, "Sending data failed (%d)", err);
+ }
+ printsub(data, '>', &temp[2], len - 2);
+ break;
}
return CURLE_OK;
}
/* data suboption is now ready */
printsub(data, '>', (unsigned char *)tn->subbuffer + 2,
- CURL_SB_LEN(tn)-2);
+ CURL_SB_LEN(tn) - 2);
/* we send the header of the suboption... */
bytes_written = swrite(conn->sock[FIRSTSOCKET], tn->subbuffer, 3);
}
}
-static
-CURLcode telrcv(struct Curl_easy *data,
- struct TELNET *tn,
- const unsigned char *inbuf, /* Data received from socket */
- ssize_t count) /* Number of bytes received */
+static CURLcode telrcv(struct Curl_easy *data,
+ struct TELNET *tn,
+ const unsigned char *inbuf, /* Data received from
+ socket */
+ ssize_t count) /* Number of bytes
+ received */
{
unsigned char c;
CURLcode result;
} \
startwrite = -1
-#define writebyte() \
- if(startwrite < 0) \
- startwrite = in
+#define writebyte() \
+ if(startwrite < 0) \
+ startwrite = in
#define bufferflush() startskipping()
}
break;
- case CURL_TS_WILL:
- printoption(data, "RCVD", CURL_WILL, c);
- tn->please_negotiate = 1;
- rec_will(data, tn, c);
- tn->telrcv_state = CURL_TS_DATA;
- break;
+ case CURL_TS_WILL:
+ printoption(data, "RCVD", CURL_WILL, c);
+ tn->please_negotiate = 1;
+ rec_will(data, tn, c);
+ tn->telrcv_state = CURL_TS_DATA;
+ break;
- case CURL_TS_WONT:
- printoption(data, "RCVD", CURL_WONT, c);
- tn->please_negotiate = 1;
- rec_wont(data, tn, c);
- tn->telrcv_state = CURL_TS_DATA;
- break;
+ case CURL_TS_WONT:
+ printoption(data, "RCVD", CURL_WONT, c);
+ tn->please_negotiate = 1;
+ rec_wont(data, tn, c);
+ tn->telrcv_state = CURL_TS_DATA;
+ break;
- case CURL_TS_DO:
- printoption(data, "RCVD", CURL_DO, c);
- tn->please_negotiate = 1;
- rec_do(data, tn, c);
- tn->telrcv_state = CURL_TS_DATA;
- break;
+ case CURL_TS_DO:
+ printoption(data, "RCVD", CURL_DO, c);
+ tn->please_negotiate = 1;
+ rec_do(data, tn, c);
+ tn->telrcv_state = CURL_TS_DATA;
+ break;
- case CURL_TS_DONT:
- printoption(data, "RCVD", CURL_DONT, c);
- tn->please_negotiate = 1;
- rec_dont(data, tn, c);
- tn->telrcv_state = CURL_TS_DATA;
- break;
+ case CURL_TS_DONT:
+ printoption(data, "RCVD", CURL_DONT, c);
+ tn->please_negotiate = 1;
+ rec_dont(data, tn, c);
+ tn->telrcv_state = CURL_TS_DATA;
+ break;
- case CURL_TS_SB:
- if(c == CURL_IAC)
- tn->telrcv_state = CURL_TS_SE;
- else
- CURL_SB_ACCUM(tn, c);
- break;
+ case CURL_TS_SB:
+ if(c == CURL_IAC)
+ tn->telrcv_state = CURL_TS_SE;
+ else
+ CURL_SB_ACCUM(tn, c);
+ break;
- case CURL_TS_SE:
- if(c != CURL_SE) {
- if(c != CURL_IAC) {
- /*
- * This is an error. We only expect to get "IAC IAC" or "IAC SE".
- * Several things may have happened. An IAC was not doubled, the
- * IAC SE was left off, or another option got inserted into the
- * suboption are all possibilities. If we assume that the IAC was
- * not doubled, and really the IAC SE was left off, we could get
- * into an infinite loop here. So, instead, we terminate the
- * suboption, and process the partial suboption if we can.
- */
- CURL_SB_ACCUM(tn, CURL_IAC);
- CURL_SB_ACCUM(tn, c);
- tn->subpointer -= 2;
- CURL_SB_TERM(tn);
-
- printoption(data, "In SUBOPTION processing, RCVD", CURL_IAC, c);
- result = suboption(data, tn); /* handle sub-option */
- if(result)
- return result;
- tn->telrcv_state = CURL_TS_IAC;
- goto process_iac;
- }
- CURL_SB_ACCUM(tn, c);
- tn->telrcv_state = CURL_TS_SB;
- }
- else {
+ case CURL_TS_SE:
+ if(c != CURL_SE) {
+ if(c != CURL_IAC) {
+ /*
+ * This is an error. We only expect to get "IAC IAC" or "IAC SE".
+ * Several things may have happened. An IAC was not doubled, the
+ * IAC SE was left off, or another option got inserted into the
+ * suboption are all possibilities. If we assume that the IAC was
+ * not doubled, and really the IAC SE was left off, we could get
+ * into an infinite loop here. So, instead, we terminate the
+ * suboption, and process the partial suboption if we can.
+ */
CURL_SB_ACCUM(tn, CURL_IAC);
- CURL_SB_ACCUM(tn, CURL_SE);
+ CURL_SB_ACCUM(tn, c);
tn->subpointer -= 2;
CURL_SB_TERM(tn);
+
+ printoption(data, "In SUBOPTION processing, RCVD", CURL_IAC, c);
result = suboption(data, tn); /* handle sub-option */
if(result)
return result;
- tn->telrcv_state = CURL_TS_DATA;
+ tn->telrcv_state = CURL_TS_IAC;
+ goto process_iac;
}
- break;
+ CURL_SB_ACCUM(tn, c);
+ tn->telrcv_state = CURL_TS_SB;
+ }
+ else {
+ CURL_SB_ACCUM(tn, CURL_IAC);
+ CURL_SB_ACCUM(tn, CURL_SE);
+ tn->subpointer -= 2;
+ CURL_SB_TERM(tn);
+ result = suboption(data, tn); /* handle sub-option */
+ if(result)
+ return result;
+ tn->telrcv_state = CURL_TS_DATA;
+ }
+ break;
}
++in;
}
pfd[0].fd = conn->sock[FIRSTSOCKET];
pfd[0].events = POLLOUT;
switch(Curl_poll(pfd, 1, -1)) {
- case -1: /* error, abort writing */
- case 0: /* timeout (will never happen) */
- result = CURLE_SEND_ERROR;
- break;
- default: /* write! */
- bytes_written = 0;
- result = Curl_xfer_send(data, outbuf + total_written,
- outlen - total_written, FALSE, &bytes_written);
- total_written += bytes_written;
- break;
+ case -1: /* error, abort writing */
+ case 0: /* timeout (will never happen) */
+ result = CURLE_SEND_ERROR;
+ break;
+ default: /* write! */
+ bytes_written = 0;
+ result = Curl_xfer_send(data, outbuf + total_written,
+ outlen - total_written, FALSE, &bytes_written);
+ total_written += bytes_written;
+ break;
}
}
WSANETWORKEVENTS events;
HANDLE stdin_handle;
HANDLE objs[2];
- DWORD obj_count;
- DWORD wait_timeout;
+ DWORD obj_count;
+ DWORD wait_timeout;
DWORD readfile_read;
int err;
#else
#endif
struct curltime now;
bool keepon = TRUE;
- char buffer[4*1024];
+ char buffer[4 * 1024];
struct TELNET *tn;
*done = TRUE; /* unconditionally */
}
/* Tell Winsock what events we want to listen to */
- if(WSAEventSelect(sockfd, event_handle, FD_READ|FD_CLOSE) == SOCKET_ERROR) {
+ if(WSAEventSelect(sockfd, event_handle, FD_READ | FD_CLOSE) ==
+ SOCKET_ERROR) {
WSACloseEvent(event_handle);
return CURLE_RECV_ERROR;
}
/* If stdin_handle is a pipe, use PeekNamedPipe() method to check it,
else use the old WaitForMultipleObjects() way */
- if(GetFileType(stdin_handle) == FILE_TYPE_PIPE ||
- data->set.is_fread_set) {
+ if(GetFileType(stdin_handle) == FILE_TYPE_PIPE || data->set.is_fread_set) {
/* Do not wait for stdin_handle, just wait for event_handle */
obj_count = 1;
/* Check stdin_handle per 100 milliseconds */
FALSE, wait_timeout);
switch(waitret) {
- case WAIT_TIMEOUT:
- {
+ case WAIT_TIMEOUT: {
for(;;) {
if(data->set.is_fread_set) {
size_t n;
if(!readfile_read)
break;
- if(!ReadFile(stdin_handle, buffer, buf_size,
- &readfile_read, NULL)) {
+ if(!ReadFile(stdin_handle, buffer, buf_size, &readfile_read, NULL)) {
keepon = FALSE;
result = CURLE_READ_ERROR;
break;
}
break;
- case WAIT_OBJECT_0 + 1:
- {
- if(!ReadFile(stdin_handle, buffer, buf_size,
- &readfile_read, NULL)) {
+ case WAIT_OBJECT_0 + 1: {
+ if(!ReadFile(stdin_handle, buffer, buf_size, &readfile_read, NULL)) {
keepon = FALSE;
result = CURLE_READ_ERROR;
break;
}
break;
- case WAIT_OBJECT_0:
- {
+ case WAIT_OBJECT_0: {
events.lNetworkEvents = 0;
if(WSAEnumNetworkEvents(sockfd, event_handle, &events) == SOCKET_ERROR) {
err = SOCKERRNO;
break;
}
- result = telrcv(data, tn, (unsigned char *) buffer, nread);
+ result = telrcv(data, tn, (unsigned char *)buffer, nread);
if(result) {
keepon = FALSE;
break;
if(events.lNetworkEvents & FD_CLOSE) {
keepon = FALSE;
}
+ break;
}
- break;
-
- }
+ } /* switch */
if(data->set.timeout) {
now = curlx_now();
else {
/* read from user-supplied method */
snread = (int)data->state.fread_func(buffer, 1, sizeof(buffer),
- data->state.in);
+ data->state.in);
if(snread == CURL_READFUNC_ABORT) {
keepon = FALSE;
break;
/* RFC2348 allows the block size to be negotiated */
#define TFTP_BLKSIZE_DEFAULT 512
-#define TFTP_OPTION_BLKSIZE "blksize"
+#define TFTP_OPTION_BLKSIZE "blksize"
/* from RFC2349: */
#define TFTP_OPTION_TSIZE "tsize"
struct easy_pollset *ps);
static CURLcode tftp_translate_code(tftp_error_t error);
-
/*
* TFTP protocol handler.
*/
timeout = 15;
/* Average reposting an ACK after 5 seconds */
- state->retry_max = (int)timeout/5;
+ state->retry_max = (int)timeout / 5;
/* But bound the total number */
if(state->retry_max < 3)
state->retry_max = 50;
/* Compute the re-ACK interval to suit the timeout */
- state->retry_time = (int)(timeout/state->retry_max);
+ state->retry_time = (int)(timeout / state->retry_max);
if(state->retry_time < 1)
state->retry_time = 1;
packet->data[1] = (unsigned char)(num & 0xff);
}
-
static void setpacketblock(struct tftp_packet *packet, unsigned short num)
{
packet->data[2] = (unsigned char)(num >> 8);
static size_t tftp_strnlen(const char *string, size_t maxlen)
{
const char *end = memchr(string, '\0', maxlen);
- return end ? (size_t) (end - string) : maxlen;
+ return end ? (size_t)(end - string) : maxlen;
}
static const char *tftp_option_get(const char *buf, size_t len,
return NULL;
*option = buf;
- loc += tftp_strnlen(buf + loc, len-loc);
+ loc += tftp_strnlen(buf + loc, len - loc);
loc++; /* NULL term */
if(loc > len)
/* the next blocknum is x + 1 but it needs to wrap at an unsigned 16bit
boundary */
-#define NEXT_BLOCKNUM(x) (((x) + 1)&0xffff)
+#define NEXT_BLOCKNUM(x) (((x) + 1) & 0xffff)
/**********************************************************
*
bufptr += cb;
} while(state->sbytes < state->blksize && cb);
- sbytes = sendto(state->sockfd, (void *) state->spacket.data,
+ sbytes = sendto(state->sockfd, (void *)state->spacket.data,
4 + (SEND_TYPE_ARG3)state->sbytes, SEND_4TH_ARG,
(struct sockaddr *)&state->remote_addr,
state->remote_addrlen);
(NEXT_BLOCKNUM(state->block) == getrpacketblock(&state->rpacket))) {
result = Curl_client_write(data, CLIENTWRITE_BODY,
(char *)state->rpacket.data + 4,
- state->rbytes-4);
+ state->rbytes - 4);
if(result) {
tftp_state_machine(state, TFTP_EVENT_ERROR);
return result;
}
}
break;
- case TFTP_EVENT_ERROR:
- {
+ case TFTP_EVENT_ERROR: {
unsigned short error = getrpacketblock(&state->rpacket);
char *str = (char *)state->rpacket.data + 4;
size_t strn = state->rbytes - 4;
return result;
}
-
/**********************************************************
*
* tftp_do
#include "curlx/warnless.h"
#if !defined(CURL_DISABLE_HTTP) || !defined(CURL_DISABLE_SMTP) || \
- !defined(CURL_DISABLE_IMAP)
+ !defined(CURL_DISABLE_IMAP)
/*
* checkheaders() checks the linked list of custom headers for a
* particular header (prefix). Provide the prefix without colon!
{
struct curl_slist *head;
DEBUGASSERT(thislen);
- DEBUGASSERT(thisheader[thislen-1] != ':');
+ DEBUGASSERT(thisheader[thislen - 1] != ':');
for(head = data->set.headers; head; head = head->next) {
if(curl_strnequal(head->data, thisheader, thislen) &&
- Curl_headersep(head->data[thislen]) )
+ Curl_headersep(head->data[thislen]))
return head->data;
}
{
struct connectdata *conn = data->conn;
- if(conn->handler->protocol&PROTO_FAMILY_FTP)
+ if(conn->handler->protocol & PROTO_FAMILY_FTP)
return Curl_conn_data_pending(data, SECONDARYSOCKET);
/* in the case of libssh2, we can never be really sure that we have emptied
its internal buffers so we MUST always try until we get EAGAIN back */
return (!rcvd_eagain &&
- conn->handler->protocol&(CURLPROTO_SCP|CURLPROTO_SFTP)) ||
+ conn->handler->protocol & (CURLPROTO_SCP | CURLPROTO_SFTP)) ||
Curl_conn_data_pending(data, FIRSTSOCKET);
}
CURL_TRC_M(data, "sendrecv_dl() no EAGAIN/pending data, mark as dirty");
}
- if(((k->keepon & (KEEP_RECV|KEEP_SEND)) == KEEP_SEND) &&
+ if(((k->keepon & (KEEP_RECV | KEEP_SEND)) == KEEP_SEND) &&
(conn->bits.close || is_multiplex)) {
/* When we have read the entire thing and the close bit is set, the server
may now close the connection. If there is now any kind of sending going
}
/* If there is nothing more to send/recv, the request is done */
- if((k->keepon & (KEEP_RECV|KEEP_SEND)) == 0)
+ if((k->keepon & (KEEP_RECV | KEEP_SEND)) == 0)
data->req.done = TRUE;
result = Curl_pgrsUpdate(data);
protocol is HTTP as when uploading over HTTP we will still get a
response */
if(data->state.upload &&
- !(conn->handler->protocol&(PROTO_FAMILY_HTTP|CURLPROTO_RTSP)))
+ !(conn->handler->protocol & (PROTO_FAMILY_HTTP | CURLPROTO_RTSP)))
return CURLE_OK;
if(conn->bits.reuse &&
it again. Bad luck. Retry the same request on a fresh connect! */
retry = TRUE;
else if(data->state.refused_stream &&
- (data->req.bytecount + data->req.headerbytecount == 0) ) {
+ (data->req.bytecount + data->req.headerbytecount == 0)) {
/* This was sent on a refused stream, safe to rerun. A refused stream
error can typically only happen on HTTP/2 level if the stream is safe
to issue again, but the nghttp2 API can deliver the message to other
*
***************************************************************************/
-#define Curl_headersep(x) ((((x)==':') || ((x)==';')))
+#define Curl_headersep(x) ((((x) == ':') || ((x) == ';')))
+
char *Curl_checkheaders(const struct Curl_easy *data,
const char *thisheader,
const size_t thislen);
#endif
}
-
CURLcode Curl_uint32_bset_resize(struct uint32_bset *bset, uint32_t nmax)
{
- uint32_t nslots = (nmax < (UINT32_MAX-63)) ?
+ uint32_t nslots = (nmax < (UINT32_MAX - 63)) ?
((nmax + 63) / 64) : (UINT32_MAX / 64);
DEBUGASSERT(bset->init == CURL_UINT32_BSET_MAGIC);
return CURLE_OK;
}
-
void Curl_uint32_bset_destroy(struct uint32_bset *bset)
{
DEBUGASSERT(bset->init == CURL_UINT32_BSET_MAGIC);
return TRUE;
}
-
void Curl_uint32_bset_clear(struct uint32_bset *bset)
{
if(bset->nslots) {
}
}
-
bool Curl_uint32_bset_add(struct uint32_bset *bset, uint32_t i)
{
uint32_t islot = i / 64;
return TRUE;
}
-
void Curl_uint32_bset_remove(struct uint32_bset *bset, uint32_t i)
{
size_t islot = i / 64;
bset->slots[islot] &= ~((uint64_t)1 << (i % 64));
}
-
bool Curl_uint32_bset_contains(struct uint32_bset *bset, uint32_t i)
{
uint32_t islot = i / 64;
return (bset->slots[islot] & ((uint64_t)1 << (i % 64))) != 0;
}
-
bool Curl_uint32_bset_first(struct uint32_bset *bset, uint32_t *pfirst)
{
uint32_t i;
}
#endif /* CURL_POPCOUNT64_IMPLEMENT */
-
#ifdef CURL_CTZ64_IMPLEMENT
uint32_t Curl_ctz64(uint64_t x)
{
bool Curl_uint32_bset_next(struct uint32_bset *bset, uint32_t last,
uint32_t *pnext);
-
#ifndef CURL_POPCOUNT64
-#define CURL_POPCOUNT64(x) Curl_popcount64(x)
+#define CURL_POPCOUNT64(x) Curl_popcount64(x)
#define CURL_POPCOUNT64_IMPLEMENT
uint32_t Curl_popcount64(uint64_t x);
#endif /* !CURL_POPCOUNT64 */
return (id % slots);
}
-
struct uint_hash_entry {
struct uint_hash_entry *next;
- void *value;
+ void *value;
uint32_t id;
};
++h->size;
}
-#define CURL_UINT32_HASH_SLOT(h,id) h->table[uint32_hash_hash(id, h->slots)]
-#define CURL_UINT32_HASH_SLOT_ADDR(h,id) &CURL_UINT32_HASH_SLOT(h,id)
+#define CURL_UINT32_HASH_SLOT(h, id) h->table[uint32_hash_hash(id, h->slots)]
+#define CURL_UINT32_HASH_SLOT_ADDR(h, id) &CURL_UINT32_HASH_SLOT(h, id)
bool Curl_uint32_hash_set(struct uint_hash *h, uint32_t id, void *value)
{
#endif
};
-
void Curl_uint32_hash_init(struct uint_hash *h,
uint32_t slots,
Curl_uint32_hash_dtor *dtor);
void *Curl_uint32_hash_get(struct uint_hash *h, uint32_t id);
uint32_t Curl_uint32_hash_count(struct uint_hash *h);
-
typedef bool Curl_uint32_hash_visit_cb(uint32_t id, void *value,
void *user_data);
memset(&bset->head, 0, sizeof(bset->head));
}
-
static struct uint32_spbset_chunk *
uint32_spbset_get_chunk(struct uint32_spbset *bset, uint32_t i, bool grow)
{
return chunk;
}
-
bool Curl_uint32_spbset_add(struct uint32_spbset *bset, uint32_t i)
{
struct uint32_spbset_chunk *chunk;
return TRUE;
}
-
void Curl_uint32_spbset_remove(struct uint32_spbset *bset, uint32_t i)
{
struct uint32_spbset_chunk *chunk;
}
}
-
bool Curl_uint32_spbset_contains(struct uint32_spbset *bset, uint32_t i)
{
struct uint32_spbset_chunk *chunk;
return FALSE;
}
-
static bool uint32_spbset_chunk_first(struct uint32_spbset_chunk *chunk,
uint32_t *pfirst)
{
return FALSE;
}
-
static bool uint32_spbset_chunk_next(struct uint32_spbset_chunk *chunk,
uint32_t last,
uint32_t *pnext)
#endif
}
-
static void uint32_tbl_clear_rows(struct uint32_tbl *tbl,
uint32_t from,
uint32_t upto_excluding)
}
}
-
CURLcode Curl_uint32_tbl_resize(struct uint32_tbl *tbl, uint32_t nrows)
{
/* we use `tbl->nrows + 1` during iteration, want that to work */
return CURLE_OK;
}
-
void Curl_uint32_tbl_destroy(struct uint32_tbl *tbl)
{
DEBUGASSERT(tbl->init == CURL_UINT32_TBL_MAGIC);
tbl->last_key_added = UINT32_MAX;
}
-
uint32_t Curl_uint32_tbl_capacity(struct uint32_tbl *tbl)
{
return tbl->nrows;
}
-
uint32_t Curl_uint32_tbl_count(struct uint32_tbl *tbl)
{
return tbl->nentries;
}
-
void *Curl_uint32_tbl_get(struct uint32_tbl *tbl, uint32_t key)
{
return (key < tbl->nrows) ? tbl->rows[key] : NULL;
}
-
bool Curl_uint32_tbl_add(struct uint32_tbl *tbl, void *entry, uint32_t *pkey)
{
uint32_t key, start_pos;
return FALSE;
}
-
void Curl_uint32_tbl_remove(struct uint32_tbl *tbl, uint32_t key)
{
uint32_tbl_clear_rows(tbl, key, key + 1);
}
-
bool Curl_uint32_tbl_contains(struct uint32_tbl *tbl, uint32_t key)
{
return (key < tbl->nrows) ? !!tbl->rows[key] : FALSE;
}
-
static bool uint32_tbl_next_at(struct uint32_tbl *tbl, uint32_t key,
uint32_t *pkey, void **pentry)
{
return FALSE;
}
-
bool Curl_uint32_tbl_next(struct uint32_tbl *tbl, uint32_t last_key,
uint32_t *pkey, void **pentry)
{
#define MAX_URL_LEN 0xffff
/*
-* get_protocol_family()
-*
-* This is used to return the protocol family for a given protocol.
-*
-* Parameters:
-*
-* 'h' [in] - struct Curl_handler pointer.
-*
-* Returns the family as a single bit protocol identifier.
-*/
+ * get_protocol_family()
+ *
+ * This is used to return the protocol family for a given protocol.
+ *
+ * Parameters:
+ *
+ * 'h' [in] - struct Curl_handler pointer.
+ *
+ * Returns the family as a single bit protocol identifier.
+ */
static curl_prot_t get_protocol_family(const struct Curl_handler *h)
{
DEBUGASSERT(h);
set->conn_max_idle_ms = 118 * 1000;
set->conn_max_age_ms = 24 * 3600 * 1000;
set->http09_allowed = FALSE;
- set->httpwant = CURL_HTTP_VERSION_NONE
- ;
+ set->httpwant = CURL_HTTP_VERSION_NONE;
#if defined(USE_HTTP2) || defined(USE_HTTP3)
memset(&set->priority, 0, sizeof(set->priority));
#endif
(!conn->bits.protoconnstart || !conn->bits.close)) {
if(Curl_multiplex_wanted(data->multi) &&
- (data->state.http_neg.allowed & (CURL_HTTP_V2x|CURL_HTTP_V3x)))
+ (data->state.http_neg.allowed & (CURL_HTTP_V2x | CURL_HTTP_V3x)))
/* allows HTTP/2 or newer */
return TRUE;
}
}
#ifndef CURL_DISABLE_PROXY
-static bool
-proxy_info_matches(const struct proxy_info *data,
- const struct proxy_info *needle)
+static bool proxy_info_matches(const struct proxy_info *data,
+ const struct proxy_info *needle)
{
if((data->proxytype == needle->proxytype) &&
(data->port == needle->port) &&
return FALSE;
}
-static bool
-socks_proxy_info_matches(const struct proxy_info *data,
- const struct proxy_info *needle)
+static bool socks_proxy_info_matches(const struct proxy_info *data,
+ const struct proxy_info *needle)
{
if(!proxy_info_matches(data, needle))
return FALSE;
}
#else
/* disabled, will not get called */
-#define proxy_info_matches(x,y) FALSE
-#define socks_proxy_info_matches(x,y) FALSE
+#define proxy_info_matches(x, y) FALSE
+#define socks_proxy_info_matches(x, y) FALSE
#endif
/* A connection has to have been idle for less than 'conn_max_idle_ms'
dead = (state & CONNRESULT_DEAD);
/* detach the connection again */
Curl_detach_connection(data);
-
}
else {
bool input_pending = FALSE;
return FALSE;
/* ip_version must match */
- if(m->data->set.ipver != CURL_IPRESOLVE_WHATEVER
- && m->data->set.ipver != conn->ip_version)
+ if(m->data->set.ipver != CURL_IPRESOLVE_WHATEVER &&
+ m->data->set.ipver != conn->ip_version)
return FALSE;
if(m->needle->localdev || m->needle->localport) {
return FALSE;
}
if(CONN_ATTACHED(conn) >=
- Curl_conn_get_max_concurrent(m->data, conn, FIRSTSOCKET)) {
+ Curl_conn_get_max_concurrent(m->data, conn, FIRSTSOCKET)) {
infof(m->data, "MAX_CONCURRENT_STREAMS reached, skip (%u)",
CONN_ATTACHED(conn));
return FALSE;
return FALSE;
if(m->needle->bits.socksproxy &&
- !socks_proxy_info_matches(&m->needle->socks_proxy,
- &conn->socks_proxy))
+ !socks_proxy_info_matches(&m->needle->socks_proxy, &conn->socks_proxy))
return FALSE;
if(m->needle->bits.httpproxy) {
/* match SSL config to proxy */
if(!Curl_ssl_conn_config_match(m->data, conn, TRUE)) {
DEBUGF(infof(m->data,
- "Connection #%" FMT_OFF_T
- " has different SSL proxy parameters, cannot reuse",
- conn->connection_id));
+ "Connection #%" FMT_OFF_T
+ " has different SSL proxy parameters, cannot reuse",
+ conn->connection_id));
return FALSE;
}
/* the SSL config to the server, which may apply here is checked
return TRUE;
}
#else
-#define url_match_proxy_use(c,m) ((void)c, (void)m, TRUE)
+#define url_match_proxy_use(c, m) ((void)c, (void)m, TRUE)
#endif
#ifndef CURL_DISABLE_HTTP
struct url_conn_match *m)
{
if(m->may_multiplex &&
- (m->data->state.http_neg.allowed & (CURL_HTTP_V2x|CURL_HTTP_V3x)) &&
+ (m->data->state.http_neg.allowed & (CURL_HTTP_V2x | CURL_HTTP_V3x)) &&
(m->needle->handler->protocol & CURLPROTO_HTTP) &&
!conn->httpversion_seen) {
if(m->data->set.pipewait) {
return TRUE;
}
#else
-#define url_match_http_multiplex(c,m) ((void)c, (void)m, TRUE)
-#define url_match_http_version(c,m) ((void)c, (void)m, TRUE)
+#define url_match_http_multiplex(c, m) ((void)c, (void)m, TRUE)
+#define url_match_http_version(c, m) ((void)c, (void)m, TRUE)
#endif
static bool url_match_proto_config(struct connectdata *conn,
{
/* Additional match requirements if talking TLS OR
* not talking to an HTTP proxy OR using a tunnel through a proxy */
- if((m->needle->handler->flags&PROTOPT_SSL)
+ if((m->needle->handler->flags & PROTOPT_SSL)
#ifndef CURL_DISABLE_PROXY
|| !m->needle->bits.httpproxy || m->needle->bits.tunnel_proxy
#endif
if((m->needle->bits.conn_to_host && !curl_strequal(
m->needle->conn_to_host.name, conn->conn_to_host.name)) ||
(m->needle->bits.conn_to_port &&
- m->needle->conn_to_port != conn->conn_to_port))
+ m->needle->conn_to_port != conn->conn_to_port))
return FALSE;
/* hostname and port must match */
return TRUE;
}
#else
-#define url_match_auth_ntlm(c,m) ((void)c, (void)m, TRUE)
+#define url_match_auth_ntlm(c, m) ((void)c, (void)m, TRUE)
#endif
static bool url_match_conn(struct connectdata *conn, void *userdata)
*
* The force_reuse flag is set if the connection must be used.
*/
-static bool
-ConnectionExists(struct Curl_easy *data,
- struct connectdata *needle,
- struct connectdata **usethis,
- bool *force_reuse,
- bool *waitpipe)
+static bool ConnectionExists(struct Curl_easy *data,
+ struct connectdata *needle,
+ struct connectdata **usethis,
+ bool *force_reuse,
+ bool *waitpipe)
{
struct url_conn_match match;
bool result;
create_conn() function when the connectdata struct is allocated. */
failf(data, "Protocol \"%s\" %s%s", protostr,
p ? "disabled" : "not supported",
- data->state.this_is_a_follow ? " (in redirect)":"");
+ data->state.this_is_a_follow ? " (in redirect)" : "");
return CURLE_UNSUPPORTED_PROTOCOL;
}
-
CURLcode Curl_uc_to_curlcode(CURLUcode uc)
{
switch(uc) {
}
}
#else
-#define zonefrom_url(a,b,c) Curl_nop_stmt
+#define zonefrom_url(a, b, c) Curl_nop_stmt
#endif
/*
else if(uc != CURLUE_NO_OPTIONS)
return Curl_uc_to_curlcode(uc);
- uc = curl_url_get(uh, CURLUPART_PATH, &data->state.up.path,
- CURLU_URLENCODE);
+ uc = curl_url_get(uh, CURLUPART_PATH, &data->state.up.path, CURLU_URLENCODE);
if(uc)
return Curl_uc_to_curlcode(uc);
return CURLE_OK;
}
-
/*
* If we are doing a resumed transfer, we need to setup our stuff
* properly.
return CURLE_OK;
}
-
/*
* setup_connection_internals() -
*
return CURLE_OK;
}
-
#ifndef CURL_DISABLE_PROXY
#ifndef CURL_DISABLE_HTTP
/****************************************************************
-* Detect what (if any) proxy to use. Remember that this selects a host
-* name and is not limited to HTTP proxies only.
-* The returned pointer must be freed by the caller (unless NULL)
-****************************************************************/
+ * Detect what (if any) proxy to use. Remember that this selects a host
+ * name and is not limited to HTTP proxies only.
+ * The returned pointer must be freed by the caller (unless NULL)
+ ****************************************************************/
static char *detect_proxy(struct Curl_easy *data,
struct connectdata *conn)
{
/* When parsing the proxy, allowing non-supported schemes since we have
these made up ones for proxies. Guess scheme for URLs without it. */
uc = curl_url_set(uhp, CURLUPART_URL, proxy,
- CURLU_NON_SUPPORT_SCHEME|CURLU_GUESS_SCHEME);
+ CURLU_NON_SUPPORT_SCHEME | CURLU_GUESS_SCHEME);
if(!uc) {
/* parsed okay as a URL */
uc = curl_url_get(uhp, CURLUPART_SCHEME, &scheme, 0);
if(strcmp("/", path)) {
is_unix_proxy = TRUE;
curlx_free(host);
- host = curl_maprintf(UNIX_SOCKET_PREFIX"%s", path);
+ host = curl_maprintf(UNIX_SOCKET_PREFIX "%s", path);
if(!host) {
result = CURLE_OUT_OF_MEMORY;
goto error;
if(host[0] == '[') {
/* this is a numerical IPv6, strip off the brackets */
size_t len = strlen(host);
- host[len-1] = 0; /* clear the trailing bracket */
+ host[len - 1] = 0; /* clear the trailing bracket */
host++;
zonefrom_url(uhp, data, conn);
}
return CURLE_READ_ERROR;
}
else {
- if(!(conn->handler->flags&PROTOPT_USERPWDCTRL)) {
+ if(!(conn->handler->flags & PROTOPT_USERPWDCTRL)) {
/* if the protocol cannot handle control codes in credentials, make
sure there are none */
if(str_has_ctrl(*userp) || str_has_ctrl(*passwdp)) {
* If the protocol is using SSL and HTTP proxy is used, we set
* the tunnel_proxy bit.
*************************************************************/
- if((conn->given->flags&PROTOPT_SSL) && conn->bits.httpproxy)
+ if((conn->given->flags & PROTOPT_SSL) && conn->bits.httpproxy)
conn->bits.tunnel_proxy = TRUE;
#endif
* we set the tunnel_proxy bit.
*************************************************************/
if((conn->bits.conn_to_host || conn->bits.conn_to_port) &&
- conn->bits.httpproxy)
+ conn->bits.httpproxy)
conn->bits.tunnel_proxy = TRUE;
#endif
#endif /* USE_HTTP2 || USE_HTTP3 */
-
CURLcode Curl_conn_meta_set(struct connectdata *conn, const char *key,
void *meta_data, Curl_meta_dtor *meta_dtor)
{
#include "curl_memrchr.h"
#ifdef _WIN32
- /* MS-DOS/Windows style drive prefix, eg c: in c:foo */
-#define STARTS_WITH_DRIVE_PREFIX(str) \
- ((('a' <= str[0] && str[0] <= 'z') || \
+/* MS-DOS/Windows style drive prefix, eg c: in c:foo */
+#define STARTS_WITH_DRIVE_PREFIX(str) \
+ ((('a' <= str[0] && str[0] <= 'z') || \
('A' <= str[0] && str[0] <= 'Z')) && \
(str[1] == ':'))
#endif
- /* MS-DOS/Windows style drive prefix, optionally with
- * a '|' instead of ':', followed by a slash or NUL */
-#define STARTS_WITH_URL_DRIVE_PREFIX(str) \
- ((('a' <= (str)[0] && (str)[0] <= 'z') || \
- ('A' <= (str)[0] && (str)[0] <= 'Z')) && \
- ((str)[1] == ':' || (str)[1] == '|') && \
+/* MS-DOS/Windows style drive prefix, optionally with
+ * a '|' instead of ':', followed by a slash or NUL */
+#define STARTS_WITH_URL_DRIVE_PREFIX(str) \
+ ((('a' <= (str)[0] && (str)[0] <= 'z') || \
+ ('A' <= (str)[0] && (str)[0] <= 'Z')) && \
+ ((str)[1] == ':' || (str)[1] == '|') && \
((str)[2] == '/' || (str)[2] == '\\' || (str)[2] == 0))
/* scheme is not URL encoded, the longest libcurl supported ones are... */
/* we must add this with whitespace-replacing */
bool left = !query;
const unsigned char *iptr;
- const unsigned char *host_sep = (const unsigned char *) url;
+ const unsigned char *host_sep = (const unsigned char *)url;
CURLcode result = CURLE_OK;
if(!relative) {
size_t n;
- host_sep = (const unsigned char *) find_host_sep(url);
+ host_sep = (const unsigned char *)find_host_sep(url);
/* output the first piece as-is */
n = (const char *)host_sep - url;
result = curlx_dyn_addn(o, "+", 1);
}
else if((*iptr < ' ') || (*iptr >= 0x7f)) {
- unsigned char out[3]={'%'};
+ unsigned char out[3] = { '%' };
Curl_hexbyte(&out[1], *iptr);
result = curlx_dyn_addn(o, out, 3);
}
if(ISALPHA(url[0]))
for(i = 1; i < MAX_SCHEME_LEN; ++i) {
char s = url[i];
- if(s && (ISALNUM(s) || (s == '+') || (s == '-') || (s == '.') )) {
+ if(s && (ISALNUM(s) || (s == '+') || (s == '-') || (s == '.'))) {
/* RFC 3986 3.1 explains:
scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )
*/
if(curlx_str_number(&portptr, &port, 0xffff) || *portptr)
return CURLUE_BAD_PORT_NUMBER;
- u->portnum = (unsigned short) port;
+ u->portnum = (unsigned short)port;
/* generate a new port number string to get rid of leading zeroes etc */
curlx_free(u->port);
u->port = curl_maprintf("%" CURL_FORMAT_CURL_OFF_T, port);
bool done = FALSE;
int n = 0;
const char *c = curlx_dyn_ptr(host);
- unsigned int parts[4] = {0, 0, 0, 0};
+ unsigned int parts[4] = { 0, 0, 0, 0 };
CURLcode result = CURLE_OK;
if(*c == '[')
goto fail;
schemelen = Curl_is_absolute_url(url, schemebuf, sizeof(schemebuf),
- flags & (CURLU_GUESS_SCHEME|
+ flags & (CURLU_GUESS_SCHEME |
CURLU_DEFAULT_SCHEME));
/* handle the file: scheme */
pathlen--;
}
#endif
-
}
else {
/* clear path */
else {
/* no scheme! */
- if(!(flags & (CURLU_DEFAULT_SCHEME|CURLU_GUESS_SCHEME))) {
+ if(!(flags & (CURLU_DEFAULT_SCHEME | CURLU_GUESS_SCHEME))) {
result = CURLUE_BAD_SCHEME;
goto fail;
}
}
#ifndef USE_IDN
-#define host_decode(x,y) CURLUE_LACKS_IDN
-#define host_encode(x,y) CURLUE_LACKS_IDN
+#define host_decode(x, y) CURLUE_LACKS_IDN
+#define host_encode(x, y) CURLUE_LACKS_IDN
#else
static CURLUcode host_decode(const char *host, char **allochost)
{
/* if the new URL is absolute replace the existing with the new. */
if(Curl_is_absolute_url(url, NULL, 0,
- flags & (CURLU_GUESS_SCHEME|CURLU_DEFAULT_SCHEME)))
+ flags & (CURLU_GUESS_SCHEME | CURLU_DEFAULT_SCHEME)))
return parseurl_and_replace(url, u, flags);
/* if the old URL is incomplete (we cannot get an absolute URL in
static bool allowed_in_path(unsigned char x)
{
switch(x) {
- case '!': case '$': case '&': case '\'':
- case '(': case ')': case '{': case '}':
- case '[': case ']': case '*': case '+':
- case ',': case ';': case '=': case ':':
- case '@': case '/':
+ case '!':
+ case '$':
+ case '&':
+ case '\'':
+ case '(':
+ case ')':
+ case '{':
+ case '}':
+ case '[':
+ case ']':
+ case '*':
+ case '+':
+ case ',':
+ case ';':
+ case '=':
+ case ':':
+ case '@':
+ case '/':
return TRUE;
}
return FALSE;
return cc2cu(result);
}
else {
- unsigned char out[3]={'%'};
+ unsigned char out[3] = { '%' };
Curl_hexbyte(&out[1], *i);
result = curlx_dyn_addn(&enc, out, 3);
if(result)
none is present at the end of the existing query already */
size_t querylen = u->query ? strlen(u->query) : 0;
- bool addamperand = querylen && (u->query[querylen -1] != '&');
+ bool addamperand = querylen && (u->query[querylen - 1] != '&');
if(querylen) {
struct dynbuf qbuf;
curlx_dyn_init(&qbuf, CURL_MAX_INPUT_LENGTH);
#include "curl_setup.h"
-#define PORT_FTP 21
-#define PORT_FTPS 990
+#define PORT_FTP 21
+#define PORT_FTPS 990
#define PORT_TELNET 23
-#define PORT_HTTP 80
-#define PORT_HTTPS 443
-#define PORT_DICT 2628
-#define PORT_LDAP 389
-#define PORT_LDAPS 636
-#define PORT_TFTP 69
-#define PORT_SSH 22
-#define PORT_IMAP 143
-#define PORT_IMAPS 993
-#define PORT_POP3 110
-#define PORT_POP3S 995
-#define PORT_SMB 445
-#define PORT_SMBS 445
-#define PORT_SMTP 25
-#define PORT_SMTPS 465 /* sometimes called SSMTP */
-#define PORT_RTSP 554
-#define PORT_RTMP 1935
-#define PORT_RTMPT PORT_HTTP
-#define PORT_RTMPS PORT_HTTPS
+#define PORT_HTTP 80
+#define PORT_HTTPS 443
+#define PORT_DICT 2628
+#define PORT_LDAP 389
+#define PORT_LDAPS 636
+#define PORT_TFTP 69
+#define PORT_SSH 22
+#define PORT_IMAP 143
+#define PORT_IMAPS 993
+#define PORT_POP3 110
+#define PORT_POP3S 995
+#define PORT_SMB 445
+#define PORT_SMBS 445
+#define PORT_SMTP 25
+#define PORT_SMTPS 465 /* sometimes called SSMTP */
+#define PORT_RTSP 554
+#define PORT_RTMP 1935
+#define PORT_RTMPT PORT_HTTP
+#define PORT_RTMPS PORT_HTTPS
#define PORT_GOPHER 70
-#define PORT_MQTT 1883
+#define PORT_MQTT 1883
struct curl_trc_featt;
#ifdef USE_ECH
/* CURLECH_ bits for the tls_ech option */
-# define CURLECH_DISABLE (1<<0)
-# define CURLECH_GREASE (1<<1)
-# define CURLECH_ENABLE (1<<2)
-# define CURLECH_HARD (1<<3)
-# define CURLECH_CLA_CFG (1<<4)
+# define CURLECH_DISABLE (1 << 0)
+# define CURLECH_GREASE (1 << 1)
+# define CURLECH_ENABLE (1 << 2)
+# define CURLECH_HARD (1 << 3)
+# define CURLECH_CLA_CFG (1 << 4)
#endif
#ifndef CURL_DISABLE_WEBSOCKETS
* platforms that have a >= 64-bit type and then we use such a type for the
* protocol fields in the protocol handler.
*/
-#define CURLPROTO_WS (1L<<30)
-#define CURLPROTO_WSS ((curl_prot_t)1<<31)
+#define CURLPROTO_WS (1L << 30)
+#define CURLPROTO_WSS ((curl_prot_t)1 << 31)
#else
#define CURLPROTO_WS 0L
#define CURLPROTO_WSS 0L
/* Convenience defines for checking protocols or their SSL based version. Each
protocol handler should only ever have a single CURLPROTO_ in its protocol
field. */
-#define PROTO_FAMILY_HTTP (CURLPROTO_HTTP|CURLPROTO_HTTPS|CURLPROTO_WS| \
+#define PROTO_FAMILY_HTTP (CURLPROTO_HTTP | CURLPROTO_HTTPS | CURLPROTO_WS | \
CURLPROTO_WSS)
-#define PROTO_FAMILY_FTP (CURLPROTO_FTP|CURLPROTO_FTPS)
-#define PROTO_FAMILY_POP3 (CURLPROTO_POP3|CURLPROTO_POP3S)
-#define PROTO_FAMILY_SMB (CURLPROTO_SMB|CURLPROTO_SMBS)
-#define PROTO_FAMILY_SMTP (CURLPROTO_SMTP|CURLPROTO_SMTPS)
-#define PROTO_FAMILY_SSH (CURLPROTO_SCP|CURLPROTO_SFTP)
+#define PROTO_FAMILY_FTP (CURLPROTO_FTP | CURLPROTO_FTPS)
+#define PROTO_FAMILY_POP3 (CURLPROTO_POP3 | CURLPROTO_POP3S)
+#define PROTO_FAMILY_SMB (CURLPROTO_SMB | CURLPROTO_SMBS)
+#define PROTO_FAMILY_SMTP (CURLPROTO_SMTP | CURLPROTO_SMTPS)
+#define PROTO_FAMILY_SSH (CURLPROTO_SCP | CURLPROTO_SFTP)
-#if !defined(CURL_DISABLE_FTP) || defined(USE_SSH) || \
+#if !defined(CURL_DISABLE_FTP) || defined(USE_SSH) || \
!defined(CURL_DISABLE_POP3)
/* these protocols support CURLOPT_DIRLISTONLY */
#define CURL_LIST_ONLY_PROTOCOL 1
#define MAX_IPADR_LEN sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")
/* Default FTP/IMAP etc response timeout in milliseconds */
-#define RESP_TIMEOUT (60*1000)
+#define RESP_TIMEOUT (60 * 1000)
/* Max string input length is a precaution against abuse and to detect junk
input easier and better. */
larger buffers can help further, but this is deemed a fair memory/speed
compromise. */
#define UPLOADBUFFER_DEFAULT 65536
-#define UPLOADBUFFER_MAX (2*1024*1024)
-#define UPLOADBUFFER_MIN CURL_MAX_WRITE_SIZE
+#define UPLOADBUFFER_MAX (2 * 1024 * 1024)
+#define UPLOADBUFFER_MIN CURL_MAX_WRITE_SIZE
#define CURLEASY_MAGIC_NUMBER 0xc0dedbadU
#ifdef DEBUGBUILD
* are not NULL, but no longer have the MAGIC touch. This gives
* us early warning on things only discovered by valgrind otherwise. */
#define GOOD_EASY_HANDLE(x) \
- (((x) && ((x)->magic == CURLEASY_MAGIC_NUMBER))? TRUE: \
+ (((x) && ((x)->magic == CURLEASY_MAGIC_NUMBER)) ? TRUE : \
(DEBUGASSERT(!(x)), FALSE))
#else
#define GOOD_EASY_HANDLE(x) \
long certverifyresult; /* result from the certificate verification */
curl_ssl_ctx_callback fsslctx; /* function to initialize ssl ctx */
void *fsslctxp; /* parameter for call back */
- char *cert_type; /* format for certificate (default: PEM)*/
+ char *cert_type; /* format for certificate (default: PEM) */
char *key; /* private key filename */
struct curl_blob *key_blob;
char *key_type; /* format for private key (default: PEM) */
*/
#define KEEP_NONE 0
-#define KEEP_RECV (1<<0) /* there is or may be data to read */
-#define KEEP_SEND (1<<1) /* there is or may be data to write */
+#define KEEP_RECV (1 << 0) /* there is or may be data to read */
+#define KEEP_SEND (1 << 1) /* there is or may be data to write */
/* transfer wants to send */
#define CURL_WANT_SEND(data) ((data)->req.keepon & KEEP_SEND)
#define CONNRESULT_DEAD (1<<0) /* The connection is dead. */
#define TRNSPRT_NONE 0
-#define TRNSPRT_TCP 3
-#define TRNSPRT_UDP 4
+#define TRNSPRT_TCP 3
+#define TRNSPRT_UDP 4
#define TRNSPRT_QUIC 5
#define TRNSPRT_UNIX 6
uint8_t transport;
};
-#define CUR_IP_QUAD_HAS_PORTS(x) (((x)->transport == TRNSPRT_TCP) || \
- ((x)->transport == TRNSPRT_UDP) || \
- ((x)->transport == TRNSPRT_QUIC))
+#define CUR_IP_QUAD_HAS_PORTS(x) \
+ (((x)->transport == TRNSPRT_TCP) || \
+ ((x)->transport == TRNSPRT_UDP) || \
+ ((x)->transport == TRNSPRT_QUIC))
struct proxy_info {
struct hostname host;
#define CURL_SPEED_RECORDS (5 + 1) /* 6 entries for 5 seconds */
- curl_off_t speed_amount[ CURL_SPEED_RECORDS ];
- struct curltime speed_time[ CURL_SPEED_RECORDS ];
+ curl_off_t speed_amount[CURL_SPEED_RECORDS];
+ struct curltime speed_time[CURL_SPEED_RECORDS];
unsigned char speeder_c;
BIT(hide);
BIT(ul_size_known);
};
typedef enum {
- RTSPREQ_NONE, /* first in list */
- RTSPREQ_OPTIONS,
- RTSPREQ_DESCRIBE,
- RTSPREQ_ANNOUNCE,
- RTSPREQ_SETUP,
- RTSPREQ_PLAY,
- RTSPREQ_PAUSE,
- RTSPREQ_TEARDOWN,
- RTSPREQ_GET_PARAMETER,
- RTSPREQ_SET_PARAMETER,
- RTSPREQ_RECORD,
- RTSPREQ_RECEIVE,
- RTSPREQ_LAST /* last in list */
+ RTSPREQ_NONE, /* first in list */
+ RTSPREQ_OPTIONS,
+ RTSPREQ_DESCRIBE,
+ RTSPREQ_ANNOUNCE,
+ RTSPREQ_SETUP,
+ RTSPREQ_PLAY,
+ RTSPREQ_PAUSE,
+ RTSPREQ_TEARDOWN,
+ RTSPREQ_GET_PARAMETER,
+ RTSPREQ_SET_PARAMETER,
+ RTSPREQ_RECORD,
+ RTSPREQ_RECEIVE,
+ RTSPREQ_LAST /* last in list */
} Curl_RtspReq;
struct auth {
EXPIRE_LAST /* not an actual timer, used as a marker only */
} expire_id;
-
typedef enum {
TRAILERS_NONE,
TRAILERS_INITIALIZED,
TRAILERS_DONE
} trailers_state;
-
/*
* One instance for each timeout an easy handle can set.
*/
BLOB_LAST
};
-
struct UserDefined {
FILE *err; /* the stderr user data goes here */
void *debugdata; /* the data that will be passed to fdebug */
#ifndef CURL_DISABLE_LDAP
"ldap",
#if !defined(CURL_DISABLE_LDAPS) && \
- ((defined(USE_OPENLDAP) && defined(USE_SSL)) || \
- (!defined(USE_OPENLDAP) && defined(HAVE_LDAP_SSL)))
+ ((defined(USE_OPENLDAP) && defined(USE_SSL)) || \
+ (!defined(USE_OPENLDAP) && defined(HAVE_LDAP_SSL)))
"ldaps",
#endif
#endif
* Use FEATURE() macro to define an entry: this allows documentation check.
*/
-#define FEATURE(name, present, bitmask) {(name), (present), (bitmask)}
+#define FEATURE(name, present, bitmask) { (name), (present), (bitmask) }
struct feat {
const char *name;
|N|V|V|V| |
| |1|2|3| |
*/
-#define WSBIT_FIN (0x80)
-#define WSBIT_RSV1 (0x40)
-#define WSBIT_RSV2 (0x20)
-#define WSBIT_RSV3 (0x10)
-#define WSBIT_RSV_MASK (WSBIT_RSV1 | WSBIT_RSV2 | WSBIT_RSV3)
+#define WSBIT_FIN (0x80)
+#define WSBIT_RSV1 (0x40)
+#define WSBIT_RSV2 (0x20)
+#define WSBIT_RSV3 (0x10)
+#define WSBIT_RSV_MASK (WSBIT_RSV1 | WSBIT_RSV2 | WSBIT_RSV3)
#define WSBIT_OPCODE_CONT (0x0)
#define WSBIT_OPCODE_TEXT (0x1)
#define WSBIT_OPCODE_BIN (0x2)
#define WSBIT_MASK 0x80
/* buffer dimensioning */
-#define WS_CHUNK_SIZE 65535
+#define WS_CHUNK_SIZE 65535
#define WS_CHUNK_COUNT 2
-
/* a client-side WS frame decoder, parsing frame headers and
* payload, keeping track of current position and stats */
enum ws_dec_state {
size_t sendbuf_payload; /* number of payload bytes in sendbuf */
};
-
static const char *ws_frame_name_of_op(uint8_t firstbyte)
{
switch(firstbyte & WSBIT_OPCODE_MASK) {
- case WSBIT_OPCODE_CONT:
- return "CONT";
- case WSBIT_OPCODE_TEXT:
- return "TEXT";
- case WSBIT_OPCODE_BIN:
- return "BIN";
- case WSBIT_OPCODE_CLOSE:
- return "CLOSE";
- case WSBIT_OPCODE_PING:
- return "PING";
- case WSBIT_OPCODE_PONG:
- return "PONG";
- default:
- return "???";
+ case WSBIT_OPCODE_CONT:
+ return "CONT";
+ case WSBIT_OPCODE_TEXT:
+ return "TEXT";
+ case WSBIT_OPCODE_BIN:
+ return "BIN";
+ case WSBIT_OPCODE_CLOSE:
+ return "CLOSE";
+ case WSBIT_OPCODE_PING:
+ return "PING";
+ case WSBIT_OPCODE_PONG:
+ return "PONG";
+ default:
+ return "???";
}
}
uint8_t firstbyte, int cont_flags)
{
switch(firstbyte) {
- /* 0x00 - intermediate TEXT/BINARY fragment */
- case WSBIT_OPCODE_CONT:
- if(!(cont_flags & CURLWS_CONT)) {
- failf(data, "[WS] no ongoing fragmented message to resume");
- return 0;
- }
- return cont_flags | CURLWS_CONT;
- /* 0x80 - final TEXT/BIN fragment */
- case (WSBIT_OPCODE_CONT | WSBIT_FIN):
- if(!(cont_flags & CURLWS_CONT)) {
- failf(data, "[WS] no ongoing fragmented message to resume");
- return 0;
- }
- return cont_flags & ~CURLWS_CONT;
- /* 0x01 - first TEXT fragment */
- case WSBIT_OPCODE_TEXT:
- if(cont_flags & CURLWS_CONT) {
- failf(data, "[WS] fragmented message interrupted by new TEXT msg");
- return 0;
- }
- return CURLWS_TEXT | CURLWS_CONT;
- /* 0x81 - unfragmented TEXT msg */
- case (WSBIT_OPCODE_TEXT | WSBIT_FIN):
- if(cont_flags & CURLWS_CONT) {
- failf(data, "[WS] fragmented message interrupted by new TEXT msg");
- return 0;
- }
- return CURLWS_TEXT;
- /* 0x02 - first BINARY fragment */
- case WSBIT_OPCODE_BIN:
- if(cont_flags & CURLWS_CONT) {
- failf(data, "[WS] fragmented message interrupted by new BINARY msg");
- return 0;
- }
- return CURLWS_BINARY | CURLWS_CONT;
- /* 0x82 - unfragmented BINARY msg */
- case (WSBIT_OPCODE_BIN | WSBIT_FIN):
- if(cont_flags & CURLWS_CONT) {
- failf(data, "[WS] fragmented message interrupted by new BINARY msg");
- return 0;
- }
- return CURLWS_BINARY;
- /* 0x08 - first CLOSE fragment */
- case WSBIT_OPCODE_CLOSE:
- failf(data, "[WS] invalid fragmented CLOSE frame");
+ /* 0x00 - intermediate TEXT/BINARY fragment */
+ case WSBIT_OPCODE_CONT:
+ if(!(cont_flags & CURLWS_CONT)) {
+ failf(data, "[WS] no ongoing fragmented message to resume");
return 0;
- /* 0x88 - unfragmented CLOSE */
- case (WSBIT_OPCODE_CLOSE | WSBIT_FIN):
- return CURLWS_CLOSE;
- /* 0x09 - first PING fragment */
- case WSBIT_OPCODE_PING:
- failf(data, "[WS] invalid fragmented PING frame");
+ }
+ return cont_flags | CURLWS_CONT;
+ /* 0x80 - final TEXT/BIN fragment */
+ case (WSBIT_OPCODE_CONT | WSBIT_FIN):
+ if(!(cont_flags & CURLWS_CONT)) {
+ failf(data, "[WS] no ongoing fragmented message to resume");
return 0;
- /* 0x89 - unfragmented PING */
- case (WSBIT_OPCODE_PING | WSBIT_FIN):
- return CURLWS_PING;
- /* 0x0a - first PONG fragment */
- case WSBIT_OPCODE_PONG:
- failf(data, "[WS] invalid fragmented PONG frame");
+ }
+ return cont_flags & ~CURLWS_CONT;
+ /* 0x01 - first TEXT fragment */
+ case WSBIT_OPCODE_TEXT:
+ if(cont_flags & CURLWS_CONT) {
+ failf(data, "[WS] fragmented message interrupted by new TEXT msg");
return 0;
- /* 0x8a - unfragmented PONG */
- case (WSBIT_OPCODE_PONG | WSBIT_FIN):
- return CURLWS_PONG;
- /* invalid first byte */
- default:
- if(firstbyte & WSBIT_RSV_MASK)
- /* any of the reserved bits 0x40/0x20/0x10 are set */
- failf(data, "[WS] invalid reserved bits: %02x", firstbyte);
- else
- /* any of the reserved opcodes 0x3-0x7 or 0xb-0xf is used */
- failf(data, "[WS] invalid opcode: %02x", firstbyte);
+ }
+ return CURLWS_TEXT | CURLWS_CONT;
+ /* 0x81 - unfragmented TEXT msg */
+ case (WSBIT_OPCODE_TEXT | WSBIT_FIN):
+ if(cont_flags & CURLWS_CONT) {
+ failf(data, "[WS] fragmented message interrupted by new TEXT msg");
+ return 0;
+ }
+ return CURLWS_TEXT;
+ /* 0x02 - first BINARY fragment */
+ case WSBIT_OPCODE_BIN:
+ if(cont_flags & CURLWS_CONT) {
+ failf(data, "[WS] fragmented message interrupted by new BINARY msg");
+ return 0;
+ }
+ return CURLWS_BINARY | CURLWS_CONT;
+ /* 0x82 - unfragmented BINARY msg */
+ case (WSBIT_OPCODE_BIN | WSBIT_FIN):
+ if(cont_flags & CURLWS_CONT) {
+ failf(data, "[WS] fragmented message interrupted by new BINARY msg");
return 0;
+ }
+ return CURLWS_BINARY;
+ /* 0x08 - first CLOSE fragment */
+ case WSBIT_OPCODE_CLOSE:
+ failf(data, "[WS] invalid fragmented CLOSE frame");
+ return 0;
+ /* 0x88 - unfragmented CLOSE */
+ case (WSBIT_OPCODE_CLOSE | WSBIT_FIN):
+ return CURLWS_CLOSE;
+ /* 0x09 - first PING fragment */
+ case WSBIT_OPCODE_PING:
+ failf(data, "[WS] invalid fragmented PING frame");
+ return 0;
+ /* 0x89 - unfragmented PING */
+ case (WSBIT_OPCODE_PING | WSBIT_FIN):
+ return CURLWS_PING;
+ /* 0x0a - first PONG fragment */
+ case WSBIT_OPCODE_PONG:
+ failf(data, "[WS] invalid fragmented PONG frame");
+ return 0;
+ /* 0x8a - unfragmented PONG */
+ case (WSBIT_OPCODE_PONG | WSBIT_FIN):
+ return CURLWS_PONG;
+ /* invalid first byte */
+ default:
+ if(firstbyte & WSBIT_RSV_MASK)
+ /* any of the reserved bits 0x40/0x20/0x10 are set */
+ failf(data, "[WS] invalid reserved bits: %02x", firstbyte);
+ else
+ /* any of the reserved opcodes 0x3-0x7 or 0xb-0xf is used */
+ failf(data, "[WS] invalid opcode: %02x", firstbyte);
+ return 0;
}
}
{
*pfirstbyte = 0;
switch(flags & ~CURLWS_OFFSET) {
- case 0:
- if(contfragment) {
- CURL_TRC_WS(data, "no flags given; interpreting as continuation "
- "fragment for compatibility");
- *pfirstbyte = (WSBIT_OPCODE_CONT | WSBIT_FIN);
- return CURLE_OK;
- }
- failf(data, "[WS] no flags given");
- return CURLE_BAD_FUNCTION_ARGUMENT;
- case CURLWS_CONT:
- if(contfragment) {
- infof(data, "[WS] setting CURLWS_CONT flag without message type is "
- "supported for compatibility but highly discouraged");
- *pfirstbyte = WSBIT_OPCODE_CONT;
- return CURLE_OK;
- }
- failf(data, "[WS] No ongoing fragmented message to continue");
- return CURLE_BAD_FUNCTION_ARGUMENT;
- case CURLWS_TEXT:
- *pfirstbyte = contfragment ? (WSBIT_OPCODE_CONT | WSBIT_FIN)
- : (WSBIT_OPCODE_TEXT | WSBIT_FIN);
- return CURLE_OK;
- case (CURLWS_TEXT | CURLWS_CONT):
- *pfirstbyte = contfragment ? WSBIT_OPCODE_CONT : WSBIT_OPCODE_TEXT;
- return CURLE_OK;
- case CURLWS_BINARY:
- *pfirstbyte = contfragment ? (WSBIT_OPCODE_CONT | WSBIT_FIN)
- : (WSBIT_OPCODE_BIN | WSBIT_FIN);
- return CURLE_OK;
- case (CURLWS_BINARY | CURLWS_CONT):
- *pfirstbyte = contfragment ? WSBIT_OPCODE_CONT : WSBIT_OPCODE_BIN;
- return CURLE_OK;
- case CURLWS_CLOSE:
- *pfirstbyte = WSBIT_OPCODE_CLOSE | WSBIT_FIN;
- return CURLE_OK;
- case (CURLWS_CLOSE | CURLWS_CONT):
- failf(data, "[WS] CLOSE frame must not be fragmented");
- return CURLE_BAD_FUNCTION_ARGUMENT;
- case CURLWS_PING:
- *pfirstbyte = WSBIT_OPCODE_PING | WSBIT_FIN;
+ case 0:
+ if(contfragment) {
+ CURL_TRC_WS(data, "no flags given; interpreting as continuation "
+ "fragment for compatibility");
+ *pfirstbyte = (WSBIT_OPCODE_CONT | WSBIT_FIN);
return CURLE_OK;
- case (CURLWS_PING | CURLWS_CONT):
- failf(data, "[WS] PING frame must not be fragmented");
- return CURLE_BAD_FUNCTION_ARGUMENT;
- case CURLWS_PONG:
- *pfirstbyte = WSBIT_OPCODE_PONG | WSBIT_FIN;
+ }
+ failf(data, "[WS] no flags given");
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+ case CURLWS_CONT:
+ if(contfragment) {
+ infof(data, "[WS] setting CURLWS_CONT flag without message type is "
+ "supported for compatibility but highly discouraged");
+ *pfirstbyte = WSBIT_OPCODE_CONT;
return CURLE_OK;
- case (CURLWS_PONG | CURLWS_CONT):
- failf(data, "[WS] PONG frame must not be fragmented");
- return CURLE_BAD_FUNCTION_ARGUMENT;
- default:
- failf(data, "[WS] unknown flags: %x", flags);
- return CURLE_BAD_FUNCTION_ARGUMENT;
+ }
+ failf(data, "[WS] No ongoing fragmented message to continue");
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+ case CURLWS_TEXT:
+ *pfirstbyte = contfragment ? (WSBIT_OPCODE_CONT | WSBIT_FIN)
+ : (WSBIT_OPCODE_TEXT | WSBIT_FIN);
+ return CURLE_OK;
+ case (CURLWS_TEXT | CURLWS_CONT):
+ *pfirstbyte = contfragment ? WSBIT_OPCODE_CONT : WSBIT_OPCODE_TEXT;
+ return CURLE_OK;
+ case CURLWS_BINARY:
+ *pfirstbyte = contfragment ? (WSBIT_OPCODE_CONT | WSBIT_FIN)
+ : (WSBIT_OPCODE_BIN | WSBIT_FIN);
+ return CURLE_OK;
+ case (CURLWS_BINARY | CURLWS_CONT):
+ *pfirstbyte = contfragment ? WSBIT_OPCODE_CONT : WSBIT_OPCODE_BIN;
+ return CURLE_OK;
+ case CURLWS_CLOSE:
+ *pfirstbyte = WSBIT_OPCODE_CLOSE | WSBIT_FIN;
+ return CURLE_OK;
+ case (CURLWS_CLOSE | CURLWS_CONT):
+ failf(data, "[WS] CLOSE frame must not be fragmented");
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+ case CURLWS_PING:
+ *pfirstbyte = WSBIT_OPCODE_PING | WSBIT_FIN;
+ return CURLE_OK;
+ case (CURLWS_PING | CURLWS_CONT):
+ failf(data, "[WS] PING frame must not be fragmented");
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+ case CURLWS_PONG:
+ *pfirstbyte = WSBIT_OPCODE_PONG | WSBIT_FIN;
+ return CURLE_OK;
+ case (CURLWS_PONG | CURLWS_CONT):
+ failf(data, "[WS] PONG frame must not be fragmented");
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+ default:
+ failf(data, "[WS] unknown flags: %x", flags);
+ return CURLE_BAD_FUNCTION_ARGUMENT;
}
}
failf(data, "[WS] frame length longer than 63 bit not supported");
return CURLE_RECV_ERROR;
}
- dec->payload_len = ((curl_off_t)dec->head[2] << 56) |
+ dec->payload_len =
+ (curl_off_t)dec->head[2] << 56 |
(curl_off_t)dec->head[3] << 48 |
(curl_off_t)dec->head[4] << 40 |
(curl_off_t)dec->head[5] << 32 |
(curl_off_t)dec->head[6] << 24 |
(curl_off_t)dec->head[7] << 16 |
- (curl_off_t)dec->head[8] << 8 |
+ (curl_off_t)dec->head[8] << 8 |
dec->head[9];
break;
default:
sizeof(struct cr_ws_ctx)
};
-
struct wsfield {
const char *name;
const char *val;
size_t randlen;
char keyval[40];
struct SingleRequest *k = &data->req;
- struct wsfield heads[]= {
+ struct wsfield heads[] = {
{
/* The request MUST contain an |Upgrade| header field whose value
MUST include the "websocket" keyword. */
curlx_free(randstr);
for(i = 0; !result && (i < CURL_ARRAYSIZE(heads)); i++) {
if(!Curl_checkheaders(data, heads[i].name, strlen(heads[i].name))) {
- result = curlx_dyn_addf(req, "%s: %s\r\n", heads[i].name,
- heads[i].val);
+ result = curlx_dyn_addf(req, "%s: %s\r\n", heads[i].name, heads[i].val);
}
}
data->state.http_hd_upgrade = TRUE;
const char *p = getenv("CURL_WS_CHUNK_SIZE");
if(p) {
curl_off_t l;
- if(!curlx_str_number(&p, &l, 1*1024*1024))
+ if(!curlx_str_number(&p, &l, 1 * 1024 * 1024))
chunk_size = (size_t)l;
}
}
const char *p = getenv("CURL_WS_CHUNK_EAGAIN");
if(p) {
curl_off_t l;
- if(!curlx_str_number(&p, &l, 1*1024*1024))
+ if(!curlx_str_number(&p, &l, 1 * 1024 * 1024))
chunk_egain = (size_t)l;
}
#endif
return Curl_http_setup_conn(data, conn);
}
-
const struct curl_ws_frame *curl_ws_meta(CURL *d)
{
/* we only return something for websocket, called from within the callback
ws = Curl_conn_meta_get(data->conn, CURL_META_PROTO_WS_CONN);
if(ws)
return &ws->recvframe;
-
}
return NULL;
}
CURLPROTO_WSS, /* protocol */
CURLPROTO_HTTP, /* family */
PROTOPT_SSL | PROTOPT_CREDSPERREQUEST | /* flags */
- PROTOPT_USERPWDCTRL
+ PROTOPT_USERPWDCTRL
};
#endif
-
#else
CURLcode curl_ws_recv(CURL *curl, void *buffer, size_t buflen,
extern const struct Curl_handler Curl_handler_wss;
#endif
-
#else
-#define Curl_ws_request(x,y) CURLE_OK
-#define Curl_ws_free(x) Curl_nop_stmt
+#define Curl_ws_request(x, y) CURLE_OK
+#define Curl_ws_free(x) Curl_nop_stmt
#endif
#endif /* HEADER_CURL_WS_H */