*/
void Curl_resolver_cancel(struct connectdata *conn)
{
- if( conn && conn->data && conn->data->state.resolver )
+ if(conn && conn->data && conn->data->state.resolver)
ares_cancel((ares_channel)conn->data->state.resolver);
destroy_async_data(&conn->async);
}
if(async->os_specific) {
struct ResolverResults *res = (struct ResolverResults *)async->os_specific;
- if( res ) {
- if( res->temp_ai ) {
+ if(res) {
+ if(res->temp_ai) {
Curl_freeaddrinfo(res->temp_ai);
res->temp_ai = NULL;
}
waitperform(conn, 0);
- if( res && !res->num_pending ) {
+ if(res && !res->num_pending) {
(void)Curl_addrinfo_callback(conn, res->last_status, res->temp_ai);
/* temp_ai ownership is moved to the connection, so we need not free-up
them */
return;
ai_tail = ai;
- while (ai_tail->ai_next)
+ while(ai_tail->ai_next)
ai_tail = ai_tail->ai_next;
/* Add the new results to the list of old results. */
}
}
/* A successful result overwrites any previous error */
- if( res->last_status != ARES_SUCCESS )
+ if(res->last_status != ARES_SUCCESS)
res->last_status = status;
}
conn->async.status = 0; /* clear */
conn->async.dns = NULL; /* clear */
res = (struct ResolverResults *)calloc(sizeof(struct ResolverResults),1);
- if( !res ) {
+ if(!res) {
Curl_safefree(conn->async.hostname);
conn->async.hostname = NULL;
return NULL;
res->num_pending = 2;
/* areschannel is already setup in the Curl_open() function */
- ares_gethostbyname((ares_channel)data->state.resolver, hostname, PF_INET,
- query_completed_cb, conn);
- ares_gethostbyname((ares_channel)data->state.resolver, hostname, PF_INET6,
- query_completed_cb, conn);
+ ares_gethostbyname((ares_channel)data->state.resolver, hostname,
+ PF_INET, query_completed_cb, conn);
+ ares_gethostbyname((ares_channel)data->state.resolver, hostname,
+ PF_INET6, query_completed_cb, conn);
}
else
#endif /* CURLRES_IPV6 */
else {
/* no device was given, prepare sa to match af's needs */
#ifdef ENABLE_IPV6
- if( af == AF_INET6 ) {
+ if(af == AF_INET6) {
si6->sin6_family = AF_INET6;
si6->sin6_port = htons(port);
sizeof_sa = sizeof(struct sockaddr_in6);
}
else
#endif
- if( af == AF_INET ) {
+ if(af == AF_INET) {
si4->sin_family = AF_INET;
si4->sin_port = htons(port);
sizeof_sa = sizeof(struct sockaddr_in);
}
for(;;) {
- if( bind(sockfd, sock, sizeof_sa) >= 0) {
+ if(bind(sockfd, sock, sizeof_sa) >= 0) {
/* we succeeded to bind */
struct Curl_sockaddr_storage add;
curl_socklen_t size = sizeof(add);
non-session cookie */
if(co->expires == 0)
co->expires = 1;
- else if( co->expires < 0 )
- co->expires = 0;
+ else if(co->expires < 0)
+ co->expires = 0;
}
else if(!co->name) {
co->name = strdup(name);
/* only process this cookie if it is not expired or had no expire
date AND that if the cookie requires we're secure we must only
continue if we are! */
- if( (!co->expires || (co->expires > now)) &&
- (co->secure?secure:TRUE) ) {
+ if((!co->expires || (co->expires > now)) &&
+ (co->secure?secure:TRUE)) {
/* now check if the domain is correct */
if(!co->domain ||
/* wVersionRequested in wVersion. wHighVersion contains the */
/* highest supported version. */
- if( LOBYTE( wsaData.wVersion ) != LOBYTE(wVersionRequested) ||
- HIBYTE( wsaData.wVersion ) != HIBYTE(wVersionRequested) ) {
+ if(LOBYTE( wsaData.wVersion ) != LOBYTE(wVersionRequested) ||
+ HIBYTE( wsaData.wVersion ) != HIBYTE(wVersionRequested) ) {
/* Tell the user that we couldn't find a useable */
/* winsock.dll. */
return CURLE_FAILED_INIT;
/* Already initialized, don't do it again */
- if( initialized )
+ if(initialized)
return CURLE_OK;
/* Call the actual init function first */
if(!data)
return CURLE_BAD_FUNCTION_ARGUMENT;
- if( ! (data->share && data->share->hostcache) ) {
+ if(! (data->share && data->share->hostcache)) {
/* this handle is not using a shared dns cache */
if(data->set.global_dns_cache &&
}
/* Clone the resolver handle, if present, for the new handle */
- if( Curl_resolver_duphandle(&outcurl->state.resolver,
- data->state.resolver) != CURLE_OK )
+ if(Curl_resolver_duphandle(&outcurl->state.resolver,
+ data->state.resolver) != CURLE_OK)
goto fail;
Curl_convert_setup(outcurl);
/*skip bytes before resume point*/
if(data->state.resume_from) {
- if( (curl_off_t)nread <= data->state.resume_from ) {
+ if((curl_off_t)nread <= data->state.resume_from ) {
data->state.resume_from -= nread;
nread = 0;
buf2 = buf;
fd = conn->data->state.proto.file->fd;
/* VMS: This only works reliable for STREAMLF files */
- if( -1 != fstat(fd, &statbuf)) {
+ if(-1 != fstat(fd, &statbuf)) {
/* we could stat it, then read out the size */
expected_size = statbuf.st_size;
/* and store the modification time */
bytestoread = (expected_size < BUFSIZE-1)?(size_t)expected_size:BUFSIZE-1;
nread = read(fd, buf, bytestoread);
- if( nread > 0)
+ if(nread > 0)
buf[nread] = 0;
if(nread <= 0 || expected_size == 0)
while(return_value == CURL_FORMADD_OK) {
/* first see if we have more parts of the array param */
- if( array_state && forms ) {
+ if(array_state && forms) {
/* get the upcoming option from the given array */
option = forms->option;
array_value = (char *)forms->value;
(struct curl_slist*)array_value:
va_arg(params, struct curl_slist*);
- if( current_form->contentheader )
+ if(current_form->contentheader)
return_value = CURL_FORMADD_OPTION_TWICE;
else
current_form->contentheader = list;
{
const char *filename = array_state?array_value:
va_arg(params, char *);
- if( current_form->showfilename )
+ if(current_form->showfilename)
return_value = CURL_FORMADD_OPTION_TWICE;
else {
current_form->showfilename = strdup(filename);
for(form = first_form;
form != NULL;
form = form->more) {
- if( ((!form->name || !form->value) && !post) ||
- ( (form->contentslength) &&
- (form->flags & HTTPPOST_FILENAME) ) ||
- ( (form->flags & HTTPPOST_FILENAME) &&
- (form->flags & HTTPPOST_PTRCONTENTS) ) ||
-
- ( (!form->buffer) &&
- (form->flags & HTTPPOST_BUFFER) &&
- (form->flags & HTTPPOST_PTRBUFFER) ) ||
-
- ( (form->flags & HTTPPOST_READFILE) &&
- (form->flags & HTTPPOST_PTRCONTENTS) )
+ if(((!form->name || !form->value) && !post) ||
+ ( (form->contentslength) &&
+ (form->flags & HTTPPOST_FILENAME) ) ||
+ ( (form->flags & HTTPPOST_FILENAME) &&
+ (form->flags & HTTPPOST_PTRCONTENTS) ) ||
+
+ ( (!form->buffer) &&
+ (form->flags & HTTPPOST_BUFFER) &&
+ (form->flags & HTTPPOST_PTRBUFFER) ) ||
+
+ ( (form->flags & HTTPPOST_READFILE) &&
+ (form->flags & HTTPPOST_PTRCONTENTS) )
) {
return_value = CURL_FORMADD_INCOMPLETE;
break;
}
else {
- if( ((form->flags & HTTPPOST_FILENAME) ||
- (form->flags & HTTPPOST_BUFFER)) &&
- !form->contenttype ) {
+ if(((form->flags & HTTPPOST_FILENAME) ||
+ (form->flags & HTTPPOST_BUFFER)) &&
+ !form->contenttype ) {
/* our contenttype is missing */
form->contenttype
= strdup(ContentTypeForFilename(form->value, prevtype));
}
form->contenttype_alloc = TRUE;
}
- if( !(form->flags & HTTPPOST_PTRNAME) &&
- (form == first_form) ) {
+ if(!(form->flags & HTTPPOST_PTRNAME) &&
+ (form == first_form) ) {
/* Note that there's small risk that form->name is NULL here if the
app passed in a bad combo, so we better check for that first. */
if(form->name)
}
form->name_alloc = TRUE;
}
- if( !(form->flags & (HTTPPOST_FILENAME | HTTPPOST_READFILE |
- HTTPPOST_PTRCONTENTS | HTTPPOST_PTRBUFFER |
- HTTPPOST_CALLBACK)) ) {
+ if(!(form->flags & (HTTPPOST_FILENAME | HTTPPOST_READFILE |
+ HTTPPOST_PTRCONTENTS | HTTPPOST_PTRBUFFER |
+ HTTPPOST_CALLBACK)) ) {
/* copy value (without strdup; possibly contains null characters) */
form->value = memdup(form->value, form->contentslength);
if(!form->value) {
if(form->more)
curl_formfree(form->more);
- if( !(form->flags & HTTPPOST_PTRNAME) && form->name)
+ if(!(form->flags & HTTPPOST_PTRNAME) && form->name)
free(form->name); /* free the name */
- if( !(form->flags & (HTTPPOST_PTRCONTENTS|HTTPPOST_CALLBACK)) &&
- form->contents)
+ if(!(form->flags & (HTTPPOST_PTRCONTENTS|HTTPPOST_CALLBACK)) &&
+ form->contents)
free(form->contents); /* free the contents */
if(form->contenttype)
free(form->contenttype); /* free the content type */
}
curList = file->contentheader;
- while( curList ) {
+ while(curList) {
/* Process the additional headers specified for this form */
result = AddFormDataf( &form, &size, "\r\n%s", curList->data );
if(result)
}
do {
- if( (form->data->length - form->sent ) > wantedsize - gotsize) {
+ if((form->data->length - form->sent ) > wantedsize - gotsize) {
memcpy(buffer + gotsize , form->data->line + form->sent,
wantedsize - gotsize);
}
else
#endif
- if( *string_ftpport == ':') {
+ if(*string_ftpport == ':') {
/* :port */
ip_end = string_ftpport;
}
- else if( (ip_end = strchr(string_ftpport, ':')) != NULL) {
+ else if((ip_end = strchr(string_ftpport, ':')) != NULL) {
/* either ipv6 or (ipv4|domain|interface):port(-range) */
#ifdef ENABLE_IPV6
if(Curl_inet_pton(AF_INET6, string_ftpport, sa6) == 1) {
strcpy(addr, string_ftpport);
/* parse the port */
- if( ip_end != NULL ) {
+ if(ip_end != NULL) {
if((port_start = strchr(ip_end, ':')) != NULL) {
port_min = curlx_ultous(strtoul(port_start+1, NULL, 10));
if((port_sep = strchr(port_start, '-')) != NULL) {
memcpy(sa, ai->ai_addr, ai->ai_addrlen);
sslen = ai->ai_addrlen;
- for( port = port_min; port <= port_max; ) {
- if( sa->sa_family == AF_INET )
+ for(port = port_min; port <= port_max;) {
+ if(sa->sa_family == AF_INET)
sa4->sin_port = htons(port);
#ifdef ENABLE_IPV6
else
/* BLOCKING */
/* PORT means we are now awaiting the server to connect to us. */
result = AllowServerConnect(conn);
- if( result )
+ if(result)
return result;
}
if(data->set.ftp_use_port) {
/* BLOCKING */
result = AllowServerConnect(conn);
- if( result )
+ if(result)
return result;
}
return CURLE_SSL_CONNECT_ERROR;
if(data->set.str[STRING_CERT]) {
- if( gnutls_certificate_set_x509_key_file(
- conn->ssl[sockindex].cred,
- data->set.str[STRING_CERT],
- data->set.str[STRING_KEY] ?
- data->set.str[STRING_KEY] : data->set.str[STRING_CERT],
- do_file_type(data->set.str[STRING_CERT_TYPE]) ) !=
- GNUTLS_E_SUCCESS) {
+ if(gnutls_certificate_set_x509_key_file(
+ conn->ssl[sockindex].cred,
+ data->set.str[STRING_CERT],
+ data->set.str[STRING_KEY] ?
+ data->set.str[STRING_KEY] : data->set.str[STRING_CERT],
+ do_file_type(data->set.str[STRING_CERT_TYPE]) ) !=
+ GNUTLS_E_SUCCESS) {
failf(data, "error reading X.509 key or certificate file");
return CURLE_SSL_CONNECT_ERROR;
}
{
struct hostcache_prune_data user;
- if( !dns || (data->set.dns_cache_timeout == -1) || !data->dns.hostcache)
+ if(!dns || (data->set.dns_cache_timeout == -1) || !data->dns.hostcache)
/* cache forever means never prune, and NULL hostcache means
we can't do it */
return 0;
time(&user.now);
user.cache_timeout = data->set.dns_cache_timeout;
- if( !hostcache_timestamp_remove(&user,dns) )
+ if(!hostcache_timestamp_remove(&user,dns) )
return 0;
Curl_hash_clean_with_criterium(data->dns.hostcache,
free(entry_id);
/* See whether the returned entry is stale. Done before we release lock */
- if( remove_entry_if_stale(data, dns) )
+ if(remove_entry_if_stale(data, dns))
dns = NULL; /* the memory deallocation is being handled by the hash */
if(dns) {
return CURLE_OUT_OF_MEMORY;
}
- if( (conn->handler->protocol&(CURLPROTO_HTTP|CURLPROTO_FTP)) &&
- data->set.upload) {
+ if((conn->handler->protocol&(CURLPROTO_HTTP|CURLPROTO_FTP)) &&
+ data->set.upload) {
httpreq = HTTPREQ_PUT;
}
case IDENTITY:
#endif
if(!k->ignorebody) {
- if( !data->set.http_te_skip )
+ if(!data->set.http_te_skip)
result = Curl_client_write(conn, CLIENTWRITE_BODY, datap,
piece);
else
size_t responseTokenLength = 0;
responseToken = malloc(neg_ctx->output_token.length);
- if( responseToken == NULL)
+ if(responseToken == NULL)
return CURLE_OUT_OF_MEMORY;
memcpy(responseToken, neg_ctx->output_token.value,
neg_ctx->output_token.length);
neg_ctx->credentials = (CredHandle *)malloc(sizeof(CredHandle));
neg_ctx->context = (CtxtHandle *)malloc(sizeof(CtxtHandle));
- if( !neg_ctx->credentials || !neg_ctx->context)
+ if(!neg_ctx->credentials || !neg_ctx->context)
return -1;
neg_ctx->status =
SECPKG_CRED_OUTBOUND, NULL, NULL,
NULL, NULL, neg_ctx->credentials,
&lifetime);
- if( neg_ctx->status != SEC_E_OK )
+ if(neg_ctx->status != SEC_E_OK)
return -1;
}
&context_attributes,
&lifetime);
- if( GSS_ERROR(neg_ctx->status) )
+ if(GSS_ERROR(neg_ctx->status))
return -1;
- if( neg_ctx->status == SEC_I_COMPLETE_NEEDED ||
- neg_ctx->status == SEC_I_COMPLETE_AND_CONTINUE ) {
+ if(neg_ctx->status == SEC_I_COMPLETE_NEEDED ||
+ neg_ctx->status == SEC_I_COMPLETE_AND_CONTINUE) {
neg_ctx->status = s_pSecFn->CompleteAuthToken(neg_ctx->context,
&out_buff_desc);
- if( GSS_ERROR(neg_ctx->status) )
+ if(GSS_ERROR(neg_ctx->status))
return -1;
}
size_t len;
str = (char *) p->data.str;
- if( str == NULL) {
+ if(str == NULL) {
/* Write null[] if there's space. */
if(prec == -1 || prec >= (long) sizeof(null) - 1) {
str = null;
case CURLM_STATE_TOOFAST: /* limit-rate exceeded in either direction */
/* if both rates are within spec, resume transfer */
Curl_pgrsUpdate(easy->easy_conn);
- if( ( (data->set.max_send_speed == 0) ||
- (data->progress.ulspeed < data->set.max_send_speed )) &&
- ( (data->set.max_recv_speed == 0) ||
- (data->progress.dlspeed < data->set.max_recv_speed) ) )
+ if(( (data->set.max_send_speed == 0) ||
+ (data->progress.ulspeed < data->set.max_send_speed )) &&
+ ( (data->set.max_recv_speed == 0) ||
+ (data->progress.dlspeed < data->set.max_recv_speed)))
multistate(easy, CURLM_STATE_PERFORM);
break;
case CURLM_STATE_PERFORM:
/* check if over send speed */
- if( (data->set.max_send_speed > 0) &&
- (data->progress.ulspeed > data->set.max_send_speed) ) {
+ if((data->set.max_send_speed > 0) &&
+ (data->progress.ulspeed > data->set.max_send_speed)) {
int buffersize;
multistate(easy, CURLM_STATE_TOOFAST);
}
/* check if over recv speed */
- if( (data->set.max_recv_speed > 0) &&
- (data->progress.dlspeed > data->set.max_recv_speed) ) {
+ if((data->set.max_recv_speed > 0) &&
+ (data->progress.dlspeed > data->set.max_recv_speed)) {
int buffersize;
multistate(easy, CURLM_STATE_TOOFAST);
*running_handles = multi->num_alive;
- if( CURLM_OK >= returncode )
+ if(CURLM_OK >= returncode)
update_timer(multi);
return returncode;
if(multi_timeout(multi, &timeout_ms)) {
return -1;
}
- if( timeout_ms < 0 ) {
+ if(timeout_ms < 0) {
static const struct timeval none={0,0};
if(Curl_splaycomparekeys(none, multi->timer_lastcall)) {
multi->timer_lastcall = none;
char *line = pp->linestart_resp;
size_t len = pp->nread_resp;
- if( ((len >= 3) && !memcmp("+OK", line, 3)) ||
- ((len >= 4) && !memcmp("-ERR", line, 4)) ) {
+ if(((len >= 3) && !memcmp("+OK", line, 3)) ||
+ ((len >= 4) && !memcmp("-ERR", line, 4))) {
*resp=line[1]; /* O or E */
return TRUE;
}
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
for "low speed time" seconds we consider that enough reason
to abort the download. */
- if( (howlong/1000) > data->set.low_speed_time) {
+ if((howlong/1000) > data->set.low_speed_time) {
/* we have been this slow for long enough, now die */
failf(data,
"Operation too slow. "
static size_t tftp_option_add(tftp_state_data_t *state, size_t csize,
char *buf, const char *option)
{
- if( ( strlen(option) + csize + 1 ) > (size_t)state->blksize )
+ if(( strlen(option) + csize + 1 ) > (size_t)state->blksize)
return 0;
strcpy(buf, option);
return( strlen(option) + 1 );
*
* This behaviour can be overridden with CURLOPT_POSTREDIR.
*/
- if( (data->set.httpreq == HTTPREQ_POST
- || data->set.httpreq == HTTPREQ_POST_FORM)
- && !data->set.post301) {
+ if((data->set.httpreq == HTTPREQ_POST
+ || data->set.httpreq == HTTPREQ_POST_FORM)
+ && !data->set.post301) {
infof(data,
"Violate RFC 2616/10.3.2 and switch from POST to GET\n");
data->set.httpreq = HTTPREQ_GET;
This behaviour can be overriden with CURLOPT_POSTREDIR
*/
- if( (data->set.httpreq == HTTPREQ_POST
- || data->set.httpreq == HTTPREQ_POST_FORM)
- && !data->set.post302) {
+ if((data->set.httpreq == HTTPREQ_POST
+ || data->set.httpreq == HTTPREQ_POST_FORM)
+ && !data->set.post302) {
infof(data,
"Violate RFC 2616/10.3.3 and switch from POST to GET\n");
data->set.httpreq = HTTPREQ_GET;
const char *user, const char *passwd)
{
/* If our protocol needs a password and we have none, use the defaults */
- if( (conn->handler->protocol & (CURLPROTO_FTP|CURLPROTO_IMAP)) &&
- !conn->bits.user_passwd) {
+ if((conn->handler->protocol & (CURLPROTO_FTP|CURLPROTO_IMAP)) &&
+ !conn->bits.user_passwd) {
conn->user = strdup(CURL_DEFAULT_USER);
if(conn->user)
bool authproblem; /* TRUE if there's some problem authenticating */
- void *resolver; /* resolver state, if it is used in the URL state - ares_channel f.e. */
+ void *resolver; /* resolver state, if it is used in the URL state -
+ ares_channel f.e. */
#if defined(USE_SSLEAY) && defined(HAVE_OPENSSL_ENGINE_H)
ENGINE *engine;