1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-21 15:48:49 -05:00

removed space after if and while before the parenthesis for better source code

consistency
This commit is contained in:
Daniel Stenberg 2007-11-05 09:45:09 +00:00
parent af29dcbafb
commit ad6e28073c
24 changed files with 1070 additions and 1068 deletions

View File

@ -101,7 +101,7 @@ size_t Curl_base64_decode(const char *src, unsigned char **outptr)
numQuantums = (length + equalsTerm) / 4;
/* Don't allocate a buffer if the decoded length is 0 */
if (numQuantums <= 0)
if(numQuantums <= 0)
return 0;
rawlen = (numQuantums * 3) - equalsTerm;

View File

@ -116,7 +116,7 @@ int Curl_nonblock(curl_socket_t sockfd, /* operate on this */
int flags;
flags = fcntl(sockfd, F_GETFL, 0);
if (FALSE != nonblock)
if(FALSE != nonblock)
return fcntl(sockfd, F_SETFL, flags | O_NONBLOCK);
else
return fcntl(sockfd, F_SETFL, flags & (~O_NONBLOCK));
@ -165,7 +165,7 @@ int Curl_nonblock(curl_socket_t sockfd, /* operate on this */
#define SETBLOCK 6
#endif
#if (SETBLOCK == 0)
#if(SETBLOCK == 0)
#error "no non-blocking method was found/used/set"
#endif
}
@ -233,7 +233,7 @@ static CURLcode bindlocal(struct connectdata *conn,
/*************************************************************
* Select device to bind socket to
*************************************************************/
if (dev && (strlen(dev)<255) ) {
if(dev && (strlen(dev)<255) ) {
struct Curl_dns_entry *h=NULL;
char myhost[256] = "";
in_addr_t in;
@ -303,11 +303,11 @@ static CURLcode bindlocal(struct connectdata *conn,
* interfaces to go out the external interface.
*
*/
if (was_iface) {
if(was_iface) {
/* Only bind to the interface when specified as interface, not just as a
* hostname or ip address.
*/
if (setsockopt(sockfd, SOL_SOCKET, SO_BINDTODEVICE,
if(setsockopt(sockfd, SOL_SOCKET, SO_BINDTODEVICE,
dev, strlen(dev)+1) != 0) {
/* printf("Failed to BINDTODEVICE, socket: %d device: %s error: %s\n",
sockfd, dev, Curl_strerror(SOCKERRNO)); */
@ -323,12 +323,12 @@ static CURLcode bindlocal(struct connectdata *conn,
#ifdef ENABLE_IPV6
in6 = Curl_inet_pton (AF_INET6, myhost, (void *)&ipv6_addr);
#endif
if (CURL_INADDR_NONE == in && -1 == in6) {
if(CURL_INADDR_NONE == in && -1 == in6) {
failf(data,"couldn't find my own IP address (%s)", myhost);
return CURLE_INTERFACE_FAILED;
} /* end of inet_addr */
if ( h ) {
if( h ) {
Curl_addrinfo *addr = h->addr;
sock = addr->ai_addr;
socksize = addr->ai_addrlen;
@ -433,33 +433,33 @@ static bool verifyconnect(curl_socket_t sockfd, int *error)
#endif
if (0 != getsockopt(sockfd, SOL_SOCKET, SO_ERROR, (void *)&err, &errSize))
if(0 != getsockopt(sockfd, SOL_SOCKET, SO_ERROR, (void *)&err, &errSize))
err = SOCKERRNO;
#ifdef _WIN32_WCE
/* Old WinCE versions don't support SO_ERROR */
if (WSAENOPROTOOPT == err) {
if(WSAENOPROTOOPT == err) {
SET_SOCKERRNO(0);
err = 0;
}
#endif
#ifdef __minix
/* Minix 3.1.x doesn't support getsockopt on UDP sockets */
if (EBADIOCTL == err) {
if(EBADIOCTL == err) {
SET_SOCKERRNO(0);
err = 0;
}
#endif
if ((0 == err) || (EISCONN == err))
if((0 == err) || (EISCONN == err))
/* we are connected, awesome! */
rc = TRUE;
else
/* This wasn't a successful connect */
rc = FALSE;
if (error)
if(error)
*error = err;
#else
(void)sockfd;
if (error)
if(error)
*error = SOCKERRNO;
#endif
return rc;
@ -504,7 +504,7 @@ static bool trynextip(struct connectdata *conn,
/* try the next address */
ai = conn->ip_addr->ai_next;
while (ai) {
while(ai) {
sockfd = singleipconnect(conn, ai, 0L, connected);
if(sockfd != CURL_SOCKET_BAD) {
/* store the new socket descriptor */
@ -545,7 +545,7 @@ CURLcode Curl_is_connected(struct connectdata *conn,
/* subtract the most strict timeout of the ones */
if(data->set.timeout && data->set.connecttimeout) {
if (data->set.timeout < data->set.connecttimeout)
if(data->set.timeout < data->set.connecttimeout)
allow_total = allow = data->set.timeout;
else
allow = data->set.connecttimeout;
@ -576,7 +576,7 @@ CURLcode Curl_is_connected(struct connectdata *conn,
if(WAITCONN_CONNECTED == rc) {
int error;
if (verifyconnect(sockfd, &error)) {
if(verifyconnect(sockfd, &error)) {
/* we are connected, awesome! */
*connected = TRUE;
return CURLE_OK;
@ -594,7 +594,7 @@ CURLcode Curl_is_connected(struct connectdata *conn,
int error = 0;
/* nope, not connected */
if (WAITCONN_FDSET_ERROR == rc) {
if(WAITCONN_FDSET_ERROR == rc) {
(void)verifyconnect(sockfd, &error);
data->state.os_errno = error;
infof(data, "%s\n",Curl_strerror(conn,error));
@ -628,7 +628,7 @@ static void tcpnodelay(struct connectdata *conn,
#ifdef HAVE_GETPROTOBYNAME
struct protoent *pe = getprotobyname("tcp");
if (pe)
if(pe)
proto = pe->p_proto;
#endif
@ -703,7 +703,7 @@ singleipconnect(struct connectdata *conn,
CURLSOCKTYPE_IPCXN, addr);
else
sockfd = socket(addr->family, addr->socktype, addr->protocol);
if (sockfd == CURL_SOCKET_BAD)
if(sockfd == CURL_SOCKET_BAD)
return CURL_SOCKET_BAD;
*connected = FALSE; /* default is not connected */
@ -728,7 +728,7 @@ singleipconnect(struct connectdata *conn,
error = data->set.fsockopt(data->set.sockopt_client,
sockfd,
CURLSOCKTYPE_IPCXN);
if (error) {
if(error) {
sclose(sockfd); /* close the socket and bail out */
return CURL_SOCKET_BAD;
}
@ -836,9 +836,9 @@ CURLcode Curl_connecthost(struct connectdata *conn, /* context */
/* if a timeout is set, use the most restrictive one */
if (data->set.timeout > 0)
if(data->set.timeout > 0)
timeout_set += 1;
if (data->set.connecttimeout > 0)
if(data->set.connecttimeout > 0)
timeout_set += 2;
switch (timeout_set) {
@ -849,7 +849,7 @@ CURLcode Curl_connecthost(struct connectdata *conn, /* context */
timeout_ms = data->set.connecttimeout;
break;
case 3:
if (data->set.timeout < data->set.connecttimeout)
if(data->set.timeout < data->set.connecttimeout)
timeout_ms = data->set.timeout;
else
timeout_ms = data->set.connecttimeout;
@ -859,7 +859,7 @@ CURLcode Curl_connecthost(struct connectdata *conn, /* context */
break;
}
if (timeout_set > 0) {
if(timeout_set > 0) {
/* if a timeout was already set, substract elapsed time */
timeout_ms -= Curl_tvdiff(before, data->progress.t_startsingle);
if(timeout_ms < 0) {
@ -906,7 +906,7 @@ CURLcode Curl_connecthost(struct connectdata *conn, /* context */
before = after;
} /* end of connect-to-each-address loop */
if (sockfd == CURL_SOCKET_BAD) {
if(sockfd == CURL_SOCKET_BAD) {
/* no good connect was made */
*sockconn = CURL_SOCKET_BAD;
failf(data, "couldn't connect to host");

View File

@ -57,7 +57,7 @@ static CURLcode
process_zlib_error(struct connectdata *conn, z_stream *z)
{
struct SessionHandle *data = conn->data;
if (z->msg)
if(z->msg)
failf (data, "Error while processing content unencoding: %s",
z->msg);
else
@ -90,7 +90,7 @@ inflate_stream(struct connectdata *conn,
/* Dynamically allocate a buffer for decompression because it's uncommonly
large to hold on the stack */
decomp = (char*)malloc(DSIZ);
if (decomp == NULL) {
if(decomp == NULL) {
return exit_zlib(z, &k->zlib_init, CURLE_OUT_OF_MEMORY);
}
@ -102,39 +102,39 @@ inflate_stream(struct connectdata *conn,
z->avail_out = DSIZ;
status = inflate(z, Z_SYNC_FLUSH);
if (status == Z_OK || status == Z_STREAM_END) {
if(status == Z_OK || status == Z_STREAM_END) {
allow_restart = 0;
if(DSIZ - z->avail_out) {
result = Curl_client_write(conn, CLIENTWRITE_BODY, decomp,
DSIZ - z->avail_out);
/* if !CURLE_OK, clean up, return */
if (result) {
if(result) {
free(decomp);
return exit_zlib(z, &k->zlib_init, result);
}
}
/* Done? clean up, return */
if (status == Z_STREAM_END) {
if(status == Z_STREAM_END) {
free(decomp);
if (inflateEnd(z) == Z_OK)
if(inflateEnd(z) == Z_OK)
return exit_zlib(z, &k->zlib_init, result);
else
return exit_zlib(z, &k->zlib_init, process_zlib_error(conn, z));
}
/* Done with these bytes, exit */
if (status == Z_OK && z->avail_in == 0) {
if(status == Z_OK && z->avail_in == 0) {
free(decomp);
return result;
}
}
else if (allow_restart && status == Z_DATA_ERROR) {
else if(allow_restart && status == Z_DATA_ERROR) {
/* some servers seem to not generate zlib headers, so this is an attempt
to fix and continue anyway */
(void) inflateEnd(z); /* don't care about the return code */
if (inflateInit2(z, -MAX_WBITS) != Z_OK) {
if(inflateInit2(z, -MAX_WBITS) != Z_OK) {
return process_zlib_error(conn, z);
}
z->next_in = orig_in;
@ -158,13 +158,13 @@ Curl_unencode_deflate_write(struct connectdata *conn,
z_stream *z = &k->z; /* zlib state structure */
/* Initialize zlib? */
if (k->zlib_init == ZLIB_UNINIT) {
if(k->zlib_init == ZLIB_UNINIT) {
z->zalloc = (alloc_func)Z_NULL;
z->zfree = (free_func)Z_NULL;
z->opaque = 0;
z->next_in = NULL;
z->avail_in = 0;
if (inflateInit(z) != Z_OK)
if(inflateInit(z) != Z_OK)
return process_zlib_error(conn, z);
k->zlib_init = ZLIB_INIT;
}
@ -189,16 +189,16 @@ static enum {
const ssize_t totallen = len;
/* The shortest header is 10 bytes */
if (len < 10)
if(len < 10)
return GZIP_UNDERFLOW;
if ((data[0] != GZIP_MAGIC_0) || (data[1] != GZIP_MAGIC_1))
if((data[0] != GZIP_MAGIC_0) || (data[1] != GZIP_MAGIC_1))
return GZIP_BAD;
method = data[2];
flags = data[3];
if (method != Z_DEFLATED || (flags & RESERVED) != 0) {
if(method != Z_DEFLATED || (flags & RESERVED) != 0) {
/* Can't handle this compression method or unknown flag */
return GZIP_BAD;
}
@ -207,28 +207,28 @@ static enum {
len -= 10;
data += 10;
if (flags & EXTRA_FIELD) {
if(flags & EXTRA_FIELD) {
ssize_t extra_len;
if (len < 2)
if(len < 2)
return GZIP_UNDERFLOW;
extra_len = (data[1] << 8) | data[0];
if (len < (extra_len+2))
if(len < (extra_len+2))
return GZIP_UNDERFLOW;
len -= (extra_len + 2);
data += (extra_len + 2);
}
if (flags & ORIG_NAME) {
if(flags & ORIG_NAME) {
/* Skip over NUL-terminated file name */
while (len && *data) {
while(len && *data) {
--len;
++data;
}
if (!len || *data)
if(!len || *data)
return GZIP_UNDERFLOW;
/* Skip over the NUL */
@ -236,13 +236,13 @@ static enum {
++data;
}
if (flags & COMMENT) {
if(flags & COMMENT) {
/* Skip over NUL-terminated comment */
while (len && *data) {
while(len && *data) {
--len;
++data;
}
if (!len || *data)
if(!len || *data)
return GZIP_UNDERFLOW;
/* Skip over the NUL */
@ -250,8 +250,8 @@ static enum {
++data;
}
if (flags & HEAD_CRC) {
if (len < 2)
if(flags & HEAD_CRC) {
if(len < 2)
return GZIP_UNDERFLOW;
len -= 2;
@ -271,30 +271,30 @@ Curl_unencode_gzip_write(struct connectdata *conn,
z_stream *z = &k->z; /* zlib state structure */
/* Initialize zlib? */
if (k->zlib_init == ZLIB_UNINIT) {
if(k->zlib_init == ZLIB_UNINIT) {
z->zalloc = (alloc_func)Z_NULL;
z->zfree = (free_func)Z_NULL;
z->opaque = 0;
z->next_in = NULL;
z->avail_in = 0;
if (strcmp(zlibVersion(), "1.2.0.4") >= 0) {
if(strcmp(zlibVersion(), "1.2.0.4") >= 0) {
/* zlib ver. >= 1.2.0.4 supports transparent gzip decompressing */
if (inflateInit2(z, MAX_WBITS+32) != Z_OK) {
if(inflateInit2(z, MAX_WBITS+32) != Z_OK) {
return process_zlib_error(conn, z);
}
k->zlib_init = ZLIB_INIT_GZIP; /* Transparent gzip decompress state */
} else {
/* we must parse the gzip header ourselves */
if (inflateInit2(z, -MAX_WBITS) != Z_OK) {
if(inflateInit2(z, -MAX_WBITS) != Z_OK) {
return process_zlib_error(conn, z);
}
k->zlib_init = ZLIB_INIT; /* Initial call state */
}
}
if (k->zlib_init == ZLIB_INIT_GZIP) {
if(k->zlib_init == ZLIB_INIT_GZIP) {
/* Let zlib handle the gzip decompression entirely */
z->next_in = (Bytef *)k->str;
z->avail_in = (uInt)nread;
@ -342,7 +342,7 @@ Curl_unencode_gzip_write(struct connectdata *conn,
*/
z->avail_in = (uInt)nread;
z->next_in = malloc(z->avail_in);
if (z->next_in == NULL) {
if(z->next_in == NULL) {
return exit_zlib(z, &k->zlib_init, CURLE_OUT_OF_MEMORY);
}
memcpy(z->next_in, k->str, z->avail_in);
@ -366,7 +366,7 @@ Curl_unencode_gzip_write(struct connectdata *conn,
z->avail_in += nread;
z->next_in = realloc(z->next_in, z->avail_in);
if (z->next_in == NULL) {
if(z->next_in == NULL) {
free(oldblock);
return exit_zlib(z, &k->zlib_init, CURLE_OUT_OF_MEMORY);
}
@ -404,7 +404,7 @@ Curl_unencode_gzip_write(struct connectdata *conn,
break;
}
if (z->avail_in == 0) {
if(z->avail_in == 0) {
/* We don't have any data to inflate; wait until next time */
return CURLE_OK;
}

View File

@ -127,7 +127,7 @@ static CURLcode win32_init(void)
err = WSAStartup(wVersionRequested, &wsaData);
if (err != 0)
if(err != 0)
/* Tell the user that we couldn't find a useable */
/* winsock.dll. */
return CURLE_FAILED_INIT;
@ -138,7 +138,7 @@ static CURLcode win32_init(void)
/* wVersionRequested in wVersion. wHighVersion contains the */
/* highest supported version. */
if ( LOBYTE( wsaData.wVersion ) != LOBYTE(wVersionRequested) ||
if( LOBYTE( wsaData.wVersion ) != LOBYTE(wVersionRequested) ||
HIBYTE( wsaData.wVersion ) != HIBYTE(wVersionRequested) ) {
/* Tell the user that we couldn't find a useable */
@ -168,7 +168,7 @@ static void idna_init (void)
char buf[60];
UINT cp = GetACP();
if (!getenv("CHARSET") && cp > 0) {
if(!getenv("CHARSET") && cp > 0) {
snprintf(buf, sizeof(buf), "CHARSET=cp%u", cp);
putenv(buf);
}
@ -212,7 +212,7 @@ curl_calloc_callback Curl_ccalloc = (curl_calloc_callback)calloc;
*/
CURLcode curl_global_init(long flags)
{
if (initialized++)
if(initialized++)
return CURLE_OK;
/* Setup the default memory functions here (again) */
@ -222,14 +222,14 @@ CURLcode curl_global_init(long flags)
Curl_cstrdup = (curl_strdup_callback)system_strdup;
Curl_ccalloc = (curl_calloc_callback)calloc;
if (flags & CURL_GLOBAL_SSL)
if (!Curl_ssl_init()) {
if(flags & CURL_GLOBAL_SSL)
if(!Curl_ssl_init()) {
DEBUGF(fprintf(stderr, "Error: Curl_ssl_init failed\n"));
return CURLE_FAILED_INIT;
}
if (flags & CURL_GLOBAL_WIN32)
if (win32_init() != CURLE_OK) {
if(flags & CURL_GLOBAL_WIN32)
if(win32_init() != CURLE_OK) {
DEBUGF(fprintf(stderr, "Error: win32_init failed\n"));
return CURLE_FAILED_INIT;
}
@ -267,16 +267,16 @@ CURLcode curl_global_init_mem(long flags, curl_malloc_callback m,
CURLcode code = CURLE_OK;
/* Invalid input, return immediately */
if (!m || !f || !r || !s || !c)
if(!m || !f || !r || !s || !c)
return CURLE_FAILED_INIT;
/* Already initialized, don't do it again */
if ( initialized )
if( initialized )
return CURLE_OK;
/* Call the actual init function first */
code = curl_global_init(flags);
if (code == CURLE_OK) {
if(code == CURLE_OK) {
Curl_cmalloc = m;
Curl_cfree = f;
Curl_cstrdup = s;
@ -293,18 +293,18 @@ CURLcode curl_global_init_mem(long flags, curl_malloc_callback m,
*/
void curl_global_cleanup(void)
{
if (!initialized)
if(!initialized)
return;
if (--initialized)
if(--initialized)
return;
Curl_global_host_cache_dtor();
if (init_flags & CURL_GLOBAL_SSL)
if(init_flags & CURL_GLOBAL_SSL)
Curl_ssl_cleanup();
if (init_flags & CURL_GLOBAL_WIN32)
if(init_flags & CURL_GLOBAL_WIN32)
win32_cleanup();
#ifdef __AMIGA__
@ -324,7 +324,7 @@ CURL *curl_easy_init(void)
struct SessionHandle *data;
/* Make sure we inited the global SSL stuff */
if (!initialized) {
if(!initialized) {
res = curl_global_init(CURL_GLOBAL_DEFAULT);
if(res) {
/* something in the global init failed, return nothing */
@ -465,17 +465,17 @@ CURLcode curl_easy_perform(CURL *curl)
if(!data)
return CURLE_BAD_FUNCTION_ARGUMENT;
if ( ! (data->share && data->share->hostcache) ) {
if( ! (data->share && data->share->hostcache) ) {
if (Curl_global_host_cache_use(data) &&
if(Curl_global_host_cache_use(data) &&
(data->dns.hostcachetype != HCACHE_GLOBAL)) {
if (data->dns.hostcachetype == HCACHE_PRIVATE)
if(data->dns.hostcachetype == HCACHE_PRIVATE)
Curl_hash_destroy(data->dns.hostcache);
data->dns.hostcache = Curl_global_host_cache_get();
data->dns.hostcachetype = HCACHE_GLOBAL;
}
if (!data->dns.hostcache) {
if(!data->dns.hostcache) {
data->dns.hostcachetype = HCACHE_PRIVATE;
data->dns.hostcache = Curl_mk_dnscache();
@ -520,7 +520,7 @@ void Curl_easy_addmulti(struct SessionHandle *data,
void *multi)
{
data->multi = multi;
if (multi == NULL)
if(multi == NULL)
/* the association is cleared, mark the easy handle as not used by an
interface */
data->state.used_interface = Curl_if_none;
@ -579,7 +579,7 @@ CURL *curl_easy_duphandle(CURL *incurl)
outcurl->state.headersize=HEADERSIZE;
/* copy all userdefined values */
if (Curl_dupset(outcurl, data) != CURLE_OK)
if(Curl_dupset(outcurl, data) != CURLE_OK)
break;
if(data->state.used_interface == Curl_if_multi)
@ -789,7 +789,7 @@ CURLcode Curl_convert_to_network(struct SessionHandle *data,
in_bytes = out_bytes = length;
rc = iconv(data->outbound_cd, (const char**)&input_ptr, &in_bytes,
&output_ptr, &out_bytes);
if ((rc == ICONV_ERROR) || (in_bytes != 0)) {
if((rc == ICONV_ERROR) || (in_bytes != 0)) {
error = ERRNO;
failf(data,
"The Curl_convert_to_network iconv call failed with errno %i: %s",
@ -849,7 +849,7 @@ CURLcode Curl_convert_from_network(struct SessionHandle *data,
in_bytes = out_bytes = length;
rc = iconv(data->inbound_cd, (const char **)&input_ptr, &in_bytes,
&output_ptr, &out_bytes);
if ((rc == ICONV_ERROR) || (in_bytes != 0)) {
if((rc == ICONV_ERROR) || (in_bytes != 0)) {
error = ERRNO;
failf(data,
"The Curl_convert_from_network iconv call failed with errno %i: %s",
@ -910,14 +910,14 @@ CURLcode Curl_convert_from_utf8(struct SessionHandle *data,
in_bytes = out_bytes = length;
rc = iconv(data->utf8_cd, &input_ptr, &in_bytes,
&output_ptr, &out_bytes);
if ((rc == ICONV_ERROR) || (in_bytes != 0)) {
if((rc == ICONV_ERROR) || (in_bytes != 0)) {
error = ERRNO;
failf(data,
"The Curl_convert_from_utf8 iconv call failed with errno %i: %s",
error, strerror(error));
return CURLE_CONV_FAILED;
}
if (output_ptr < input_ptr) {
if(output_ptr < input_ptr) {
/* null terminate the now shorter output string */
*output_ptr = 0x00;
}

View File

@ -187,7 +187,7 @@ AddHttpPost(char * name, size_t namelength,
else
return NULL;
if (parent_post) {
if(parent_post) {
/* now, point our 'more' to the original 'more' */
post->more = parent_post->more;
@ -224,16 +224,16 @@ static FormInfo * AddFormInfo(char *value,
form_info = (FormInfo *)malloc(sizeof(FormInfo));
if(form_info) {
memset(form_info, 0, sizeof(FormInfo));
if (value)
if(value)
form_info->value = value;
if (contenttype)
if(contenttype)
form_info->contenttype = contenttype;
form_info->flags = HTTPPOST_FILENAME;
}
else
return NULL;
if (parent_form_info) {
if(parent_form_info) {
/* now, point our 'more' to the original 'more' */
form_info->more = parent_form_info->more;
@ -316,7 +316,7 @@ static char *memdup(const char *src, size_t buffer_length)
bool add = FALSE;
char *buffer;
if (buffer_length)
if(buffer_length)
length = buffer_length;
else if(src) {
length = strlen(src);
@ -327,13 +327,13 @@ static char *memdup(const char *src, size_t buffer_length)
return strdup((char *)"");
buffer = (char*)malloc(length+add);
if (!buffer)
if(!buffer)
return NULL; /* fail */
memcpy(buffer, src, length);
/* if length unknown do null termination */
if (add)
if(add)
buffer[length] = '\0';
return buffer;
@ -418,16 +418,16 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
/*
* Loop through all the options set. Break if we have an error to report.
*/
while (return_value == CURL_FORMADD_OK) {
while(return_value == CURL_FORMADD_OK) {
/* first see if we have more parts of the array param */
if ( array_state ) {
if( array_state ) {
/* get the upcoming option from the given array */
option = forms->option;
array_value = (char *)forms->value;
forms++; /* advance this to next entry */
if (CURLFORM_END == option) {
if(CURLFORM_END == option) {
/* end of array state */
array_state = FALSE;
continue;
@ -436,7 +436,7 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
else {
/* This is not array-state, get next option */
option = va_arg(params, CURLformoption);
if (CURLFORM_END == option)
if(CURLFORM_END == option)
break;
}
@ -447,7 +447,7 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
return_value = CURL_FORMADD_ILLEGAL_ARRAY;
else {
forms = va_arg(params, struct curl_forms *);
if (forms)
if(forms)
array_state = TRUE;
else
return_value = CURL_FORMADD_NULL;
@ -465,19 +465,19 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
current_form->flags |= HTTPPOST_PTRNAME; /* fall through */
#endif
case CURLFORM_COPYNAME:
if (current_form->name)
if(current_form->name)
return_value = CURL_FORMADD_OPTION_TWICE;
else {
char *name = array_state?
array_value:va_arg(params, char *);
if (name)
if(name)
current_form->name = name; /* store for the moment */
else
return_value = CURL_FORMADD_NULL;
}
break;
case CURLFORM_NAMELENGTH:
if (current_form->namelength)
if(current_form->namelength)
return_value = CURL_FORMADD_OPTION_TWICE;
else
current_form->namelength =
@ -490,19 +490,19 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
case CURLFORM_PTRCONTENTS:
current_form->flags |= HTTPPOST_PTRCONTENTS; /* fall through */
case CURLFORM_COPYCONTENTS:
if (current_form->value)
if(current_form->value)
return_value = CURL_FORMADD_OPTION_TWICE;
else {
char *value =
array_state?array_value:va_arg(params, char *);
if (value)
if(value)
current_form->value = value; /* store for the moment */
else
return_value = CURL_FORMADD_NULL;
}
break;
case CURLFORM_CONTENTSLENGTH:
if (current_form->contentslength)
if(current_form->contentslength)
return_value = CURL_FORMADD_OPTION_TWICE;
else
current_form->contentslength =
@ -511,12 +511,12 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
/* Get contents from a given file name */
case CURLFORM_FILECONTENT:
if (current_form->flags != 0)
if(current_form->flags != 0)
return_value = CURL_FORMADD_OPTION_TWICE;
else {
const char *filename = array_state?
array_value:va_arg(params, char *);
if (filename) {
if(filename) {
current_form->value = strdup(filename);
if(!current_form->value)
return_value = CURL_FORMADD_MEMORY;
@ -536,10 +536,10 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
const char *filename = array_state?array_value:
va_arg(params, char *);
if (current_form->value) {
if (current_form->flags & HTTPPOST_FILENAME) {
if (filename) {
if ((current_form = AddFormInfo(strdup(filename),
if(current_form->value) {
if(current_form->flags & HTTPPOST_FILENAME) {
if(filename) {
if((current_form = AddFormInfo(strdup(filename),
NULL, current_form)) == NULL)
return_value = CURL_FORMADD_MEMORY;
}
@ -550,7 +550,7 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
return_value = CURL_FORMADD_OPTION_TWICE;
}
else {
if (filename) {
if(filename) {
current_form->value = strdup(filename);
if(!current_form->value)
return_value = CURL_FORMADD_MEMORY;
@ -570,10 +570,10 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
const char *filename = array_state?array_value:
va_arg(params, char *);
if (current_form->value) {
if (current_form->flags & HTTPPOST_BUFFER) {
if (filename) {
if ((current_form = AddFormInfo(strdup(filename),
if(current_form->value) {
if(current_form->flags & HTTPPOST_BUFFER) {
if(filename) {
if((current_form = AddFormInfo(strdup(filename),
NULL, current_form)) == NULL)
return_value = CURL_FORMADD_MEMORY;
}
@ -584,7 +584,7 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
return_value = CURL_FORMADD_OPTION_TWICE;
}
else {
if (filename) {
if(filename) {
current_form->value = strdup(filename);
if(!current_form->value)
return_value = CURL_FORMADD_MEMORY;
@ -598,12 +598,12 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
case CURLFORM_BUFFERPTR:
current_form->flags |= HTTPPOST_PTRBUFFER;
if (current_form->buffer)
if(current_form->buffer)
return_value = CURL_FORMADD_OPTION_TWICE;
else {
char *buffer =
array_state?array_value:va_arg(params, char *);
if (buffer)
if(buffer)
current_form->buffer = buffer; /* store for the moment */
else
return_value = CURL_FORMADD_NULL;
@ -611,7 +611,7 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
break;
case CURLFORM_BUFFERLENGTH:
if (current_form->bufferlength)
if(current_form->bufferlength)
return_value = CURL_FORMADD_OPTION_TWICE;
else
current_form->bufferlength =
@ -622,10 +622,10 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
{
const char *contenttype =
array_state?array_value:va_arg(params, char *);
if (current_form->contenttype) {
if (current_form->flags & HTTPPOST_FILENAME) {
if (contenttype) {
if ((current_form = AddFormInfo(NULL,
if(current_form->contenttype) {
if(current_form->flags & HTTPPOST_FILENAME) {
if(contenttype) {
if((current_form = AddFormInfo(NULL,
strdup(contenttype),
current_form)) == NULL)
return_value = CURL_FORMADD_MEMORY;
@ -637,7 +637,7 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
return_value = CURL_FORMADD_OPTION_TWICE;
}
else {
if (contenttype) {
if(contenttype) {
current_form->contenttype = strdup(contenttype);
if(!current_form->contenttype)
return_value = CURL_FORMADD_MEMORY;
@ -692,7 +692,7 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
for(form = first_form;
form != NULL;
form = form->more) {
if ( ((!form->name || !form->value) && !post) ||
if( ((!form->name || !form->value) && !post) ||
( (form->contentslength) &&
(form->flags & HTTPPOST_FILENAME) ) ||
( (form->flags & HTTPPOST_FILENAME) &&
@ -709,7 +709,7 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
break;
}
else {
if ( ((form->flags & HTTPPOST_FILENAME) ||
if( ((form->flags & HTTPPOST_FILENAME) ||
(form->flags & HTTPPOST_BUFFER)) &&
!form->contenttype ) {
/* our contenttype is missing */
@ -721,23 +721,23 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
}
form->contenttype_alloc = TRUE;
}
if ( !(form->flags & HTTPPOST_PTRNAME) &&
if( !(form->flags & HTTPPOST_PTRNAME) &&
(form == first_form) ) {
/* copy name (without strdup; possibly contains null characters) */
form->name = memdup(form->name, form->namelength);
if (!form->name) {
if(!form->name) {
return_value = CURL_FORMADD_MEMORY;
break;
}
form->name_alloc = TRUE;
}
if ( !(form->flags & HTTPPOST_FILENAME) &&
if( !(form->flags & HTTPPOST_FILENAME) &&
!(form->flags & HTTPPOST_READFILE) &&
!(form->flags & HTTPPOST_PTRCONTENTS) &&
!(form->flags & HTTPPOST_PTRBUFFER) ) {
/* copy value (without strdup; possibly contains null characters) */
form->value = memdup(form->value, form->contentslength);
if (!form->value) {
if(!form->value) {
return_value = CURL_FORMADD_MEMORY;
break;
}
@ -756,7 +756,7 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
break;
}
if (form->contenttype)
if(form->contenttype)
prevtype = form->contenttype;
}
}
@ -780,7 +780,7 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
/* always delete the allocated memory before returning */
form = first_form;
while (form != NULL) {
while(form != NULL) {
FormInfo *delete_form;
delete_form = form;
@ -820,7 +820,7 @@ static CURLcode AddFormData(struct FormData **formp,
{
struct FormData *newform = (struct FormData *)
malloc(sizeof(struct FormData));
if (!newform)
if(!newform)
return CURLE_OUT_OF_MEMORY;
newform->next = NULL;
@ -829,7 +829,7 @@ static CURLcode AddFormData(struct FormData **formp,
length = strlen((char *)line);
newform->line = (char *)malloc(length+1);
if (!newform->line) {
if(!newform->line) {
free(newform);
return CURLE_OUT_OF_MEMORY;
}
@ -845,7 +845,7 @@ static CURLcode AddFormData(struct FormData **formp,
else
*formp = newform;
if (size) {
if(size) {
if((type == FORM_DATA) || (type == FORM_CONTENT))
*size += length;
else {
@ -896,7 +896,7 @@ void Curl_formclean(struct FormData **form_ptr)
free(form->line); /* free the line */
free(form); /* free the struct */
} while ((form = next) != NULL); /* continue */
} while((form = next) != NULL); /* continue */
*form_ptr = NULL;
}
@ -920,13 +920,13 @@ CURLcode Curl_formconvert(struct SessionHandle *data, struct FormData *form)
do {
next=form->next; /* the following form line */
if (form->type == FORM_DATA) {
if(form->type == FORM_DATA) {
rc = Curl_convert_to_network(data, form->line, form->length);
/* Curl_convert_to_network calls failf if unsuccessful */
if (rc != CURLE_OK)
if(rc != CURLE_OK)
return rc;
}
} while ((form = next) != NULL); /* continue */
} while((form = next) != NULL); /* continue */
return CURLE_OK;
}
#endif /* CURL_DOES_CONVERSIONS */
@ -944,11 +944,11 @@ int curl_formget(struct curl_httppost *form, void *arg,
struct FormData *data, *ptr;
rc = Curl_getFormData(&data, form, NULL, &size);
if (rc != CURLE_OK)
if(rc != CURLE_OK)
return (int)rc;
for (ptr = data; ptr; ptr = ptr->next) {
if (ptr->type == FORM_FILE) {
if(ptr->type == FORM_FILE) {
char buffer[8192];
size_t nread;
struct Form temp;
@ -957,16 +957,16 @@ int curl_formget(struct curl_httppost *form, void *arg,
do {
nread = readfromfile(&temp, buffer, sizeof(buffer));
if ((nread == (size_t) -1) || (nread != append(arg, buffer, nread))) {
if (temp.fp) {
if((nread == (size_t) -1) || (nread != append(arg, buffer, nread))) {
if(temp.fp) {
fclose(temp.fp);
}
Curl_formclean(&data);
return -1;
}
} while (nread == sizeof(buffer));
} while(nread == sizeof(buffer));
} else {
if (ptr->length != append(arg, ptr->line, ptr->length)) {
if(ptr->length != append(arg, ptr->line, ptr->length)) {
Curl_formclean(&data);
return -1;
}
@ -1005,7 +1005,7 @@ void curl_formfree(struct curl_httppost *form)
free(form->showfilename); /* free the faked file name */
free(form); /* free the struct */
} while ((form = next) != NULL); /* continue */
} while((form = next) != NULL); /* continue */
}
#ifndef HAVE_BASENAME
@ -1110,7 +1110,7 @@ CURLcode Curl_getFormData(struct FormData **finalform,
"Content-Type: multipart/form-data",
boundary);
if (result) {
if(result) {
free(boundary);
return result;
}
@ -1123,13 +1123,13 @@ CURLcode Curl_getFormData(struct FormData **finalform,
if(size) {
result = AddFormDataf(&form, &size, "\r\n");
if (result)
if(result)
break;
}
/* boundary */
result = AddFormDataf(&form, &size, "--%s\r\n", boundary);
if (result)
if(result)
break;
/* Maybe later this should be disabled when a custom_content_type is
@ -1138,16 +1138,16 @@ CURLcode Curl_getFormData(struct FormData **finalform,
*/
result = AddFormDataf(&form, &size,
"Content-Disposition: form-data; name=\"");
if (result)
if(result)
break;
result = AddFormData(&form, FORM_DATA, post->name, post->namelength,
&size);
if (result)
if(result)
break;
result = AddFormDataf(&form, &size, "\"");
if (result)
if(result)
break;
if(post->more) {
@ -1160,7 +1160,7 @@ CURLcode Curl_getFormData(struct FormData **finalform,
"\r\nContent-Type: multipart/mixed,"
" boundary=%s\r\n",
fileboundary);
if (result)
if(result)
break;
}
@ -1183,9 +1183,9 @@ CURLcode Curl_getFormData(struct FormData **finalform,
fileboundary,
(file->showfilename?file->showfilename:
filebasename));
if (filebasename)
if(filebasename)
free(filebasename);
if (result)
if(result)
break;
}
else if((post->flags & HTTPPOST_FILENAME) ||
@ -1198,10 +1198,10 @@ CURLcode Curl_getFormData(struct FormData **finalform,
"; filename=\"%s\"",
(post->showfilename?post->showfilename:
filebasename));
if (filebasename)
if(filebasename)
free(filebasename);
if (result)
if(result)
break;
}
@ -1210,7 +1210,7 @@ CURLcode Curl_getFormData(struct FormData **finalform,
result = AddFormDataf(&form, &size,
"\r\nContent-Type: %s",
file->contenttype);
if (result)
if(result)
break;
}
@ -1218,11 +1218,11 @@ CURLcode Curl_getFormData(struct FormData **finalform,
while( curList ) {
/* Process the additional headers specified for this form */
result = AddFormDataf( &form, &size, "\r\n%s", curList->data );
if (result)
if(result)
break;
curList = curList->next;
}
if (result) {
if(result) {
Curl_formclean(&firstform);
free(boundary);
return result;
@ -1240,13 +1240,13 @@ CURLcode Curl_getFormData(struct FormData **finalform,
/* this is not a text content, mention our binary encoding */
result = AddFormDataf(&form, &size,
"\r\nContent-Transfer-Encoding: binary");
if (result)
if(result)
break;
}
#endif
result = AddFormDataf(&form, &size, "\r\n\r\n");
if (result)
if(result)
break;
if((post->flags & HTTPPOST_FILENAME) ||
@ -1278,14 +1278,14 @@ CURLcode Curl_getFormData(struct FormData **finalform,
*/
size_t nread;
char buffer[512];
while ((nread = fread(buffer, 1, sizeof(buffer), fileread)) != 0) {
while((nread = fread(buffer, 1, sizeof(buffer), fileread)) != 0) {
result = AddFormData(&form, FORM_CONTENT, buffer, nread, &size);
if (result)
if(result)
break;
}
}
if (result) {
if(result) {
Curl_formclean(&firstform);
free(boundary);
return result;
@ -1305,11 +1305,11 @@ CURLcode Curl_getFormData(struct FormData **finalform,
}
}
else if (post->flags & HTTPPOST_BUFFER) {
else if(post->flags & HTTPPOST_BUFFER) {
/* include contents of buffer */
result = AddFormData(&form, FORM_CONTENT, post->buffer,
post->bufferlength, &size);
if (result)
if(result)
break;
}
@ -1317,11 +1317,11 @@ CURLcode Curl_getFormData(struct FormData **finalform,
/* include the contents we got */
result = AddFormData(&form, FORM_CONTENT, post->contents,
post->contentslength, &size);
if (result)
if(result)
break;
}
} while ((file = file->more) != NULL); /* for each specified file for this field */
if (result) {
} while((file = file->more) != NULL); /* for each specified file for this field */
if(result) {
Curl_formclean(&firstform);
free(boundary);
return result;
@ -1334,12 +1334,12 @@ CURLcode Curl_getFormData(struct FormData **finalform,
"\r\n--%s--",
fileboundary);
free(fileboundary);
if (result)
if(result)
break;
}
} while ((post = post->next) != NULL); /* for each field */
if (result) {
} while((post = post->next) != NULL); /* for each field */
if(result) {
Curl_formclean(&firstform);
free(boundary);
return result;
@ -1349,7 +1349,7 @@ CURLcode Curl_getFormData(struct FormData **finalform,
result = AddFormDataf(&form, &size,
"\r\n--%s--\r\n",
boundary);
if (result) {
if(result) {
Curl_formclean(&firstform);
free(boundary);
return result;
@ -1488,7 +1488,7 @@ int FormAddTest(const char * errormsg,
int result;
va_list arg;
va_start(arg, last_post);
if ((result = FormAdd(httppost, last_post, arg)))
if((result = FormAdd(httppost, last_post, arg)))
fprintf (stderr, "ERROR doing FormAdd ret: %d action: %s\n", result,
errormsg);
va_end(arg);
@ -1539,11 +1539,11 @@ int main(int argc, argv_item_t argv[])
(void) argc;
(void) argv;
if (FormAddTest("simple COPYCONTENTS test", &httppost, &last_post,
if(FormAddTest("simple COPYCONTENTS test", &httppost, &last_post,
CURLFORM_COPYNAME, name1, CURLFORM_COPYCONTENTS, value1,
CURLFORM_END))
++errors;
if (FormAddTest("COPYCONTENTS + CONTENTTYPE test", &httppost, &last_post,
if(FormAddTest("COPYCONTENTS + CONTENTTYPE test", &httppost, &last_post,
CURLFORM_COPYNAME, name2, CURLFORM_COPYCONTENTS, value2,
CURLFORM_CONTENTTYPE, type2, CURLFORM_END))
++errors;
@ -1551,41 +1551,41 @@ int main(int argc, argv_item_t argv[])
correctly */
name3[1] = '\0';
value3[1] = '\0';
if (FormAddTest("PTRNAME + NAMELENGTH + COPYNAME + CONTENTSLENGTH test",
if(FormAddTest("PTRNAME + NAMELENGTH + COPYNAME + CONTENTSLENGTH test",
&httppost, &last_post,
CURLFORM_PTRNAME, name3, CURLFORM_COPYCONTENTS, value3,
CURLFORM_CONTENTSLENGTH, value3length,
CURLFORM_NAMELENGTH, name3length, CURLFORM_END))
++errors;
if (FormAddTest("simple PTRCONTENTS test", &httppost, &last_post,
if(FormAddTest("simple PTRCONTENTS test", &httppost, &last_post,
CURLFORM_COPYNAME, name4, CURLFORM_PTRCONTENTS, value4,
CURLFORM_END))
++errors;
/* make null character at start to check that contentslength works
correctly */
value5[1] = '\0';
if (FormAddTest("PTRCONTENTS + CONTENTSLENGTH test", &httppost, &last_post,
if(FormAddTest("PTRCONTENTS + CONTENTSLENGTH test", &httppost, &last_post,
CURLFORM_COPYNAME, name5, CURLFORM_PTRCONTENTS, value5,
CURLFORM_CONTENTSLENGTH, value5length, CURLFORM_END))
++errors;
/* make null character at start to check that contentslength works
correctly */
value6[1] = '\0';
if (FormAddTest("PTRCONTENTS + CONTENTSLENGTH + CONTENTTYPE test",
if(FormAddTest("PTRCONTENTS + CONTENTSLENGTH + CONTENTTYPE test",
&httppost, &last_post,
CURLFORM_COPYNAME, name6, CURLFORM_PTRCONTENTS, value6,
CURLFORM_CONTENTSLENGTH, value6length,
CURLFORM_CONTENTTYPE, type6, CURLFORM_END))
++errors;
if (FormAddTest("FILE + CONTENTTYPE test", &httppost, &last_post,
if(FormAddTest("FILE + CONTENTTYPE test", &httppost, &last_post,
CURLFORM_COPYNAME, name7, CURLFORM_FILE, value7,
CURLFORM_CONTENTTYPE, type7, CURLFORM_END))
++errors;
if (FormAddTest("FILE1 + FILE2 test", &httppost, &last_post,
if(FormAddTest("FILE1 + FILE2 test", &httppost, &last_post,
CURLFORM_COPYNAME, name8, CURLFORM_FILE, value7,
CURLFORM_FILE, value8, CURLFORM_END))
++errors;
if (FormAddTest("FILE1 + FILE2 + FILE3 test", &httppost, &last_post,
if(FormAddTest("FILE1 + FILE2 + FILE3 test", &httppost, &last_post,
CURLFORM_COPYNAME, name9, CURLFORM_FILE, value7,
CURLFORM_FILE, value8, CURLFORM_FILE, value7, CURLFORM_END))
++errors;
@ -1596,11 +1596,11 @@ int main(int argc, argv_item_t argv[])
forms[2].option = CURLFORM_FILE;
forms[2].value = value7;
forms[3].option = CURLFORM_END;
if (FormAddTest("FILE1 + FILE2 + FILE3 ARRAY test", &httppost, &last_post,
if(FormAddTest("FILE1 + FILE2 + FILE3 ARRAY test", &httppost, &last_post,
CURLFORM_COPYNAME, name10, CURLFORM_ARRAY, forms,
CURLFORM_END))
++errors;
if (FormAddTest("FILECONTENT test", &httppost, &last_post,
if(FormAddTest("FILECONTENT test", &httppost, &last_post,
CURLFORM_COPYNAME, name11, CURLFORM_FILECONTENT, value7,
CURLFORM_END))
++errors;
@ -1628,7 +1628,7 @@ int main(int argc, argv_item_t argv[])
fprintf(stdout, "size: ");
fprintf(stdout, CURL_FORMAT_OFF_T, size);
fprintf(stdout, "\n");
if (errors)
if(errors)
fprintf(stdout, "\n==> %d Test(s) failed!\n", errors);
else
fprintf(stdout, "\nAll Tests seem to have worked (please check output)\n");

114
lib/ftp.c
View File

@ -152,9 +152,9 @@ static CURLcode Curl_ftps_setup_connection(struct connectdata * conn);
#endif
/* easy-to-use macro: */
#define FTPSENDF(x,y,z) if ((result = Curl_ftpsendf(x,y,z)) != CURLE_OK) \
#define FTPSENDF(x,y,z) if((result = Curl_ftpsendf(x,y,z)) != CURLE_OK) \
return result
#define NBFTPSENDF(x,y,z) if ((result = Curl_nbftpsendf(x,y,z)) != CURLE_OK) \
#define NBFTPSENDF(x,y,z) if((result = Curl_nbftpsendf(x,y,z)) != CURLE_OK) \
return result
@ -307,9 +307,9 @@ static CURLcode AllowServerConnect(struct connectdata *conn)
/* if a timeout is set, use the most restrictive one */
if (data->set.timeout > 0)
if(data->set.timeout > 0)
timeout_set += 1;
if (data->set.connecttimeout > 0)
if(data->set.connecttimeout > 0)
timeout_set += 2;
switch (timeout_set) {
@ -320,7 +320,7 @@ static CURLcode AllowServerConnect(struct connectdata *conn)
timeout_ms = data->set.connecttimeout;
break;
case 3:
if (data->set.timeout < data->set.connecttimeout)
if(data->set.timeout < data->set.connecttimeout)
timeout_ms = data->set.timeout;
else
timeout_ms = data->set.connecttimeout;
@ -330,7 +330,7 @@ static CURLcode AllowServerConnect(struct connectdata *conn)
break;
}
if (timeout_set > 0) {
if(timeout_set > 0) {
/* if a timeout was already set, substract elapsed time */
timeout_ms -= Curl_tvdiff(Curl_tvnow(), conn->now);
if(timeout_ms < 0) {
@ -366,7 +366,7 @@ static CURLcode AllowServerConnect(struct connectdata *conn)
}
sclose(sock); /* close the first socket */
if (CURL_SOCKET_BAD == s) {
if(CURL_SOCKET_BAD == s) {
/* DIE! */
failf(data, "Error accept()ing server connect");
return CURLE_FTP_PORT_FAILED;
@ -643,7 +643,7 @@ CURLcode Curl_GetFTPResponse(ssize_t *nreadp, /* return number of bytes read */
size_t nread;
int cache_skip=0;
if (ftpcode)
if(ftpcode)
*ftpcode = 0; /* 0 for errors */
*nreadp=0;
@ -846,7 +846,7 @@ static CURLcode ftp_state_cwd(struct connectdata *conn)
result = ftp_state_post_cwd(conn);
else {
ftpc->count2 = 0;
if (conn->bits.reuse && ftpc->entrypath) {
if(conn->bits.reuse && ftpc->entrypath) {
/* This is a re-used connection. Since we change directory to where the
transfer is taking place, we must first get back to the original dir
where we ended up after login: */
@ -922,13 +922,13 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
the IP from the control connection */
sslen = sizeof(ss);
if (getsockname(conn->sock[FIRSTSOCKET], (struct sockaddr *)&ss, &sslen)) {
if(getsockname(conn->sock[FIRSTSOCKET], (struct sockaddr *)&ss, &sslen)) {
failf(data, "getsockname() failed: %s",
Curl_strerror(conn, SOCKERRNO) );
return CURLE_FTP_PORT_FAILED;
}
if (sslen > (socklen_t)sizeof(ss))
if(sslen > (socklen_t)sizeof(ss))
sslen = sizeof(ss);
rc = getnameinfo((struct sockaddr *)&ss, sslen, hbuf, sizeof(hbuf), NULL,
0, NIFLAGS);
@ -960,11 +960,11 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
/*
* Workaround for AIX5 getaddrinfo() problem (it doesn't set ai_socktype):
*/
if (ai->ai_socktype == 0)
if(ai->ai_socktype == 0)
ai->ai_socktype = conn->socktype;
portsock = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
if (portsock == CURL_SOCKET_BAD) {
if(portsock == CURL_SOCKET_BAD) {
error = SOCKERRNO;
continue;
}
@ -978,11 +978,11 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
/* step 3, bind to a suitable local address */
/* Try binding the given address. */
if (bind(portsock, ai->ai_addr, ai->ai_addrlen)) {
if(bind(portsock, ai->ai_addr, ai->ai_addrlen)) {
/* It failed. Bind the address used for the control connection instead */
sslen = sizeof(ss);
if (getsockname(conn->sock[FIRSTSOCKET],
if(getsockname(conn->sock[FIRSTSOCKET],
(struct sockaddr *)sa, &sslen)) {
failf(data, "getsockname() failed: %s",
Curl_strerror(conn, SOCKERRNO) );
@ -996,7 +996,7 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
else
((struct sockaddr_in6 *)sa)->sin6_port =0;
if (sslen > (socklen_t)sizeof(ss))
if(sslen > (socklen_t)sizeof(ss))
sslen = sizeof(ss);
if(bind(portsock, (struct sockaddr *)sa, sslen)) {
@ -1018,7 +1018,7 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
/* step 4, listen on the socket */
if (listen(portsock, 1)) {
if(listen(portsock, 1)) {
failf(data, "socket failure: %s", Curl_strerror(conn, SOCKERRNO));
sclose(portsock);
return CURLE_FTP_PORT_FAILED;
@ -1054,7 +1054,7 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
break;
}
if (EPRT == fcmd) {
if(EPRT == fcmd) {
/*
* Two fine examples from RFC2428;
*
@ -1070,11 +1070,11 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
return result;
break;
}
else if (PORT == fcmd) {
else if(PORT == fcmd) {
char *source = myhost;
char *dest = tmp;
if ((PORT == fcmd) && ai->ai_family != AF_INET)
if((PORT == fcmd) && ai->ai_family != AF_INET)
continue;
/* translate x.x.x.x to x,x,x,x */
@ -1161,19 +1161,19 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
if(!addr) {
/* pick a suitable default here */
if (getsockname(conn->sock[FIRSTSOCKET],
if(getsockname(conn->sock[FIRSTSOCKET],
(struct sockaddr *)&sa, &sslen)) {
failf(data, "getsockname() failed: %s",
Curl_strerror(conn, SOCKERRNO) );
return CURLE_FTP_PORT_FAILED;
}
if (sslen > (socklen_t)sizeof(sa))
if(sslen > (socklen_t)sizeof(sa))
sslen = sizeof(sa);
sa_filled_in = TRUE; /* the sa struct is filled in */
}
if (addr || sa_filled_in) {
if(addr || sa_filled_in) {
portsock = socket(AF_INET, SOCK_STREAM, 0);
if(CURL_SOCKET_BAD != portsock) {
@ -1205,7 +1205,7 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
}
porttouse = ntohs(add.sin_port);
if ( listen(portsock, 1) < 0 ) {
if( listen(portsock, 1) < 0 ) {
failf(data, "listen(2) failed on socket");
return CURLE_FTP_PORT_FAILED;
}
@ -1484,7 +1484,7 @@ static CURLcode ftp_state_post_mdtm(struct connectdata *conn)
/* Some servers return different sizes for different modes, and thus we
must set the proper type before we check the size */
result = ftp_nb_type(conn, data->set.prefer_ascii, FTP_TYPE);
if (result)
if(result)
return result;
}
else
@ -1659,7 +1659,7 @@ static CURLcode ftp_state_quote(struct connectdata *conn,
result = ftp_state_cwd(conn);
break;
case FTP_RETR_PREQUOTE:
if (ftp->transfer != FTPTRANSFER_BODY)
if(ftp->transfer != FTPTRANSFER_BODY)
state(conn, FTP_STOP);
else {
NBFTPSENDF(conn, "SIZE %s", ftpc->file);
@ -1724,7 +1724,7 @@ static CURLcode ftp_state_pasv_resp(struct connectdata *conn,
if(ptr) {
newport = (unsigned short)(num & 0xffff);
if (conn->bits.tunnel_proxy ||
if(conn->bits.tunnel_proxy ||
data->set.proxytype == CURLPROXY_SOCKS5 ||
data->set.proxytype == CURLPROXY_SOCKS4)
/* proxy tunnel -> use other host info because ip_addr_str is the
@ -1759,7 +1759,7 @@ static CURLcode ftp_state_pasv_resp(struct connectdata *conn,
* "227 Entering passive mode. 127,0,0,1,4,51"
*/
while(*str) {
if (6 == sscanf(str, "%d,%d,%d,%d,%d,%d",
if(6 == sscanf(str, "%d,%d,%d,%d,%d,%d",
&ip[0], &ip[1], &ip[2], &ip[3],
&port[0], &port[1]))
break;
@ -1778,7 +1778,7 @@ static CURLcode ftp_state_pasv_resp(struct connectdata *conn,
infof(data, "Skips %d.%d.%d.%d for data connection, uses %s instead\n",
ip[0], ip[1], ip[2], ip[3],
conn->ip_addr_str);
if (conn->bits.tunnel_proxy ||
if(conn->bits.tunnel_proxy ||
data->set.proxytype == CURLPROXY_SOCKS5 ||
data->set.proxytype == CURLPROXY_SOCKS4)
/* proxy tunnel -> use other host info because ip_addr_str is the
@ -1848,7 +1848,7 @@ static CURLcode ftp_state_pasv_resp(struct connectdata *conn,
Curl_resolv_unlock(data, addr); /* we're done using this address */
if (result && ftpc->count1 == 0 && ftpcode == 229) {
if(result && ftpc->count1 == 0 && ftpcode == 229) {
infof(data, "got positive EPSV response, but can't connect. "
"Disabling EPSV\n");
/* disable it for next transfer */
@ -1936,7 +1936,7 @@ static CURLcode ftp_state_port_resp(struct connectdata *conn,
if(ftpcode != 200) {
/* the command failed */
if (EPRT == fcmd) {
if(EPRT == fcmd) {
infof(data, "disabling EPRT usage\n");
conn->bits.ftp_use_eprt = FALSE;
}
@ -2098,7 +2098,7 @@ static CURLcode ftp_state_post_retr_size(struct connectdata *conn,
struct FTP *ftp = data->reqdata.proto.ftp;
struct ftp_conn *ftpc = &conn->proto.ftpc;
if (data->set.max_filesize && (filesize > data->set.max_filesize)) {
if(data->set.max_filesize && (filesize > data->set.max_filesize)) {
failf(data, "Maximum file size exceeded");
return CURLE_FILESIZE_EXCEEDED;
}
@ -2220,7 +2220,7 @@ static CURLcode ftp_state_rest_resp(struct connectdata *conn,
case FTP_REST:
default:
#ifdef CURL_FTP_HTTPSTYLE_HEAD
if (ftpcode == 350) {
if(ftpcode == 350) {
char buffer[24]= { "Accept-ranges: bytes\r\n" };
result = Curl_client_write(conn, CLIENTWRITE_BOTH, buffer, 0);
if(result)
@ -2231,7 +2231,7 @@ static CURLcode ftp_state_rest_resp(struct connectdata *conn,
break;
case FTP_RETR_REST:
if (ftpcode != 350) {
if(ftpcode != 350) {
failf(conn->data, "Couldn't use REST");
result = CURLE_FTP_COULDNT_USE_REST;
}
@ -2497,7 +2497,7 @@ static CURLcode ftp_state_user_resp(struct connectdata *conn,
530 User ... access denied
(the server denies to log the specified user) */
if (conn->data->set.str[STRING_FTP_ALTERNATIVE_TO_USER] &&
if(conn->data->set.str[STRING_FTP_ALTERNATIVE_TO_USER] &&
!conn->data->state.ftp_trying_alternative) {
/* Ok, USER failed. Let's try the supplied command. */
NBFTPSENDF(conn, "%s",
@ -2721,7 +2721,7 @@ static CURLcode ftp_statemach_act(struct connectdata *conn)
break;
case FTP_CCC:
if (ftpcode < 500) {
if(ftpcode < 500) {
/* First shut down the SSL layer (note: this call will block) */
result = Curl_ssl_shutdown(conn, FIRSTSOCKET);
@ -3024,7 +3024,7 @@ static CURLcode ftp_init(struct connectdata *conn)
/* no need to duplicate them, this connectdata struct won't change */
ftp->user = conn->user;
ftp->passwd = conn->passwd;
if (isBadFtpString(ftp->user) || isBadFtpString(ftp->passwd))
if(isBadFtpString(ftp->user) || isBadFtpString(ftp->passwd))
return CURLE_URL_MALFORMAT;
return CURLE_OK;
@ -3066,7 +3066,7 @@ static CURLcode Curl_ftp_connect(struct connectdata *conn,
ftpc->response_time = 3600000; /* set default response time-out */
#ifndef CURL_DISABLE_HTTP
if (conn->bits.tunnel_proxy && conn->bits.httpproxy) {
if(conn->bits.tunnel_proxy && conn->bits.httpproxy) {
/* BLOCKING */
/* We want "seamless" FTP operations through HTTP proxy tunnel */
@ -3159,7 +3159,7 @@ static CURLcode Curl_ftp_done(struct connectdata *conn, CURLcode status,
/* the connection stays alive fine even though this happened */
/* fall-through */
case CURLE_OK: /* doesn't affect the control connection's status */
if (!premature) {
if(!premature) {
ftpc->ctl_valid = was_ctl_valid;
break;
}
@ -3330,15 +3330,15 @@ CURLcode ftp_sendquote(struct connectdata *conn, struct curl_slist *quote)
CURLcode result;
item = quote;
while (item) {
if (item->data) {
while(item) {
if(item->data) {
FTPSENDF(conn, "%s", item->data);
result = Curl_GetFTPResponse(&nread, conn, &ftpcode);
if (result)
if(result)
return result;
if (ftpcode >= 400) {
if(ftpcode >= 400) {
failf(conn->data, "QUOT string not accepted: %s", item->data);
return CURLE_QUOTE_ERROR;
}
@ -3377,7 +3377,7 @@ static CURLcode ftp_nb_type(struct connectdata *conn,
CURLcode result;
char want = (char)(ascii?'A':'I');
if (ftpc->transfertype == want) {
if(ftpc->transfertype == want) {
state(conn, newstate);
return ftp_state_type_resp(conn, 200, newstate);
}
@ -3493,7 +3493,7 @@ static CURLcode Curl_ftp_nextconnect(struct connectdata *conn)
if(data->set.upload) {
result = ftp_nb_type(conn, data->set.prefer_ascii, FTP_STOR_TYPE);
if (result)
if(result)
return result;
}
else {
@ -3511,14 +3511,14 @@ static CURLcode Curl_ftp_nextconnect(struct connectdata *conn)
/* But only if a body transfer was requested. */
if(ftp->transfer == FTPTRANSFER_BODY) {
result = ftp_nb_type(conn, 1, FTP_LIST_TYPE);
if (result)
if(result)
return result;
}
/* otherwise just fall through */
}
else {
result = ftp_nb_type(conn, data->set.prefer_ascii, FTP_RETR_TYPE);
if (result)
if(result)
return result;
}
}
@ -3612,7 +3612,7 @@ static CURLcode Curl_ftp(struct connectdata *conn, bool *done)
return retcode;
retcode = ftp_parse_url_path(conn);
if (retcode)
if(retcode)
return retcode;
retcode = ftp_regular_transfer(conn, done);
@ -3809,7 +3809,7 @@ static CURLcode Curl_ftp_disconnect(struct connectdata *conn)
if(ftpc->entrypath) {
struct SessionHandle *data = conn->data;
if (data->state.most_recent_ftp_entrypath == ftpc->entrypath) {
if(data->state.most_recent_ftp_entrypath == ftpc->entrypath) {
data->state.most_recent_ftp_entrypath = NULL;
}
free(ftpc->entrypath);
@ -3922,25 +3922,25 @@ CURLcode ftp_parse_url_path(struct connectdata *conn)
}
else {
/* parse the URL path into separate path components */
while ((slash_pos = strchr(cur_pos, '/')) != NULL) {
while((slash_pos = strchr(cur_pos, '/')) != NULL) {
/* 1 or 0 to indicate absolute directory */
bool absolute_dir = (bool)((cur_pos - data->reqdata.path > 0) &&
(ftpc->dirdepth == 0));
/* seek out the next path component */
if (slash_pos-cur_pos) {
if(slash_pos-cur_pos) {
/* we skip empty path components, like "x//y" since the FTP command
CWD requires a parameter and a non-existant parameter a) doesn't
work on many servers and b) has no effect on the others. */
int len = (int)(slash_pos - cur_pos + absolute_dir);
ftpc->dirs[ftpc->dirdepth] =
curl_easy_unescape(conn->data, cur_pos - absolute_dir, len, NULL);
if (!ftpc->dirs[ftpc->dirdepth]) { /* run out of memory ... */
if(!ftpc->dirs[ftpc->dirdepth]) { /* run out of memory ... */
failf(data, "no memory");
freedirs(ftpc);
return CURLE_OUT_OF_MEMORY;
}
if (isBadFtpString(ftpc->dirs[ftpc->dirdepth])) {
if(isBadFtpString(ftpc->dirs[ftpc->dirdepth])) {
free(ftpc->dirs[ftpc->dirdepth]);
freedirs(ftpc);
return CURLE_URL_MALFORMAT;
@ -3975,7 +3975,7 @@ CURLcode ftp_parse_url_path(struct connectdata *conn)
failf(data, "no memory");
return CURLE_OUT_OF_MEMORY;
}
if (isBadFtpString(ftpc->file)) {
if(isBadFtpString(ftpc->file)) {
freedirs(ftpc);
return CURLE_URL_MALFORMAT;
}
@ -4117,7 +4117,7 @@ static CURLcode Curl_ftp_setup_connection(struct connectdata * conn)
/* Unless we have asked to tunnel ftp operations through the proxy, we
switch and use HTTP operations only */
#ifndef CURL_DISABLE_HTTP
if (conn->handler == &Curl_handler_ftp)
if(conn->handler == &Curl_handler_ftp)
conn->handler = &Curl_handler_ftp_proxy;
else {
#ifdef USE_SSL
@ -4140,10 +4140,10 @@ static CURLcode Curl_ftp_setup_connection(struct connectdata * conn)
* we'll try to get now! */
type = strstr(data->reqdata.path, ";type=");
if (!type)
if(!type)
type = strstr(conn->host.rawalloc, ";type=");
if (type) {
if(type) {
*type = 0; /* it was in the middle of the hostname */
command = (char) toupper((int) type[6]);

View File

@ -110,18 +110,18 @@ static bool init_resolve_thread(struct connectdata *conn,
defined(DEBUG_THREADING_GETADDRINFO)
/* If this is defined, provide tracing */
#define TRACE(args) \
do { trace_it("%u: ", __LINE__); trace_it args; } while (0)
do { trace_it("%u: ", __LINE__); trace_it args; } while(0)
static void trace_it (const char *fmt, ...)
{
static int do_trace = -1;
va_list args;
if (do_trace == -1) {
if(do_trace == -1) {
const char *env = getenv("CURL_TRACE");
do_trace = (env && atoi(env) > 0);
}
if (!do_trace)
if(!do_trace)
return;
va_start (args, fmt);
vfprintf (stderr, fmt, args);
@ -141,7 +141,7 @@ static void dump_addrinfo (struct connectdata *conn, const struct addrinfo *ai)
trace_it(" fam %2d, CNAME %s, ",
ai->ai_family, ai->ai_canonname ? ai->ai_canonname : "<none>");
if (Curl_printable_address(ai, buf, sizeof(buf)))
if(Curl_printable_address(ai, buf, sizeof(buf)))
trace_it("%s\n", buf);
else
trace_it("failed; %s\n", Curl_strerror(conn, SOCKERRNO));
@ -179,13 +179,13 @@ struct thread_sync_data {
static
void destroy_thread_sync_data(struct thread_sync_data * tsd)
{
if (tsd->hostname)
if(tsd->hostname)
free(tsd->hostname);
if (tsd->event_terminate)
if(tsd->event_terminate)
CloseHandle(tsd->event_terminate);
if (tsd->mutex_terminate)
if(tsd->mutex_terminate)
CloseHandle(tsd->mutex_terminate);
if (tsd->mutex_waiting)
if(tsd->mutex_waiting)
CloseHandle(tsd->mutex_waiting);
memset(tsd,0,sizeof(*tsd));
}
@ -199,21 +199,21 @@ BOOL init_thread_sync_data(struct thread_data * td,
HANDLE curr_proc = GetCurrentProcess();
memset(tsd, 0, sizeof(*tsd));
if (!DuplicateHandle(curr_proc, td->mutex_waiting,
if(!DuplicateHandle(curr_proc, td->mutex_waiting,
curr_proc, &tsd->mutex_waiting, 0, FALSE,
DUPLICATE_SAME_ACCESS)) {
/* failed to duplicate the mutex, no point in continuing */
destroy_thread_sync_data(tsd);
return FALSE;
}
if (!DuplicateHandle(curr_proc, td->mutex_terminate,
if(!DuplicateHandle(curr_proc, td->mutex_terminate,
curr_proc, &tsd->mutex_terminate, 0, FALSE,
DUPLICATE_SAME_ACCESS)) {
/* failed to duplicate the mutex, no point in continuing */
destroy_thread_sync_data(tsd);
return FALSE;
}
if (!DuplicateHandle(curr_proc, td->event_terminate,
if(!DuplicateHandle(curr_proc, td->event_terminate,
curr_proc, &tsd->event_terminate, 0, FALSE,
DUPLICATE_SAME_ACCESS)) {
/* failed to duplicate the event, no point in continuing */
@ -224,7 +224,7 @@ BOOL init_thread_sync_data(struct thread_data * td,
* thread during gethostbyname execution.
*/
tsd->hostname = strdup(hostname);
if (!tsd->hostname) {
if(!tsd->hostname) {
/* Memory allocation failed */
destroy_thread_sync_data(tsd);
return FALSE;
@ -237,15 +237,15 @@ static
BOOL acquire_thread_sync(struct thread_sync_data * tsd)
{
/* is the thread initiator still waiting for us ? */
if (WaitForSingleObject(tsd->mutex_waiting, 0) == WAIT_TIMEOUT) {
if(WaitForSingleObject(tsd->mutex_waiting, 0) == WAIT_TIMEOUT) {
/* yes, it is */
/* Waiting access to event_terminate */
if (WaitForSingleObject(tsd->mutex_terminate, INFINITE) != WAIT_OBJECT_0) {
if(WaitForSingleObject(tsd->mutex_terminate, INFINITE) != WAIT_OBJECT_0) {
/* Something went wrong - now just ignoring */
}
else {
if (WaitForSingleObject(tsd->event_terminate, 0) != WAIT_TIMEOUT) {
if(WaitForSingleObject(tsd->event_terminate, 0) != WAIT_TIMEOUT) {
/* Parent thread signaled us to terminate.
* This means that all data in conn->async is now destroyed
* and we cannot use it.
@ -287,7 +287,7 @@ static unsigned __stdcall gethostbyname_thread (void *arg)
*/
struct thread_sync_data tsd = { 0,0,0,NULL };
if (!init_thread_sync_data(td, conn->async.hostname, &tsd)) {
if(!init_thread_sync_data(td, conn->async.hostname, &tsd)) {
/* thread synchronization data initialization failed */
return (unsigned)-1;
}
@ -302,11 +302,11 @@ static unsigned __stdcall gethostbyname_thread (void *arg)
he = gethostbyname (tsd.hostname);
/* is parent thread waiting for us and are we able to access conn members? */
if (acquire_thread_sync(&tsd)) {
if(acquire_thread_sync(&tsd)) {
/* Mark that we have obtained the information, and that we are calling
* back with it. */
SetEvent(td->event_resolved);
if (he) {
if(he) {
rc = Curl_addrinfo4_callback(conn, CURL_ASYNC_SUCCESS, he);
}
else {
@ -348,7 +348,7 @@ static unsigned __stdcall getaddrinfo_thread (void *arg)
*/
struct thread_sync_data tsd = { 0,0,0,NULL };
if (!init_thread_sync_data(td, conn->async.hostname, &tsd)) {
if(!init_thread_sync_data(td, conn->async.hostname, &tsd)) {
/* thread synchronization data initialization failed */
return -1;
}
@ -365,12 +365,12 @@ static unsigned __stdcall getaddrinfo_thread (void *arg)
rc = getaddrinfo(tsd.hostname, service, &hints, &res);
/* is parent thread waiting for us and are we able to access conn members? */
if (acquire_thread_sync(&tsd)) {
if(acquire_thread_sync(&tsd)) {
/* Mark that we have obtained the information, and that we are calling
back with it. */
SetEvent(td->event_resolved);
if (rc == 0) {
if(rc == 0) {
#ifdef DEBUG_THREADING_GETADDRINFO
dump_addrinfo (conn, res);
#endif
@ -397,16 +397,16 @@ static unsigned __stdcall getaddrinfo_thread (void *arg)
*/
void Curl_destroy_thread_data (struct Curl_async *async)
{
if (async->hostname)
if(async->hostname)
free(async->hostname);
if (async->os_specific) {
if(async->os_specific) {
struct thread_data *td = (struct thread_data*) async->os_specific;
curl_socket_t sock = td->dummy_sock;
if (td->mutex_terminate && td->event_terminate) {
if(td->mutex_terminate && td->event_terminate) {
/* Signaling resolver thread to terminate */
if (WaitForSingleObject(td->mutex_terminate, INFINITE) == WAIT_OBJECT_0) {
if(WaitForSingleObject(td->mutex_terminate, INFINITE) == WAIT_OBJECT_0) {
SetEvent(td->event_terminate);
ReleaseMutex(td->mutex_terminate);
}
@ -415,24 +415,24 @@ void Curl_destroy_thread_data (struct Curl_async *async)
}
}
if (td->mutex_terminate)
if(td->mutex_terminate)
CloseHandle(td->mutex_terminate);
if (td->event_terminate)
if(td->event_terminate)
CloseHandle(td->event_terminate);
if (td->event_thread_started)
if(td->event_thread_started)
CloseHandle(td->event_thread_started);
if (sock != CURL_SOCKET_BAD)
if(sock != CURL_SOCKET_BAD)
sclose(sock);
/* destroy the synchronization objects */
if (td->mutex_waiting)
if(td->mutex_waiting)
CloseHandle(td->mutex_waiting);
td->mutex_waiting = NULL;
if (td->event_resolved)
if(td->event_resolved)
CloseHandle(td->event_resolved);
if (td->thread_hnd)
if(td->thread_hnd)
CloseHandle(td->thread_hnd);
free(async->os_specific);
@ -454,14 +454,14 @@ static bool init_resolve_thread (struct connectdata *conn,
struct thread_data *td = calloc(sizeof(*td), 1);
HANDLE thread_and_event[2] = {0};
if (!td) {
if(!td) {
SET_ERRNO(ENOMEM);
return FALSE;
}
Curl_safefree(conn->async.hostname);
conn->async.hostname = strdup(hostname);
if (!conn->async.hostname) {
if(!conn->async.hostname) {
free(td);
SET_ERRNO(ENOMEM);
return FALSE;
@ -478,7 +478,7 @@ static bool init_resolve_thread (struct connectdata *conn,
* still waiting, and take initial ownership.
*/
td->mutex_waiting = CreateMutex(NULL, TRUE, NULL);
if (td->mutex_waiting == NULL) {
if(td->mutex_waiting == NULL) {
Curl_destroy_thread_data(&conn->async);
SET_ERRNO(EAGAIN);
return FALSE;
@ -488,7 +488,7 @@ static bool init_resolve_thread (struct connectdata *conn,
* done resolving. Do not signal it.
*/
td->event_resolved = CreateEvent(NULL, TRUE, FALSE, NULL);
if (td->event_resolved == NULL) {
if(td->event_resolved == NULL) {
Curl_destroy_thread_data(&conn->async);
SET_ERRNO(EAGAIN);
return FALSE;
@ -497,7 +497,7 @@ static bool init_resolve_thread (struct connectdata *conn,
* between us and resolver thread.
*/
td->mutex_terminate = CreateMutex(NULL, FALSE, NULL);
if (td->mutex_terminate == NULL) {
if(td->mutex_terminate == NULL) {
Curl_destroy_thread_data(&conn->async);
SET_ERRNO(EAGAIN);
return FALSE;
@ -505,7 +505,7 @@ static bool init_resolve_thread (struct connectdata *conn,
/* Create the event used to signal thread that it should terminate.
*/
td->event_terminate = CreateEvent(NULL, TRUE, FALSE, NULL);
if (td->event_terminate == NULL) {
if(td->event_terminate == NULL) {
Curl_destroy_thread_data(&conn->async);
SET_ERRNO(EAGAIN);
return FALSE;
@ -513,7 +513,7 @@ static bool init_resolve_thread (struct connectdata *conn,
/* Create the event used by thread to inform it has initialized its own data.
*/
td->event_thread_started = CreateEvent(NULL, TRUE, FALSE, NULL);
if (td->event_thread_started == NULL) {
if(td->event_thread_started == NULL) {
Curl_destroy_thread_data(&conn->async);
SET_ERRNO(EAGAIN);
return FALSE;
@ -535,7 +535,7 @@ static bool init_resolve_thread (struct connectdata *conn,
(void) hints;
#endif
if (!td->thread_hnd) {
if(!td->thread_hnd) {
#ifdef _WIN32_WCE
TRACE(("CreateThread() failed; %s\n", Curl_strerror(conn, ERRNO)));
#else
@ -549,7 +549,7 @@ static bool init_resolve_thread (struct connectdata *conn,
*/
thread_and_event[0] = td->thread_hnd;
thread_and_event[1] = td->event_thread_started;
if (WaitForMultipleObjects(sizeof(thread_and_event) /
if(WaitForMultipleObjects(sizeof(thread_and_event) /
sizeof(thread_and_event[0]),
(const HANDLE*)thread_and_event, FALSE,
INFINITE) == WAIT_FAILED) {
@ -608,9 +608,9 @@ CURLcode Curl_wait_for_resolv(struct connectdata *conn,
td->event_resolved = NULL;
/* has the resolver thread succeeded in resolving our query ? */
if (status == WAIT_OBJECT_0) {
if(status == WAIT_OBJECT_0) {
/* wait for the thread to exit, it's in the callback sequence */
if (WaitForSingleObject(td->thread_hnd, 5000) == WAIT_TIMEOUT) {
if(WaitForSingleObject(td->thread_hnd, 5000) == WAIT_TIMEOUT) {
TerminateThread(td->thread_hnd, 0);
conn->async.done = TRUE;
td->thread_status = (DWORD)-1;
@ -640,9 +640,9 @@ CURLcode Curl_wait_for_resolv(struct connectdata *conn,
rc = CURLE_OK;
if (!conn->async.dns) {
if(!conn->async.dns) {
/* a name was not resolved */
if (td->thread_status == CURLE_OUT_OF_MEMORY) {
if(td->thread_status == CURLE_OUT_OF_MEMORY) {
rc = CURLE_OUT_OF_MEMORY;
failf(data, "Could not resolve host: %s", curl_easy_strerror(rc));
}
@ -658,7 +658,7 @@ CURLcode Curl_wait_for_resolv(struct connectdata *conn,
rc = CURLE_COULDNT_RESOLVE_HOST;
}
}
else if (td->thread_status == (DWORD)-1 || conn->async.status == NO_DATA) {
else if(td->thread_status == (DWORD)-1 || conn->async.status == NO_DATA) {
failf(data, "Resolving host timed out: %s", conn->host.name);
rc = CURLE_OPERATION_TIMEDOUT;
}
@ -684,10 +684,10 @@ CURLcode Curl_is_resolved(struct connectdata *conn,
{
*entry = NULL;
if (conn->async.done) {
if(conn->async.done) {
/* we're done */
Curl_destroy_thread_data(&conn->async);
if (!conn->async.dns) {
if(!conn->async.dns) {
TRACE(("Curl_is_resolved(): CURLE_COULDNT_RESOLVE_HOST\n"));
return CURLE_COULDNT_RESOLVE_HOST;
}
@ -704,7 +704,7 @@ int Curl_resolv_getsock(struct connectdata *conn,
const struct thread_data *td =
(const struct thread_data *) conn->async.os_specific;
if (td && td->dummy_sock != CURL_SOCKET_BAD) {
if(td && td->dummy_sock != CURL_SOCKET_BAD) {
if(numsocks) {
/* return one socket waiting for writable, even though this is just
a dummy */
@ -731,12 +731,12 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn,
*waitp = 0; /* don't wait, we act synchronously */
in = inet_addr(hostname);
if (in != CURL_INADDR_NONE)
if(in != CURL_INADDR_NONE)
/* This is a dotted IP address 123.123.123.123-style */
return Curl_ip2addr(in, hostname, port);
/* fire up a new resolver thread! */
if (init_resolve_thread(conn, hostname, port, NULL)) {
if(init_resolve_thread(conn, hostname, port, NULL)) {
*waitp = TRUE; /* please wait for the response */
return NULL;
}
@ -746,7 +746,7 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn,
hostname, Curl_strerror(conn, ERRNO));
h = gethostbyname(hostname);
if (!h) {
if(!h) {
infof(data, "gethostbyname(2) failed for %s:%d; %s\n",
hostname, port, Curl_strerror(conn, SOCKERRNO));
return NULL;
@ -775,7 +775,7 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn,
/* see if we have an IPv6 stack */
s = socket(PF_INET6, SOCK_DGRAM, 0);
if (s == CURL_SOCKET_BAD) {
if(s == CURL_SOCKET_BAD) {
/* Some non-IPv6 stacks have been found to make very slow name resolves
* when PF_UNSPEC is used, so thus we switch to a mere PF_INET lookup if
* the stack seems to be a non-ipv6 one. */
@ -813,7 +813,7 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn,
itoa(port, sbuf, 10);
/* fire up a new resolver thread! */
if (init_resolve_thread(conn, hostname, port, &hints)) {
if(init_resolve_thread(conn, hostname, port, &hints)) {
*waitp = TRUE; /* please wait for the response */
return NULL;
}
@ -823,7 +823,7 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn,
hostname, Curl_strerror(conn, ERRNO));
error = getaddrinfo(hostname, sbuf, &hints, &res);
if (error) {
if(error) {
infof(data, "getaddrinfo() failed for %s:%d; %s\n",
hostname, port, Curl_strerror(conn, SOCKERRNO));
return NULL;

View File

@ -385,7 +385,7 @@ CURLcode Curl_http_auth_act(struct connectdata *conn)
if(pickhost || pickproxy) {
data->reqdata.newurl = strdup(data->change.url); /* clone URL */
if (!data->reqdata.newurl)
if(!data->reqdata.newurl)
return CURLE_OUT_OF_MEMORY;
if((data->set.httpreq != HTTPREQ_GET) &&
@ -407,12 +407,12 @@ CURLcode Curl_http_auth_act(struct connectdata *conn)
if((data->set.httpreq != HTTPREQ_GET) &&
(data->set.httpreq != HTTPREQ_HEAD)) {
data->reqdata.newurl = strdup(data->change.url); /* clone URL */
if (!data->reqdata.newurl)
if(!data->reqdata.newurl)
return CURLE_OUT_OF_MEMORY;
data->state.authhost.done = TRUE;
}
}
if (Curl_http_should_fail(conn)) {
if(Curl_http_should_fail(conn)) {
failf (data, "The requested URL returned error: %d",
data->reqdata.keep.httpcode);
code = CURLE_HTTP_RETURNED_ERROR;
@ -475,7 +475,7 @@ Curl_http_output_auth(struct connectdata *conn,
authproxy->picked = authproxy->want;
/* Send proxy authentication header if needed */
if (conn->bits.httpproxy &&
if(conn->bits.httpproxy &&
(conn->bits.tunnel_proxy == proxytunnel)) {
#ifdef HAVE_GSSAPI
if((authproxy->picked == CURLAUTH_GSSNEGOTIATE) &&
@ -483,7 +483,7 @@ Curl_http_output_auth(struct connectdata *conn,
!GSS_ERROR(data->state.negotiate.status)) {
auth="GSS-Negotiate";
result = Curl_output_negotiate(conn, TRUE);
if (result)
if(result)
return result;
authproxy->done = TRUE;
}
@ -552,7 +552,7 @@ Curl_http_output_auth(struct connectdata *conn,
!GSS_ERROR(data->state.negotiate.status)) {
auth="GSS-Negotiate";
result = Curl_output_negotiate(conn, FALSE);
if (result)
if(result)
return result;
authhost->done = TRUE;
}
@ -627,7 +627,7 @@ CURLcode Curl_http_input_auth(struct connectdata *conn,
const char *start;
struct auth *authp;
if (httpcode == 407) {
if(httpcode == 407) {
start = header+strlen("Proxy-authenticate:");
availp = &data->info.proxyauthavail;
authp = &data->state.authproxy;
@ -652,14 +652,14 @@ CURLcode Curl_http_input_auth(struct connectdata *conn,
*/
#ifdef HAVE_GSSAPI
if (checkprefix("GSS-Negotiate", start) ||
if(checkprefix("GSS-Negotiate", start) ||
checkprefix("Negotiate", start)) {
*availp |= CURLAUTH_GSSNEGOTIATE;
authp->avail |= CURLAUTH_GSSNEGOTIATE;
if(authp->picked == CURLAUTH_GSSNEGOTIATE) {
/* if exactly this is wanted, go */
int neg = Curl_input_negotiate(conn, (bool)(httpcode == 407), start);
if (neg == 0) {
if(neg == 0) {
data->reqdata.newurl = strdup(data->change.url);
data->state.authproblem = (data->reqdata.newurl == NULL);
}
@ -758,16 +758,16 @@ int Curl_http_should_fail(struct connectdata *conn)
** If we haven't been asked to fail on error,
** don't fail.
*/
if (!data->set.http_fail_on_error)
if(!data->set.http_fail_on_error)
return 0;
/*
** Any code < 400 is never terminal.
*/
if (k->httpcode < 400)
if(k->httpcode < 400)
return 0;
if (data->reqdata.resume_from &&
if(data->reqdata.resume_from &&
(data->set.httpreq==HTTPREQ_GET) &&
(k->httpcode == 416)) {
/* "Requested Range Not Satisfiable", just proceed and
@ -779,7 +779,7 @@ int Curl_http_should_fail(struct connectdata *conn)
** Any code >= 400 that's not 401 or 407 is always
** a terminal error
*/
if ((k->httpcode != 401) &&
if((k->httpcode != 401) &&
(k->httpcode != 407))
return 1;
@ -986,12 +986,12 @@ CURLcode add_buffer_send(send_buffer *in,
/* this data _may_ contain binary stuff */
Curl_debug(conn->data, CURLINFO_HEADER_OUT, ptr,
(size_t)(amount-included_body_bytes), conn);
if (included_body_bytes)
if(included_body_bytes)
Curl_debug(conn->data, CURLINFO_DATA_OUT,
ptr+amount-included_body_bytes,
(size_t)included_body_bytes, conn);
}
if (included_body_bytes)
if(included_body_bytes)
/* since we sent a piece of the body here, up the byte counter for it
accordingly */
http->writebytecount = included_body_bytes;
@ -1207,7 +1207,7 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn,
conn->bits.proxy_connect_closed = FALSE;
do {
if (!conn->bits.tunnel_connecting) { /* BEGIN CONNECT PHASE */
if(!conn->bits.tunnel_connecting) { /* BEGIN CONNECT PHASE */
char *host_port;
send_buffer *req_buffer;
@ -1314,8 +1314,8 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn,
}
/* if we're in multi-mode and we would block, return instead for a retry */
if (Curl_if_multi == data->state.used_interface) {
if (0 == Curl_socket_ready(tunnelsocket, CURL_SOCKET_BAD, 0))
if(Curl_if_multi == data->state.used_interface) {
if(0 == Curl_socket_ready(tunnelsocket, CURL_SOCKET_BAD, 0))
/* return so we'll be called again polling-style */
return CURLE_OK;
else {
@ -1571,7 +1571,7 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn,
headers. 'newurl' is set to a new URL if we must loop. */
Curl_http_auth_act(conn);
if (closeConnection && data->reqdata.newurl) {
if(closeConnection && data->reqdata.newurl) {
/* Connection closed by server. Don't use it anymore */
sclose(conn->sock[sockindex]);
conn->sock[sockindex] = CURL_SOCKET_BAD;
@ -1584,7 +1584,7 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn,
failf(data, "Received HTTP code %d from proxy after CONNECT",
k->httpcode);
if (closeConnection && data->reqdata.newurl)
if(closeConnection && data->reqdata.newurl)
conn->bits.proxy_connect_closed = TRUE;
return CURLE_RECV_ERROR;
@ -1634,14 +1634,14 @@ CURLcode Curl_http_connect(struct connectdata *conn, bool *done)
return result;
}
if (conn->bits.tunnel_connecting) {
if(conn->bits.tunnel_connecting) {
/* nothing else to do except wait right now - we're not done here. */
return CURLE_OK;
}
if(!data->state.this_is_a_follow) {
/* this is not a followed location, get the original host name */
if (data->state.first_host)
if(data->state.first_host)
/* Free to avoid leaking memory on multiple requests*/
free(data->state.first_host);
@ -1692,18 +1692,18 @@ static int Curl_https_getsock(struct connectdata *conn,
curl_socket_t *socks,
int numsocks)
{
if (conn->protocol & PROT_HTTPS) {
if(conn->protocol & PROT_HTTPS) {
struct ssl_connect_data *connssl = &conn->ssl[FIRSTSOCKET];
if(!numsocks)
return GETSOCK_BLANK;
if (connssl->connecting_state == ssl_connect_2_writing) {
if(connssl->connecting_state == ssl_connect_2_writing) {
/* write mode */
socks[0] = conn->sock[FIRSTSOCKET];
return GETSOCK_WRITESOCK(0);
}
else if (connssl->connecting_state == ssl_connect_2_reading) {
else if(connssl->connecting_state == ssl_connect_2_reading) {
/* read mode */
socks[0] = conn->sock[FIRSTSOCKET];
return GETSOCK_READSOCK(0);
@ -1766,7 +1766,7 @@ CURLcode Curl_http_done(struct connectdata *conn,
conn->fread_func = data->set.fread_func; /* restore */
conn->fread_in = data->set.in; /* restore */
if (http == NULL)
if(http == NULL)
return CURLE_OK;
if(http->send_buffer) {
@ -1790,7 +1790,7 @@ CURLcode Curl_http_done(struct connectdata *conn,
else if(HTTPREQ_PUT == data->set.httpreq)
k->bytecount = http->readbytecount + http->writebytecount;
if (status != CURLE_OK)
if(status != CURLE_OK)
return (status);
if(!conn->bits.retry &&
@ -1909,7 +1909,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
else
http = data->reqdata.proto.http;
if ( (conn->protocol&(PROT_HTTP|PROT_FTP)) &&
if( (conn->protocol&(PROT_HTTP|PROT_FTP)) &&
data->set.upload) {
httpreq = HTTPREQ_PUT;
}
@ -1990,7 +1990,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
Curl_compareheader(ptr, "Transfer-Encoding:", "chunked");
}
else {
if (httpreq == HTTPREQ_GET)
if(httpreq == HTTPREQ_GET)
conn->bits.upload_chunky = FALSE;
if(conn->bits.upload_chunky)
te = "Transfer-Encoding: chunked\r\n";
@ -2035,7 +2035,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
if(((conn->protocol&PROT_HTTPS) && (conn->remote_port == PORT_HTTPS)) ||
(!(conn->protocol&PROT_HTTPS) && (conn->remote_port == PORT_HTTP)) )
/* If (HTTPS on port 443) OR (non-HTTPS on port 80) then don't include
/* if(HTTPS on port 443) OR (non-HTTPS on port 80) then don't include
the port number in the host string */
conn->allocptr.host = aprintf("Host: %s%s%s\r\n",
conn->bits.ipv6_ip?"[":"",
@ -2053,7 +2053,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
return CURLE_OUT_OF_MEMORY;
}
if (conn->bits.httpproxy && !conn->bits.tunnel_proxy) {
if(conn->bits.httpproxy && !conn->bits.tunnel_proxy) {
/* Using a proxy but does not tunnel through it */
/* The path sent to the proxy is in fact the entire URL. But if the remote
@ -2095,9 +2095,9 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
}
ppath = data->change.url;
/* when doing ftp, append ;type=<a|i> if not present */
if (checkprefix("ftp://", ppath) || checkprefix("ftps://", ppath)) {
if(checkprefix("ftp://", ppath) || checkprefix("ftps://", ppath)) {
char *p = strstr(ppath, ";type=");
if (p && p[6] && p[7] == 0) {
if(p && p[6] && p[7] == 0) {
switch (toupper((int)((unsigned char)p[6]))) {
case 'A':
case 'D':
@ -2107,7 +2107,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
p = NULL;
}
}
if (!p)
if(!p)
snprintf(ftp_typecode, sizeof(ftp_typecode), ";type=%c",
data->set.prefer_ascii ? 'a' : 'i');
}

View File

@ -64,13 +64,13 @@ get_gss_name(struct connectdata *conn, bool proxy, gss_name_t *server)
/* IIS uses the <service>@<fqdn> form but uses 'http' as the service name */
if (neg_ctx->gss)
if(neg_ctx->gss)
service = "KHTTP";
else
service = "HTTP";
token.length = strlen(service) + 1 + strlen(proxy ? conn->proxy.name : conn->host.name) + 1;
if (token.length + 1 > sizeof(name))
if(token.length + 1 > sizeof(name))
return EMSGSIZE;
snprintf(name, sizeof(name), "%s@%s", service, proxy ? conn->proxy.name : conn->host.name);
@ -102,13 +102,13 @@ log_gss_error(struct connectdata *conn, OM_uint32 error_status, char *prefix)
GSS_C_NO_OID,
&msg_ctx,
&status_string);
if (sizeof(buf) > len + status_string.length + 1) {
if(sizeof(buf) > len + status_string.length + 1) {
snprintf(buf + len, sizeof(buf) - len,
": %s", (char*) status_string.value);
len += status_string.length;
}
gss_release_buffer(&min_stat, &status_string);
} while (!GSS_ERROR(maj_stat) && msg_ctx != 0);
} while(!GSS_ERROR(maj_stat) && msg_ctx != 0);
infof(conn->data, "%s", buf);
}
@ -130,15 +130,15 @@ int Curl_input_negotiate(struct connectdata *conn, bool proxy, const char *heade
protocol = "GSS-Negotiate";
gss = TRUE;
}
else if (checkprefix("Negotiate", header)) {
else if(checkprefix("Negotiate", header)) {
protocol = "Negotiate";
gss = FALSE;
}
else
return -1;
if (neg_ctx->context) {
if (neg_ctx->gss != gss) {
if(neg_ctx->context) {
if(neg_ctx->gss != gss) {
return -1;
}
}
@ -147,7 +147,7 @@ int Curl_input_negotiate(struct connectdata *conn, bool proxy, const char *heade
neg_ctx->gss = gss;
}
if (neg_ctx->context && neg_ctx->status == GSS_S_COMPLETE) {
if(neg_ctx->context && neg_ctx->status == GSS_S_COMPLETE) {
/* We finished succesfully our part of authentication, but server
* rejected it (since we're again here). Exit with an error since we
* can't invent anything better */
@ -155,7 +155,7 @@ int Curl_input_negotiate(struct connectdata *conn, bool proxy, const char *heade
return -1;
}
if (neg_ctx->server_name == NULL &&
if(neg_ctx->server_name == NULL &&
(ret = get_gss_name(conn, proxy, &neg_ctx->server_name)))
return ret;
@ -164,14 +164,14 @@ int Curl_input_negotiate(struct connectdata *conn, bool proxy, const char *heade
header++;
len = strlen(header);
if (len > 0) {
if(len > 0) {
int rawlen = Curl_base64_decode(header, (unsigned char **)&input_token.value);
if (rawlen < 0)
if(rawlen < 0)
return -1;
input_token.length = rawlen;
#ifdef HAVE_SPNEGO /* Handle SPNEGO */
if (checkprefix("Negotiate", header)) {
if(checkprefix("Negotiate", header)) {
ASN1_OBJECT * object = NULL;
int rc = 1;
unsigned char * spnegoToken = NULL;
@ -180,12 +180,12 @@ int Curl_input_negotiate(struct connectdata *conn, bool proxy, const char *heade
size_t mechTokenLength = 0;
spnegoToken = malloc(input_token.length);
if (input_token.value == NULL)
if(input_token.value == NULL)
return ENOMEM;
spnegoTokenLength = input_token.length;
object = OBJ_txt2obj ("1.2.840.113554.1.2.2", 1);
if (!parseSpnegoTargetToken(spnegoToken,
if(!parseSpnegoTargetToken(spnegoToken,
spnegoTokenLength,
NULL,
NULL,
@ -224,17 +224,17 @@ int Curl_input_negotiate(struct connectdata *conn, bool proxy, const char *heade
&output_token,
NULL,
NULL);
if (input_token.length > 0)
if(input_token.length > 0)
gss_release_buffer(&minor_status2, &input_token);
neg_ctx->status = major_status;
if (GSS_ERROR(major_status)) {
if(GSS_ERROR(major_status)) {
/* Curl_cleanup_negotiate(conn->data) ??? */
log_gss_error(conn, minor_status,
(char *)"gss_init_sec_context() failed: ");
return -1;
}
if (output_token.length == 0) {
if(output_token.length == 0) {
return -1;
}
@ -253,7 +253,7 @@ CURLcode Curl_output_negotiate(struct connectdata *conn, bool proxy)
int len;
#ifdef HAVE_SPNEGO /* Handle SPNEGO */
if (checkprefix("Negotiate",neg_ctx->protocol)) {
if(checkprefix("Negotiate",neg_ctx->protocol)) {
ASN1_OBJECT * object = NULL;
int rc = 1;
unsigned char * spnegoToken = NULL;
@ -262,14 +262,14 @@ CURLcode Curl_output_negotiate(struct connectdata *conn, bool proxy)
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);
responseTokenLength = neg_ctx->output_token.length;
object=OBJ_txt2obj ("1.2.840.113554.1.2.2", 1);
if (!makeSpnegoInitialToken (object,
if(!makeSpnegoInitialToken (object,
responseToken,
responseTokenLength,
&spnegoToken,
@ -295,7 +295,7 @@ CURLcode Curl_output_negotiate(struct connectdata *conn, bool proxy)
neg_ctx->output_token.length,
&encoded);
if (len == 0)
if(len == 0)
return CURLE_OUT_OF_MEMORY;
conn->allocptr.userpwd =
@ -310,13 +310,13 @@ void Curl_cleanup_negotiate(struct SessionHandle *data)
OM_uint32 minor_status;
struct negotiatedata *neg_ctx = &data->state.negotiate;
if (neg_ctx->context != GSS_C_NO_CONTEXT)
if(neg_ctx->context != GSS_C_NO_CONTEXT)
gss_delete_sec_context(&minor_status, &neg_ctx->context, GSS_C_NO_BUFFER);
if (neg_ctx->output_token.length != 0)
if(neg_ctx->output_token.length != 0)
gss_release_buffer(&minor_status, &neg_ctx->output_token);
if (neg_ctx->server_name != GSS_C_NO_NAME)
if(neg_ctx->server_name != GSS_C_NO_NAME)
gss_release_name(&minor_status, &neg_ctx->server_name);
memset(neg_ctx, 0, sizeof(*neg_ctx));

View File

@ -198,7 +198,7 @@ static void print_hex(FILE *handle, const char *buf, size_t len)
{
const char *p = buf;
fprintf(stderr, "0x");
while (len-- > 0)
while(len-- > 0)
fprintf(stderr, "%02.2x", (unsigned int)*p++);
}
#else
@ -263,7 +263,7 @@ CURLntlm Curl_input_ntlm(struct connectdata *conn,
#ifdef USE_WINDOWS_SSPI
ntlm->type_2 = malloc(size+1);
if (ntlm->type_2 == NULL) {
if(ntlm->type_2 == NULL) {
free(buffer);
return CURLE_OUT_OF_MEMORY;
}
@ -368,7 +368,7 @@ static void mk_lm_hash(struct SessionHandle *data,
unsigned int i;
size_t len = strlen(password);
if (len > 14)
if(len > 14)
len = 14;
for (i=0; i<len; i++)
@ -425,7 +425,7 @@ static CURLcode mk_nt_hash(struct SessionHandle *data,
{
size_t len = strlen(password);
unsigned char *pw = malloc(len*2);
if (!pw)
if(!pw)
return CURLE_OUT_OF_MEMORY;
utf8_to_unicode_le(pw, password, len);
@ -465,19 +465,19 @@ static CURLcode mk_nt_hash(struct SessionHandle *data,
static void
ntlm_sspi_cleanup(struct ntlmdata *ntlm)
{
if (ntlm->type_2) {
if(ntlm->type_2) {
free(ntlm->type_2);
ntlm->type_2 = NULL;
}
if (ntlm->has_handles) {
if(ntlm->has_handles) {
s_pSecFn->DeleteSecurityContext(&ntlm->c_handle);
s_pSecFn->FreeCredentialsHandle(&ntlm->handle);
ntlm->has_handles = 0;
}
if (ntlm->p_identity) {
if (ntlm->identity.User) free(ntlm->identity.User);
if (ntlm->identity.Password) free(ntlm->identity.Password);
if (ntlm->identity.Domain) free(ntlm->identity.Domain);
if(ntlm->p_identity) {
if(ntlm->identity.User) free(ntlm->identity.User);
if(ntlm->identity.Password) free(ntlm->identity.Password);
if(ntlm->identity.Domain) free(ntlm->identity.Domain);
ntlm->p_identity = NULL;
}
}
@ -546,7 +546,7 @@ CURLcode Curl_output_ntlm(struct connectdata *conn,
#ifdef USE_WINDOWS_SSPI
/* If security interface is not yet initialized try to do this */
if (s_hSecDll == NULL) {
if(s_hSecDll == NULL) {
/* Determine Windows version. Security functions are located in
* security.dll on WinNT 4.0 and in secur32.dll on Win9x. Win2K and XP
* contain both these DLLs (security.dll just forwards calls to
@ -555,21 +555,21 @@ CURLcode Curl_output_ntlm(struct connectdata *conn,
OSVERSIONINFO osver;
osver.dwOSVersionInfoSize = sizeof(osver);
GetVersionEx(&osver);
if (osver.dwPlatformId == VER_PLATFORM_WIN32_NT
if(osver.dwPlatformId == VER_PLATFORM_WIN32_NT
&& osver.dwMajorVersion == 4)
s_hSecDll = LoadLibrary("security.dll");
else
s_hSecDll = LoadLibrary("secur32.dll");
if (s_hSecDll != NULL) {
if(s_hSecDll != NULL) {
INIT_SECURITY_INTERFACE pInitSecurityInterface;
pInitSecurityInterface =
(INIT_SECURITY_INTERFACE)GetProcAddress(s_hSecDll,
"InitSecurityInterfaceA");
if (pInitSecurityInterface != NULL)
if(pInitSecurityInterface != NULL)
s_pSecFn = pInitSecurityInterface();
}
}
if (s_pSecFn == NULL)
if(s_pSecFn == NULL)
return CURLE_RECV_ERROR;
#endif
@ -589,10 +589,10 @@ CURLcode Curl_output_ntlm(struct connectdata *conn,
ntlm_sspi_cleanup(ntlm);
user = strchr(userp, '\\');
if (!user)
if(!user)
user = strchr(userp, '/');
if (user) {
if(user) {
domain = userp;
domlen = user - userp;
user++;
@ -603,19 +603,19 @@ CURLcode Curl_output_ntlm(struct connectdata *conn,
domlen = 0;
}
if (user && *user) {
if(user && *user) {
/* note: initialize all of this before doing the mallocs so that
* it can be cleaned up later without leaking memory.
*/
ntlm->p_identity = &ntlm->identity;
memset(ntlm->p_identity, 0, sizeof(*ntlm->p_identity));
if ((ntlm->identity.User = (unsigned char *)strdup(user)) == NULL)
if((ntlm->identity.User = (unsigned char *)strdup(user)) == NULL)
return CURLE_OUT_OF_MEMORY;
ntlm->identity.UserLength = strlen(user);
if ((ntlm->identity.Password = (unsigned char *)strdup(passwdp)) == NULL)
if((ntlm->identity.Password = (unsigned char *)strdup(passwdp)) == NULL)
return CURLE_OUT_OF_MEMORY;
ntlm->identity.PasswordLength = strlen(passwdp);
if ((ntlm->identity.Domain = malloc(domlen+1)) == NULL)
if((ntlm->identity.Domain = malloc(domlen+1)) == NULL)
return CURLE_OUT_OF_MEMORY;
strncpy((char *)ntlm->identity.Domain, domain, domlen);
ntlm->identity.Domain[domlen] = '\0';
@ -626,7 +626,7 @@ CURLcode Curl_output_ntlm(struct connectdata *conn,
ntlm->p_identity = NULL;
}
if (s_pSecFn->AcquireCredentialsHandle(
if(s_pSecFn->AcquireCredentialsHandle(
NULL, (char *)"NTLM", SECPKG_CRED_OUTBOUND, NULL, ntlm->p_identity,
NULL, NULL, &ntlm->handle, &tsDummy
) != SEC_E_OK) {
@ -650,11 +650,11 @@ CURLcode Curl_output_ntlm(struct connectdata *conn,
&ntlm->c_handle, &desc,
&attrs, &tsDummy);
if (status == SEC_I_COMPLETE_AND_CONTINUE ||
if(status == SEC_I_COMPLETE_AND_CONTINUE ||
status == SEC_I_CONTINUE_NEEDED) {
s_pSecFn->CompleteAuthToken(&ntlm->c_handle, &desc);
}
else if (status != SEC_E_OK) {
else if(status != SEC_E_OK) {
s_pSecFn->FreeCredentialsHandle(&ntlm->handle);
return CURLE_RECV_ERROR;
}
@ -805,7 +805,7 @@ CURLcode Curl_output_ntlm(struct connectdata *conn,
0, &ntlm->c_handle, &type_3_desc,
&attrs, &tsDummy);
if (status != SEC_E_OK)
if(status != SEC_E_OK)
return CURLE_RECV_ERROR;
size = type_3.cbBuffer;
@ -827,7 +827,7 @@ CURLcode Curl_output_ntlm(struct connectdata *conn,
if(!user)
user = strchr(userp, '/');
if (user) {
if(user) {
domain = userp;
domlen = (user - domain);
user++;
@ -836,7 +836,7 @@ CURLcode Curl_output_ntlm(struct connectdata *conn,
user = userp;
userlen = strlen(user);
if (gethostname(host, HOSTNAME_MAX)) {
if(gethostname(host, HOSTNAME_MAX)) {
infof(conn->data, "gethostname() failed, continuing without!");
hostlen = 0;
}
@ -846,14 +846,14 @@ CURLcode Curl_output_ntlm(struct connectdata *conn,
* name, which NTLM doesn't like.
*/
char *dot = strchr(host, '.');
if (dot)
if(dot)
*dot = '\0';
hostlen = strlen(host);
}
#if USE_NTLM2SESSION
/* We don't support NTLM2 if we don't have USE_NTRESPONSES */
if (ntlm->flags & NTLMFLAG_NEGOTIATE_NTLM2_KEY) {
if(ntlm->flags & NTLMFLAG_NEGOTIATE_NTLM2_KEY) {
unsigned char ntbuffer[0x18];
unsigned char tmp[0x18];
unsigned char md5sum[MD5_DIGEST_LENGTH];
@ -878,7 +878,7 @@ CURLcode Curl_output_ntlm(struct connectdata *conn,
MD5_Final(md5sum, &MD5pw);
/* We shall only use the first 8 bytes of md5sum,
but the des code in lm_resp only encrypt the first 8 bytes */
if (mk_nt_hash(conn->data, passwdp, ntbuffer) == CURLE_OUT_OF_MEMORY)
if(mk_nt_hash(conn->data, passwdp, ntbuffer) == CURLE_OUT_OF_MEMORY)
return CURLE_OUT_OF_MEMORY;
lm_resp(ntbuffer, md5sum, ntresp);
@ -893,7 +893,7 @@ CURLcode Curl_output_ntlm(struct connectdata *conn,
unsigned char lmbuffer[0x18];
#if USE_NTRESPONSES
if (mk_nt_hash(conn->data, passwdp, ntbuffer) == CURLE_OUT_OF_MEMORY)
if(mk_nt_hash(conn->data, passwdp, ntbuffer) == CURLE_OUT_OF_MEMORY)
return CURLE_OUT_OF_MEMORY;
lm_resp(ntbuffer, &ntlm->nonce[0], ntresp);
#endif
@ -1113,7 +1113,7 @@ Curl_ntlm_cleanup(struct connectdata *conn)
#ifdef USE_WINDOWS_SSPI
ntlm_sspi_cleanup(&conn->ntlm);
ntlm_sspi_cleanup(&conn->proxyntlm);
if (s_hSecDll != NULL) {
if(s_hSecDll != NULL) {
FreeLibrary(s_hSecDll);
s_hSecDll = NULL;
s_pSecFn = NULL;

View File

@ -111,26 +111,28 @@ inet_pton4(const char *src, unsigned char *dst)
while ((ch = *src++) != '\0') {
const char *pch;
if ((pch = strchr(digits, ch)) != NULL) {
if((pch = strchr(digits, ch)) != NULL) {
unsigned int val = *tp * 10 + (unsigned int)(pch - digits);
if (val > 255)
if(val > 255)
return (0);
*tp = (unsigned char)val;
if (! saw_digit) {
if (++octets > 4)
if(! saw_digit) {
if(++octets > 4)
return (0);
saw_digit = 1;
}
} else if (ch == '.' && saw_digit) {
if (octets == 4)
}
else if(ch == '.' && saw_digit) {
if(octets == 4)
return (0);
*++tp = 0;
saw_digit = 0;
} else
}
else
return (0);
}
if (octets < 4)
if(octets < 4)
return (0);
/* bcopy(tmp, dst, INADDRSZ); */
memcpy(dst, tmp, INADDRSZ);
@ -165,8 +167,8 @@ inet_pton6(const char *src, unsigned char *dst)
endp = tp + IN6ADDRSZ;
colonp = NULL;
/* Leading :: requires some special handling. */
if (*src == ':')
if (*++src != ':')
if(*src == ':')
if(*++src != ':')
return (0);
curtok = src;
saw_xdigit = 0;
@ -174,25 +176,25 @@ inet_pton6(const char *src, unsigned char *dst)
while ((ch = *src++) != '\0') {
const char *pch;
if ((pch = strchr((xdigits = xdigits_l), ch)) == NULL)
if((pch = strchr((xdigits = xdigits_l), ch)) == NULL)
pch = strchr((xdigits = xdigits_u), ch);
if (pch != NULL) {
if(pch != NULL) {
val <<= 4;
val |= (pch - xdigits);
if (val > 0xffff)
if(val > 0xffff)
return (0);
saw_xdigit = 1;
continue;
}
if (ch == ':') {
if(ch == ':') {
curtok = src;
if (!saw_xdigit) {
if (colonp)
if(!saw_xdigit) {
if(colonp)
return (0);
colonp = tp;
continue;
}
if (tp + INT16SZ > endp)
if(tp + INT16SZ > endp)
return (0);
*tp++ = (unsigned char) (val >> 8) & 0xff;
*tp++ = (unsigned char) val & 0xff;
@ -200,7 +202,7 @@ inet_pton6(const char *src, unsigned char *dst)
val = 0;
continue;
}
if (ch == '.' && ((tp + INADDRSZ) <= endp) &&
if(ch == '.' && ((tp + INADDRSZ) <= endp) &&
inet_pton4(curtok, tp) > 0) {
tp += INADDRSZ;
saw_xdigit = 0;
@ -208,13 +210,13 @@ inet_pton6(const char *src, unsigned char *dst)
}
return (0);
}
if (saw_xdigit) {
if (tp + INT16SZ > endp)
if(saw_xdigit) {
if(tp + INT16SZ > endp)
return (0);
*tp++ = (unsigned char) (val >> 8) & 0xff;
*tp++ = (unsigned char) val & 0xff;
}
if (colonp != NULL) {
if(colonp != NULL) {
/*
* Since some memmove()'s erroneously fail to handle
* overlapping regions, we'll do the shift by hand.
@ -228,7 +230,7 @@ inet_pton6(const char *src, unsigned char *dst)
}
tp = endp;
}
if (tp != endp)
if(tp != endp)
return (0);
/* bcopy(tmp, dst, IN6ADDRSZ); */
memcpy(dst, tmp, IN6ADDRSZ);

View File

@ -110,7 +110,7 @@ static void _ldap_free_urldesc (LDAPURLDesc *ludp);
#define LDAP_TRACE(x) do { \
_ldap_trace ("%u: ", __LINE__); \
_ldap_trace x; \
} while (0)
} while(0)
static void _ldap_trace (const char *fmt, ...);
#else
@ -191,14 +191,14 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
#else
rc = _ldap_url_parse(conn, &ludp);
#endif
if (rc != 0) {
if(rc != 0) {
failf(data, "LDAP local: %s", ldap_err2string(rc));
status = CURLE_LDAP_INVALID_URL;
goto quit;
}
/* Get the URL scheme ( either ldap or ldaps ) */
if (strequal(conn->protostr, "LDAPS"))
if(strequal(conn->protostr, "LDAPS"))
ldap_ssl = 1;
infof(data, "LDAP local: trying to establish %s connection\n",
ldap_ssl ? "encrypted" : "cleartext");
@ -208,7 +208,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
#endif
ldap_set_option(NULL, LDAP_OPT_PROTOCOL_VERSION, &ldap_proto);
if (ldap_ssl) {
if(ldap_ssl) {
#ifdef HAVE_LDAP_SSL
#ifdef CURL_LDAP_WIN
/* Win32 LDAP SDK doesnt support insecure mode without CA! */
@ -219,18 +219,18 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
char* ldap_ca = data->set.str[STRING_SSL_CAFILE];
#if defined(CURL_HAS_NOVELL_LDAPSDK)
rc = ldapssl_client_init(NULL, NULL);
if (rc != LDAP_SUCCESS) {
if(rc != LDAP_SUCCESS) {
failf(data, "LDAP local: ldapssl_client_init %s", ldap_err2string(rc));
status = CURLE_SSL_CERTPROBLEM;
goto quit;
}
if (data->set.ssl.verifypeer) {
if(data->set.ssl.verifypeer) {
/* Novell SDK supports DER or BASE64 files. */
int cert_type = LDAPSSL_CERT_FILETYPE_B64;
if ((data->set.str[STRING_CERT_TYPE]) &&
if((data->set.str[STRING_CERT_TYPE]) &&
(strequal(data->set.str[STRING_CERT_TYPE], "DER")))
cert_type = LDAPSSL_CERT_FILETYPE_DER;
if (!ldap_ca) {
if(!ldap_ca) {
failf(data, "LDAP local: ERROR %s CA cert not set!",
(cert_type == LDAPSSL_CERT_FILETYPE_DER ? "DER" : "PEM"));
status = CURLE_SSL_CERTPROBLEM;
@ -240,7 +240,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
(cert_type == LDAPSSL_CERT_FILETYPE_DER ? "DER" : "PEM"),
ldap_ca);
rc = ldapssl_add_trusted_cert(ldap_ca, cert_type);
if (rc != LDAP_SUCCESS) {
if(rc != LDAP_SUCCESS) {
failf(data, "LDAP local: ERROR setting %s CA cert: %s",
(cert_type == LDAPSSL_CERT_FILETYPE_DER ? "DER" : "PEM"),
ldap_err2string(rc));
@ -252,36 +252,36 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
ldap_option = LDAPSSL_VERIFY_NONE;
}
rc = ldapssl_set_verify_mode(ldap_option);
if (rc != LDAP_SUCCESS) {
if(rc != LDAP_SUCCESS) {
failf(data, "LDAP local: ERROR setting cert verify mode: %s",
ldap_err2string(rc));
status = CURLE_SSL_CERTPROBLEM;
goto quit;
}
server = ldapssl_init(conn->host.name, (int)conn->port, 1);
if (server == NULL) {
if(server == NULL) {
failf(data, "LDAP local: Cannot connect to %s:%d",
conn->host.name, conn->port);
status = CURLE_COULDNT_CONNECT;
goto quit;
}
#elif defined(LDAP_OPT_X_TLS)
if (data->set.ssl.verifypeer) {
if(data->set.ssl.verifypeer) {
/* OpenLDAP SDK supports BASE64 files. */
if ((data->set.str[STRING_CERT_TYPE]) &&
if((data->set.str[STRING_CERT_TYPE]) &&
(!strequal(data->set.str[STRING_CERT_TYPE], "PEM"))) {
failf(data, "LDAP local: ERROR OpenLDAP does only support PEM cert-type!");
status = CURLE_SSL_CERTPROBLEM;
goto quit;
}
if (!ldap_ca) {
if(!ldap_ca) {
failf(data, "LDAP local: ERROR PEM CA cert not set!");
status = CURLE_SSL_CERTPROBLEM;
goto quit;
}
infof(data, "LDAP local: using PEM CA cert: %s\n", ldap_ca);
rc = ldap_set_option(NULL, LDAP_OPT_X_TLS_CACERTFILE, ldap_ca);
if (rc != LDAP_SUCCESS) {
if(rc != LDAP_SUCCESS) {
failf(data, "LDAP local: ERROR setting PEM CA cert: %s",
ldap_err2string(rc));
status = CURLE_SSL_CERTPROBLEM;
@ -292,14 +292,14 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
ldap_option = LDAP_OPT_X_TLS_NEVER;
}
rc = ldap_set_option(NULL, LDAP_OPT_X_TLS_REQUIRE_CERT, &ldap_option);
if (rc != LDAP_SUCCESS) {
if(rc != LDAP_SUCCESS) {
failf(data, "LDAP local: ERROR setting cert verify mode: %s",
ldap_err2string(rc));
status = CURLE_SSL_CERTPROBLEM;
goto quit;
}
server = ldap_init(conn->host.name, (int)conn->port);
if (server == NULL) {
if(server == NULL) {
failf(data, "LDAP local: Cannot connect to %s:%d",
conn->host.name, conn->port);
status = CURLE_COULDNT_CONNECT;
@ -307,7 +307,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
}
ldap_option = LDAP_OPT_X_TLS_HARD;
rc = ldap_set_option(server, LDAP_OPT_X_TLS, &ldap_option);
if (rc != LDAP_SUCCESS) {
if(rc != LDAP_SUCCESS) {
failf(data, "LDAP local: ERROR setting SSL/TLS mode: %s",
ldap_err2string(rc));
status = CURLE_SSL_CERTPROBLEM;
@ -315,7 +315,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
}
/*
rc = ldap_start_tls_s(server, NULL, NULL);
if (rc != LDAP_SUCCESS) {
if(rc != LDAP_SUCCESS) {
failf(data, "LDAP local: ERROR starting SSL/TLS mode: %s",
ldap_err2string(rc));
status = CURLE_SSL_CERTPROBLEM;
@ -334,7 +334,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
#endif /* CURL_LDAP_USE_SSL */
} else {
server = ldap_init(conn->host.name, (int)conn->port);
if (server == NULL) {
if(server == NULL) {
failf(data, "LDAP local: Cannot connect to %s:%d",
conn->host.name, conn->port);
status = CURLE_COULDNT_CONNECT;
@ -348,14 +348,14 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
rc = ldap_simple_bind_s(server,
conn->bits.user_passwd ? conn->user : NULL,
conn->bits.user_passwd ? conn->passwd : NULL);
if (!ldap_ssl && rc != 0) {
if(!ldap_ssl && rc != 0) {
ldap_proto = LDAP_VERSION2;
ldap_set_option(server, LDAP_OPT_PROTOCOL_VERSION, &ldap_proto);
rc = ldap_simple_bind_s(server,
conn->bits.user_passwd ? conn->user : NULL,
conn->bits.user_passwd ? conn->passwd : NULL);
}
if (rc != 0) {
if(rc != 0) {
failf(data, "LDAP local: ldap_simple_bind_s %s", ldap_err2string(rc));
status = CURLE_LDAP_CANNOT_BIND;
goto quit;
@ -364,7 +364,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
rc = ldap_search_s(server, ludp->lud_dn, ludp->lud_scope,
ludp->lud_filter, ludp->lud_attrs, 0, &result);
if (rc != 0 && rc != LDAP_SIZELIMIT_EXCEEDED) {
if(rc != 0 && rc != LDAP_SIZELIMIT_EXCEEDED) {
failf(data, "LDAP remote: %s", ldap_err2string(rc));
status = CURLE_LDAP_SEARCH_FAILED;
goto quit;
@ -389,14 +389,14 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
{
BerValue **vals = ldap_get_values_len(server, entryIterator, attribute);
if (vals != NULL)
if(vals != NULL)
{
for (i = 0; (vals[i] != NULL); i++)
{
Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\t", 1);
Curl_client_write(conn, CLIENTWRITE_BODY, (char *) attribute, 0);
Curl_client_write(conn, CLIENTWRITE_BODY, (char *)": ", 2);
if ((strlen(attribute) > 7) &&
if((strlen(attribute) > 7) &&
(strcmp(";binary",
(char *)attribute +
(strlen((char *)attribute) - 7)) == 0)) {
@ -405,7 +405,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
vals[i]->bv_val,
vals[i]->bv_len,
&val_b64);
if (val_b64_sz > 0) {
if(val_b64_sz > 0) {
Curl_client_write(conn, CLIENTWRITE_BODY, val_b64, val_b64_sz);
free(val_b64);
}
@ -423,23 +423,23 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
ldap_memfree(attribute);
}
ldap_memfree(dn);
if (ber)
if(ber)
ber_free(ber, 0);
}
quit:
if (result) {
if(result) {
ldap_msgfree(result);
LDAP_TRACE (("Received %d entries\n", num));
}
if (rc == LDAP_SIZELIMIT_EXCEEDED)
if(rc == LDAP_SIZELIMIT_EXCEEDED)
infof(data, "There are more than %d entries\n", num);
if (ludp)
if(ludp)
ldap_free_urldesc(ludp);
if (server)
if(server)
ldap_unbind_s(server);
#if defined(HAVE_LDAP_SSL) && defined(CURL_HAS_NOVELL_LDAPSDK)
if (ldap_ssl)
if(ldap_ssl)
ldapssl_client_deinit();
#endif /* HAVE_LDAP_SSL && CURL_HAS_NOVELL_LDAPSDK */
@ -456,11 +456,11 @@ static void _ldap_trace (const char *fmt, ...)
static int do_trace = -1;
va_list args;
if (do_trace == -1) {
if(do_trace == -1) {
const char *env = getenv("CURL_TRACE");
do_trace = (env && atoi(env) > 0);
}
if (!do_trace)
if(!do_trace)
return;
va_start (args, fmt);
@ -476,15 +476,15 @@ static void _ldap_trace (const char *fmt, ...)
*/
static int str2scope (const char *p)
{
if (!stricmp(p, "one"))
if(!stricmp(p, "one"))
return LDAP_SCOPE_ONELEVEL;
if (!stricmp(p, "onetree"))
if(!stricmp(p, "onetree"))
return LDAP_SCOPE_ONELEVEL;
if (!stricmp(p, "base"))
if(!stricmp(p, "base"))
return LDAP_SCOPE_BASE;
if (!stricmp(p, "sub"))
if(!stricmp(p, "sub"))
return LDAP_SCOPE_SUBTREE;
if (!stricmp( p, "subtree"))
if(!stricmp( p, "subtree"))
return LDAP_SCOPE_SUBTREE;
return (-1);
}
@ -502,7 +502,7 @@ static char **split_str (char *str)
s = strchr(++s,',');
res = calloc(i, sizeof(char*));
if (!res)
if(!res)
return NULL;
for (i = 0, s = strtok_r(str, ",", &lasts); s;
@ -518,31 +518,31 @@ static bool unescape_elements (void *data, LDAPURLDesc *ludp)
{
int i;
if (ludp->lud_filter) {
if(ludp->lud_filter) {
ludp->lud_filter = curl_easy_unescape(data, ludp->lud_filter, 0, NULL);
if (!ludp->lud_filter)
if(!ludp->lud_filter)
return (FALSE);
}
for (i = 0; ludp->lud_attrs && ludp->lud_attrs[i]; i++) {
ludp->lud_attrs[i] = curl_easy_unescape(data, ludp->lud_attrs[i], 0, NULL);
if (!ludp->lud_attrs[i])
if(!ludp->lud_attrs[i])
return (FALSE);
}
for (i = 0; ludp->lud_exts && ludp->lud_exts[i]; i++) {
ludp->lud_exts[i] = curl_easy_unescape(data, ludp->lud_exts[i], 0, NULL);
if (!ludp->lud_exts[i])
if(!ludp->lud_exts[i])
return (FALSE);
}
if (ludp->lud_dn) {
if(ludp->lud_dn) {
char *dn = ludp->lud_dn;
char *new_dn = curl_easy_unescape(data, dn, 0, NULL);
free(dn);
ludp->lud_dn = new_dn;
if (!new_dn)
if(!new_dn)
return (FALSE);
}
return (TRUE);
@ -567,7 +567,7 @@ static int _ldap_url_parse2 (const struct connectdata *conn, LDAPURLDesc *ludp)
char *p, *q;
int i;
if (!conn->data ||
if(!conn->data ||
!conn->data->reqdata.path ||
conn->data->reqdata.path[0] != '/' ||
!checkprefix(conn->protostr, conn->data->change.url))
@ -580,14 +580,14 @@ static int _ldap_url_parse2 (const struct connectdata *conn, LDAPURLDesc *ludp)
/* parse DN (Distinguished Name).
*/
ludp->lud_dn = strdup(conn->data->reqdata.path+1);
if (!ludp->lud_dn)
if(!ludp->lud_dn)
return LDAP_NO_MEMORY;
p = strchr(ludp->lud_dn, '?');
LDAP_TRACE (("DN '%.*s'\n", p ? (size_t)(p-ludp->lud_dn) :
strlen(ludp->lud_dn), ludp->lud_dn));
if (!p)
if(!p)
goto success;
*p++ = '\0';
@ -595,12 +595,12 @@ static int _ldap_url_parse2 (const struct connectdata *conn, LDAPURLDesc *ludp)
/* parse attributes. skip "??".
*/
q = strchr(p, '?');
if (q)
if(q)
*q++ = '\0';
if (*p && *p != '?') {
if(*p && *p != '?') {
ludp->lud_attrs = split_str(p);
if (!ludp->lud_attrs)
if(!ludp->lud_attrs)
return LDAP_NO_MEMORY;
for (i = 0; ludp->lud_attrs[i]; i++)
@ -608,52 +608,52 @@ static int _ldap_url_parse2 (const struct connectdata *conn, LDAPURLDesc *ludp)
}
p = q;
if (!p)
if(!p)
goto success;
/* parse scope. skip "??"
*/
q = strchr(p, '?');
if (q)
if(q)
*q++ = '\0';
if (*p && *p != '?') {
if(*p && *p != '?') {
ludp->lud_scope = str2scope(p);
if (ludp->lud_scope == -1)
if(ludp->lud_scope == -1)
return LDAP_INVALID_SYNTAX;
LDAP_TRACE (("scope %d\n", ludp->lud_scope));
}
p = q;
if (!p)
if(!p)
goto success;
/* parse filter
*/
q = strchr(p, '?');
if (q)
if(q)
*q++ = '\0';
if (!*p)
if(!*p)
return LDAP_INVALID_SYNTAX;
ludp->lud_filter = p;
LDAP_TRACE (("filter '%s'\n", ludp->lud_filter));
p = q;
if (!p)
if(!p)
goto success;
/* parse extensions
*/
ludp->lud_exts = split_str(p);
if (!ludp->lud_exts)
if(!ludp->lud_exts)
return LDAP_NO_MEMORY;
for (i = 0; ludp->lud_exts[i]; i++)
LDAP_TRACE (("exts[%d] '%s'\n", i, ludp->lud_exts[i]));
success:
if (!unescape_elements(conn->data, ludp))
if(!unescape_elements(conn->data, ludp))
return LDAP_NO_MEMORY;
return LDAP_SUCCESS;
}
@ -665,11 +665,11 @@ static int _ldap_url_parse (const struct connectdata *conn,
int rc;
*ludpp = NULL;
if (!ludp)
if(!ludp)
return LDAP_NO_MEMORY;
rc = _ldap_url_parse2 (conn, ludp);
if (rc != LDAP_SUCCESS) {
if(rc != LDAP_SUCCESS) {
_ldap_free_urldesc(ludp);
ludp = NULL;
}
@ -681,22 +681,22 @@ static void _ldap_free_urldesc (LDAPURLDesc *ludp)
{
int i;
if (!ludp)
if(!ludp)
return;
if (ludp->lud_dn)
if(ludp->lud_dn)
free(ludp->lud_dn);
if (ludp->lud_filter)
if(ludp->lud_filter)
free(ludp->lud_filter);
if (ludp->lud_attrs) {
if(ludp->lud_attrs) {
for (i = 0; ludp->lud_attrs[i]; i++)
free(ludp->lud_attrs[i]);
free(ludp->lud_attrs);
}
if (ludp->lud_exts) {
if(ludp->lud_exts) {
for (i = 0; ludp->lud_exts[i]; i++)
free(ludp->lud_exts[i]);
free(ludp->lud_exts);

View File

@ -308,9 +308,9 @@ static long dprintf_Pass1(const char *format, va_stack_t *vto, char **endpos,
long max_param=0;
long i;
while (*fmt) {
if (*fmt++ == '%') {
if (*fmt == '%') {
while(*fmt) {
if(*fmt++ == '%') {
if(*fmt == '%') {
fmt++;
continue; /* while */
}
@ -322,11 +322,11 @@ static long dprintf_Pass1(const char *format, va_stack_t *vto, char **endpos,
param_num++;
this_param = dprintf_DollarString(fmt, &fmt);
if (0 == this_param)
if(0 == this_param)
/* we got no positional, get the next counter */
this_param = param_num;
if (this_param > max_param)
if(this_param > max_param)
max_param = this_param;
/*
@ -340,7 +340,7 @@ static long dprintf_Pass1(const char *format, va_stack_t *vto, char **endpos,
/* Handle the flags */
while (dprintf_IsQualifierNoDollar(*fmt)) {
while(dprintf_IsQualifierNoDollar(*fmt)) {
switch (*fmt++) {
case ' ':
flags |= FLAGS_SPACE;
@ -357,7 +357,7 @@ static long dprintf_Pass1(const char *format, va_stack_t *vto, char **endpos,
break;
case '.':
flags |= FLAGS_PREC;
if ('*' == *fmt) {
if('*' == *fmt) {
/* The precision is picked from a specified parameter */
flags |= FLAGS_PRECPARAM;
@ -365,12 +365,12 @@ static long dprintf_Pass1(const char *format, va_stack_t *vto, char **endpos,
param_num++;
i = dprintf_DollarString(fmt, &fmt);
if (i)
if(i)
precision = i;
else
precision = param_num;
if (precision > max_param)
if(precision > max_param)
max_param = precision;
}
else {
@ -382,7 +382,7 @@ static long dprintf_Pass1(const char *format, va_stack_t *vto, char **endpos,
flags |= FLAGS_SHORT;
break;
case 'l':
if (flags & FLAGS_LONG)
if(flags & FLAGS_LONG)
flags |= FLAGS_LONGLONG;
else
flags |= FLAGS_LONG;
@ -410,7 +410,7 @@ static long dprintf_Pass1(const char *format, va_stack_t *vto, char **endpos,
#endif
break;
case '0':
if (!(flags & FLAGS_LEFT))
if(!(flags & FLAGS_LEFT))
flags |= FLAGS_PAD_NIL;
/* FALLTHROUGH */
case '1': case '2': case '3': case '4':
@ -503,7 +503,7 @@ static long dprintf_Pass1(const char *format, va_stack_t *vto, char **endpos,
vto[i].width = width;
vto[i].precision = precision;
if (flags & FLAGS_WIDTHPARAM) {
if(flags & FLAGS_WIDTHPARAM) {
/* we have the width specified from a parameter, so we make that
parameter's info setup properly */
vto[i].width = width - 1;
@ -513,7 +513,7 @@ static long dprintf_Pass1(const char *format, va_stack_t *vto, char **endpos,
vto[i].precision = vto[i].width = 0; /* can't use width or precision
of width! */
}
if (flags & FLAGS_PRECPARAM) {
if(flags & FLAGS_PRECPARAM) {
/* we have the precision specified from a parameter, so we make that
parameter's info setup properly */
vto[i].precision = precision - 1;
@ -533,7 +533,7 @@ static long dprintf_Pass1(const char *format, va_stack_t *vto, char **endpos,
/* Read the arg list parameters into our data list */
for (i=0; i<max_param; i++) {
if ((i + 1 < max_param) && (vto[i + 1].type == FORMAT_WIDTH))
if((i + 1 < max_param) && (vto[i + 1].type == FORMAT_WIDTH))
{
/* Width/precision arguments must be read before the main argument
* they are attached to
@ -620,7 +620,7 @@ static int dprintf_formatf(
created for us */
f = (char *)format;
while (*f != '\0') {
while(*f != '\0') {
/* Format spec modifiers. */
char alt;
@ -644,7 +644,7 @@ static int dprintf_formatf(
#endif
long signed_num;
if (*f != '%') {
if(*f != '%') {
/* This isn't a format spec, so write everything out until the next one
OR end of string is reached. */
do {
@ -659,7 +659,7 @@ static int dprintf_formatf(
'%' as a conversion specifier, it says "The complete format
specification shall be `%%'," so we can avoid all the width
and precision processing. */
if (*f == '%') {
if(*f == '%') {
++f;
OUTCHAR('%');
continue;
@ -700,12 +700,12 @@ static int dprintf_formatf(
num = p->data.num;
if(p->flags & FLAGS_CHAR) {
/* Character. */
if (!(p->flags & FLAGS_LEFT))
while (--width > 0)
if(!(p->flags & FLAGS_LEFT))
while(--width > 0)
OUTCHAR(' ');
OUTCHAR((char) num);
if (p->flags & FLAGS_LEFT)
while (--width > 0)
if(p->flags & FLAGS_LEFT)
while(--width > 0)
OUTCHAR(' ');
break;
}
@ -756,47 +756,47 @@ static int dprintf_formatf(
char *w;
/* Supply a default precision if none was given. */
if (prec == -1)
if(prec == -1)
prec = 1;
/* Put the number in WORK. */
w = workend;
while (num > 0) {
while(num > 0) {
*w-- = digits[num % base];
num /= base;
}
width -= (long)(workend - w);
prec -= (long)(workend - w);
if (alt && base == 8 && prec <= 0) {
if(alt && base == 8 && prec <= 0) {
*w-- = '0';
--width;
}
if (prec > 0) {
if(prec > 0) {
width -= prec;
while (prec-- > 0)
while(prec-- > 0)
*w-- = '0';
}
if (alt && base == 16)
if(alt && base == 16)
width -= 2;
if (is_neg || (p->flags & FLAGS_SHOWSIGN) || (p->flags & FLAGS_SPACE))
if(is_neg || (p->flags & FLAGS_SHOWSIGN) || (p->flags & FLAGS_SPACE))
--width;
if (!(p->flags & FLAGS_LEFT) && !(p->flags & FLAGS_PAD_NIL))
while (width-- > 0)
if(!(p->flags & FLAGS_LEFT) && !(p->flags & FLAGS_PAD_NIL))
while(width-- > 0)
OUTCHAR(' ');
if (is_neg)
if(is_neg)
OUTCHAR('-');
else if (p->flags & FLAGS_SHOWSIGN)
else if(p->flags & FLAGS_SHOWSIGN)
OUTCHAR('+');
else if (p->flags & FLAGS_SPACE)
else if(p->flags & FLAGS_SPACE)
OUTCHAR(' ');
if (alt && base == 16) {
if(alt && base == 16) {
OUTCHAR('0');
if(p->flags & FLAGS_UPPER)
OUTCHAR('X');
@ -804,17 +804,17 @@ static int dprintf_formatf(
OUTCHAR('x');
}
if (!(p->flags & FLAGS_LEFT) && (p->flags & FLAGS_PAD_NIL))
while (width-- > 0)
if(!(p->flags & FLAGS_LEFT) && (p->flags & FLAGS_PAD_NIL))
while(width-- > 0)
OUTCHAR('0');
/* Write the number. */
while (++w <= workend) {
while(++w <= workend) {
OUTCHAR(*w);
}
if (p->flags & FLAGS_LEFT)
while (width-- > 0)
if(p->flags & FLAGS_LEFT)
while(width-- > 0)
OUTCHAR(' ');
}
break;
@ -827,9 +827,9 @@ static int dprintf_formatf(
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) {
if(prec == -1 || prec >= (long) sizeof(null) - 1) {
str = null;
len = sizeof(null) - 1;
/* Disable quotes around (nil) */
@ -843,24 +843,24 @@ static int dprintf_formatf(
else
len = strlen(str);
if (prec != -1 && (size_t) prec < len)
if(prec != -1 && (size_t) prec < len)
len = prec;
width -= (long)len;
if (p->flags & FLAGS_ALT)
if(p->flags & FLAGS_ALT)
OUTCHAR('"');
if (!(p->flags&FLAGS_LEFT))
while (width-- > 0)
if(!(p->flags&FLAGS_LEFT))
while(width-- > 0)
OUTCHAR(' ');
while (len-- > 0)
while(len-- > 0)
OUTCHAR(*str++);
if (p->flags&FLAGS_LEFT)
while (width-- > 0)
if(p->flags&FLAGS_LEFT)
while(width-- > 0)
OUTCHAR(' ');
if (p->flags & FLAGS_ALT)
if(p->flags & FLAGS_ALT)
OUTCHAR('"');
}
break;
@ -870,7 +870,7 @@ static int dprintf_formatf(
{
void *ptr;
ptr = (void *) p->data.ptr;
if (ptr != NULL) {
if(ptr != NULL) {
/* If the pointer is not NULL, write it as a %#x spec. */
base = 16;
digits = (p->flags & FLAGS_UPPER)? upper_digits : lower_digits;
@ -885,13 +885,13 @@ static int dprintf_formatf(
const char *point;
width -= sizeof(strnil) - 1;
if (p->flags & FLAGS_LEFT)
while (width-- > 0)
if(p->flags & FLAGS_LEFT)
while(width-- > 0)
OUTCHAR(' ');
for (point = strnil; *point != '\0'; ++point)
OUTCHAR(*point);
if (! (p->flags & FLAGS_LEFT))
while (width-- > 0)
if(! (p->flags & FLAGS_LEFT))
while(width-- > 0)
OUTCHAR(' ');
}
}
@ -905,24 +905,24 @@ static int dprintf_formatf(
int len;
width = -1;
if (p->flags & FLAGS_WIDTH)
if(p->flags & FLAGS_WIDTH)
width = p->width;
else if (p->flags & FLAGS_WIDTHPARAM)
else if(p->flags & FLAGS_WIDTHPARAM)
width = vto[p->width].data.num;
prec = -1;
if (p->flags & FLAGS_PREC)
if(p->flags & FLAGS_PREC)
prec = p->precision;
else if (p->flags & FLAGS_PRECPARAM)
else if(p->flags & FLAGS_PRECPARAM)
prec = vto[p->precision].data.num;
if (p->flags & FLAGS_LEFT)
if(p->flags & FLAGS_LEFT)
strcat(formatbuf, "-");
if (p->flags & FLAGS_SHOWSIGN)
if(p->flags & FLAGS_SHOWSIGN)
strcat(formatbuf, "+");
if (p->flags & FLAGS_SPACE)
if(p->flags & FLAGS_SPACE)
strcat(formatbuf, " ");
if (p->flags & FLAGS_ALT)
if(p->flags & FLAGS_ALT)
strcat(formatbuf, "#");
fptr=&formatbuf[strlen(formatbuf)];
@ -939,12 +939,12 @@ static int dprintf_formatf(
fptr += len;
left -= len;
}
if (p->flags & FLAGS_LONG)
if(p->flags & FLAGS_LONG)
*fptr++ = 'l';
if (p->flags & FLAGS_FLOATE)
if(p->flags & FLAGS_FLOATE)
*fptr++ = (char)((p->flags & FLAGS_UPPER) ? 'E':'e');
else if (p->flags & FLAGS_FLOATG)
else if(p->flags & FLAGS_FLOATG)
*fptr++ = (char)((p->flags & FLAGS_UPPER) ? 'G' : 'g');
else
*fptr++ = 'f';
@ -963,13 +963,13 @@ static int dprintf_formatf(
case FORMAT_INTPTR:
/* Answer the count of characters written. */
#ifdef ENABLE_64BIT
if (p->flags & FLAGS_LONGLONG)
if(p->flags & FLAGS_LONGLONG)
*(LONG_LONG *) p->data.ptr = (LONG_LONG)done;
else
#endif
if (p->flags & FLAGS_LONG)
if(p->flags & FLAGS_LONG)
*(long *) p->data.ptr = (long)done;
else if (!(p->flags & FLAGS_SHORT))
else if(!(p->flags & FLAGS_SHORT))
*(int *) p->data.ptr = (int)done;
else
*(short *) p->data.ptr = (short)done;

View File

@ -446,14 +446,14 @@ CURLMcode curl_multi_add_handle(CURLM *multi_handle,
/* for multi interface connections, we share DNS cache automatically if the
easy handle's one is currently private. */
if (easy->easy_handle->dns.hostcache &&
if(easy->easy_handle->dns.hostcache &&
(easy->easy_handle->dns.hostcachetype == HCACHE_PRIVATE)) {
Curl_hash_destroy(easy->easy_handle->dns.hostcache);
easy->easy_handle->dns.hostcache = NULL;
easy->easy_handle->dns.hostcachetype = HCACHE_NONE;
}
if (!easy->easy_handle->dns.hostcache ||
if(!easy->easy_handle->dns.hostcache ||
(easy->easy_handle->dns.hostcachetype == HCACHE_NONE)) {
easy->easy_handle->dns.hostcache = multi->hostcache;
easy->easy_handle->dns.hostcachetype = HCACHE_MULTI;
@ -578,7 +578,7 @@ CURLMcode curl_multi_remove_handle(CURLM *multi_handle,
alive connections when this is removed */
multi->num_alive--;
if (easy->easy_handle->state.is_in_pipeline &&
if(easy->easy_handle->state.is_in_pipeline &&
easy->state > CURLM_STATE_DO &&
easy->state < CURLM_STATE_COMPLETED) {
/* If the handle is in a pipeline and has finished sending off its
@ -679,7 +679,7 @@ CURLMcode curl_multi_remove_handle(CURLM *multi_handle,
/* NOTE NOTE NOTE
We do not touch the easy handle here! */
if (easy->msg)
if(easy->msg)
free(easy->msg);
free(easy);
@ -701,7 +701,7 @@ void Curl_multi_handlePipeBreak(struct SessionHandle *data)
{
struct Curl_one_easy *one_easy = data->set.one_easy;
if (one_easy)
if(one_easy)
one_easy->easy_conn = NULL;
}
@ -745,12 +745,12 @@ static int multi_getsock(struct Curl_one_easy *easy,
singlesocket() => multi_getsock().
*/
if (easy->easy_handle->state.pipe_broke ||
if(easy->easy_handle->state.pipe_broke ||
!easy->easy_conn) {
return 0;
}
if (easy->state > CURLM_STATE_CONNECT &&
if(easy->state > CURLM_STATE_CONNECT &&
easy->state < CURLM_STATE_COMPLETED) {
/* Set up ownership correctly */
easy->easy_conn->data = easy->easy_handle;
@ -855,7 +855,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
/* Handle the case when the pipe breaks, i.e., the connection
we're using gets cleaned up and we're left with nothing. */
if (easy->easy_handle->state.pipe_broke) {
if(easy->easy_handle->state.pipe_broke) {
infof(easy->easy_handle, "Pipe broke: handle 0x%x, url = %s\n",
easy, easy->easy_handle->reqdata.path);
@ -875,13 +875,13 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
break;
}
if (easy->state > CURLM_STATE_CONNECT &&
if(easy->state > CURLM_STATE_CONNECT &&
easy->state < CURLM_STATE_COMPLETED) {
/* Make sure we set the connection's current owner */
easy->easy_conn->data = easy->easy_handle;
}
if (CURLM_STATE_WAITCONNECT <= easy->state &&
if(CURLM_STATE_WAITCONNECT <= easy->state &&
easy->state <= CURLM_STATE_DO &&
easy->easy_handle->change.url_changed) {
char *gotourl;
@ -949,7 +949,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
multistate(easy, CURLM_STATE_WAITDO);
else {
#ifndef CURL_DISABLE_HTTP
if (easy->easy_conn->bits.tunnel_connecting)
if(easy->easy_conn->bits.tunnel_connecting)
multistate(easy, CURLM_STATE_WAITPROXYCONNECT);
else
#endif
@ -985,7 +985,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
multistate(easy, CURLM_STATE_WAITDO);
else {
#ifndef CURL_DISABLE_HTTP
if (easy->easy_conn->bits.tunnel_connecting)
if(easy->easy_conn->bits.tunnel_connecting)
multistate(easy, CURLM_STATE_WAITPROXYCONNECT);
else
#endif
@ -1008,7 +1008,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
easy->result = Curl_http_connect(easy->easy_conn, &protocol_connect);
if(CURLE_OK == easy->result) {
if (!easy->easy_conn->bits.tunnel_connecting)
if(!easy->easy_conn->bits.tunnel_connecting)
multistate(easy, CURLM_STATE_WAITCONNECT);
}
break;
@ -1038,7 +1038,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
BUT if we are using a proxy we must change to WAITPROXYCONNECT
*/
#ifndef CURL_DISABLE_HTTP
if (easy->easy_conn->bits.tunnel_connecting)
if(easy->easy_conn->bits.tunnel_connecting)
multistate(easy, CURLM_STATE_WAITPROXYCONNECT);
else
#endif
@ -1080,7 +1080,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
Curl_isHandleAtHead(easy->easy_handle,
easy->easy_conn->send_pipe));
#endif
if (!easy->easy_conn->writechannel_inuse &&
if(!easy->easy_conn->writechannel_inuse &&
Curl_isHandleAtHead(easy->easy_handle,
easy->easy_conn->send_pipe)) {
/* Grab the channel */
@ -1222,7 +1222,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
easy->easy_conn->recv_pipe));
#endif
/* Wait for our turn to PERFORM */
if (!easy->easy_conn->readchannel_inuse &&
if(!easy->easy_conn->readchannel_inuse &&
Curl_isHandleAtHead(easy->easy_handle,
easy->easy_conn->recv_pipe)) {
/* Grab the channel */
@ -1235,7 +1235,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
case CURLM_STATE_TOOFAST: /* limit-rate exceeded in either direction */
/* if both rates are within spec, resume transfer */
Curl_pgrsUpdate(easy->easy_conn);
if ( ( ( easy->easy_handle->set.max_send_speed == 0 ) ||
if( ( ( easy->easy_handle->set.max_send_speed == 0 ) ||
( easy->easy_handle->progress.ulspeed <
easy->easy_handle->set.max_send_speed ) ) &&
( ( easy->easy_handle->set.max_recv_speed == 0 ) ||
@ -1247,7 +1247,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
case CURLM_STATE_PERFORM:
/* check if over speed */
if ( ( ( easy->easy_handle->set.max_send_speed > 0 ) &&
if( ( ( easy->easy_handle->set.max_send_speed > 0 ) &&
( easy->easy_handle->progress.ulspeed >
easy->easy_handle->set.max_send_speed ) ) ||
( ( easy->easy_handle->set.max_recv_speed > 0 ) &&
@ -1266,12 +1266,12 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
k = &easy->easy_handle->reqdata.keep;
if (!(k->keepon & KEEP_READ)) {
if(!(k->keepon & KEEP_READ)) {
/* We're done reading */
easy->easy_conn->readchannel_inuse = FALSE;
}
if (!(k->keepon & KEEP_WRITE)) {
if(!(k->keepon & KEEP_WRITE)) {
/* We're done writing */
easy->easy_conn->writechannel_inuse = FALSE;
}
@ -1337,14 +1337,14 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
easy->easy_conn->recv_pipe);
easy->easy_handle->state.is_in_pipeline = FALSE;
if (easy->easy_conn->bits.stream_was_rewound) {
if(easy->easy_conn->bits.stream_was_rewound) {
/* This request read past its response boundary so we quickly
let the other requests consume those bytes since there is no
guarantee that the socket will become active again */
result = CURLM_CALL_MULTI_PERFORM;
}
if (!easy->easy_handle->state.cancelled) {
if(!easy->easy_handle->state.cancelled) {
/* post-transfer command */
easy->result = Curl_done(&easy->easy_conn, CURLE_OK, FALSE);
@ -1356,7 +1356,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
break;
case CURLM_STATE_COMPLETED:
if (easy->easy_handle->state.cancelled)
if(easy->easy_handle->state.cancelled)
/* Go into the CANCELLED state if we were cancelled */
multistate(easy, CURLM_STATE_CANCELLED);
@ -1404,7 +1404,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
easy->easy_conn->recv_pipe);
}
if (disconnect_conn) {
if(disconnect_conn) {
Curl_disconnect(easy->easy_conn); /* disconnect properly */
/* This is where we make sure that the easy_conn pointer is reset.
@ -1417,9 +1417,9 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
}
}
} while (easy->easy_handle->change.url_changed);
} while(easy->easy_handle->change.url_changed);
if ((CURLM_STATE_COMPLETED == easy->state) && !easy->msg) {
if((CURLM_STATE_COMPLETED == easy->state) && !easy->msg) {
if(easy->easy_handle->dns.hostcachetype == HCACHE_MULTI) {
/* clear out the usage of the shared DNS cache */
easy->easy_handle->dns.hostcache = NULL;
@ -1472,7 +1472,7 @@ CURLMcode curl_multi_perform(CURLM *multi_handle, int *running_handles)
while(easy != &multi->easy) {
CURLMcode result;
if (easy->easy_handle->state.cancelled &&
if(easy->easy_handle->state.cancelled &&
easy->state == CURLM_STATE_CANCELLED) {
/* Remove cancelled handles once it's safe to do so */
Curl_multi_rmeasy(multi_handle, easy->easy_handle);
@ -1498,7 +1498,7 @@ CURLMcode curl_multi_perform(CURLM *multi_handle, int *running_handles)
int key = now.tv_sec; /* drop the usec part */
multi->timetree = Curl_splaygetbest(key, multi->timetree, &t);
if (t) {
if(t) {
struct SessionHandle *d = t->payload;
struct timeval* tv = &d->state.expiretime;
@ -1512,7 +1512,7 @@ CURLMcode curl_multi_perform(CURLM *multi_handle, int *running_handles)
*running_handles = multi->num_alive;
if ( CURLM_OK >= returncode )
if( CURLM_OK >= returncode )
update_timer(multi);
return returncode;
}
@ -1578,7 +1578,7 @@ CURLMcode curl_multi_cleanup(CURLM *multi_handle)
Curl_easy_addmulti(easy->easy_handle, NULL); /* clear the association */
if (easy->msg)
if(easy->msg)
free(easy->msg);
free(easy);
easy = nexteasy;
@ -1753,7 +1753,7 @@ static CURLMcode multi_socket(struct Curl_multi *multi,
/* or should we fall-through and do the timer-based stuff? */
return result;
}
else if (s != CURL_SOCKET_TIMEOUT) {
else if(s != CURL_SOCKET_TIMEOUT) {
struct Curl_sh_entry *entry =
Curl_hash_pick(multi->sockhash, (char *)&s, sizeof(s));
@ -1768,12 +1768,12 @@ static CURLMcode multi_socket(struct Curl_multi *multi,
/* bad bad bad bad bad bad bad */
return CURLM_INTERNAL_ERROR;
if (data->set.one_easy->easy_conn) /* set socket event bitmask */
if(data->set.one_easy->easy_conn) /* set socket event bitmask */
data->set.one_easy->easy_conn->cselect_bits = ev_bitmask;
result = multi_runsingle(multi, data->set.one_easy);
if (data->set.one_easy->easy_conn)
if(data->set.one_easy->easy_conn)
data->set.one_easy->easy_conn->cselect_bits = 0;
if(CURLM_OK >= result)
@ -1878,7 +1878,7 @@ CURLMcode curl_multi_socket(CURLM *multi_handle, curl_socket_t s,
{
CURLMcode result = multi_socket((struct Curl_multi *)multi_handle, FALSE, s,
0, running_handles);
if (CURLM_OK >= result)
if(CURLM_OK >= result)
update_timer((struct Curl_multi *)multi_handle);
return result;
}
@ -1888,7 +1888,7 @@ CURLMcode curl_multi_socket_action(CURLM *multi_handle, curl_socket_t s,
{
CURLMcode result = multi_socket((struct Curl_multi *)multi_handle, FALSE, s,
ev_bitmask, running_handles);
if (CURLM_OK >= result)
if(CURLM_OK >= result)
update_timer((struct Curl_multi *)multi_handle);
return result;
}
@ -1898,7 +1898,7 @@ CURLMcode curl_multi_socket_all(CURLM *multi_handle, int *running_handles)
{
CURLMcode result = multi_socket((struct Curl_multi *)multi_handle,
TRUE, CURL_SOCKET_BAD, 0, running_handles);
if (CURLM_OK >= result)
if(CURLM_OK >= result)
update_timer((struct Curl_multi *)multi_handle);
return result;
}
@ -1945,11 +1945,11 @@ CURLMcode curl_multi_timeout(CURLM *multi_handle,
static int update_timer(struct Curl_multi *multi)
{
long timeout_ms;
if (!multi->timer_cb)
if(!multi->timer_cb)
return 0;
if ( multi_timeout(multi, &timeout_ms) != CURLM_OK )
if( multi_timeout(multi, &timeout_ms) != CURLM_OK )
return -1;
if ( timeout_ms < 0 )
if( timeout_ms < 0 )
return 0;
/* When multi_timeout() is done, multi->timetree points to the node with the

View File

@ -283,7 +283,7 @@ nss_load_cert(const char *filename, PRBool cacert)
}
else {
/* A nickname from the NSS internal database */
if (cacert)
if(cacert)
return 0; /* You can't specify an NSS CA nickname this way */
nickname = strdup(filename);
goto done;
@ -296,7 +296,7 @@ nss_load_cert(const char *filename, PRBool cacert)
* for storing certificates. With each new user certificate we increment
* the slot count. We only support 1 user certificate right now.
*/
if (cacert)
if(cacert)
slotID = 0;
else
slotID = 1;
@ -308,7 +308,7 @@ nss_load_cert(const char *filename, PRBool cacert)
slot = PK11_FindSlotByName(slotname);
if (!slot) {
if(!slot) {
free(slotname);
free(nickname);
return 0;
@ -318,7 +318,7 @@ nss_load_cert(const char *filename, PRBool cacert)
PK11_SETATTRS(attrs, CKA_TOKEN, &cktrue, sizeof(CK_BBOOL) ); attrs++;
PK11_SETATTRS(attrs, CKA_LABEL, (unsigned char *)filename,
strlen(filename)+1); attrs++;
if (cacert) {
if(cacert) {
PK11_SETATTRS(attrs, CKA_TRUST, &cktrue, sizeof(CK_BBOOL) ); attrs++;
}
else {
@ -348,11 +348,11 @@ done:
/* Double-check that the certificate or nickname requested exists in
* either the token or the NSS certificate database.
*/
if (!cacert) {
if(!cacert) {
cert = PK11_FindCertFromNickname((char *)nickname, NULL);
/* An invalid nickname was passed in */
if (cert == NULL) {
if(cert == NULL) {
free(nickname);
PR_SetError(SEC_ERROR_UNKNOWN_CERT, 0);
return 0;
@ -533,7 +533,7 @@ static SECStatus nss_Init_Tokens(struct connectdata * conn)
ret = PK11_Authenticate(slot, PR_TRUE, parg);
if(SECSuccess != ret) {
if (PR_GetError() == SEC_ERROR_BAD_PASSWORD)
if(PR_GetError() == SEC_ERROR_BAD_PASSWORD)
infof(conn->data, "The password for token '%s' is incorrect\n",
PK11_GetTokenName(slot));
status = SECFailure;
@ -556,7 +556,7 @@ static SECStatus BadCertHandler(void *arg, PRFileDesc *sock)
CERTCertificate *cert = NULL;
char *subject, *issuer;
if (conn->data->set.ssl.certverifyresult!=0)
if(conn->data->set.ssl.certverifyresult!=0)
return success;
conn->data->set.ssl.certverifyresult=err;
@ -568,34 +568,34 @@ static SECStatus BadCertHandler(void *arg, PRFileDesc *sock)
switch(err) {
case SEC_ERROR_CA_CERT_INVALID:
infof(conn->data, "Issuer certificate is invalid: '%s'\n", issuer);
if (conn->data->set.ssl.verifypeer)
if(conn->data->set.ssl.verifypeer)
success = SECFailure;
break;
case SEC_ERROR_UNTRUSTED_ISSUER:
if (conn->data->set.ssl.verifypeer)
if(conn->data->set.ssl.verifypeer)
success = SECFailure;
infof(conn->data, "Certificate is signed by an untrusted issuer: '%s'\n",
issuer);
break;
case SSL_ERROR_BAD_CERT_DOMAIN:
if (conn->data->set.ssl.verifypeer)
if(conn->data->set.ssl.verifypeer)
success = SECFailure;
infof(conn->data, "common name: %s (does not match '%s')\n",
subject, conn->host.dispname);
break;
case SEC_ERROR_EXPIRED_CERTIFICATE:
if (conn->data->set.ssl.verifypeer)
if(conn->data->set.ssl.verifypeer)
success = SECFailure;
infof(conn->data, "Remote Certificate has expired.\n");
break;
default:
if (conn->data->set.ssl.verifypeer)
if(conn->data->set.ssl.verifypeer)
success = SECFailure;
infof(conn->data, "Bad certificate received. Subject = '%s', "
"Issuer = '%s'\n", subject, issuer);
break;
}
if (success == SECSuccess)
if(success == SECSuccess)
infof(conn->data, "SSL certificate verify ok.\n");
PR_Free(subject);
PR_Free(issuer);
@ -623,10 +623,10 @@ static void display_conn_info(struct connectdata *conn, PRFileDesc *sock)
char timeString[256];
PRTime notBefore, notAfter;
if (SSL_GetChannelInfo(sock, &channel, sizeof channel) ==
if(SSL_GetChannelInfo(sock, &channel, sizeof channel) ==
SECSuccess && channel.length == sizeof channel &&
channel.cipherSuite) {
if (SSL_GetCipherSuiteInfo(channel.cipherSuite,
if(SSL_GetCipherSuiteInfo(channel.cipherSuite,
&suite, sizeof suite) == SECSuccess) {
infof(conn->data, "SSL connection using %s\n", suite.cipherSuiteName);
}
@ -678,7 +678,7 @@ static SECStatus SelectClientCert(void *arg, PRFileDesc *sock,
proto_win = SSL_RevealPinArg(sock);
if (!nickname)
if(!nickname)
return secStatus;
cert = PK11_FindCertFromNickname(nickname, proto_win);
@ -708,7 +708,7 @@ static SECStatus SelectClientCert(void *arg, PRFileDesc *sock,
*pRetKey = privKey;
}
else {
if (cert)
if(cert)
CERT_DestroyCertificate(cert);
}
@ -814,11 +814,11 @@ CURLcode Curl_nss_connect(struct connectdata * conn, int sockindex)
certDir = getenv("SSL_DIR"); /* Look in $SSL_DIR */
if (!certDir) {
if(!certDir) {
struct stat st;
if (stat(SSL_DIR, &st) == 0)
if (S_ISDIR(st.st_mode)) {
if(stat(SSL_DIR, &st) == 0)
if(S_ISDIR(st.st_mode)) {
certDir = (char *)SSL_DIR;
}
}
@ -845,8 +845,8 @@ CURLcode Curl_nss_connect(struct connectdata * conn, int sockindex)
mod = SECMOD_LoadUserModule(configstring, NULL, PR_FALSE);
free(configstring);
if (!mod || !mod->loaded) {
if (mod) {
if(!mod || !mod->loaded) {
if(mod) {
SECMOD_DestroyModule(mod);
mod = NULL;
}
@ -912,31 +912,31 @@ CURLcode Curl_nss_connect(struct connectdata * conn, int sockindex)
if(!data->set.ssl.verifypeer)
/* skip the verifying of the peer */
;
else if (data->set.ssl.CAfile) {
else if(data->set.ssl.CAfile) {
int rc = nss_load_cert(data->set.ssl.CAfile, PR_TRUE);
if (!rc) {
if(!rc) {
curlerr = CURLE_SSL_CACERT_BADFILE;
goto error;
}
}
else if (data->set.ssl.CApath) {
else if(data->set.ssl.CApath) {
struct stat st;
PRDir *dir;
PRDirEntry *entry;
if (stat(data->set.ssl.CApath, &st) == -1) {
if(stat(data->set.ssl.CApath, &st) == -1) {
curlerr = CURLE_SSL_CACERT_BADFILE;
goto error;
}
if (S_ISDIR(st.st_mode)) {
if(S_ISDIR(st.st_mode)) {
int rc;
dir = PR_OpenDir(data->set.ssl.CApath);
do {
entry = PR_ReadDir(dir, PR_SKIP_BOTH | PR_SKIP_HIDDEN);
if (entry) {
if(entry) {
char fullpath[PATH_MAX];
snprintf(fullpath, sizeof(fullpath), "%s/%s", data->set.ssl.CApath,
@ -946,7 +946,7 @@ CURLcode Curl_nss_connect(struct connectdata * conn, int sockindex)
}
/* This is purposefully tolerant of errors so non-PEM files
* can be in the same directory */
} while (entry != NULL);
} while(entry != NULL);
PR_CloseDir(dir);
}
}
@ -963,7 +963,7 @@ CURLcode Curl_nss_connect(struct connectdata * conn, int sockindex)
nickname = (char *)malloc(PATH_MAX);
if(is_file(data->set.str[STRING_CERT])) {
n = strrchr(data->set.str[STRING_CERT], '/');
if (n) {
if(n) {
n++; /* skip last slash */
snprintf(nickname, PATH_MAX, "PEM Token #%ld:%s", 1, n);
}
@ -975,7 +975,7 @@ CURLcode Curl_nss_connect(struct connectdata * conn, int sockindex)
free(nickname);
goto error;
}
if (!cert_stuff(conn, data->set.str[STRING_CERT],
if(!cert_stuff(conn, data->set.str[STRING_CERT],
data->set.str[STRING_KEY])) {
/* failf() is already done in cert_stuff() */
free(nickname);
@ -1011,10 +1011,10 @@ CURLcode Curl_nss_connect(struct connectdata * conn, int sockindex)
SSL_SetURL(connssl->handle, conn->host.name);
/* Force the handshake now */
if (SSL_ForceHandshakeWithTimeout(connssl->handle,
if(SSL_ForceHandshakeWithTimeout(connssl->handle,
PR_SecondsToInterval(HANDSHAKE_TIMEOUT))
!= SECSuccess) {
if (conn->data->set.ssl.certverifyresult!=0)
if(conn->data->set.ssl.certverifyresult!=0)
curlerr = CURLE_SSL_CACERT;
goto error;
}

View File

@ -52,7 +52,7 @@
/* Winsock and TPF sockets are not in range [0..FD_SETSIZE-1] */
#if defined(USE_WINSOCK) || defined(TPF)
#define VERIFY_SOCK(x) do { } while (0)
#define VERIFY_SOCK(x) do { } while(0)
#else
#define VALID_SOCK(s) (((s) >= 0) && ((s) < FD_SETSIZE))
#define VERIFY_SOCK(x) do { \
@ -105,9 +105,9 @@ static int wait_ms(int timeout_ms)
#endif
int r = 0;
if (!timeout_ms)
if(!timeout_ms)
return 0;
if (timeout_ms < 0) {
if(timeout_ms < 0) {
SET_SOCKERRNO(EINVAL);
return -1;
}
@ -126,17 +126,17 @@ static int wait_ms(int timeout_ms)
pending_tv.tv_usec = (pending_ms % 1000) * 1000;
r = select(0, NULL, NULL, NULL, &pending_tv);
#endif /* HAVE_POLL_FINE */
if (r != -1)
if(r != -1)
break;
error = SOCKERRNO;
if ((error == EINVAL) || error_is_EINTR)
if((error == EINVAL) || error_is_EINTR)
break;
pending_ms = timeout_ms - elapsed_ms;
if (pending_ms <= 0)
if(pending_ms <= 0)
break;
} while (r == -1);
} while(r == -1);
#endif /* USE_WINSOCK */
if (r)
if(r)
r = -1;
return r;
}
@ -189,7 +189,7 @@ int Curl_socket_ready(curl_socket_t readfd, curl_socket_t writefd,
when function is called with a zero timeout or a negative timeout
value indicating a blocking call should be performed. */
if (timeout_ms > 0) {
if(timeout_ms > 0) {
pending_ms = timeout_ms;
initial_tv = curlx_tvnow();
}
@ -197,13 +197,13 @@ int Curl_socket_ready(curl_socket_t readfd, curl_socket_t writefd,
#ifdef HAVE_POLL_FINE
num = 0;
if (readfd != CURL_SOCKET_BAD) {
if(readfd != CURL_SOCKET_BAD) {
pfd[num].fd = readfd;
pfd[num].events = POLLRDNORM|POLLIN|POLLRDBAND|POLLPRI;
pfd[num].revents = 0;
num++;
}
if (writefd != CURL_SOCKET_BAD) {
if(writefd != CURL_SOCKET_BAD) {
pfd[num].fd = writefd;
pfd[num].events = POLLWRNORM|POLLOUT;
pfd[num].revents = 0;
@ -211,41 +211,41 @@ int Curl_socket_ready(curl_socket_t readfd, curl_socket_t writefd,
}
do {
if (timeout_ms < 0)
if(timeout_ms < 0)
pending_ms = -1;
else if (!timeout_ms)
else if(!timeout_ms)
pending_ms = 0;
r = poll(pfd, num, pending_ms);
if (r != -1)
if(r != -1)
break;
error = SOCKERRNO;
if ((error == EINVAL) || error_is_EINTR)
if((error == EINVAL) || error_is_EINTR)
break;
if (timeout_ms > 0) {
if(timeout_ms > 0) {
pending_ms = timeout_ms - elapsed_ms;
if (pending_ms <= 0)
if(pending_ms <= 0)
break;
}
} while (r == -1);
} while(r == -1);
if (r < 0)
if(r < 0)
return -1;
if (r == 0)
if(r == 0)
return 0;
ret = 0;
num = 0;
if (readfd != CURL_SOCKET_BAD) {
if (pfd[num].revents & (POLLRDNORM|POLLIN|POLLERR|POLLHUP))
if(readfd != CURL_SOCKET_BAD) {
if(pfd[num].revents & (POLLRDNORM|POLLIN|POLLERR|POLLHUP))
ret |= CURL_CSELECT_IN;
if (pfd[num].revents & (POLLRDBAND|POLLPRI|POLLNVAL))
if(pfd[num].revents & (POLLRDBAND|POLLPRI|POLLNVAL))
ret |= CURL_CSELECT_ERR;
num++;
}
if (writefd != CURL_SOCKET_BAD) {
if (pfd[num].revents & (POLLWRNORM|POLLOUT))
if(writefd != CURL_SOCKET_BAD) {
if(pfd[num].revents & (POLLWRNORM|POLLOUT))
ret |= CURL_CSELECT_OUT;
if (pfd[num].revents & (POLLERR|POLLHUP|POLLNVAL))
if(pfd[num].revents & (POLLERR|POLLHUP|POLLNVAL))
ret |= CURL_CSELECT_ERR;
}
@ -257,7 +257,7 @@ int Curl_socket_ready(curl_socket_t readfd, curl_socket_t writefd,
maxfd = (curl_socket_t)-1;
FD_ZERO(&fds_read);
if (readfd != CURL_SOCKET_BAD) {
if(readfd != CURL_SOCKET_BAD) {
VERIFY_SOCK(readfd);
FD_SET(readfd, &fds_read);
FD_SET(readfd, &fds_err);
@ -265,54 +265,54 @@ int Curl_socket_ready(curl_socket_t readfd, curl_socket_t writefd,
}
FD_ZERO(&fds_write);
if (writefd != CURL_SOCKET_BAD) {
if(writefd != CURL_SOCKET_BAD) {
VERIFY_SOCK(writefd);
FD_SET(writefd, &fds_write);
FD_SET(writefd, &fds_err);
if (writefd > maxfd)
if(writefd > maxfd)
maxfd = writefd;
}
ptimeout = (timeout_ms < 0) ? NULL : &pending_tv;
do {
if (timeout_ms > 0) {
if(timeout_ms > 0) {
pending_tv.tv_sec = pending_ms / 1000;
pending_tv.tv_usec = (pending_ms % 1000) * 1000;
}
else if (!timeout_ms) {
else if(!timeout_ms) {
pending_tv.tv_sec = 0;
pending_tv.tv_usec = 0;
}
r = select((int)maxfd + 1, &fds_read, &fds_write, &fds_err, ptimeout);
if (r != -1)
if(r != -1)
break;
error = SOCKERRNO;
if ((error == EINVAL) || (error == EBADF) || error_is_EINTR)
if((error == EINVAL) || (error == EBADF) || error_is_EINTR)
break;
if (timeout_ms > 0) {
if(timeout_ms > 0) {
pending_ms = timeout_ms - elapsed_ms;
if (pending_ms <= 0)
if(pending_ms <= 0)
break;
}
} while (r == -1);
} while(r == -1);
if (r < 0)
if(r < 0)
return -1;
if (r == 0)
if(r == 0)
return 0;
ret = 0;
if (readfd != CURL_SOCKET_BAD) {
if (FD_ISSET(readfd, &fds_read))
if(readfd != CURL_SOCKET_BAD) {
if(FD_ISSET(readfd, &fds_read))
ret |= CURL_CSELECT_IN;
if (FD_ISSET(readfd, &fds_err))
if(FD_ISSET(readfd, &fds_err))
ret |= CURL_CSELECT_ERR;
}
if (writefd != CURL_SOCKET_BAD) {
if (FD_ISSET(writefd, &fds_write))
if(writefd != CURL_SOCKET_BAD) {
if(FD_ISSET(writefd, &fds_write))
ret |= CURL_CSELECT_OUT;
if (FD_ISSET(writefd, &fds_err))
if(FD_ISSET(writefd, &fds_err))
ret |= CURL_CSELECT_ERR;
}
@ -355,15 +355,15 @@ int Curl_poll(struct pollfd ufds[], unsigned int nfds, int timeout_ms)
int error;
int r;
if (ufds) {
if(ufds) {
for (i = 0; i < nfds; i++) {
if (ufds[i].fd != CURL_SOCKET_BAD) {
if(ufds[i].fd != CURL_SOCKET_BAD) {
fds_none = FALSE;
break;
}
}
}
if (fds_none) {
if(fds_none) {
r = wait_ms(timeout_ms);
return r;
}
@ -373,7 +373,7 @@ int Curl_poll(struct pollfd ufds[], unsigned int nfds, int timeout_ms)
when function is called with a zero timeout or a negative timeout
value indicating a blocking call should be performed. */
if (timeout_ms > 0) {
if(timeout_ms > 0) {
pending_ms = timeout_ms;
initial_tv = curlx_tvnow();
}
@ -381,22 +381,22 @@ int Curl_poll(struct pollfd ufds[], unsigned int nfds, int timeout_ms)
#ifdef HAVE_POLL_FINE
do {
if (timeout_ms < 0)
if(timeout_ms < 0)
pending_ms = -1;
else if (!timeout_ms)
else if(!timeout_ms)
pending_ms = 0;
r = poll(ufds, nfds, pending_ms);
if (r != -1)
if(r != -1)
break;
error = SOCKERRNO;
if ((error == EINVAL) || error_is_EINTR)
if((error == EINVAL) || error_is_EINTR)
break;
if (timeout_ms > 0) {
if(timeout_ms > 0) {
pending_ms = timeout_ms - elapsed_ms;
if (pending_ms <= 0)
if(pending_ms <= 0)
break;
}
} while (r == -1);
} while(r == -1);
#else /* HAVE_POLL_FINE */
@ -407,18 +407,18 @@ int Curl_poll(struct pollfd ufds[], unsigned int nfds, int timeout_ms)
for (i = 0; i < nfds; i++) {
ufds[i].revents = 0;
if (ufds[i].fd == CURL_SOCKET_BAD)
if(ufds[i].fd == CURL_SOCKET_BAD)
continue;
VERIFY_SOCK(ufds[i].fd);
if (ufds[i].events & (POLLIN|POLLOUT|POLLPRI|
if(ufds[i].events & (POLLIN|POLLOUT|POLLPRI|
POLLRDNORM|POLLWRNORM|POLLRDBAND)) {
if (ufds[i].fd > maxfd)
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);
}
}
@ -426,44 +426,44 @@ int Curl_poll(struct pollfd ufds[], unsigned int nfds, int timeout_ms)
ptimeout = (timeout_ms < 0) ? NULL : &pending_tv;
do {
if (timeout_ms > 0) {
if(timeout_ms > 0) {
pending_tv.tv_sec = pending_ms / 1000;
pending_tv.tv_usec = (pending_ms % 1000) * 1000;
}
else if (!timeout_ms) {
else if(!timeout_ms) {
pending_tv.tv_sec = 0;
pending_tv.tv_usec = 0;
}
r = select((int)maxfd + 1, &fds_read, &fds_write, &fds_err, ptimeout);
if (r != -1)
if(r != -1)
break;
error = SOCKERRNO;
if ((error == EINVAL) || (error == EBADF) || error_is_EINTR)
if((error == EINVAL) || (error == EBADF) || error_is_EINTR)
break;
if (timeout_ms > 0) {
if(timeout_ms > 0) {
pending_ms = timeout_ms - elapsed_ms;
if (pending_ms <= 0)
if(pending_ms <= 0)
break;
}
} while (r == -1);
} while(r == -1);
if (r < 0)
if(r < 0)
return -1;
if (r == 0)
if(r == 0)
return 0;
r = 0;
for (i = 0; i < nfds; i++) {
ufds[i].revents = 0;
if (ufds[i].fd == CURL_SOCKET_BAD)
if(ufds[i].fd == CURL_SOCKET_BAD)
continue;
if (FD_ISSET(ufds[i].fd, &fds_read))
if(FD_ISSET(ufds[i].fd, &fds_read))
ufds[i].revents |= POLLIN;
if (FD_ISSET(ufds[i].fd, &fds_write))
if(FD_ISSET(ufds[i].fd, &fds_write))
ufds[i].revents |= POLLOUT;
if (FD_ISSET(ufds[i].fd, &fds_err))
if(FD_ISSET(ufds[i].fd, &fds_err))
ufds[i].revents |= POLLPRI;
if (ufds[i].revents != 0)
if(ufds[i].revents != 0)
r++;
}

View File

@ -67,12 +67,12 @@ static struct curl_slist *slist_get_last(struct curl_slist *list)
struct curl_slist *item;
/* if caller passed us a NULL, return now */
if (!list)
if(!list)
return NULL;
/* loop through to find the last item */
item = list;
while (item->next) {
while(item->next) {
item = item->next;
}
return item;
@ -92,7 +92,7 @@ struct curl_slist *curl_slist_append(struct curl_slist *list,
struct curl_slist *new_item;
new_item = (struct curl_slist *) malloc(sizeof(struct curl_slist));
if (new_item) {
if(new_item) {
char *dupdata = strdup(data);
if(dupdata) {
new_item->next = NULL;
@ -106,7 +106,7 @@ struct curl_slist *curl_slist_append(struct curl_slist *list,
else
return NULL;
if (list) {
if(list) {
last = slist_get_last(list);
last->next = new_item;
return list;
@ -122,19 +122,19 @@ void curl_slist_free_all(struct curl_slist *list)
struct curl_slist *next;
struct curl_slist *item;
if (!list)
if(!list)
return;
item = list;
do {
next = item->next;
if (item->data) {
if(item->data) {
free(item->data);
}
free(item);
item = next;
} while (next);
} while(next);
}
#ifdef CURL_DO_LINEEND_CONV
@ -150,14 +150,14 @@ static size_t convert_lineends(struct SessionHandle *data,
char *inPtr, *outPtr;
/* sanity check */
if ((startPtr == NULL) || (size < 1)) {
if((startPtr == NULL) || (size < 1)) {
return(size);
}
if (data->state.prev_block_had_trailing_cr == TRUE) {
if(data->state.prev_block_had_trailing_cr == TRUE) {
/* The previous block of incoming data
had a trailing CR, which was turned into a LF. */
if (*startPtr == '\n') {
if(*startPtr == '\n') {
/* This block of incoming data starts with the
previous block's LF so get rid of it */
memcpy(startPtr, startPtr+1, size-1);
@ -170,11 +170,11 @@ static size_t convert_lineends(struct SessionHandle *data,
/* find 1st CR, if any */
inPtr = outPtr = memchr(startPtr, '\r', size);
if (inPtr) {
if(inPtr) {
/* at least one CR, now look for CRLF */
while (inPtr < (startPtr+size-1)) {
while(inPtr < (startPtr+size-1)) {
/* note that it's size-1, so we'll never look past the last byte */
if (memcmp(inPtr, "\r\n", 2) == 0) {
if(memcmp(inPtr, "\r\n", 2) == 0) {
/* CRLF found, bump past the CR and copy the NL */
inPtr++;
*outPtr = *inPtr;
@ -182,7 +182,7 @@ static size_t convert_lineends(struct SessionHandle *data,
data->state.crlf_conversions++;
}
else {
if (*inPtr == '\r') {
if(*inPtr == '\r') {
/* lone CR, move LF instead */
*outPtr = '\n';
}
@ -195,9 +195,9 @@ static size_t convert_lineends(struct SessionHandle *data,
inPtr++;
} /* end of while loop */
if (inPtr < startPtr+size) {
if(inPtr < startPtr+size) {
/* handle last byte */
if (*inPtr == '\r') {
if(*inPtr == '\r') {
/* deal with a CR at the end of the buffer */
*outPtr = '\n'; /* copy a NL instead */
/* note that a CRLF might be split across two blocks */
@ -210,7 +210,7 @@ static size_t convert_lineends(struct SessionHandle *data,
outPtr++;
inPtr++;
}
if (outPtr < startPtr+size) {
if(outPtr < startPtr+size) {
/* tidy up by null terminating the now shorter data */
*outPtr = '\0';
}
@ -285,7 +285,7 @@ CURLcode Curl_sendf(curl_socket_t sockfd, struct connectdata *conn,
write_len = strlen(s);
sptr = s;
while (1) {
while(1) {
/* Write the buffer to the socket */
res = Curl_write(conn, sockfd, sptr, write_len, &bytes_written);
@ -355,13 +355,13 @@ CURLcode Curl_write(struct connectdata *conn,
CURLcode retcode;
int num = (sockfd == conn->sock[SECONDARYSOCKET]);
if (conn->ssl[num].use)
if(conn->ssl[num].use)
/* only TRUE if SSL enabled */
bytes_written = Curl_ssl_send(conn, num, mem, len);
#ifdef USE_LIBSSH2
else if (conn->protocol & PROT_SCP)
else if(conn->protocol & PROT_SCP)
bytes_written = Curl_scp_send(conn, num, mem, len);
else if (conn->protocol & PROT_SFTP)
else if(conn->protocol & PROT_SFTP)
bytes_written = Curl_sftp_send(conn, num, mem, len);
#endif /* !USE_LIBSSH2 */
else if(conn->sec_complete)
@ -389,7 +389,7 @@ CURLcode Curl_client_write(struct connectdata *conn,
struct SessionHandle *data = conn->data;
size_t wrote;
if (data->state.cancelled) {
if(data->state.cancelled) {
/* We just suck everything into a black hole */
return CURLE_OK;
}
@ -415,7 +415,7 @@ CURLcode Curl_client_write(struct connectdata *conn,
}
/* If the previous block of data ended with CR and this block of data is
just a NL, then the length might be zero */
if (len) {
if(len) {
wrote = data->set.fwrite_func(ptr, 1, len, data->set.out);
}
else {
@ -485,7 +485,7 @@ int Curl_read(struct connectdata *conn, /* connection data */
size_t bytestocopy = MIN(conn->buf_len - conn->read_pos, sizerequested);
/* Copy from our master buffer first if we have some unread data there*/
if (bytestocopy > 0) {
if(bytestocopy > 0) {
memcpy(buf, conn->master_buffer + conn->read_pos, bytestocopy);
conn->read_pos += bytestocopy;
conn->bits.stream_was_rewound = FALSE;
@ -512,10 +512,10 @@ int Curl_read(struct connectdata *conn, /* connection data */
}
}
#ifdef USE_LIBSSH2
else if (conn->protocol & (PROT_SCP|PROT_SFTP)) {
else if(conn->protocol & (PROT_SCP|PROT_SFTP)) {
if(conn->protocol & PROT_SCP)
nread = Curl_scp_recv(conn, num, buffertofill, bytesfromsocket);
else if (conn->protocol & PROT_SFTP)
else if(conn->protocol & PROT_SFTP)
nread = Curl_sftp_recv(conn, num, buffertofill, bytesfromsocket);
#ifdef LIBSSH2CHANNEL_EAGAIN
if((nread == LIBSSH2CHANNEL_EAGAIN) || (nread == 0))
@ -545,7 +545,7 @@ int Curl_read(struct connectdata *conn, /* connection data */
}
}
if (nread >= 0) {
if(nread >= 0) {
if(pipelining) {
memcpy(buf, conn->master_buffer, nread);
conn->buf_len = nread;
@ -573,7 +573,7 @@ static int showit(struct SessionHandle *data, curl_infotype type,
case CURLINFO_HEADER_OUT:
/* assume output headers are ASCII */
/* copy the data into my buffer so the original is unchanged */
if (size > BUFSIZE) {
if(size > BUFSIZE) {
size = BUFSIZE; /* truncate if necessary */
buf[BUFSIZE] = '\0';
}

View File

@ -136,7 +136,7 @@ CURLcode Curl_SOCKS4(const char *proxy_name,
/* get timeout */
if(data->set.timeout && data->set.connecttimeout) {
if (data->set.timeout < data->set.connecttimeout)
if(data->set.timeout < data->set.connecttimeout)
timeout = data->set.timeout;
else
timeout = data->set.connecttimeout;
@ -186,7 +186,7 @@ CURLcode Curl_SOCKS4(const char *proxy_name,
*/
if(dns)
hp=dns->addr;
if (hp) {
if(hp) {
char buf[64];
unsigned short ip[4];
Curl_printable_address(hp, buf, sizeof(buf));
@ -216,7 +216,7 @@ CURLcode Curl_SOCKS4(const char *proxy_name,
* This is currently not supporting "Identification Protocol (RFC1413)".
*/
socksreq[8] = 0; /* ensure empty userid is NUL-terminated */
if (proxy_name)
if(proxy_name)
strlcat((char*)socksreq + 8, proxy_name, sizeof(socksreq) - 8);
/*
@ -230,7 +230,7 @@ CURLcode Curl_SOCKS4(const char *proxy_name,
/* Send request */
code = Curl_write(conn, sock, (char *)socksreq, packetsize, &written);
if ((code != CURLE_OK) || (written != packetsize)) {
if((code != CURLE_OK) || (written != packetsize)) {
failf(data, "Failed to send SOCKS4 connect request.");
return CURLE_COULDNT_CONNECT;
}
@ -240,7 +240,7 @@ CURLcode Curl_SOCKS4(const char *proxy_name,
/* Receive response */
result = blockread_all(conn, sock, (char *)socksreq, packetsize,
&actualread, timeout);
if ((result != CURLE_OK) || (actualread != packetsize)) {
if((result != CURLE_OK) || (actualread != packetsize)) {
failf(data, "Failed to receive SOCKS4 connect request ack.");
return CURLE_COULDNT_CONNECT;
}
@ -265,7 +265,7 @@ CURLcode Curl_SOCKS4(const char *proxy_name,
*/
/* wrong version ? */
if (socksreq[0] != 0) {
if(socksreq[0] != 0) {
failf(data,
"SOCKS4 reply has wrong version, version should be 4.");
return CURLE_COULDNT_CONNECT;
@ -362,7 +362,7 @@ CURLcode Curl_SOCKS5(const char *proxy_name,
/* get timeout */
if(data->set.timeout && data->set.connecttimeout) {
if (data->set.timeout < data->set.connecttimeout)
if(data->set.timeout < data->set.connecttimeout)
timeout = data->set.timeout;
else
timeout = data->set.connecttimeout;
@ -402,7 +402,7 @@ CURLcode Curl_SOCKS5(const char *proxy_name,
code = Curl_write(conn, sock, (char *)socksreq, (2 + (int)socksreq[1]),
&written);
if ((code != CURLE_OK) || (written != (2 + (int)socksreq[1]))) {
if((code != CURLE_OK) || (written != (2 + (int)socksreq[1]))) {
failf(data, "Unable to send initial SOCKS5 request.");
return CURLE_COULDNT_CONNECT;
}
@ -428,20 +428,20 @@ CURLcode Curl_SOCKS5(const char *proxy_name,
Curl_nonblock(sock, FALSE);
result=blockread_all(conn, sock, (char *)socksreq, 2, &actualread, timeout);
if ((result != CURLE_OK) || (actualread != 2)) {
if((result != CURLE_OK) || (actualread != 2)) {
failf(data, "Unable to receive initial SOCKS5 response.");
return CURLE_COULDNT_CONNECT;
}
if (socksreq[0] != 5) {
if(socksreq[0] != 5) {
failf(data, "Received invalid version in initial SOCKS5 response.");
return CURLE_COULDNT_CONNECT;
}
if (socksreq[1] == 0) {
if(socksreq[1] == 0) {
/* Nothing to do, no authentication needed */
;
}
else if (socksreq[1] == 2) {
else if(socksreq[1] == 2) {
/* Needs user name and password */
size_t userlen, pwlen;
int len;
@ -471,20 +471,20 @@ CURLcode Curl_SOCKS5(const char *proxy_name,
len += pwlen;
code = Curl_write(conn, sock, (char *)socksreq, len, &written);
if ((code != CURLE_OK) || (len != written)) {
if((code != CURLE_OK) || (len != written)) {
failf(data, "Failed to send SOCKS5 sub-negotiation request.");
return CURLE_COULDNT_CONNECT;
}
result=blockread_all(conn, sock, (char *)socksreq, 2, &actualread,
timeout);
if ((result != CURLE_OK) || (actualread != 2)) {
if((result != CURLE_OK) || (actualread != 2)) {
failf(data, "Unable to receive SOCKS5 sub-negotiation response.");
return CURLE_COULDNT_CONNECT;
}
/* ignore the first (VER) byte */
if (socksreq[1] != 0) { /* status */
if(socksreq[1] != 0) { /* status */
failf(data, "User was rejected by the SOCKS5 server (%d %d).",
socksreq[0], socksreq[1]);
return CURLE_COULDNT_CONNECT;
@ -494,13 +494,13 @@ CURLcode Curl_SOCKS5(const char *proxy_name,
}
else {
/* error */
if (socksreq[1] == 1) {
if(socksreq[1] == 1) {
failf(data,
"SOCKS5 GSSAPI per-message authentication is not supported.");
return CURLE_COULDNT_CONNECT;
}
else if (socksreq[1] == 255) {
if (!proxy_name || !*proxy_name) {
else if(socksreq[1] == 255) {
if(!proxy_name || !*proxy_name) {
failf(data,
"No authentication method was acceptable. (It is quite likely"
" that the SOCKS5 server wanted a username/password, since none"
@ -542,7 +542,7 @@ CURLcode Curl_SOCKS5(const char *proxy_name,
*/
if(dns)
hp=dns->addr;
if (hp) {
if(hp) {
char buf[64];
unsigned short ip[4];
Curl_printable_address(hp, buf, sizeof(buf));
@ -572,24 +572,24 @@ CURLcode Curl_SOCKS5(const char *proxy_name,
const int packetsize = 10;
code = Curl_write(conn, sock, (char *)socksreq, packetsize, &written);
if ((code != CURLE_OK) || (written != packetsize)) {
if((code != CURLE_OK) || (written != packetsize)) {
failf(data, "Failed to send SOCKS5 connect request.");
return CURLE_COULDNT_CONNECT;
}
result = blockread_all(conn, sock, (char *)socksreq, packetsize,
&actualread, timeout);
if ((result != CURLE_OK) || (actualread != packetsize)) {
if((result != CURLE_OK) || (actualread != packetsize)) {
failf(data, "Failed to receive SOCKS5 connect request ack.");
return CURLE_COULDNT_CONNECT;
}
if (socksreq[0] != 5) { /* version */
if(socksreq[0] != 5) { /* version */
failf(data,
"SOCKS5 reply has wrong version, version should be 5.");
return CURLE_COULDNT_CONNECT;
}
if (socksreq[1] != 0) { /* Anything besides 0 is an error */
if(socksreq[1] != 0) { /* Anything besides 0 is an error */
failf(data,
"Can't complete SOCKS5 connection to %d.%d.%d.%d:%d. (%d)",
(unsigned char)socksreq[4], (unsigned char)socksreq[5],

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1997 - 2006, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 1997 - 2007, 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
@ -42,37 +42,37 @@ struct Curl_tree *Curl_splay(int i, struct Curl_tree *t)
struct Curl_tree N, *l, *r, *y;
int comp;
if (t == NULL)
if(t == NULL)
return t;
N.smaller = N.larger = NULL;
l = r = &N;
for (;;) {
comp = compare(i, t->key);
if (comp < 0) {
if (t->smaller == NULL)
if(comp < 0) {
if(t->smaller == NULL)
break;
if (compare(i, t->smaller->key) < 0) {
if(compare(i, t->smaller->key) < 0) {
y = t->smaller; /* rotate smaller */
t->smaller = y->larger;
y->larger = t;
t = y;
if (t->smaller == NULL)
if(t->smaller == NULL)
break;
}
r->smaller = t; /* link smaller */
r = t;
t = t->smaller;
}
else if (comp > 0) {
if (t->larger == NULL)
else if(comp > 0) {
if(t->larger == NULL)
break;
if (compare(i, t->larger->key) > 0) {
if(compare(i, t->larger->key) > 0) {
y = t->larger; /* rotate larger */
t->larger = y->smaller;
y->smaller = t;
t = y;
if (t->larger == NULL)
if(t->larger == NULL)
break;
}
l->larger = t; /* link larger */
@ -97,12 +97,12 @@ struct Curl_tree *Curl_splayinsert(int i,
struct Curl_tree *t,
struct Curl_tree *node)
{
if (node == NULL)
if(node == NULL)
return t;
if (t != NULL) {
if(t != NULL) {
t = Curl_splay(i,t);
if (compare(i, t->key)==0) {
if(compare(i, t->key)==0) {
/* There already exists a node in the tree with the very same key. Build
a linked list of nodes. We make the new 'node' struct the new master
node and make the previous node the first one in the 'same' list. */
@ -123,10 +123,10 @@ struct Curl_tree *Curl_splayinsert(int i,
}
}
if (t == NULL) {
if(t == NULL) {
node->smaller = node->larger = NULL;
}
else if (compare(i, t->key) < 0) {
else if(compare(i, t->key) < 0) {
node->smaller = t->smaller;
node->larger = t;
t->smaller = NULL;
@ -156,11 +156,11 @@ struct Curl_tree *Curl_splayremove(int i, struct Curl_tree *t,
*removed = NULL; /* default to no removed */
if (t==NULL)
if(t==NULL)
return NULL;
t = Curl_splay(i,t);
if (compare(i, t->key) == 0) { /* found it */
if(compare(i, t->key) == 0) { /* found it */
/* FIRST! Check if there is a list with identical sizes */
if((x = t->same)) {
@ -176,7 +176,7 @@ struct Curl_tree *Curl_splayremove(int i, struct Curl_tree *t,
return x; /* new root */
}
if (t->smaller == NULL) {
if(t->smaller == NULL) {
x = t->larger;
}
else {
@ -199,7 +199,7 @@ struct Curl_tree *Curl_splaygetbest(int i, struct Curl_tree *t,
{
struct Curl_tree *x;
if (!t) {
if(!t) {
*removed = NULL; /* none removed since there was no root */
return NULL;
}
@ -216,7 +216,7 @@ struct Curl_tree *Curl_splaygetbest(int i, struct Curl_tree *t,
}
}
if (compare(i, t->key) >= 0) { /* found it */
if(compare(i, t->key) >= 0) { /* found it */
/* FIRST! Check if there is a list with identical sizes */
x = t->same;
if(x) {
@ -232,7 +232,7 @@ struct Curl_tree *Curl_splaygetbest(int i, struct Curl_tree *t,
return x; /* new root */
}
if (t->smaller == NULL) {
if(t->smaller == NULL) {
x = t->larger;
}
else {
@ -265,14 +265,14 @@ int Curl_splayremovebyaddr(struct Curl_tree *t,
{
struct Curl_tree *x;
if (!t || !removenode)
if(!t || !removenode)
return 1;
if(KEY_NOTUSED == removenode->key) {
/* Key set to NOTUSED means it is a subnode within a 'same' linked list
and thus we can unlink it easily. The 'smaller' link of a subnode
links to the parent node. */
if (removenode->smaller == NULL)
if(removenode->smaller == NULL)
return 3;
removenode->smaller->same = removenode->same;
@ -312,7 +312,7 @@ int Curl_splayremovebyaddr(struct Curl_tree *t,
}
else {
/* Remove the root node */
if (t->smaller == NULL)
if(t->smaller == NULL)
x = t->larger;
else {
x = Curl_splay(removenode->key, t->smaller);
@ -332,7 +332,7 @@ void Curl_splayprint(struct Curl_tree * t, int d, char output)
struct Curl_tree *node;
int i;
int count;
if (t == NULL)
if(t == NULL)
return;
Curl_splayprint(t->larger, d+1, output);

View File

@ -238,7 +238,7 @@ static int ossl_seed(struct SessionHandle *data)
RAND_add(area, len, (len >> 1));
free(area); /* now remove the random junk */
} while (!RAND_status());
} while(!RAND_status());
}
#endif
@ -366,7 +366,7 @@ int cert_stuff(struct connectdata *conn,
EVP_PKEY *pri;
f = fopen(cert_file,"rb");
if (!f) {
if(!f) {
failf(data, "could not open PKCS12 file '%s'", cert_file);
return 0;
}
@ -375,7 +375,7 @@ int cert_stuff(struct connectdata *conn,
PKCS12_PBE_add();
if (!PKCS12_parse(p12, data->set.str[STRING_KEY_PASSWD], &pri, &x509,
if(!PKCS12_parse(p12, data->set.str[STRING_KEY_PASSWD], &pri, &x509,
NULL)) {
failf(data,
"could not parse PKCS12 file, check password, OpenSSL error %s",
@ -483,7 +483,7 @@ int cert_stuff(struct connectdata *conn,
}
ssl=SSL_new(ctx);
if (NULL == ssl) {
if(NULL == ssl) {
failf(data,"unable to create an SSL structure\n");
return 0;
}
@ -564,7 +564,7 @@ int Curl_ossl_init(void)
SSL_load_error_strings();
/* Setup all the global SSL stuff */
if (!SSLeay_add_ssl_algorithms())
if(!SSLeay_add_ssl_algorithms())
return 0;
return 1;
@ -609,10 +609,10 @@ int Curl_ossl_check_cxn(struct connectdata *conn)
char buf;
rc = SSL_peek(conn->ssl[FIRSTSOCKET].handle, (void*)&buf, 1);
if (rc > 0)
if(rc > 0)
return 1; /* connection still in place */
if (rc == 0)
if(rc == 0)
return 0; /* connection has been closed */
return -1; /* connection status unknown */
@ -625,17 +625,17 @@ CURLcode Curl_ossl_set_engine(struct SessionHandle *data, const char *engine)
#if defined(USE_SSLEAY) && defined(HAVE_OPENSSL_ENGINE_H)
ENGINE *e = ENGINE_by_id(engine);
if (!e) {
if(!e) {
failf(data, "SSL Engine '%s' not found", engine);
return (CURLE_SSL_ENGINE_NOTFOUND);
}
if (data->state.engine) {
if(data->state.engine) {
ENGINE_finish(data->state.engine);
ENGINE_free(data->state.engine);
data->state.engine = NULL;
}
if (!ENGINE_init(e)) {
if(!ENGINE_init(e)) {
char buf[256];
ENGINE_free(e);
@ -657,8 +657,8 @@ CURLcode Curl_ossl_set_engine(struct SessionHandle *data, const char *engine)
CURLcode Curl_ossl_set_engine_default(struct SessionHandle *data)
{
#ifdef HAVE_OPENSSL_ENGINE_H
if (data->state.engine) {
if (ENGINE_set_default(data->state.engine, ENGINE_METHOD_ALL) > 0) {
if(data->state.engine) {
if(ENGINE_set_default(data->state.engine, ENGINE_METHOD_ALL) > 0) {
infof(data,"set default crypto engine '%s'\n", ENGINE_get_id(data->state.engine));
}
else {
@ -683,11 +683,11 @@ struct curl_slist *Curl_ossl_engines_list(struct SessionHandle *data)
for (e = ENGINE_get_first(); e; e = ENGINE_get_next(e)) {
list = curl_slist_append(list, ENGINE_get_id(e));
if (list == NULL) {
if(list == NULL) {
curl_slist_free_all(beg);
return NULL;
}
else if (beg == NULL) {
else if(beg == NULL) {
beg = list;
}
}
@ -919,26 +919,26 @@ static int Curl_ASN1_UTCTIME_output(struct connectdata *conn,
static int hostmatch(const char *hostname, const char *pattern)
{
while (1) {
while(1) {
char c = *pattern++;
if (c == '\0')
if(c == '\0')
return (*hostname ? HOST_NOMATCH : HOST_MATCH);
if (c == '*') {
if(c == '*') {
c = *pattern;
if (c == '\0') /* "*\0" matches anything remaining */
if(c == '\0') /* "*\0" matches anything remaining */
return HOST_MATCH;
while (*hostname) {
while(*hostname) {
/* The only recursive function in libcurl! */
if (hostmatch(hostname++,pattern) == HOST_MATCH)
if(hostmatch(hostname++,pattern) == HOST_MATCH)
return HOST_MATCH;
}
break;
}
if (toupper(c) != toupper(*hostname++))
if(toupper(c) != toupper(*hostname++))
break;
}
return HOST_NOMATCH;
@ -947,14 +947,14 @@ static int hostmatch(const char *hostname, const char *pattern)
static int
cert_hostcheck(const char *match_pattern, const char *hostname)
{
if (!match_pattern || !*match_pattern ||
if(!match_pattern || !*match_pattern ||
!hostname || !*hostname) /* sanity check */
return 0;
if(curl_strequal(hostname,match_pattern)) /* trivial case */
return 1;
if (hostmatch(hostname,match_pattern) == HOST_MATCH)
if(hostmatch(hostname,match_pattern) == HOST_MATCH)
return 1;
return 0;
}
@ -1042,7 +1042,7 @@ static CURLcode verifyhost(struct connectdata *conn,
"I checked the 0.9.6 and 0.9.8 sources before my patch and
it always 0-terminates an IA5String."
*/
if (cert_hostcheck(altptr, conn->host.name))
if(cert_hostcheck(altptr, conn->host.name))
matched = TRUE;
break;
@ -1073,15 +1073,15 @@ static CURLcode verifyhost(struct connectdata *conn,
unsigned char *peer_CN = nulstr;
X509_NAME *name = X509_get_subject_name(server_cert) ;
if (name)
while ((j=X509_NAME_get_index_by_NID(name,NID_commonName,i))>=0)
if(name)
while((j=X509_NAME_get_index_by_NID(name,NID_commonName,i))>=0)
i=j;
/* we have the name entry and we will now convert this to a string
that we can use for comparison. Doing this we support BMPstring,
UTF8 etc. */
if (i>=0) {
if(i>=0) {
ASN1_STRING *tmp = X509_NAME_ENTRY_get_data(X509_NAME_get_entry(name,i));
/* In OpenSSL 0.9.7d and earlier, ASN1_STRING_to_UTF8 fails if the input
@ -1089,11 +1089,11 @@ static CURLcode verifyhost(struct connectdata *conn,
string manually to avoid the problem. This code can be made
conditional in the future when OpenSSL has been fixed. Work-around
brought by Alexis S. L. Carvalho. */
if (tmp && ASN1_STRING_type(tmp) == V_ASN1_UTF8STRING) {
if(tmp && ASN1_STRING_type(tmp) == V_ASN1_UTF8STRING) {
j = ASN1_STRING_length(tmp);
if (j >= 0) {
if(j >= 0) {
peer_CN = OPENSSL_malloc(j+1);
if (peer_CN) {
if(peer_CN) {
memcpy(peer_CN, ASN1_STRING_data(tmp), j);
peer_CN[j] = '\0';
}
@ -1103,7 +1103,7 @@ static CURLcode verifyhost(struct connectdata *conn,
j = ASN1_STRING_to_UTF8(&peer_CN, tmp);
}
if (peer_CN == nulstr)
if(peer_CN == nulstr)
peer_CN = NULL;
#ifdef CURL_DOES_CONVERSIONS
else {
@ -1111,14 +1111,14 @@ static CURLcode verifyhost(struct connectdata *conn,
size_t rc;
rc = Curl_convert_from_utf8(data, peer_CN, strlen(peer_CN));
/* Curl_convert_from_utf8 calls failf if unsuccessful */
if (rc != CURLE_OK) {
if(rc != CURLE_OK) {
OPENSSL_free(peer_CN);
return rc;
}
}
#endif /* CURL_DOES_CONVERSIONS */
if (!peer_CN) {
if(!peer_CN) {
failf(data,
"SSL: unable to obtain common name from peer certificate");
return CURLE_PEER_FAILED_VERIFICATION;
@ -1149,7 +1149,7 @@ static CURLcode verifyhost(struct connectdata *conn,
static const char *ssl_msg_type(int ssl_ver, int msg)
{
if (ssl_ver == SSL2_VERSION_MAJOR) {
if(ssl_ver == SSL2_VERSION_MAJOR) {
switch (msg) {
case SSL2_MT_ERROR:
return "Error";
@ -1171,7 +1171,7 @@ static const char *ssl_msg_type(int ssl_ver, int msg)
return "Client CERT";
}
}
else if (ssl_ver == SSL3_VERSION_MAJOR) {
else if(ssl_ver == SSL3_VERSION_MAJOR) {
switch (msg) {
case SSL3_MT_HELLO_REQUEST:
return "Hello request";
@ -1221,7 +1221,7 @@ static void ssl_tls_trace(int direction, int ssl_ver, int content_type,
char ssl_buf[1024];
int ver, msg_type, txt_len;
if (!conn || !conn->data || !conn->data->set.fdebug ||
if(!conn || !conn->data || !conn->data->set.fdebug ||
(direction != 0 && direction != 1))
return;
@ -1234,7 +1234,7 @@ static void ssl_tls_trace(int direction, int ssl_ver, int content_type,
* always pass-up content-type as 0. But the interesting message-type
* is at 'buf[0]'.
*/
if (ssl_ver == SSL3_VERSION_MAJOR && content_type != 0)
if(ssl_ver == SSL3_VERSION_MAJOR && content_type != 0)
tls_rt_name = tls_rt_type(content_type);
else
tls_rt_name = "";
@ -1290,7 +1290,7 @@ Curl_ossl_connect_step1(struct connectdata *conn,
break;
}
if (connssl->ctx)
if(connssl->ctx)
SSL_CTX_free(connssl->ctx);
connssl->ctx = SSL_CTX_new(req_method);
@ -1300,14 +1300,14 @@ Curl_ossl_connect_step1(struct connectdata *conn,
}
#ifdef SSL_CTRL_SET_MSG_CALLBACK
if (data->set.fdebug && data->set.verbose) {
if(data->set.fdebug && data->set.verbose) {
/* the SSL trace callback is only used for verbose logging so we only
inform about failures of setting it */
if (!SSL_CTX_callback_ctrl(connssl->ctx, SSL_CTRL_SET_MSG_CALLBACK,
if(!SSL_CTX_callback_ctrl(connssl->ctx, SSL_CTRL_SET_MSG_CALLBACK,
(void (*)(void))ssl_tls_trace)) {
infof(data, "SSL: couldn't set callback!\n");
}
else if (!SSL_CTX_ctrl(connssl->ctx, SSL_CTRL_SET_MSG_CALLBACK_ARG, 0,
else if(!SSL_CTX_ctrl(connssl->ctx, SSL_CTRL_SET_MSG_CALLBACK_ARG, 0,
conn)) {
infof(data, "SSL: couldn't set callback argument!\n");
}
@ -1330,7 +1330,7 @@ Curl_ossl_connect_step1(struct connectdata *conn,
* non-blocking. It doesn't seem to care, but just return with
* SSL_ERROR_WANT_x.
*/
if (data->state.used_interface == Curl_if_multi)
if(data->state.used_interface == Curl_if_multi)
SSL_CTX_ctrl(connssl->ctx, BIO_C_SET_NBIO, 1, NULL);
#endif
@ -1354,13 +1354,13 @@ Curl_ossl_connect_step1(struct connectdata *conn,
}
}
if (data->set.str[STRING_SSL_CAFILE] || data->set.str[STRING_SSL_CAPATH]) {
if(data->set.str[STRING_SSL_CAFILE] || data->set.str[STRING_SSL_CAPATH]) {
/* tell SSL where to find CA certificates that are used to verify
the servers certificate. */
if (!SSL_CTX_load_verify_locations(connssl->ctx,
if(!SSL_CTX_load_verify_locations(connssl->ctx,
data->set.str[STRING_SSL_CAFILE],
data->set.str[STRING_SSL_CAPATH])) {
if (data->set.ssl.verifypeer) {
if(data->set.ssl.verifypeer) {
/* Fail if we insist on successfully verifying the server. */
failf(data,"error setting certificate verify locations:\n"
" CAfile: %s\n CApath: %s\n",
@ -1408,10 +1408,10 @@ Curl_ossl_connect_step1(struct connectdata *conn,
}
/* Lets make an SSL structure */
if (connssl->handle)
if(connssl->handle)
SSL_free(connssl->handle);
connssl->handle = SSL_new(connssl->ctx);
if (!connssl->handle) {
if(!connssl->handle) {
failf(data, "SSL: couldn't create a context (handle)!");
return CURLE_OUT_OF_MEMORY;
}
@ -1422,7 +1422,7 @@ Curl_ossl_connect_step1(struct connectdata *conn,
/* Check if there's a cached ID we can/should use here! */
if(!Curl_ssl_getsessionid(conn, &ssl_sessionid, NULL)) {
/* we got a session id, use it! */
if (!SSL_set_session(connssl->handle, ssl_sessionid)) {
if(!SSL_set_session(connssl->handle, ssl_sessionid)) {
failf(data, "SSL: SSL_set_session failed: %s",
ERR_error_string(ERR_get_error(),NULL));
return CURLE_SSL_CONNECT_ERROR;
@ -1432,7 +1432,7 @@ Curl_ossl_connect_step1(struct connectdata *conn,
}
/* pass the raw socket into the SSL layers */
if (!SSL_set_fd(connssl->handle, sockfd)) {
if(!SSL_set_fd(connssl->handle, sockfd)) {
failf(data, "SSL: SSL_set_fd failed: %s",
ERR_error_string(ERR_get_error(),NULL));
return CURLE_SSL_CONNECT_ERROR;
@ -1545,7 +1545,7 @@ Curl_ossl_connect_step2(struct connectdata *conn,
* (RST connection etc.), OpenSSL gives no explanation whatsoever and
* the SO_ERROR is also lost.
*/
if (CURLE_SSL_CONNECT_ERROR == rc && errdetail == 0) {
if(CURLE_SSL_CONNECT_ERROR == rc && errdetail == 0) {
failf(data, "Unknown SSL protocol error in connection to %s:%d ",
conn->host.name, conn->port);
return rc;
@ -1704,19 +1704,19 @@ Curl_ossl_connect_common(struct connectdata *conn,
curl_socket_t sockfd = conn->sock[sockindex];
long timeout_ms;
if (ssl_connect_1==connssl->connecting_state) {
if(ssl_connect_1==connssl->connecting_state) {
retcode = Curl_ossl_connect_step1(conn, sockindex);
if (retcode)
if(retcode)
return retcode;
}
timeout_ms = 0;
while (ssl_connect_2 == connssl->connecting_state ||
ssl_connect_2_reading == connssl->connecting_state ||
ssl_connect_2_writing == connssl->connecting_state) {
while(ssl_connect_2 == connssl->connecting_state ||
ssl_connect_2_reading == connssl->connecting_state ||
ssl_connect_2_writing == connssl->connecting_state) {
/* if ssl is expecting something, check if it's available. */
if (connssl->connecting_state == ssl_connect_2_reading
if(connssl->connecting_state == ssl_connect_2_reading
|| connssl->connecting_state == ssl_connect_2_writing) {
int writefd = ssl_connect_2_writing==
@ -1730,7 +1730,7 @@ Curl_ossl_connect_common(struct connectdata *conn,
/* readable or writable, go loop in the outer loop */
break;
else if(0 == what) {
if (nonblocking) {
if(nonblocking) {
*done = FALSE;
return CURLE_OK;
}
@ -1750,19 +1750,19 @@ Curl_ossl_connect_common(struct connectdata *conn,
/* get the timeout from step2 to avoid computing it twice. */
retcode = Curl_ossl_connect_step2(conn, sockindex, &timeout_ms);
if (retcode)
if(retcode)
return retcode;
} /* repeat step2 until all transactions are done. */
if (ssl_connect_3==connssl->connecting_state) {
if(ssl_connect_3==connssl->connecting_state) {
retcode = Curl_ossl_connect_step3(conn, sockindex);
if (retcode)
if(retcode)
return retcode;
}
if (ssl_connect_done==connssl->connecting_state) {
if(ssl_connect_done==connssl->connecting_state) {
*done = TRUE;
}
else {
@ -1791,7 +1791,7 @@ Curl_ossl_connect(struct connectdata *conn,
bool done = FALSE;
retcode = Curl_ossl_connect_common(conn, sockindex, FALSE, &done);
if (retcode)
if(retcode)
return retcode;
DEBUGASSERT(done);
@ -1892,7 +1892,7 @@ size_t Curl_ossl_version(char *buffer, size_t size)
return snprintf(buffer, size, "yassl/%s", YASSL_VERSION);
#else /* YASSL_VERSION */
#if (SSLEAY_VERSION_NUMBER >= 0x905000)
#if(SSLEAY_VERSION_NUMBER >= 0x905000)
{
char sub[2];
unsigned long ssleay_value;
@ -1919,7 +1919,7 @@ size_t Curl_ossl_version(char *buffer, size_t size)
#else /* SSLEAY_VERSION_NUMBER is less than 0.9.5 */
#if (SSLEAY_VERSION_NUMBER >= 0x900000)
#if(SSLEAY_VERSION_NUMBER >= 0x900000)
return snprintf(buffer, size, "OpenSSL/%lx.%lx.%lx",
(SSLEAY_VERSION_NUMBER>>28)&0xff,
(SSLEAY_VERSION_NUMBER>>20)&0xff,

View File

@ -40,7 +40,7 @@
/* Range tests can be used for alphanum decoding if characters are consecutive,
like in ASCII. Else an array is scanned. Determine this condition now. */
#if ('9' - '0') != 9 || ('Z' - 'A') != 25 || ('z' - 'a') != 25
#if('9' - '0') != 9 || ('Z' - 'A') != 25 || ('z' - 'a') != 25
#include <string.h>
#define NO_RANGE_TEST
@ -67,35 +67,35 @@ curlx_strtoll(const char *nptr, char **endptr, int base)
/* Skip leading whitespace. */
end = (char *)nptr;
while (ISSPACE(end[0])) {
while(ISSPACE(end[0])) {
end++;
}
/* Handle the sign, if any. */
if (end[0] == '-') {
if(end[0] == '-') {
is_negative = 1;
end++;
}
else if (end[0] == '+') {
else if(end[0] == '+') {
end++;
}
else if (end[0] == '\0') {
else if(end[0] == '\0') {
/* We had nothing but perhaps some whitespace -- there was no number. */
if (endptr) {
if(endptr) {
*endptr = end;
}
return 0;
}
/* Handle special beginnings, if present and allowed. */
if (end[0] == '0' && end[1] == 'x') {
if (base == 16 || base == 0) {
if(end[0] == '0' && end[1] == 'x') {
if(base == 16 || base == 0) {
end += 2;
base = 16;
}
}
else if (end[0] == '0') {
if (base == 8 || base == 0) {
else if(end[0] == '0') {
if(base == 8 || base == 0) {
end++;
base = 8;
}
@ -104,7 +104,7 @@ curlx_strtoll(const char *nptr, char **endptr, int base)
/* Matching strtol, if the base is 0 and it doesn't look like
* the number is octal or hex, we assume it's base 10.
*/
if (base == 0) {
if(base == 0) {
base = 10;
}
@ -115,7 +115,7 @@ curlx_strtoll(const char *nptr, char **endptr, int base)
i != -1;
end++, i = get_char(end[0], base)) {
newval = base * value + i;
if (newval < value) {
if(newval < value) {
/* We've overflowed. */
overflow = 1;
break;
@ -124,14 +124,14 @@ curlx_strtoll(const char *nptr, char **endptr, int base)
value = newval;
}
if (!overflow) {
if (is_negative) {
if(!overflow) {
if(is_negative) {
/* Fix the sign. */
value *= -1;
}
}
else {
if (is_negative)
if(is_negative)
value = CURL_LLONG_MIN;
else
value = CURL_LLONG_MAX;
@ -139,7 +139,7 @@ curlx_strtoll(const char *nptr, char **endptr, int base)
SET_ERRNO(ERANGE);
}
if (endptr)
if(endptr)
*endptr = end;
return value;
@ -159,13 +159,13 @@ static int get_char(char c, int base)
{
#ifndef NO_RANGE_TEST
int value = -1;
if (c <= '9' && c >= '0') {
if(c <= '9' && c >= '0') {
value = c - '0';
}
else if (c <= 'Z' && c >= 'A') {
else if(c <= 'Z' && c >= 'A') {
value = c - 'A' + 10;
}
else if (c <= 'z' && c >= 'a') {
else if(c <= 'z' && c >= 'a') {
value = c - 'a' + 10;
}
#else
@ -174,16 +174,16 @@ static int get_char(char c, int base)
cp = memchr(valchars, c, 10 + 26 + 26);
if (!cp)
if(!cp)
return -1;
value = cp - valchars;
if (value >= 10 + 26)
if(value >= 10 + 26)
value -= 26; /* Lowercase. */
#endif
if (value >= base) {
if(value >= base) {
value = -1;
}

View File

@ -86,7 +86,7 @@
#define CURL_SB_CLEAR(x) x->subpointer = x->subbuffer;
#define CURL_SB_TERM(x) { x->subend = x->subpointer; CURL_SB_CLEAR(x); }
#define CURL_SB_ACCUM(x,c) \
if (x->subpointer < (x->subbuffer+sizeof x->subbuffer)) { \
if(x->subpointer < (x->subbuffer+sizeof x->subbuffer)) { \
*x->subpointer++ = (c); \
}
@ -96,7 +96,7 @@
#define CURL_SB_LEN(x) (x->subend - x->subpointer)
#ifdef CURL_DISABLE_VERBOSE_STRINGS
#define printoption(a,b,c,d) do { } while (0)
#define printoption(a,b,c,d) do { } while(0)
#endif
#ifdef USE_WINSOCK
@ -213,7 +213,7 @@ check_wsock2 ( struct SessionHandle *data )
/* We must've called this once already, so this call */
/* should always succeed. But, just in case... */
if (err != 0) {
if(err != 0) {
failf(data,"WSAStartup failed (%d)",err);
return CURLE_FAILED_INIT;
}
@ -223,7 +223,7 @@ check_wsock2 ( struct SessionHandle *data )
WSACleanup();
/* Check that our version is supported */
if (LOBYTE(wsaData.wVersion) != LOBYTE(wVersionRequested) ||
if(LOBYTE(wsaData.wVersion) != LOBYTE(wVersionRequested) ||
HIBYTE(wsaData.wVersion) != HIBYTE(wVersionRequested)) {
/* Our version isn't supported */
failf(data,"insufficient winsock version to support "
@ -283,11 +283,11 @@ static void printoption(struct SessionHandle *data,
const char *fmt;
const char *opt;
if (data->set.verbose)
if(data->set.verbose)
{
if (cmd == CURL_IAC)
if(cmd == CURL_IAC)
{
if (CURL_TELCMD_OK(option))
if(CURL_TELCMD_OK(option))
infof(data, "%s IAC %s\n", direction, CURL_TELCMD(option));
else
infof(data, "%s IAC %d\n", direction, option);
@ -296,11 +296,11 @@ static void printoption(struct SessionHandle *data,
{
fmt = (cmd == CURL_WILL) ? "WILL" : (cmd == CURL_WONT) ? "WONT" :
(cmd == CURL_DO) ? "DO" : (cmd == CURL_DONT) ? "DONT" : 0;
if (fmt)
if(fmt)
{
if (CURL_TELOPT_OK(option))
if(CURL_TELOPT_OK(option))
opt = CURL_TELOPT(option);
else if (option == CURL_TELOPT_EXOPL)
else if(option == CURL_TELOPT_EXOPL)
opt = "EXOPL";
else
opt = NULL;
@ -705,30 +705,30 @@ static void printsub(struct SessionHandle *data,
{
unsigned int i = 0;
if (data->set.verbose)
if(data->set.verbose)
{
if (direction)
if(direction)
{
infof(data, "%s IAC SB ", (direction == '<')? "RCVD":"SENT");
if (length >= 3)
if(length >= 3)
{
int j;
i = pointer[length-2];
j = pointer[length-1];
if (i != CURL_IAC || j != CURL_SE)
if(i != CURL_IAC || j != CURL_SE)
{
infof(data, "(terminated by ");
if (CURL_TELOPT_OK(i))
if(CURL_TELOPT_OK(i))
infof(data, "%s ", CURL_TELOPT(i));
else if (CURL_TELCMD_OK(i))
else if(CURL_TELCMD_OK(i))
infof(data, "%s ", CURL_TELCMD(i));
else
infof(data, "%d ", i);
if (CURL_TELOPT_OK(j))
if(CURL_TELOPT_OK(j))
infof(data, "%s", CURL_TELOPT(j));
else if (CURL_TELCMD_OK(j))
else if(CURL_TELCMD_OK(j))
infof(data, "%s", CURL_TELCMD(j));
else
infof(data, "%d", j);
@ -737,13 +737,13 @@ static void printsub(struct SessionHandle *data,
}
length -= 2;
}
if (length < 1)
if(length < 1)
{
infof(data, "(Empty suboption?)");
return;
}
if (CURL_TELOPT_OK(pointer[0])) {
if(CURL_TELOPT_OK(pointer[0])) {
switch(pointer[0]) {
case CURL_TELOPT_TTYPE:
case CURL_TELOPT_XDISPLOC:
@ -803,7 +803,7 @@ static void printsub(struct SessionHandle *data,
break;
}
if (direction)
if(direction)
{
infof(data, "\n");
}
@ -965,7 +965,7 @@ void telrcv(struct connectdata *conn,
{
case CURL_TS_CR:
tn->telrcv_state = CURL_TS_DATA;
if (c == '\0')
if(c == '\0')
{
break; /* Ignore \0 after CR */
}
@ -974,7 +974,7 @@ void telrcv(struct connectdata *conn,
continue;
case CURL_TS_DATA:
if (c == CURL_IAC)
if(c == CURL_IAC)
{
tn->telrcv_state = CURL_TS_IAC;
break;
@ -1049,7 +1049,7 @@ void telrcv(struct connectdata *conn,
continue;
case CURL_TS_SB:
if (c == CURL_IAC)
if(c == CURL_IAC)
{
tn->telrcv_state = CURL_TS_SE;
}
@ -1060,9 +1060,9 @@ void telrcv(struct connectdata *conn,
continue;
case CURL_TS_SE:
if (c != CURL_SE)
if(c != CURL_SE)
{
if (c != CURL_IAC)
if(c != CURL_IAC)
{
/*
* This is an error. We only expect to get "IAC IAC" or "IAC SE".
@ -1161,20 +1161,20 @@ static CURLcode Curl_telnet(struct connectdata *conn, bool *done)
** make sure have it.
*/
code = check_wsock2(data);
if (code)
if(code)
return code;
/* OK, so we have WinSock 2.0. We need to dynamically */
/* load ws2_32.dll and get the function pointers we need. */
wsock2 = LoadLibrary("WS2_32.DLL");
if (wsock2 == NULL) {
if(wsock2 == NULL) {
failf(data,"failed to load WS2_32.DLL (%d)", ERRNO);
return CURLE_FAILED_INIT;
}
/* Grab a pointer to WSACreateEvent */
create_event_func = GetProcAddress(wsock2,"WSACreateEvent");
if (create_event_func == NULL) {
if(create_event_func == NULL) {
failf(data,"failed to find WSACreateEvent function (%d)",
ERRNO);
FreeLibrary(wsock2);
@ -1183,7 +1183,7 @@ static CURLcode Curl_telnet(struct connectdata *conn, bool *done)
/* And WSACloseEvent */
close_event_func = GetProcAddress(wsock2,"WSACloseEvent");
if (close_event_func == NULL) {
if(close_event_func == NULL) {
failf(data,"failed to find WSACloseEvent function (%d)",
ERRNO);
FreeLibrary(wsock2);
@ -1192,7 +1192,7 @@ static CURLcode Curl_telnet(struct connectdata *conn, bool *done)
/* And WSAEventSelect */
event_select_func = GetProcAddress(wsock2,"WSAEventSelect");
if (event_select_func == NULL) {
if(event_select_func == NULL) {
failf(data,"failed to find WSAEventSelect function (%d)",
ERRNO);
FreeLibrary(wsock2);
@ -1201,7 +1201,7 @@ static CURLcode Curl_telnet(struct connectdata *conn, bool *done)
/* And WSAEnumNetworkEvents */
enum_netevents_func = GetProcAddress(wsock2,"WSAEnumNetworkEvents");
if (enum_netevents_func == NULL) {
if(enum_netevents_func == NULL) {
failf(data,"failed to find WSAEnumNetworkEvents function (%d)",
ERRNO);
FreeLibrary(wsock2);
@ -1215,7 +1215,7 @@ static CURLcode Curl_telnet(struct connectdata *conn, bool *done)
/* First, create a sockets event object */
event_handle = (WSAEVENT)create_event_func();
if (event_handle == WSA_INVALID_EVENT) {
if(event_handle == WSA_INVALID_EVENT) {
failf(data,"WSACreateEvent failed (%d)", SOCKERRNO);
FreeLibrary(wsock2);
return CURLE_FAILED_INIT;
@ -1343,7 +1343,7 @@ static CURLcode Curl_telnet(struct connectdata *conn, bool *done)
}
/* We called WSACreateEvent, so call WSACloseEvent */
if (close_event_func(event_handle) == FALSE) {
if(close_event_func(event_handle) == FALSE) {
infof(data,"WSACloseEvent failed (%d)", SOCKERRNO);
}
@ -1354,7 +1354,7 @@ static CURLcode Curl_telnet(struct connectdata *conn, bool *done)
enum_netevents_func = NULL;
/* We called LoadLibrary, so call FreeLibrary */
if (!FreeLibrary(wsock2))
if(!FreeLibrary(wsock2))
infof(data,"FreeLibrary(wsock2) failed (%d)", ERRNO);
#else
pfd[0].fd = sockfd;
@ -1363,7 +1363,7 @@ static CURLcode Curl_telnet(struct connectdata *conn, bool *done)
pfd[1].events = POLLIN;
interval_ms = 1 * 1000;
while (keepon) {
while(keepon) {
switch (Curl_poll(pfd, 2, interval_ms)) {
case -1: /* error, stop reading */
keepon = FALSE;
@ -1396,7 +1396,7 @@ static CURLcode Curl_telnet(struct connectdata *conn, bool *done)
/* if we receive 0 or less here, the server closed the connection and
we bail out from this! */
if (nread <= 0) {
if(nread <= 0) {
keepon = FALSE;
break;
}

View File

@ -188,12 +188,12 @@ checkhttpprefix(struct SessionHandle *data,
#ifdef CURL_DOES_CONVERSIONS
/* convert from the network encoding using a scratch area */
char *scratch = calloc(1, strlen(s)+1);
if (NULL == scratch) {
if(NULL == scratch) {
failf (data, "Failed to calloc memory for conversion!");
return FALSE; /* can't return CURLE_OUT_OF_MEMORY so return FALSE */
}
strcpy(scratch, s);
if (CURLE_OK != Curl_convert_from_network(data, scratch, strlen(s)+1)) {
if(CURLE_OK != Curl_convert_from_network(data, scratch, strlen(s)+1)) {
/* Curl_convert_from_network calls failf if unsuccessful */
free(scratch);
return FALSE; /* can't return CURLE_foobar so return FALSE */
@ -201,15 +201,15 @@ checkhttpprefix(struct SessionHandle *data,
s = scratch;
#endif /* CURL_DOES_CONVERSIONS */
while (head) {
if (checkprefix(head->data, s)) {
while(head) {
if(checkprefix(head->data, s)) {
rc = TRUE;
break;
}
head = head->next;
}
if ((rc != TRUE) && (checkprefix("HTTP/", s))) {
if((rc != TRUE) && (checkprefix("HTTP/", s))) {
rc = TRUE;
}
@ -292,7 +292,7 @@ static void read_rewind(struct connectdata *conn,
size_t show;
show = MIN(conn->buf_len - conn->read_pos, sizeof(buf)-1);
if (conn->master_buffer) {
if(conn->master_buffer) {
memcpy(buf, conn->master_buffer + conn->read_pos, show);
buf[show] = '\0';
}
@ -333,7 +333,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
if((k->keepon & (KEEP_READ|KEEP_READ_HOLD)) == KEEP_READ) {
fd_read = conn->sockfd;
#if defined(USE_LIBSSH2)
if (conn->protocol & (PROT_SCP|PROT_SFTP))
if(conn->protocol & (PROT_SCP|PROT_SFTP))
select_res |= CURL_CSELECT_IN;
#endif /* USE_LIBSSH2 */
} else
@ -344,7 +344,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
else
fd_write = CURL_SOCKET_BAD;
if (!select_res) { /* Call for select()/poll() only, if read/write/error
if(!select_res) { /* Call for select()/poll() only, if read/write/error
status is not known. */
select_res = Curl_socket_ready(fd_read, fd_write, 0);
}
@ -371,7 +371,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
size_t bytestoread = buffersize;
int readrc;
if (k->size != -1 && !k->header) {
if(k->size != -1 && !k->header) {
/* make sure we don't read "too much" if we can help it since we
might be pipelining and then someone else might want to read what
follows! */
@ -393,7 +393,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
if(result>0)
return result;
if ((k->bytecount == 0) && (k->writebytecount == 0)) {
if((k->bytecount == 0) && (k->writebytecount == 0)) {
Curl_pgrsTime(data, TIMER_STARTTRANSFER);
if(k->wait100_after_headers)
/* set time stamp to compare with when waiting for the 100 */
@ -405,10 +405,10 @@ CURLcode Curl_readwrite(struct connectdata *conn,
is_empty_data = (bool)((nread == 0) && (k->bodywrites == 0));
/* NULL terminate, allowing string ops to be used */
if (0 < nread || is_empty_data) {
if(0 < nread || is_empty_data) {
k->buf[nread] = 0;
}
else if (0 >= nread) {
else if(0 >= nread) {
/* if we receive 0 or less here, the server closed the connection
and we bail out from this! */
DEBUGF(infof(data, "nread <= 0, server closed connection, bailing\n"));
@ -422,7 +422,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
/* Since this is a two-state thing, we check if we are parsing
headers at the moment or not. */
if (k->header) {
if(k->header) {
/* we are in parse-the-header-mode */
bool stop_reading = FALSE;
@ -439,11 +439,11 @@ CURLcode Curl_readwrite(struct connectdata *conn,
/* data is in network encoding so use 0x0a instead of '\n' */
k->end_ptr = memchr(k->str_start, 0x0a, nread);
if (!k->end_ptr) {
if(!k->end_ptr) {
/* Not a complete header line within buffer, append the data to
the end of the headerbuff. */
if (k->hbuflen + nread >= data->state.headersize) {
if(k->hbuflen + nread >= data->state.headersize) {
/* We enlarge the header buffer as it is too small */
char *newbuff;
size_t newsize=CURLMAX((k->hbuflen+nread)*3/2,
@ -461,7 +461,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
memcpy(k->hbufp, k->str, nread);
k->hbufp += nread;
k->hbuflen += nread;
if (!k->headerline && (k->hbuflen>5)) {
if(!k->headerline && (k->hbuflen>5)) {
/* make a first check that this looks like a HTTP header */
if(!checkhttpprefix(data, data->state.headerbuff)) {
/* this is not the beginning of a HTTP first header line */
@ -488,7 +488,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
* fit in the allocated header buffer, or else we enlarge
* it.
*/
if (k->hbuflen + full_length >=
if(k->hbuflen + full_length >=
data->state.headersize) {
char *newbuff;
size_t newsize=CURLMAX((k->hbuflen+full_length)*3/2,
@ -537,23 +537,23 @@ CURLcode Curl_readwrite(struct connectdata *conn,
/* headers are in network encoding so
use 0x0a and 0x0d instead of '\n' and '\r' */
if ((0x0a == *k->p) || (0x0d == *k->p)) {
if((0x0a == *k->p) || (0x0d == *k->p)) {
size_t headerlen;
/* Zero-length header line means end of headers! */
#ifdef CURL_DOES_CONVERSIONS
if (0x0d == *k->p) {
if(0x0d == *k->p) {
*k->p = '\r'; /* replace with CR in host encoding */
k->p++; /* pass the CR byte */
}
if (0x0a == *k->p) {
if(0x0a == *k->p) {
*k->p = '\n'; /* replace with LF in host encoding */
k->p++; /* pass the LF byte */
}
#else
if ('\r' == *k->p)
if('\r' == *k->p)
k->p++; /* pass the \r byte */
if ('\n' == *k->p)
if('\n' == *k->p)
k->p++; /* pass the \n byte */
#endif /* CURL_DOES_CONVERSIONS */
@ -568,7 +568,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
k->header = TRUE;
k->headerline = 0; /* restart the header line counter */
/* if we did wait for this do enable write now! */
if (k->write_after_100_header) {
if(k->write_after_100_header) {
k->write_after_100_header = FALSE;
k->keepon |= KEEP_WRITE;
@ -590,7 +590,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
}
}
if (417 == k->httpcode) {
if(417 == k->httpcode) {
/*
* we got: "417 Expectation Failed" this means:
* we have made a HTTP call and our Expect Header
@ -606,7 +606,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
* When all the headers have been parsed, see if we should give
* up and return an error.
*/
if (Curl_http_should_fail(conn)) {
if(Curl_http_should_fail(conn)) {
failf (data, "The requested URL returned error: %d",
k->httpcode);
return CURLE_HTTP_RETURNED_ERROR;
@ -616,7 +616,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
/* now, only output this if the header AND body are requested:
*/
writetype = CLIENTWRITE_HEADER;
if (data->set.include_header)
if(data->set.include_header)
writetype |= CLIENTWRITE_BODY;
headerlen = k->p - data->state.headerbuff;
@ -633,7 +633,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
data->reqdata.keep.deductheadercount =
(100 == k->httpcode)?data->reqdata.keep.headerbytecount:0;
if (data->reqdata.resume_from &&
if(data->reqdata.resume_from &&
(data->set.httpreq==HTTPREQ_GET) &&
(k->httpcode == 416)) {
/* "Requested Range Not Satisfiable" */
@ -721,7 +721,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
* Checks for special headers coming up.
*/
if (!k->headerline++) {
if(!k->headerline++) {
/* This is the first header, it MUST be the error code line
or else we consider this to be the body right away! */
int httpversion_major;
@ -741,7 +741,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
res = Curl_convert_from_network(data,
&scratch[0],
SCRATCHSIZE);
if (CURLE_OK != res) {
if(CURLE_OK != res) {
/* Curl_convert_from_network calls failf if unsuccessful */
return res;
}
@ -754,7 +754,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
&httpversion_major,
&k->httpversion,
&k->httpcode);
if (nc==3) {
if(nc==3) {
k->httpversion += 10 * httpversion_major;
}
else {
@ -767,8 +767,8 @@ CURLcode Curl_readwrite(struct connectdata *conn,
/* If user has set option HTTP200ALIASES,
compare header line against list of aliases
*/
if (!nc) {
if (checkhttpprefix(data, k->p)) {
if(!nc) {
if(checkhttpprefix(data, k->p)) {
nc = 1;
k->httpcode = 200;
k->httpversion = 10;
@ -776,7 +776,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
}
}
if (nc) {
if(nc) {
data->info.httpcode = k->httpcode;
data->info.httpversion = k->httpversion;
@ -788,11 +788,11 @@ CURLcode Curl_readwrite(struct connectdata *conn,
* depending on how authentication is working. Other codes
* are definitely errors, so give up here.
*/
if (data->set.http_fail_on_error && (k->httpcode >= 400) &&
if(data->set.http_fail_on_error && (k->httpcode >= 400) &&
((k->httpcode != 401) || !conn->bits.user_passwd) &&
((k->httpcode != 407) || !conn->bits.proxy_user_passwd) ) {
if (data->reqdata.resume_from &&
if(data->reqdata.resume_from &&
(data->set.httpreq==HTTPREQ_GET) &&
(k->httpcode == 416)) {
/* "Requested Range Not Satisfiable", just proceed and
@ -848,7 +848,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
#ifdef CURL_DOES_CONVERSIONS
/* convert from the network encoding */
result = Curl_convert_from_network(data, k->p, strlen(k->p));
if (CURLE_OK != result) {
if(CURLE_OK != result) {
return(result);
}
/* Curl_convert_from_network calls failf if unsuccessful */
@ -858,10 +858,10 @@ CURLcode Curl_readwrite(struct connectdata *conn,
the header completely if we get a 416 response as then we're
resuming a document that we don't get, and this header contains
info about the true size of the document we didn't get now. */
if (!k->ignorecl && !data->set.ignorecl &&
if(!k->ignorecl && !data->set.ignorecl &&
checkprefix("Content-Length:", k->p)) {
contentlength = curlx_strtoofft(k->p+15, NULL, 10);
if (data->set.max_filesize &&
if(data->set.max_filesize &&
contentlength > data->set.max_filesize) {
failf(data, "Maximum file size exceeded");
return CURLE_FILESIZE_EXCEEDED;
@ -884,7 +884,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
}
}
/* check for Content-Type: header lines to get the mime-type */
else if (checkprefix("Content-Type:", k->p)) {
else if(checkprefix("Content-Type:", k->p)) {
char *start;
char *end;
size_t len;
@ -913,7 +913,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
Curl_safefree(data->info.contenttype);
data->info.contenttype = malloc(len + 1);
if (NULL == data->info.contenttype)
if(NULL == data->info.contenttype)
return CURLE_OUT_OF_MEMORY;
/* copy the content-type string */
@ -957,7 +957,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
conn->bits.close = FALSE; /* don't close when done */
infof(data, "HTTP/1.0 connection set to keep alive!\n");
}
else if (Curl_compareheader(k->p, "Connection:", "close")) {
else if(Curl_compareheader(k->p, "Connection:", "close")) {
/*
* [RFC 2616, section 8.1.2.1]
* "Connection: close" is HTTP/1.1 language and means that
@ -966,7 +966,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
*/
conn->bits.close = TRUE; /* close when done */
}
else if (Curl_compareheader(k->p,
else if(Curl_compareheader(k->p,
"Transfer-Encoding:", "chunked")) {
/*
* [RFC 2616, section 3.6.1] A 'chunked' transfer encoding
@ -982,7 +982,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
Curl_httpchunk_init(conn);
}
else if (checkprefix("Trailer:", k->p) ||
else if(checkprefix("Trailer:", k->p) ||
checkprefix("Trailers:", k->p)) {
/*
* This test helps Curl_httpchunk_read() to determine to look
@ -995,7 +995,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
conn->bits.trailerHdrPresent = TRUE;
}
else if (checkprefix("Content-Encoding:", k->p) &&
else if(checkprefix("Content-Encoding:", k->p) &&
data->set.str[STRING_ENCODING]) {
/*
* Process Content-Encoding. Look for the values: identity,
@ -1013,18 +1013,18 @@ CURLcode Curl_readwrite(struct connectdata *conn,
; /* empty loop */
/* Record the content-encoding for later use */
if (checkprefix("identity", start))
if(checkprefix("identity", start))
k->content_encoding = IDENTITY;
else if (checkprefix("deflate", start))
else if(checkprefix("deflate", start))
k->content_encoding = DEFLATE;
else if (checkprefix("gzip", start)
else if(checkprefix("gzip", start)
|| checkprefix("x-gzip", start))
k->content_encoding = GZIP;
else if (checkprefix("compress", start)
else if(checkprefix("compress", start)
|| checkprefix("x-compress", start))
k->content_encoding = COMPRESS;
}
else if (checkprefix("Content-Range:", k->p)) {
else if(checkprefix("Content-Range:", k->p)) {
/* Content-Range: bytes [num]-
Content-Range: bytes: [num]-
Content-Range: [num]-
@ -1042,7 +1042,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
k->offset = curlx_strtoofft(ptr, NULL, 10);
if (data->reqdata.resume_from == k->offset)
if(data->reqdata.resume_from == k->offset)
/* we asked for a resume and we got it */
k->content_range = TRUE;
}
@ -1077,7 +1077,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
if(result)
return result;
}
else if ((k->httpcode >= 300 && k->httpcode < 400) &&
else if((k->httpcode >= 300 && k->httpcode < 400) &&
checkprefix("Location:", k->p)) {
if(data->set.http_follow_location) {
/* this is the URL that the server advices us to get instead */
@ -1119,7 +1119,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
*/
writetype = CLIENTWRITE_HEADER;
if (data->set.include_header)
if(data->set.include_header)
writetype |= CLIENTWRITE_BODY;
if(data->set.verbose)
@ -1137,7 +1137,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
k->hbufp = data->state.headerbuff;
k->hbuflen = 0;
}
while (!stop_reading && *k->str); /* header line within buffer */
while(!stop_reading && *k->str); /* header line within buffer */
if(stop_reading)
/* We've stopped dealing with input, get out of the do-while loop */
@ -1152,7 +1152,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
/* This is not an 'else if' since it may be a rest from the header
parsing, where the beginning of the buffer is headers and the end
is non-headers. */
if (k->str && !k->header && (nread > 0 || is_empty_data)) {
if(k->str && !k->header && (nread > 0 || is_empty_data)) {
if(0 == k->bodywrites && !is_empty_data) {
/* These checks are only made the first time we are about to
@ -1160,7 +1160,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
if(conn->protocol&PROT_HTTP) {
/* HTTP-only checks */
if (data->reqdata.newurl) {
if(data->reqdata.newurl) {
if(conn->bits.close) {
/* Abort after the headers if "follow Location" is set
and we're set to close anyway. */
@ -1174,7 +1174,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
k->ignorebody = TRUE;
infof(data, "Ignoring the response-body\n");
}
if (data->reqdata.resume_from && !k->content_range &&
if(data->reqdata.resume_from && !k->content_range &&
(data->set.httpreq==HTTPREQ_GET) &&
!k->ignorebody) {
/* we wanted to resume a download, although the server doesn't
@ -1263,7 +1263,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
Push it back to be read on the next pass. */
dataleft = conn->chunk.dataleft;
if (dataleft != 0) {
if(dataleft != 0) {
infof(conn->data, "Leftovers after chunking. "
" Rewinding %d bytes\n",dataleft);
read_rewind(conn, dataleft);
@ -1278,7 +1278,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
/* The 'excess' amount below can't be more than BUFSIZE which
always will fit in a size_t */
size_t excess = (size_t)(k->bytecount + nread - k->maxdownload);
if (excess > 0 && !k->ignorebody) {
if(excess > 0 && !k->ignorebody) {
infof(data,
"Rewinding stream by : %d"
" bytes on url %s (size = %" FORMAT_OFF_T
@ -1360,9 +1360,9 @@ CURLcode Curl_readwrite(struct connectdata *conn,
return result;
}
} /* if (! header and data to read ) */
} /* if(! header and data to read ) */
if (is_empty_data) {
if(is_empty_data) {
/* if we received nothing, the server closed the connection and we
are done */
k->keepon &= ~KEEP_READ;
@ -1381,7 +1381,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
ssize_t bytes_written;
bool writedone=TRUE;
if ((k->bytecount == 0) && (k->writebytecount == 0))
if((k->bytecount == 0) && (k->writebytecount == 0))
Curl_pgrsTime(data, TIMER_STARTTRANSFER);
didwhat |= KEEP_WRITE;
@ -1427,7 +1427,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
/* the signed int typecase of nread of for systems that has
unsigned size_t */
if (nread<=0) {
if(nread<=0) {
/* done */
k->keepon &= ~KEEP_WRITE; /* we're done writing */
writedone = TRUE;
@ -1446,9 +1446,9 @@ CURLcode Curl_readwrite(struct connectdata *conn,
/* convert LF to CRLF if so asked */
#ifdef CURL_DO_LINEEND_CONV
/* always convert if we're FTPing in ASCII mode */
if ((data->set.crlf) || (data->set.prefer_ascii)) {
if((data->set.crlf) || (data->set.prefer_ascii)) {
#else
if (data->set.crlf) {
if(data->set.crlf) {
#endif /* CURL_DO_LINEEND_CONV */
if(data->state.scratch == NULL)
data->state.scratch = malloc(2*BUFSIZE);
@ -1463,10 +1463,10 @@ CURLcode Curl_readwrite(struct connectdata *conn,
* must be used instead of the escape sequences \r & \n.
*/
for(i = 0, si = 0; i < nread; i++, si++) {
if (data->reqdata.upload_fromhere[i] == 0x0a) {
if(data->reqdata.upload_fromhere[i] == 0x0a) {
data->state.scratch[si++] = 0x0d;
data->state.scratch[si] = 0x0a;
if (!data->set.crlf) {
if(!data->set.crlf) {
/* we're here only because FTP is in ASCII mode...
bump infilesize for the LF we just added */
data->set.infilesize++;
@ -1550,7 +1550,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
}
else {
/* no read no write, this is a timeout? */
if (k->write_after_100_header) {
if(k->write_after_100_header) {
/* This should allow some time for the header to arrive, but only a
very short time as otherwise it'll be too much wasted times too
often. */
@ -1577,12 +1577,12 @@ CURLcode Curl_readwrite(struct connectdata *conn,
result = CURLE_ABORTED_BY_CALLBACK;
else
result = Curl_speedcheck(data, k->now);
if (result)
if(result)
return result;
if (data->set.timeout &&
if(data->set.timeout &&
(Curl_tvdiff(k->now, k->start) >= data->set.timeout)) {
if (k->size != -1) {
if(k->size != -1) {
failf(data, "Operation timed out after %ld milliseconds with %"
FORMAT_OFF_T " out of %" FORMAT_OFF_T " bytes received",
data->set.timeout, k->bytecount, k->size);
@ -1680,7 +1680,7 @@ CURLcode Curl_readwrite_init(struct connectdata *conn)
Curl_pgrsSetUploadCounter(data, 0);
Curl_pgrsSetDownloadCounter(data, 0);
if (!conn->bits.getheader) {
if(!conn->bits.getheader) {
k->header = FALSE;
if(k->size > 0)
Curl_pgrsSetDownloadSize(data, k->size);
@ -1702,7 +1702,7 @@ CURLcode Curl_readwrite_init(struct connectdata *conn)
Thus, we must check if the request has been sent before we set the
state info where we wait for the 100-return code
*/
if (data->state.expect100header &&
if(data->state.expect100header &&
(data->reqdata.proto.http->sending == HTTPSEND_BODY)) {
/* wait with write until we either got 100-continue or a timeout */
k->write_after_100_header = TRUE;
@ -1819,14 +1819,14 @@ Transfer(struct connectdata *conn)
if(!conn->bits.getheader && conn->bits.no_body)
return CURLE_OK;
while (!done) {
while(!done) {
curl_socket_t fd_read;
curl_socket_t fd_write;
/* limit-rate logic: if speed exceeds threshold, then do not include fd in
select set. The current speed is recalculated in each Curl_readwrite()
call */
if ((k->keepon & KEEP_WRITE) &&
if((k->keepon & KEEP_WRITE) &&
(!data->set.max_send_speed ||
(data->progress.ulspeed < data->set.max_send_speed) )) {
fd_write = conn->writesockfd;
@ -1838,7 +1838,7 @@ Transfer(struct connectdata *conn)
k->keepon |= KEEP_WRITE_HOLD; /* hold it */
}
if ((k->keepon & KEEP_READ) &&
if((k->keepon & KEEP_READ) &&
(!data->set.max_recv_speed ||
(data->progress.dlspeed < data->set.max_recv_speed)) ) {
fd_read = conn->sockfd;
@ -2034,7 +2034,7 @@ CURLcode Curl_follow(struct SessionHandle *data,
char *newest;
if(!retry) {
if ((data->set.maxredirs != -1) &&
if((data->set.maxredirs != -1) &&
(data->set.followlocation >= data->set.maxredirs)) {
failf(data,"Maximum (%d) redirects followed", data->set.maxredirs);
return CURLE_TOO_MANY_REDIRECTS;
@ -2350,7 +2350,7 @@ Curl_connect_host(struct SessionHandle *data,
the Curl_connect(), we detect it here and act as if we are redirected
to the new URL */
urlchanged = data->change.url_changed;
if ((CURLE_OK == res) && urlchanged) {
if((CURLE_OK == res) && urlchanged) {
res = Curl_done(conn, res, FALSE);
if(CURLE_OK == res) {
char *gotourl = strdup(data->change.url);
@ -2359,7 +2359,7 @@ Curl_connect_host(struct SessionHandle *data,
free(gotourl);
}
}
} while (urlchanged && res == CURLE_OK);
} while(urlchanged && res == CURLE_OK);
return res;
}

192
lib/url.c
View File

@ -300,15 +300,15 @@ static CURLcode Curl_setstropt(char **charp, char * s)
/* Release the previous storage at `charp' and replace by a dynamic storage
copy of `s'. Return CURLE_OK or CURLE_OUT_OF_MEMORY. */
if (*charp) {
if(*charp) {
free(*charp);
*charp = (char *) NULL;
}
if (s) {
if(s) {
s = strdup(s);
if (!s)
if(!s)
return CURLE_OUT_OF_MEMORY;
*charp = s;
@ -332,7 +332,7 @@ CURLcode Curl_dupset(struct SessionHandle * dst, struct SessionHandle * src)
/* duplicate all strings */
for(i=(enum dupstring)0; i< STRING_LAST; i++) {
r = Curl_setstropt(&dst->set.str[i], src->set.str[i]);
if (r != CURLE_OK)
if(r != CURLE_OK)
break;
}
@ -454,8 +454,8 @@ CURLcode Curl_close(struct SessionHandle *data)
return CURLE_OK;
}
if ( ! (data->share && data->share->hostcache) ) {
if ( !Curl_global_host_cache_use(data)) {
if( ! (data->share && data->share->hostcache) ) {
if( !Curl_global_host_cache_use(data)) {
Curl_hash_destroy(data->dns.hostcache);
}
}
@ -493,19 +493,19 @@ CURLcode Curl_close(struct SessionHandle *data)
#if defined(CURL_DOES_CONVERSIONS) && defined(HAVE_ICONV)
/* close iconv conversion descriptors */
if (data->inbound_cd != (iconv_t)-1) {
if(data->inbound_cd != (iconv_t)-1) {
iconv_close(data->inbound_cd);
}
if (data->outbound_cd != (iconv_t)-1) {
if(data->outbound_cd != (iconv_t)-1) {
iconv_close(data->outbound_cd);
}
if (data->utf8_cd != (iconv_t)-1) {
if(data->utf8_cd != (iconv_t)-1) {
iconv_close(data->utf8_cd);
}
#endif /* CURL_DOES_CONVERSIONS && HAVE_ICONV */
/* No longer a dirty share, if it exists */
if (data->share) {
if(data->share) {
Curl_share_lock(data, CURL_LOCK_DATA_SHARE, CURL_LOCK_ACCESS_SINGLE);
data->share->dirty--;
Curl_share_unlock(data, CURL_LOCK_DATA_SHARE);
@ -526,7 +526,7 @@ struct conncache *Curl_mk_connc(int type,
struct conncache *c;
long default_amount;
if (type == CONNCACHE_PRIVATE) {
if(type == CONNCACHE_PRIVATE) {
default_amount = (amount < 0) ? 5 : amount;
}
else {
@ -537,7 +537,7 @@ struct conncache *Curl_mk_connc(int type,
if(!c)
return NULL;
if ((size_t)(default_amount) > ((size_t)-1) / sizeof(struct connectdata *))
if((size_t)(default_amount) > ((size_t)-1) / sizeof(struct connectdata *))
default_amount = ((size_t)-1) / sizeof(struct connectdata *);
c->connects = calloc(sizeof(struct connectdata *), (size_t)default_amount);
@ -650,10 +650,10 @@ CURLcode Curl_open(struct SessionHandle **curl)
data->magic = CURLEASY_MAGIC_NUMBER;
#ifdef USE_ARES
if ((status = ares_init(&data->state.areschannel)) != ARES_SUCCESS) {
if((status = ares_init(&data->state.areschannel)) != ARES_SUCCESS) {
DEBUGF(fprintf(stderr, "Error: ares_init failed\n"));
free(data);
if (status == ARES_ENOMEM)
if(status == ARES_ENOMEM)
return CURLE_OUT_OF_MEMORY;
else
return CURLE_FAILED_INIT;
@ -775,7 +775,7 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
case CURLOPT_DNS_USE_GLOBAL_CACHE:
{
long use_cache = va_arg(param, long);
if (use_cache)
if(use_cache)
Curl_global_host_cache_init();
data->set.global_dns_cache = (bool)(0 != use_cache);
@ -1032,14 +1032,14 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
*/
argptr = va_arg(param, char *);
if (!argptr || data->set.postfieldsize == -1)
if(!argptr || data->set.postfieldsize == -1)
result = Curl_setstropt(&data->set.str[STRING_COPYPOSTFIELDS], argptr);
else {
/*
* Check that requested length does not overflow the size_t type.
*/
if ((data->set.postfieldsize < 0) ||
if((data->set.postfieldsize < 0) ||
((sizeof(curl_off_t) != sizeof(size_t)) &&
(data->set.postfieldsize > (curl_off_t)((size_t)-1))))
result = CURLE_OUT_OF_MEMORY;
@ -1055,10 +1055,10 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
*/
p = malloc((size_t)(data->set.postfieldsize?data->set.postfieldsize:1));
if (!p)
if(!p)
result = CURLE_OUT_OF_MEMORY;
else {
if (data->set.postfieldsize)
if(data->set.postfieldsize)
memcpy(p, argptr, data->set.postfieldsize);
data->set.str[STRING_COPYPOSTFIELDS] = p;
@ -1087,7 +1087,7 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
*/
bigsize = va_arg(param, long);
if (data->set.postfieldsize < bigsize &&
if(data->set.postfieldsize < bigsize &&
data->set.postfields == data->set.str[STRING_COPYPOSTFIELDS]) {
/* Previous CURLOPT_COPYPOSTFIELDS is no longer valid. */
(void) Curl_setstropt(&data->set.str[STRING_COPYPOSTFIELDS], NULL);
@ -1104,7 +1104,7 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
*/
bigsize = va_arg(param, curl_off_t);
if (data->set.postfieldsize < bigsize &&
if(data->set.postfieldsize < bigsize &&
data->set.postfields == data->set.str[STRING_COPYPOSTFIELDS]) {
/* Previous CURLOPT_COPYPOSTFIELDS is no longer valid. */
(void) Curl_setstropt(&data->set.str[STRING_COPYPOSTFIELDS], NULL);
@ -1475,7 +1475,7 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
result = Curl_setstropt(&data->set.str[STRING_SET_URL],
va_arg(param, char *));
data->change.url = data->set.str[STRING_SET_URL];
if (data->change.url)
if(data->change.url)
data->change.url_changed = TRUE;
break;
case CURLOPT_PORT:
@ -1694,7 +1694,7 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
* String that holds the SSL crypto engine.
*/
argptr = va_arg(param, char *);
if (argptr && argptr[0])
if(argptr && argptr[0])
result = Curl_ssl_set_engine(data, argptr);
break;
@ -1849,7 +1849,7 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
#if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_COOKIES)
if(data->share->cookies) {
/* use shared cookie list, first free own one if any */
if (data->cookies)
if(data->cookies)
Curl_cookie_cleanup(data->cookies);
data->cookies = data->share->cookies;
}
@ -2049,7 +2049,7 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
static void conn_free(struct connectdata *conn)
{
if (!conn)
if(!conn)
return;
/* close possibly still open sockets */
@ -2161,7 +2161,7 @@ CURLcode Curl_disconnect(struct connectdata *conn)
Curl_ssl_close(conn, FIRSTSOCKET);
/* Indicate to all handles on the pipe that we're dead */
if (IsPipeliningEnabled(data)) {
if(IsPipeliningEnabled(data)) {
signalPipeClose(conn->send_pipe);
signalPipeClose(conn->recv_pipe);
}
@ -2192,7 +2192,7 @@ static bool SocketIsDead(curl_socket_t sock)
static bool IsPipeliningPossible(const struct SessionHandle *handle)
{
if (handle->multi && Curl_multi_canPipeline(handle->multi) &&
if(handle->multi && Curl_multi_canPipeline(handle->multi) &&
(handle->set.httpreq == HTTPREQ_GET ||
handle->set.httpreq == HTTPREQ_HEAD) &&
handle->set.httpversion != CURL_HTTP_VERSION_1_0)
@ -2203,7 +2203,7 @@ static bool IsPipeliningPossible(const struct SessionHandle *handle)
static bool IsPipeliningEnabled(const struct SessionHandle *handle)
{
if (handle->multi && Curl_multi_canPipeline(handle->multi))
if(handle->multi && Curl_multi_canPipeline(handle->multi))
return TRUE;
return FALSE;
@ -2219,7 +2219,7 @@ CURLcode Curl_addHandleToPipeline(struct SessionHandle *data,
infof(data, "PIPE when no PIPE supposed!\n");
}
#endif
if (!Curl_llist_insert_next(pipeline, pipeline->tail, data))
if(!Curl_llist_insert_next(pipeline, pipeline->tail, data))
return CURLE_OUT_OF_MEMORY;
return CURLE_OK;
}
@ -2231,8 +2231,8 @@ int Curl_removeHandleFromPipeline(struct SessionHandle *handle,
struct curl_llist_element *curr;
curr = pipeline->head;
while (curr) {
if (curr->ptr == handle) {
while(curr) {
if(curr->ptr == handle) {
Curl_llist_remove(pipeline, curr, NULL);
return 1; /* we removed a handle */
}
@ -2248,7 +2248,7 @@ static void Curl_printPipeline(struct curl_llist *pipeline)
struct curl_llist_element *curr;
curr = pipeline->head;
while (curr) {
while(curr) {
struct SessionHandle *data = (struct SessionHandle *) curr->ptr;
infof(data, "Handle in pipeline: %s\n", data->reqdata.path);
curr = curr->next;
@ -2260,7 +2260,7 @@ bool Curl_isHandleAtHead(struct SessionHandle *handle,
struct curl_llist *pipeline)
{
struct curl_llist_element *curr = pipeline->head;
if (curr) {
if(curr) {
return (bool)(curr->ptr == handle);
}
@ -2270,7 +2270,7 @@ bool Curl_isHandleAtHead(struct SessionHandle *handle,
static struct SessionHandle* gethandleathead(struct curl_llist *pipeline)
{
struct curl_llist_element *curr = pipeline->head;
if (curr) {
if(curr) {
return (struct SessionHandle *) curr->ptr;
}
@ -2281,11 +2281,11 @@ static void signalPipeClose(struct curl_llist *pipeline)
{
struct curl_llist_element *curr;
if (!pipeline)
if(!pipeline)
return;
curr = pipeline->head;
while (curr) {
while(curr) {
struct curl_llist_element *next = curr->next;
struct SessionHandle *data = (struct SessionHandle *) curr->ptr;
@ -2336,7 +2336,7 @@ ConnectionExists(struct SessionHandle *data,
pipeLen = check->send_pipe->size + check->recv_pipe->size;
if (check->connectindex == -1) {
if(check->connectindex == -1) {
check->connectindex = i; /* Set this appropriately since it might have
been set to -1 when the easy was removed
from the multi */
@ -2351,7 +2351,7 @@ ConnectionExists(struct SessionHandle *data,
#ifdef CURLRES_ASYNCH
/* ip_addr_str is NULL only if the resolving of the name hasn't completed
yet and until then we don't re-use this connection */
if (!check->ip_addr_str) {
if(!check->ip_addr_str) {
infof(data,
"Connection #%ld hasn't finished name resolve, can't reuse\n",
check->connectindex);
@ -2359,13 +2359,13 @@ ConnectionExists(struct SessionHandle *data,
}
#endif
if ((check->sock[FIRSTSOCKET] == CURL_SOCKET_BAD) || check->bits.close) {
if((check->sock[FIRSTSOCKET] == CURL_SOCKET_BAD) || check->bits.close) {
/* Don't pick a connection that hasn't connected yet or that is going to
get closed. */
infof(data, "Connection #%ld isn't open enough, can't reuse\n",
check->connectindex);
#ifdef CURLDEBUG
if (check->recv_pipe->size > 0) {
if(check->recv_pipe->size > 0) {
infof(data, "BAD! Unconnected #%ld has a non-empty recv pipeline!\n",
check->connectindex);
}
@ -2373,21 +2373,21 @@ ConnectionExists(struct SessionHandle *data,
continue;
}
if (pipeLen >= MAX_PIPELINE_LENGTH) {
if(pipeLen >= MAX_PIPELINE_LENGTH) {
infof(data, "Connection #%ld has its pipeline full, can't reuse\n",
check->connectindex);
continue;
}
if (canPipeline) {
if(canPipeline) {
/* Make sure the pipe has only GET requests */
struct SessionHandle* sh = gethandleathead(check->send_pipe);
struct SessionHandle* rh = gethandleathead(check->recv_pipe);
if (sh) {
if(sh) {
if(!IsPipeliningPossible(sh))
continue;
}
else if (rh) {
else if(rh) {
if(!IsPipeliningPossible(rh))
continue;
}
@ -2451,7 +2451,7 @@ ConnectionExists(struct SessionHandle *data,
}
if(match) {
if (!IsPipeliningEnabled(data)) {
if(!IsPipeliningEnabled(data)) {
/* The check for a dead socket makes sense only in the
non-pipelining case */
bool dead = SocketIsDead(check->sock[FIRSTSOCKET]);
@ -2468,7 +2468,7 @@ ConnectionExists(struct SessionHandle *data,
check->inuse = TRUE; /* mark this as being in use so that no other
handle in a multi stack may nick it */
if (canPipeline) {
if(canPipeline) {
/* Mark the connection as being in a pipeline */
check->is_in_pipeline = TRUE;
}
@ -2534,7 +2534,7 @@ static void
ConnectionDone(struct connectdata *conn)
{
conn->inuse = FALSE;
if (!conn->send_pipe && !conn->recv_pipe)
if(!conn->send_pipe && !conn->recv_pipe)
conn->is_in_pipeline = FALSE;
}
@ -2763,7 +2763,7 @@ CURLcode Curl_protocol_connect(struct connectdata *conn,
/* it has started, possibly even completed but that knowledge isn't stored
in this bit! */
if (!result)
if(!result)
conn->bits.protoconnstart = TRUE;
}
@ -2778,8 +2778,8 @@ static bool is_ASCII_name(const char *hostname)
{
const unsigned char *ch = (const unsigned char*)hostname;
while (*ch) {
if (*ch++ & 0x80)
while(*ch) {
if(*ch++ & 0x80)
return FALSE;
}
return TRUE;
@ -2802,24 +2802,24 @@ static bool tld_check_name(struct SessionHandle *data,
/* Convert (and downcase) ACE-name back into locale's character set */
rc = idna_to_unicode_lzlz(ace_hostname, &uc_name, 0);
if (rc != IDNA_SUCCESS)
if(rc != IDNA_SUCCESS)
return (FALSE);
rc = tld_check_lz(uc_name, &err_pos, NULL);
#ifndef CURL_DISABLE_VERBOSE_STRINGS
#ifdef HAVE_TLD_STRERROR
if (rc != TLD_SUCCESS)
if(rc != TLD_SUCCESS)
tld_errmsg = (char *)tld_strerror((Tld_rc)rc);
#endif
if (rc == TLD_INVALID)
if(rc == TLD_INVALID)
infof(data, "WARNING: %s; pos %u = `%c'/0x%02X\n",
tld_errmsg, err_pos, uc_name[err_pos],
uc_name[err_pos] & 255);
else if (rc != TLD_SUCCESS)
else if(rc != TLD_SUCCESS)
infof(data, "WARNING: TLD check for %s failed; %s\n",
uc_name, tld_errmsg);
#endif /* CURL_DISABLE_VERBOSE_STRINGS */
if (uc_name)
if(uc_name)
idn_free(uc_name);
return (bool)(rc == TLD_SUCCESS);
}
@ -2842,13 +2842,13 @@ static void fix_hostname(struct SessionHandle *data,
/*************************************************************
* Check name for non-ASCII and convert hostname to ACE form.
*************************************************************/
if (!is_ASCII_name(host->name) &&
if(!is_ASCII_name(host->name) &&
stringprep_check_version(LIBIDN_REQUIRED_VERSION)) {
char *ace_hostname = NULL;
int rc = idna_to_ascii_lz(host->name, &ace_hostname, 0);
infof (data, "Input domain encoded as `%s'\n",
stringprep_locale_charset ());
if (rc != IDNA_SUCCESS)
if(rc != IDNA_SUCCESS)
infof(data, "Failed to convert %s to ACE; %s\n",
host->name, Curl_idn_strerror(conn,rc));
else {
@ -2937,7 +2937,7 @@ static CURLcode ParseURLAndFillConnection(struct SessionHandle *data,
/* clear path */
path[0]=0;
if (2 > sscanf(data->change.url,
if(2 > sscanf(data->change.url,
"%15[^\n:]://%[^\n/]%[^\n]",
conn->protostr,
conn->host.name, path)) {
@ -2965,9 +2965,9 @@ static CURLcode ParseURLAndFillConnection(struct SessionHandle *data,
if(checkprefix("FTP.", conn->host.name))
strcpy(conn->protostr, "ftp");
else if (checkprefix("DICT.", conn->host.name))
else if(checkprefix("DICT.", conn->host.name))
strcpy(conn->protostr, "DICT");
else if (checkprefix("LDAP.", conn->host.name))
else if(checkprefix("LDAP.", conn->host.name))
strcpy(conn->protostr, "LDAP");
else {
strcpy(conn->protostr, "http");
@ -3053,8 +3053,8 @@ static CURLcode setup_range(struct SessionHandle *data)
struct HandleData *req = &data->reqdata;
req->resume_from = data->set.set_resume_from;
if (req->resume_from || data->set.str[STRING_SET_RANGE]) {
if (req->rangestringalloc)
if(req->resume_from || data->set.str[STRING_SET_RANGE]) {
if(req->rangestringalloc)
free(req->range);
if(req->resume_from)
@ -3092,14 +3092,14 @@ static CURLcode setup_connection_internals(struct SessionHandle *data,
/* Scan protocol handler table. */
for (pp = protocols; (p = *pp) != NULL; pp++)
if (strequal(p->scheme, conn->protostr)) {
if(strequal(p->scheme, conn->protostr)) {
/* Protocol found in table. Perform setup complement if some. */
conn->handler = p;
if (p->setup_connection) {
if(p->setup_connection) {
result = (*p->setup_connection)(conn);
if (result != CURLE_OK)
if(result != CURLE_OK)
return result;
p = conn->handler; /* May have changed. */
@ -3229,7 +3229,7 @@ static char *detect_proxy(struct connectdata *conn)
conn->bits.httpproxy = TRUE;
}
}
} /* if (!nope) - it wasn't specified non-proxy */
} /* if(!nope) - it wasn't specified non-proxy */
} /* NO_PROXY wasn't specified or '*' */
if(no_proxy)
free(no_proxy);
@ -3338,7 +3338,7 @@ static CURLcode parse_proxy(struct SessionHandle *data,
/* Get port number off proxy.server.com:1080 */
prox_portno = strchr(portptr, ':');
if (prox_portno) {
if(prox_portno) {
*prox_portno = 0x0; /* cut off number from host name */
prox_portno ++;
/* now set the local port number */
@ -3507,18 +3507,18 @@ static CURLcode CreateConnection(struct SessionHandle *data,
conn->bits.ftp_use_epsv = data->set.ftp_use_epsv;
conn->bits.ftp_use_eprt = data->set.ftp_use_eprt;
if (data->multi && Curl_multi_canPipeline(data->multi) &&
if(data->multi && Curl_multi_canPipeline(data->multi) &&
!conn->master_buffer) {
/* Allocate master_buffer to be used for pipelining */
conn->master_buffer = calloc(BUFSIZE, sizeof (char));
if (!conn->master_buffer)
if(!conn->master_buffer)
return CURLE_OUT_OF_MEMORY;
}
/* Initialize the pipeline lists */
conn->send_pipe = Curl_llist_alloc((curl_llist_dtor) llist_dtor);
conn->recv_pipe = Curl_llist_alloc((curl_llist_dtor) llist_dtor);
if (!conn->send_pipe || !conn->recv_pipe)
if(!conn->send_pipe || !conn->recv_pipe)
return CURLE_OUT_OF_MEMORY;
/* This initing continues below, see the comment "Continue connectdata
@ -3556,7 +3556,7 @@ static CURLcode CreateConnection(struct SessionHandle *data,
conn->host.name[0] = 0;
result = ParseURLAndFillConnection(data, conn);
if (result != CURLE_OK) {
if(result != CURLE_OK) {
return result;
}
@ -3565,14 +3565,14 @@ static CURLcode CreateConnection(struct SessionHandle *data,
*************************************************************/
if(conn->bits.proxy_user_passwd) {
result = parse_proxy_auth(data, conn);
if (result != CURLE_OK)
if(result != CURLE_OK)
return result;
}
/*************************************************************
* Detect what (if any) proxy to use
*************************************************************/
if (data->set.str[STRING_PROXY]) {
if(data->set.str[STRING_PROXY]) {
proxy = strdup(data->set.str[STRING_PROXY]);
/* if global proxy is set, this is it */
if(NULL == proxy) {
@ -3581,9 +3581,9 @@ static CURLcode CreateConnection(struct SessionHandle *data,
}
}
if (!proxy)
if(!proxy)
proxy = detect_proxy(conn);
if (proxy && !*proxy) {
if(proxy && !*proxy) {
free(proxy); /* Don't bother with an empty proxy string */
proxy = NULL;
}
@ -3614,7 +3614,7 @@ static CURLcode CreateConnection(struct SessionHandle *data,
* Setup internals depending on protocol
*************************************************************/
result = setup_connection_internals(data, conn);
if (result != CURLE_OK) {
if(result != CURLE_OK) {
Curl_safefree(proxy);
return result;
}
@ -3625,11 +3625,11 @@ static CURLcode CreateConnection(struct SessionHandle *data,
* host name, so that we can re-use an existing connection
* that may exist registered to the same proxy host.
***********************************************************************/
if (proxy) {
if(proxy) {
result = parse_proxy(data, conn, proxy);
/* parse_proxy has freed the proxy string, so don't try to use it again */
proxy = NULL;
if (result != CURLE_OK)
if(result != CURLE_OK)
return result;
}
@ -3704,7 +3704,7 @@ static CURLcode CreateConnection(struct SessionHandle *data,
user[0] =0; /* to make everything well-defined */
passwd[0]=0;
if (conn->protocol & (PROT_FTP|PROT_HTTP|PROT_SCP|PROT_SFTP)) {
if(conn->protocol & (PROT_FTP|PROT_HTTP|PROT_SCP|PROT_SFTP)) {
/* This is a FTP, HTTP, SCP or SFTP URL, we will now try to extract the
* possible user+password pair in a string like:
* ftp://user:password@ftp.my.site:8021/README */
@ -3721,7 +3721,7 @@ static CURLcode CreateConnection(struct SessionHandle *data,
* set user/passwd, but doing that first adds more cases here :-(
*/
if (data->set.use_netrc != CURL_NETRC_REQUIRED) {
if(data->set.use_netrc != CURL_NETRC_REQUIRED) {
/* We could use the one in the URL */
conn->bits.user_passwd = 1; /* enable user+password */
@ -3747,7 +3747,7 @@ static CURLcode CreateConnection(struct SessionHandle *data,
the unconverted name, it'll be wrong but what the heck */
free(newname);
}
if (passwd[0]) {
if(passwd[0]) {
/* we have a password found in the URL, decode it! */
char *newpasswd=curl_easy_unescape(data, passwd, 0, NULL);
if(!newpasswd)
@ -3810,7 +3810,7 @@ static CURLcode CreateConnection(struct SessionHandle *data,
data->change.url_alloc = TRUE;
}
}
else if (tmp) {
else if(tmp) {
/* no CURLOPT_PORT given, extract the one from the URL */
char *rest;
@ -3818,11 +3818,11 @@ static CURLcode CreateConnection(struct SessionHandle *data,
port=strtoul(tmp+1, &rest, 10); /* Port number must be decimal */
if (rest != (tmp+1) && *rest == '\0') {
if(rest != (tmp+1) && *rest == '\0') {
/* The colon really did have only digits after it,
* so it is either a port number or a mistake */
if (port > 0xffff) { /* Single unix standard says port numbers are
if(port > 0xffff) { /* Single unix standard says port numbers are
* 16 bits long */
failf(data, "Port number too large: %lu", port);
return CURLE_URL_MALFORMAT;
@ -3842,7 +3842,7 @@ static CURLcode CreateConnection(struct SessionHandle *data,
* user_password is set in "inherit initial knowledge' above,
* so it doesn't have to be set in this block
*/
if (data->set.str[STRING_USERPWD] != NULL) {
if(data->set.str[STRING_USERPWD] != NULL) {
/* the name is given, get user+password */
sscanf(data->set.str[STRING_USERPWD],
"%" MAX_CURL_USER_LENGTH_TXT "[^:]:"
@ -3851,7 +3851,7 @@ static CURLcode CreateConnection(struct SessionHandle *data,
}
conn->bits.netrc = FALSE;
if (data->set.use_netrc != CURL_NETRC_IGNORED) {
if(data->set.use_netrc != CURL_NETRC_IGNORED) {
if(Curl_parsenetrc(conn->host.name,
user, passwd,
data->set.str[STRING_NETRC_FILE])) {
@ -3870,7 +3870,7 @@ static CURLcode CreateConnection(struct SessionHandle *data,
}
/* If our protocol needs a password and we have none, use the defaults */
if ( (conn->protocol & PROT_FTP) &&
if( (conn->protocol & PROT_FTP) &&
!conn->bits.user_passwd) {
conn->user = strdup(CURL_DEFAULT_USER);
@ -3941,7 +3941,7 @@ static CURLcode CreateConnection(struct SessionHandle *data,
/* get the user+password information from the old_conn struct since it may
* be new for this request even when we re-use an existing connection */
conn->bits.user_passwd = old_conn->bits.user_passwd;
if (conn->bits.user_passwd) {
if(conn->bits.user_passwd) {
/* use the new user namd and password though */
Curl_safefree(conn->user);
Curl_safefree(conn->passwd);
@ -3952,7 +3952,7 @@ static CURLcode CreateConnection(struct SessionHandle *data,
}
conn->bits.proxy_user_passwd = old_conn->bits.proxy_user_passwd;
if (conn->bits.proxy_user_passwd) {
if(conn->bits.proxy_user_passwd) {
/* use the new proxy user name and proxy password though */
Curl_safefree(conn->proxyuser);
Curl_safefree(conn->proxypasswd);
@ -3963,7 +3963,7 @@ static CURLcode CreateConnection(struct SessionHandle *data,
}
/* host can change, when doing keepalive with a proxy ! */
if (conn->bits.proxy) {
if(conn->bits.proxy) {
free(conn->host.rawalloc);
conn->host=old_conn->host;
}
@ -4013,7 +4013,7 @@ static CURLcode CreateConnection(struct SessionHandle *data,
conn->fread_func = data->set.fread_func;
conn->fread_in = data->set.in;
if ((conn->protocol&PROT_HTTP) &&
if((conn->protocol&PROT_HTTP) &&
data->set.upload &&
(data->set.infilesize == -1) &&
(data->set.httpversion != CURL_HTTP_VERSION_1_0)) {
@ -4098,7 +4098,7 @@ static CURLcode CreateConnection(struct SessionHandle *data,
hostaddr = NULL;
/* we'll need to clear conn->dns_entry later in Curl_disconnect() */
if (conn->bits.proxy)
if(conn->bits.proxy)
fix_hostname(data, conn, &conn->host);
}
else {
@ -4261,7 +4261,7 @@ static CURLcode SetupConnection(struct connectdata *conn,
authentication information */
if(conn->bits.proxy_connect_closed) {
/* reset the error buffer */
if (data->set.errorbuffer)
if(data->set.errorbuffer)
data->set.errorbuffer[0] = '\0';
data->state.errorbuf = FALSE;
continue;
@ -4291,7 +4291,7 @@ static CURLcode SetupConnection(struct connectdata *conn,
* characters (you get mangled text files, and corrupted binary files when
* you download to stdout and redirect it to a file). */
if ((data->set.out)->_handle == NULL) {
if((data->set.out)->_handle == NULL) {
_fsetmode(stdout, "b");
}
#endif
@ -4332,7 +4332,7 @@ CURLcode Curl_connect(struct SessionHandle *data,
}
}
else {
if ((*in_connect)->is_in_pipeline)
if((*in_connect)->is_in_pipeline)
data->state.is_in_pipeline = TRUE;
}
@ -4528,7 +4528,7 @@ CURLcode Curl_do_more(struct connectdata *conn)
void Curl_reset_reqproto(struct connectdata *conn)
{
struct SessionHandle *data = conn->data;
if (data->reqdata.proto.generic && data->reqdata.current_conn != conn) {
if(data->reqdata.proto.generic && data->reqdata.current_conn != conn) {
free(data->reqdata.proto.generic);
data->reqdata.proto.generic = NULL;
}