summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2011-04-20 15:17:42 +0200
committerDaniel Stenberg <daniel@haxx.se>2011-04-27 09:09:35 +0200
commitb903186fa0189ff241d756d25d07fdfe9885ae49 (patch)
treebd942ac8753469172661b0d30153986378337fdf /lib
parent592eda8e3feb1bf8d0f85c2baa485323b315f9d9 (diff)
downloadcurl-b903186fa0189ff241d756d25d07fdfe9885ae49.tar.gz
source cleanup: unify look, style and indent levels
By the use of a the new lib/checksrc.pl script that checks that our basic source style rules are followed.
Diffstat (limited to 'lib')
-rw-r--r--lib/Makefile.am3
-rw-r--r--lib/asyn-ares.c7
-rw-r--r--lib/asyn-thread.c51
-rw-r--r--lib/axtls.c5
-rw-r--r--lib/base64.c2
-rwxr-xr-xlib/checksrc.pl118
-rw-r--r--lib/connect.c22
-rw-r--r--lib/content_encoding.c4
-rw-r--r--lib/cookie.c10
-rw-r--r--lib/curl_addrinfo.c4
-rw-r--r--lib/curl_fnmatch.c4
-rw-r--r--lib/curl_memrchr.c6
-rw-r--r--lib/curl_rtmp.c36
-rw-r--r--lib/curl_threads.c5
-rw-r--r--lib/cyassl.c36
-rw-r--r--lib/dict.c2
-rw-r--r--lib/easy.c6
-rw-r--r--lib/escape.c3
-rw-r--r--lib/file.c14
-rw-r--r--lib/formdata.c247
-rw-r--r--lib/ftp.c52
-rw-r--r--lib/ftp.h10
-rw-r--r--lib/ftplistparser.c10
-rw-r--r--lib/gopher.c10
-rw-r--r--lib/gtls.c44
-rw-r--r--lib/hash.c24
-rw-r--r--lib/hmac.c12
-rw-r--r--lib/hostip.c6
-rw-r--r--lib/hostip6.c2
-rw-r--r--lib/http.c36
-rw-r--r--lib/http_digest.c4
-rw-r--r--lib/http_negotiate.c79
-rw-r--r--lib/http_negotiate_sspi.c20
-rw-r--r--lib/http_ntlm.c76
-rw-r--r--lib/http_proxy.c5
-rw-r--r--lib/idn_win32.c30
-rw-r--r--lib/if2ip.c16
-rw-r--r--lib/imap.c2
-rw-r--r--lib/imap.h7
-rw-r--r--lib/inet_ntop.c48
-rw-r--r--lib/inet_pton.c2
-rw-r--r--lib/krb4.c8
-rw-r--r--lib/krb4.h5
-rw-r--r--lib/krb5.c8
-rw-r--r--lib/ldap.c73
-rw-r--r--lib/llist.c8
-rw-r--r--lib/md4.c15
-rw-r--r--lib/md5.c8
-rw-r--r--lib/memdebug.h8
-rw-r--r--lib/mprintf.c146
-rw-r--r--lib/multi.c69
-rw-r--r--lib/non-ascii.c8
-rw-r--r--lib/nss.c63
-rw-r--r--lib/openldap.c138
-rw-r--r--lib/parsedate.c7
-rw-r--r--lib/pingpong.c10
-rw-r--r--lib/polarssl.c11
-rw-r--r--lib/pop3.c8
-rw-r--r--lib/progress.c8
-rw-r--r--lib/qssl.c4
-rw-r--r--lib/rawstr.c6
-rw-r--r--lib/rawstr.h3
-rw-r--r--lib/rtsp.c12
-rw-r--r--lib/security.c10
-rw-r--r--lib/select.c10
-rw-r--r--lib/sendf.c6
-rw-r--r--lib/setup.h13
-rw-r--r--lib/share.c39
-rw-r--r--lib/slist.c4
-rw-r--r--lib/smtp.c37
-rw-r--r--lib/smtp.h5
-rw-r--r--lib/socks.c25
-rw-r--r--lib/socks_gssapi.c5
-rw-r--r--lib/socks_sspi.c36
-rw-r--r--lib/splay.c17
-rw-r--r--lib/ssh.c22
-rw-r--r--lib/sslgen.c4
-rw-r--r--lib/ssluse.c111
-rw-r--r--lib/strerror.c5
-rw-r--r--lib/strtoofft.c8
-rw-r--r--lib/telnet.c683
-rw-r--r--lib/tftp.c44
-rw-r--r--lib/transfer.c49
-rw-r--r--lib/transfer.h5
-rw-r--r--lib/url.c117
-rw-r--r--lib/url.h3
-rw-r--r--lib/urldata.h9
-rw-r--r--lib/version.c7
88 files changed, 1407 insertions, 1573 deletions
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 0c7497f62..7c24e5461 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -184,3 +184,6 @@ $(VCPROJ): vc8proj.head vc8proj.foot Makefile.am
echo "<File RelativePath=\""$$file"\"></File>" $(VCPROJOUT); \
done; \
cat $(srcdir)/vc8proj.foot $(VCPROJOUT) )
+
+all-local:
+ @for i in $(CSOURCES) $(HHEADERS); do $(top_srcdir)/lib/checksrc.pl $(top_srcdir)/lib/$$i; done
diff --git a/lib/asyn-ares.c b/lib/asyn-ares.c
index 6b71e0384..308ebdc4f 100644
--- a/lib/asyn-ares.c
+++ b/lib/asyn-ares.c
@@ -424,7 +424,7 @@ CURLcode Curl_resolver_wait_resolv(struct connectdata *conn,
if(!conn->async.dns) {
/* a name was not resolved */
if((timeout < 0) || (conn->async.status == ARES_ETIMEOUT)) {
- if (conn->bits.httpproxy) {
+ if(conn->bits.httpproxy) {
failf(data, "Resolving proxy timed out: %s", conn->proxy.dispname);
rc = CURLE_COULDNT_RESOLVE_PROXY;
}
@@ -434,7 +434,7 @@ CURLcode Curl_resolver_wait_resolv(struct connectdata *conn,
}
}
else if(conn->async.done) {
- if (conn->bits.httpproxy) {
+ if(conn->bits.httpproxy) {
failf(data, "Could not resolve proxy: %s (%s)", conn->proxy.dispname,
ares_strerror(conn->async.status));
rc = CURLE_COULDNT_RESOLVE_PROXY;
@@ -542,10 +542,9 @@ Curl_addrinfo *Curl_resolver_getaddrinfo(struct connectdata *conn,
#ifdef ENABLE_IPV6 /* CURLRES_IPV6 */
/* Otherwise, check if this is an IPv6 address string */
- if (Curl_inet_pton (AF_INET6, hostname, &in6) > 0) {
+ if(Curl_inet_pton (AF_INET6, hostname, &in6) > 0)
/* This must be an IPv6 address literal. */
return Curl_ip2addr(AF_INET6, &in6, hostname, port);
- }
switch(conn->ip_version) {
default:
diff --git a/lib/asyn-thread.c b/lib/asyn-thread.c
index a3cd4d896..be3b2b51e 100644
--- a/lib/asyn-thread.c
+++ b/lib/asyn-thread.c
@@ -193,7 +193,7 @@ static struct thread_sync_data *conn_thread_sync_data(struct connectdata *conn)
static
void destroy_thread_sync_data(struct thread_sync_data * tsd)
{
- if (tsd->mtx) {
+ if(tsd->mtx) {
Curl_mutex_destroy(tsd->mtx);
free(tsd->mtx);
}
@@ -201,7 +201,7 @@ void destroy_thread_sync_data(struct thread_sync_data * tsd)
if(tsd->hostname)
free(tsd->hostname);
- if (tsd->res)
+ if(tsd->res)
Curl_freeaddrinfo(tsd->res);
memset(tsd,0,sizeof(*tsd));
@@ -225,7 +225,8 @@ int init_thread_sync_data(struct thread_sync_data * tsd,
#endif
tsd->mtx = malloc(sizeof(curl_mutex_t));
- if (tsd->mtx == NULL) goto err_exit;
+ if(tsd->mtx == NULL)
+ goto err_exit;
Curl_mutex_init(tsd->mtx);
@@ -235,7 +236,8 @@ int init_thread_sync_data(struct thread_sync_data * tsd,
* thread during gethostbyname execution.
*/
tsd->hostname = strdup(hostname);
- if (!tsd->hostname) goto err_exit;
+ if(!tsd->hostname)
+ goto err_exit;
return 1;
@@ -278,9 +280,9 @@ static unsigned int CURL_STDCALL getaddrinfo_thread (void *arg)
rc = Curl_getaddrinfo_ex(tsd->hostname, service, &tsd->hints, &tsd->res);
- if (rc != 0) {
+ if(rc != 0) {
tsd->sock_error = SOCKERRNO;
- if (tsd->sock_error == 0)
+ if(tsd->sock_error == 0)
tsd->sock_error = ENOMEM;
}
@@ -302,9 +304,9 @@ static unsigned int CURL_STDCALL gethostbyname_thread (void *arg)
tsd->res = Curl_ipv4_resolve_r(tsd->hostname, tsd->port);
- if (!tsd->res) {
+ if(!tsd->res) {
tsd->sock_error = SOCKERRNO;
- if (tsd->sock_error == 0)
+ if(tsd->sock_error == 0)
tsd->sock_error = ENOMEM;
}
@@ -328,10 +330,10 @@ static void destroy_async_data (struct Curl_async *async)
if(async->os_specific) {
struct thread_data *td = (struct thread_data*) async->os_specific;
- if (td->dummy_sock != CURL_SOCKET_BAD)
+ if(td->dummy_sock != CURL_SOCKET_BAD)
sclose(td->dummy_sock);
- if (td->thread_hnd != curl_thread_t_null)
+ if(td->thread_hnd != curl_thread_t_null)
Curl_thread_join(&td->thread_hnd);
destroy_thread_sync_data(&td->tsd);
@@ -366,7 +368,7 @@ static bool init_resolve_thread (struct connectdata *conn,
td->dummy_sock = CURL_SOCKET_BAD;
td->thread_hnd = curl_thread_t_null;
- if (!init_thread_sync_data(&td->tsd, hostname, port, hints))
+ if(!init_thread_sync_data(&td->tsd, hostname, port, hints))
goto err_exit;
Curl_safefree(conn->async.hostname);
@@ -380,7 +382,7 @@ static bool init_resolve_thread (struct connectdata *conn,
* Windows needs at least 1 socket in select().
*/
td->dummy_sock = socket(AF_INET, SOCK_DGRAM, 0);
- if (td->dummy_sock == CURL_SOCKET_BAD)
+ if(td->dummy_sock == CURL_SOCKET_BAD)
goto err_exit;
#endif
@@ -428,11 +430,10 @@ CURLcode Curl_resolver_wait_resolv(struct connectdata *conn,
DEBUGASSERT(conn && td);
/* wait for the thread to resolve the name */
- if (Curl_thread_join(&td->thread_hnd)) {
+ if(Curl_thread_join(&td->thread_hnd))
rc = getaddrinfo_complete(conn);
- } else {
+ else
DEBUGASSERT(0);
- }
conn->async.done = TRUE;
@@ -441,11 +442,12 @@ CURLcode Curl_resolver_wait_resolv(struct connectdata *conn,
if(!conn->async.dns) {
/* a name was not resolved */
- if (conn->bits.httpproxy) {
+ if(conn->bits.httpproxy) {
failf(data, "Could not resolve proxy: %s; %s",
conn->async.hostname, Curl_strerror(conn, conn->async.status));
rc = CURLE_COULDNT_RESOLVE_PROXY;
- } else {
+ }
+ else {
failf(data, "Could not resolve host: %s; %s",
conn->async.hostname, Curl_strerror(conn, conn->async.status));
rc = CURLE_COULDNT_RESOLVE_HOST;
@@ -474,7 +476,7 @@ CURLcode Curl_resolver_is_resolved(struct connectdata *conn,
*entry = NULL;
- if (!td) {
+ if(!td) {
DEBUGASSERT(td);
return CURLE_COULDNT_RESOLVE_HOST;
}
@@ -483,7 +485,7 @@ CURLcode Curl_resolver_is_resolved(struct connectdata *conn,
done = td->tsd.done;
Curl_mutex_release(td->tsd.mtx);
- if (done) {
+ if(done) {
getaddrinfo_complete(conn);
destroy_async_data(&conn->async);
@@ -493,20 +495,21 @@ CURLcode Curl_resolver_is_resolved(struct connectdata *conn,
return CURLE_COULDNT_RESOLVE_HOST;
}
*entry = conn->async.dns;
- } else {
+ }
+ else {
/* poll for name lookup done with exponential backoff up to 250ms */
int elapsed = Curl_tvdiff(Curl_tvnow(), data->progress.t_startsingle);
- if (elapsed < 0)
+ if(elapsed < 0)
elapsed = 0;
- if (td->poll_interval == 0)
+ if(td->poll_interval == 0)
/* Start at 1ms poll interval */
td->poll_interval = 1;
- else if (elapsed >= td->interval_end)
+ else if(elapsed >= td->interval_end)
/* Back-off exponentially if last interval expired */
td->poll_interval *= 2;
- if (td->poll_interval > 250)
+ if(td->poll_interval > 250)
td->poll_interval = 250;
td->interval_end = elapsed + td->poll_interval;
diff --git a/lib/axtls.c b/lib/axtls.c
index b6d93e909..ffbd1d4f3 100644
--- a/lib/axtls.c
+++ b/lib/axtls.c
@@ -82,8 +82,7 @@ int Curl_axtls_cleanup(void)
static CURLcode map_error_to_curl(int axtls_err)
{
- switch (axtls_err)
- {
+ switch (axtls_err) {
case SSL_ERROR_NOT_SUPPORTED:
case SSL_ERROR_INVALID_VERSION:
case -70: /* protocol version alert from server */
@@ -416,7 +415,7 @@ int Curl_axtls_shutdown(struct connectdata *conn, int sockindex)
nread = (ssize_t)SSL_read(conn->ssl[sockindex].ssl, buf,
sizeof(buf));
- if (nread < SSL_OK){
+ if(nread < SSL_OK){
failf(data, "close notify alert not received during shutdown");
retval = -1;
}
diff --git a/lib/base64.c b/lib/base64.c
index 0c492dc45..ae7e436ff 100644
--- a/lib/base64.c
+++ b/lib/base64.c
@@ -171,7 +171,7 @@ size_t Curl_base64_encode(struct SessionHandle *data,
indata = (char *)convbuf;
while(insize > 0) {
- for (i = inputparts = 0; i < 3; i++) {
+ for(i = inputparts = 0; i < 3; i++) {
if(insize > 0) {
inputparts++;
ibuf[i] = (unsigned char) *indata;
diff --git a/lib/checksrc.pl b/lib/checksrc.pl
new file mode 100755
index 000000000..2ec315bf4
--- /dev/null
+++ b/lib/checksrc.pl
@@ -0,0 +1,118 @@
+#!/usr/bin/perl
+
+my $file=$ARGV[0];
+
+my $max_column = 79;
+my $indent = 2;
+
+sub checkwarn {
+ my ($num, $col, $file, $line, $msg, $error) = @_;
+
+ my $w=$error?"error":"warning";
+
+ $col++;
+ print "$file:$num:$col: $w: $msg\n";
+ print " $line\n";
+
+ if($col < 80) {
+ my $pref = (' ' x $col);
+ print "${pref}^\n";
+ }
+}
+
+if(!$file) {
+ print "checksrc.pl <single C or H file>\n";
+ exit;
+}
+
+
+my $line = 1;
+open(R, "<$file") || die;
+
+my $copyright=0;
+
+while(<R>) {
+ chomp;
+ my $l = $_;
+ my $column = 0;
+
+ # check for a copyright statement
+ if(!$copyright && ($l =~ /copyright .* \d\d\d\d/i)) {
+ $copyright=1;
+ }
+
+ # detect long lines
+ if(length($l) > $max_column) {
+ checkwarn($line, length($l), $file, $l, "Longer than $max_column columns");
+ }
+ # detect TAB characters
+ if($l =~ /^(.*)\t/) {
+ checkwarn($line, length($1), $file, $l, "Contains TAB character", 1);
+ }
+ # detect trailing white space
+ if($l =~ /^(\S+)[ \t]+\z/) {
+ checkwarn($line, length($1), $file, $l, "Trailing whitespace");
+ }
+
+ # detect return statements with parenthesis
+ # doesn't really work unless we filter off typecasts
+ #if($l =~ /(.*)return \(/) {
+ # checkwarn($line, length($1)+6, $file, $l, "return with paretheses");
+ #}
+
+ # check spaces after for/if/while
+ if($l =~ /^(.*)(for|if|while) \(/) {
+ if($1 =~ / *\#/) {
+ # this is a #if, treat it differently
+ }
+ else {
+ checkwarn($line, length($1)+length($2), $file, $l,
+ "$2 with space");
+ }
+ }
+ # check for "} else"
+ if($l =~ /^(.*)\} else/) {
+ checkwarn($line, length($1), $file, $l, "else after closing brace on same line");
+ }
+ # check for open brace first on line but not first column
+ # only alert if previous line ended with a close paren and wasn't a cpp
+ # line
+ if((($prevl =~ /\)\z/) && ($prevl !~ /^ *#/)) && ($l =~ /^( +)\{/)) {
+ checkwarn($line, length($1), $file, $l, "badly placed open brace");
+ }
+
+ # if the previous line starts with if/while/for AND ends with an open
+ # brace, check that this line is indented $indent more steps, if not
+ # a cpp line
+ if($prevl =~ /^( *)(if|while|for)\(.*\{\z/) {
+ my $first = length($1);
+
+ # this line has some character besides spaces
+ if(($l !~ /^ *#/) && ($l =~ /^( *)[^ ]/)) {
+ my $second = length($1);
+ my $expect = $first+$indent;
+ if($expect != $second) {
+ my $diff = $second - $first;
+ checkwarn($line, length($1), $file, $l,
+ "not indented $indent steps, uses $diff)");
+
+ }
+ }
+ }
+
+ # check for // letters, but skip them if a double quote or asterisk was
+ # on the same line to avoid strings and comments. Not reliable.
+ #if($l =~ /^([^\"*]*)\/\//) {
+ # checkwarn($line, length($1), $file, $l, "non-C89 compliant comment",
+ # 1);
+ #}
+
+ $line++;
+ $prevl = $l;
+}
+
+if(!$copyright) {
+ checkwarn(1, 0, $file, "", "Missing copyright statement", 1);
+}
+
+close(R);
diff --git a/lib/connect.c b/lib/connect.c
index e876e7641..f815d4363 100644
--- a/lib/connect.c
+++ b/lib/connect.c
@@ -263,7 +263,7 @@ static CURLcode bindlocal(struct connectdata *conn,
/*************************************************************
* Select device to bind socket to
*************************************************************/
- if ( !dev && !port )
+ if(!dev && !port)
/* no local kind of binding was requested */
return CURLE_OK;
@@ -315,10 +315,10 @@ static CURLcode bindlocal(struct connectdata *conn,
long ipver = conn->ip_version;
int rc;
- if (af == AF_INET)
+ if(af == AF_INET)
conn->ip_version = CURL_IPRESOLVE_V4;
#ifdef ENABLE_IPV6
- else if (af == AF_INET6)
+ else if(af == AF_INET6)
conn->ip_version = CURL_IPRESOLVE_V6;
#endif
@@ -372,14 +372,14 @@ static CURLcode bindlocal(struct connectdata *conn,
else {
/* no device was given, prepare sa to match af's needs */
#ifdef ENABLE_IPV6
- if ( af == AF_INET6 ) {
+ if( af == AF_INET6 ) {
si6->sin6_family = AF_INET6;
si6->sin6_port = htons(port);
sizeof_sa = sizeof(struct sockaddr_in6);
}
else
#endif
- if ( af == AF_INET ) {
+ if( af == AF_INET ) {
si4->sin_family = AF_INET;
si4->sin_port = htons(port);
sizeof_sa = sizeof(struct sockaddr_in);
@@ -388,7 +388,7 @@ static CURLcode bindlocal(struct connectdata *conn,
for(;;) {
if( bind(sockfd, sock, sizeof_sa) >= 0) {
- /* we succeeded to bind */
+ /* we succeeded to bind */
struct Curl_sockaddr_storage add;
curl_socklen_t size = sizeof(add);
memset(&add, 0, sizeof(struct Curl_sockaddr_storage));
@@ -809,8 +809,8 @@ void Curl_sndbufset(curl_socket_t sockfd)
int curval = 0;
int curlen = sizeof(curval);
- if (getsockopt(sockfd, SOL_SOCKET, SO_SNDBUF, (char *)&curval, &curlen) == 0)
- if (curval > val)
+ if(getsockopt(sockfd, SOL_SOCKET, SO_SNDBUF, (char *)&curval, &curlen) == 0)
+ if(curval > val)
return;
setsockopt(sockfd, SOL_SOCKET, SO_SNDBUF, (const char *)&val, sizeof(val));
@@ -888,7 +888,7 @@ singleipconnect(struct connectdata *conn,
return CURLE_OK;
#if defined(ENABLE_IPV6) && defined(HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID)
- if (conn->scope && (addr.family == AF_INET6))
+ if(conn->scope && (addr.family == AF_INET6))
sa6->sin6_scope_id = conn->scope;
#endif
@@ -1067,8 +1067,8 @@ CURLcode Curl_connecthost(struct connectdata *conn, /* context */
/*
* Connecting with a Curl_addrinfo chain
*/
- for (curr_addr = ai, aliasindex=0; curr_addr;
- curr_addr = curr_addr->ai_next, aliasindex++) {
+ for(curr_addr = ai, aliasindex=0; curr_addr;
+ curr_addr = curr_addr->ai_next, aliasindex++) {
/* start connecting to the IP curr_addr points to */
CURLcode res =
diff --git a/lib/content_encoding.c b/lib/content_encoding.c
index 6fb7c8d3a..876115a32 100644
--- a/lib/content_encoding.c
+++ b/lib/content_encoding.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -95,7 +95,7 @@ inflate_stream(struct connectdata *conn,
/* because the buffer size is fixed, iteratively decompress and transfer to
the client via client_write. */
- for (;;) {
+ for(;;) {
/* (re)set buffer for decompressed output for every iteration */
z->next_out = (Bytef *)decomp;
z->avail_out = DSIZ;
diff --git a/lib/cookie.c b/lib/cookie.c
index e81b9e36e..cad34acfd 100644
--- a/lib/cookie.c
+++ b/lib/cookie.c
@@ -84,7 +84,7 @@ Example set of cookies:
#include <stdlib.h>
#include <string.h>
-#define _MPRINTF_REPLACE /* without this on windows OS we get undefined reference to snprintf */
+#define _MPRINTF_REPLACE
#include <curl/mprintf.h>
#include "urldata.h"
@@ -371,7 +371,7 @@ Curl_cookie_add(struct SessionHandle *data,
/* Session cookies have expires set to 0 so if we get that back
from the date parser let's add a second to make it a
non-session cookie */
- if (co->expires == 0)
+ if(co->expires == 0)
co->expires = 1;
else if( co->expires < 0 )
co->expires = 0;
@@ -398,7 +398,7 @@ Curl_cookie_add(struct SessionHandle *data,
if(Curl_raw_equal("secure", what)) {
co->secure = TRUE;
}
- else if (Curl_raw_equal("httponly", what)) {
+ else if(Curl_raw_equal("httponly", what)) {
co->httponly = TRUE;
}
/* else,
@@ -482,7 +482,7 @@ Curl_cookie_add(struct SessionHandle *data,
lines are preceded with #HttpOnly_ and then everything is
as usual, so we skip 10 characters of the line..
*/
- if (strncmp(lineptr, "#HttpOnly_", 10) == 0) {
+ if(strncmp(lineptr, "#HttpOnly_", 10) == 0) {
lineptr += 10;
co->httponly = TRUE;
}
@@ -531,7 +531,7 @@ Curl_cookie_add(struct SessionHandle *data,
As far as I can see, it is set to true when the cookie says
.domain.com and to false when the domain is complete www.domain.com
*/
- co->tailmatch=(bool)Curl_raw_equal(ptr, "TRUE"); /* store information */
+ co->tailmatch=(bool)Curl_raw_equal(ptr, "TRUE");
break;
case 2:
/* It turns out, that sometimes the file format allows the path
diff --git a/lib/curl_addrinfo.c b/lib/curl_addrinfo.c
index 8489204bd..023a00678 100644
--- a/lib/curl_addrinfo.c
+++ b/lib/curl_addrinfo.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -294,7 +294,7 @@ Curl_he2ai(const struct hostent *he, int port)
size_t ss_size;
#ifdef ENABLE_IPV6
- if (he->h_addrtype == AF_INET6)
+ if(he->h_addrtype == AF_INET6)
ss_size = sizeof (struct sockaddr_in6);
else
#endif
diff --git a/lib/curl_fnmatch.c b/lib/curl_fnmatch.c
index ad4ec1871..b1c91ad1b 100644
--- a/lib/curl_fnmatch.c
+++ b/lib/curl_fnmatch.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -317,7 +317,7 @@ static int loop(const unsigned char *pattern, const unsigned char *string)
unsigned char charset[CURLFNM_CHSET_SIZE] = { 0 };
int rc = 0;
- for (;;) {
+ for(;;) {
switch(state) {
case CURLFNM_LOOP_DEFAULT:
if(*p == '*') {
diff --git a/lib/curl_memrchr.c b/lib/curl_memrchr.c
index a1e2bf0e5..d79af9be7 100644
--- a/lib/curl_memrchr.c
+++ b/lib/curl_memrchr.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2009, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -50,8 +50,8 @@ Curl_memrchr(const void *s, int c, size_t n)
p += n - 1;
- while (p >= q) {
- if (*p == (unsigned char)c)
+ while(p >= q) {
+ if(*p == (unsigned char)c)
return (void *)p;
p--;
}
diff --git a/lib/curl_rtmp.c b/lib/curl_rtmp.c
index bae8a76c0..2aab52b40 100644
--- a/lib/curl_rtmp.c
+++ b/lib/curl_rtmp.c
@@ -51,7 +51,7 @@ static CURLcode rtmp_setup(struct connectdata *conn);
static CURLcode rtmp_do(struct connectdata *conn, bool *done);
static CURLcode rtmp_done(struct connectdata *conn, CURLcode, bool premature);
static CURLcode rtmp_connect(struct connectdata *conn, bool *done);
-static CURLcode rtmp_disconnect(struct connectdata *conn, bool dead_connection);
+static CURLcode rtmp_disconnect(struct connectdata *conn, bool dead);
static Curl_recv rtmp_recv;
static Curl_send rtmp_send;
@@ -171,12 +171,12 @@ static CURLcode rtmp_setup(struct connectdata *conn)
{
RTMP *r = RTMP_Alloc();
- if (!r)
+ if(!r)
return CURLE_OUT_OF_MEMORY;
RTMP_Init(r);
RTMP_SetBufferMS(r, DEF_BUFTIME);
- if (!RTMP_SetupURL(r, conn->data->change.url)) {
+ if(!RTMP_SetupURL(r, conn->data->change.url)) {
RTMP_Free(r);
return CURLE_URL_MALFORMAT;
}
@@ -194,17 +194,19 @@ static CURLcode rtmp_connect(struct connectdata *conn, bool *done)
/* We have to know if it's a write before we send the
* connect request packet
*/
- if (conn->data->set.upload)
+ if(conn->data->set.upload)
r->Link.protocol |= RTMP_FEATURE_WRITE;
/* For plain streams, use the buffer toggle trick to keep data flowing */
- if (!(r->Link.lFlags & RTMP_LF_LIVE) && !(r->Link.protocol & RTMP_FEATURE_HTTP))
+ if(!(r->Link.lFlags & RTMP_LF_LIVE) &&
+ !(r->Link.protocol & RTMP_FEATURE_HTTP))
r->Link.lFlags |= RTMP_LF_BUFX;
curlx_nonblock(r->m_sb.sb_socket, FALSE);
- setsockopt(r->m_sb.sb_socket, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof(tv));
+ setsockopt(r->m_sb.sb_socket, SOL_SOCKET, SO_RCVTIMEO,
+ (char *)&tv, sizeof(tv));
- if (!RTMP_Connect1(r, NULL))
+ if(!RTMP_Connect1(r, NULL))
return CURLE_FAILED_INIT;
/* Clients must send a periodic BytesReceived report to the server */
@@ -220,13 +222,14 @@ static CURLcode rtmp_do(struct connectdata *conn, bool *done)
{
RTMP *r = conn->proto.generic;
- if (!RTMP_ConnectStream(r, 0))
+ if(!RTMP_ConnectStream(r, 0))
return CURLE_FAILED_INIT;
- if (conn->data->set.upload) {
+ if(conn->data->set.upload) {
Curl_pgrsSetUploadSize(conn->data, conn->data->set.infilesize);
Curl_setup_transfer(conn, -1, -1, FALSE, NULL, FIRSTSOCKET, NULL);
- } else
+ }
+ else
Curl_setup_transfer(conn, FIRSTSOCKET, -1, FALSE, NULL, -1, NULL);
*done = TRUE;
return CURLE_OK;
@@ -247,7 +250,7 @@ static CURLcode rtmp_disconnect(struct connectdata *conn,
{
RTMP *r = conn->proto.generic;
(void)dead_connection;
- if (r) {
+ if(r) {
conn->proto.generic = NULL;
RTMP_Close(r);
RTMP_Free(r);
@@ -264,12 +267,13 @@ static ssize_t rtmp_recv(struct connectdata *conn, int sockindex, char *buf,
(void)sockindex; /* unused */
nread = RTMP_Read(r, buf, len);
- if (nread < 0) {
- if (r->m_read.status == RTMP_READ_COMPLETE ||
+ if(nread < 0) {
+ if(r->m_read.status == RTMP_READ_COMPLETE ||
r->m_read.status == RTMP_READ_EOF) {
conn->data->req.size = conn->data->req.bytecount;
nread = 0;
- } else
+ }
+ else
*err = CURLE_RECV_ERROR;
}
return nread;
@@ -284,9 +288,9 @@ static ssize_t rtmp_send(struct connectdata *conn, int sockindex,
(void)sockindex; /* unused */
num = RTMP_Write(r, (char *)buf, len);
- if (num < 0) {
+ if(num < 0)
*err = CURLE_SEND_ERROR;
- }
+
return num;
}
#endif /* USE_LIBRTMP */
diff --git a/lib/curl_threads.c b/lib/curl_threads.c
index fd10bd487..e9636440f 100644
--- a/lib/curl_threads.c
+++ b/lib/curl_threads.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -95,7 +95,8 @@ int Curl_thread_join(curl_thread_t *hnd)
#elif defined(USE_THREADS_WIN32)
-curl_thread_t Curl_thread_create(unsigned int (CURL_STDCALL *func) (void*), void *arg)
+curl_thread_t Curl_thread_create(unsigned int (CURL_STDCALL *func) (void*),
+ void *arg)
{
#ifdef _WIN32_WCE
return CreateThread(NULL, 0, func, arg, 0, NULL);
diff --git a/lib/cyassl.c b/lib/cyassl.c
index 3e15b1879..e8830f3be 100644
--- a/lib/cyassl.c
+++ b/lib/cyassl.c
@@ -124,10 +124,10 @@ cyassl_connect_step1(struct connectdata *conn,
/* load trusted cacert */
if(data->set.str[STRING_SSL_CAFILE]) {
- if (!SSL_CTX_load_verify_locations(conssl->ctx,
- data->set.str[STRING_SSL_CAFILE],
- data->set.str[STRING_SSL_CAPATH])) {
- if (data->set.ssl.verifypeer) {
+ if(!SSL_CTX_load_verify_locations(conssl->ctx,
+ data->set.str[STRING_SSL_CAFILE],
+ data->set.str[STRING_SSL_CAPATH])) {
+ if(data->set.ssl.verifypeer) {
/* Fail if we insiste on successfully verifying the server. */
failf(data,"error setting certificate verify locations:\n"
" CAfile: %s\n CApath: %s\n",
@@ -161,7 +161,7 @@ cyassl_connect_step1(struct connectdata *conn,
if(data->set.str[STRING_CERT] && data->set.str[STRING_KEY]) {
int file_type = do_file_type(data->set.str[STRING_CERT_TYPE]);
- if (SSL_CTX_use_certificate_file(conssl->ctx, data->set.str[STRING_CERT],
+ if(SSL_CTX_use_certificate_file(conssl->ctx, data->set.str[STRING_CERT],
file_type) != 1) {
failf(data, "unable to use client certificate (no key or wrong pass"
" phrase?)");
@@ -169,7 +169,7 @@ cyassl_connect_step1(struct connectdata *conn,
}
file_type = do_file_type(data->set.str[STRING_KEY_TYPE]);
- if (SSL_CTX_use_PrivateKey_file(conssl->ctx, data->set.str[STRING_KEY],
+ if(SSL_CTX_use_PrivateKey_file(conssl->ctx, data->set.str[STRING_KEY],
file_type) != 1) {
failf(data, "unable to set private key");
return CURLE_SSL_CONNECT_ERROR;
@@ -185,10 +185,10 @@ cyassl_connect_step1(struct connectdata *conn,
NULL);
/* Let's make an SSL structure */
- if (conssl->handle)
+ if(conssl->handle)
SSL_free(conssl->handle);
conssl->handle = SSL_new(conssl->ctx);
- if (!conssl->handle) {
+ if(!conssl->handle) {
failf(data, "SSL: couldn't create a context (handle)!");
return CURLE_OUT_OF_MEMORY;
}
@@ -206,7 +206,7 @@ cyassl_connect_step1(struct connectdata *conn,
}
/* pass the raw socket into the SSL layer */
- if (!SSL_set_fd(conssl->handle, (int)sockfd)) {
+ if(!SSL_set_fd(conssl->handle, (int)sockfd)) {
failf(data, "SSL: SSL_set_fd failed");
return CURLE_SSL_CONNECT_ERROR;
}
@@ -231,16 +231,16 @@ cyassl_connect_step2(struct connectdata *conn,
conn->send[sockindex] = cyassl_send;
ret = SSL_connect(conssl->handle);
- if (ret != 1) {
+ if(ret != 1) {
char error_buffer[80];
int detail = SSL_get_error(conssl->handle, ret);
- if (SSL_ERROR_WANT_READ == detail) {
+ if(SSL_ERROR_WANT_READ == detail) {
conssl->connecting_state = ssl_connect_2_reading;
return CURLE_OK;
}
- if (SSL_ERROR_WANT_WRITE == detail) {
+ if(SSL_ERROR_WANT_WRITE == detail) {
conssl->connecting_state = ssl_connect_2_writing;
return CURLE_OK;
}
@@ -273,14 +273,14 @@ cyassl_connect_step3(struct connectdata *conn,
our_ssl_sessionid = SSL_get_session(connssl->handle);
incache = !(Curl_ssl_getsessionid(conn, &old_ssl_sessionid, NULL));
- if (incache) {
- if (old_ssl_sessionid != our_ssl_sessionid) {
+ if(incache) {
+ if(old_ssl_sessionid != our_ssl_sessionid) {
infof(data, "old SSL session ID is stale, removing\n");
Curl_ssl_delsessionid(conn, old_ssl_sessionid);
incache = FALSE;
}
}
- if (!incache) {
+ if(!incache) {
retcode = Curl_ssl_addsessionid(conn, our_ssl_sessionid,
0 /* unknown size */);
if(retcode) {
@@ -305,7 +305,7 @@ static ssize_t cyassl_send(struct connectdata *conn,
int memlen = (len > (size_t)INT_MAX) ? INT_MAX : (int)len;
int rc = SSL_write(conn->ssl[sockindex].handle, mem, memlen);
- if (rc < 0) {
+ if(rc < 0) {
int err = SSL_get_error(conn->ssl[sockindex].handle, rc);
switch(err) {
@@ -355,7 +355,7 @@ static ssize_t cyassl_recv(struct connectdata *conn,
int buffsize = (buffersize > (size_t)INT_MAX) ? INT_MAX : (int)buffersize;
int nread = SSL_read(conn->ssl[num].handle, buf, buffsize);
- if (nread < 0) {
+ if(nread < 0) {
int err = SSL_get_error(conn->ssl[num].handle, nread);
switch(err) {
@@ -405,7 +405,7 @@ int Curl_cyassl_init(void)
bool Curl_cyassl_data_pending(const struct connectdata* conn, int connindex)
{
- if (conn->ssl[connindex].handle) /* SSL is in use */
+ if(conn->ssl[connindex].handle) /* SSL is in use */
return (bool)(0 != SSL_pending(conn->ssl[connindex].handle));
else
return FALSE;
diff --git a/lib/dict.c b/lib/dict.c
index e079fd188..c296bd998 100644
--- a/lib/dict.c
+++ b/lib/dict.c
@@ -279,7 +279,7 @@ static CURLcode dict_do(struct connectdata *conn, bool *done)
int i;
ppath++;
- for (i = 0; ppath[i]; i++) {
+ for(i = 0; ppath[i]; i++) {
if(ppath[i] == ':')
ppath[i] = ' ';
}
diff --git a/lib/easy.c b/lib/easy.c
index cfe7224a4..8b1386940 100644
--- a/lib/easy.c
+++ b/lib/easy.c
@@ -147,7 +147,7 @@ static CURLcode win32_init(void)
#ifdef USE_WINDOWS_SSPI
{
CURLcode err = Curl_sspi_global_init();
- if (err != CURLE_OK)
+ if(err != CURLE_OK)
return err;
}
#endif
@@ -764,8 +764,8 @@ CURLcode curl_easy_pause(CURL *curl, int action)
k->keepon = newstate;
if(!(newstate & KEEP_RECV_PAUSE) && data->state.tempwrite) {
- /* we have a buffer for sending that we now seem to be able to deliver since
- the receive pausing is lifted! */
+ /* we have a buffer for sending that we now seem to be able to deliver
+ since the receive pausing is lifted! */
/* get the pointer, type and length in local copies since the function may
return PAUSE again and then we'll get a new copy allocted and stored in
diff --git a/lib/escape.c b/lib/escape.c
index 4e8dd6e4c..50d310a1a 100644
--- a/lib/escape.c
+++ b/lib/escape.c
@@ -98,10 +98,9 @@ char *curl_easy_escape(CURL *handle, const char *string, int inlength)
while(length--) {
in = *string;
- if (Curl_isunreserved(in)) {
+ if(Curl_isunreserved(in))
/* just copy this */
ns[strindex++]=in;
- }
else {
/* encode it */
newlen += 2; /* the size grows with two, since this'll become a %XX */
diff --git a/lib/file.c b/lib/file.c
index ad671233c..1fee92bb2 100644
--- a/lib/file.c
+++ b/lib/file.c
@@ -90,7 +90,8 @@
/* The last #include file should be: */
#include "memdebug.h"
-#if defined(WIN32) || defined(MSDOS) || defined(__EMX__) || defined(__SYMBIAN32__)
+#if defined(WIN32) || defined(MSDOS) || defined(__EMX__) || \
+ defined(__SYMBIAN32__)
#define DOS_FILESYSTEM 1
#endif
@@ -245,18 +246,17 @@ static CURLcode file_connect(struct connectdata *conn, bool *done)
actual_path = real_path;
if((actual_path[0] == '/') &&
actual_path[1] &&
- (actual_path[2] == ':' || actual_path[2] == '|'))
- {
+ (actual_path[2] == ':' || actual_path[2] == '|')) {
actual_path[2] = ':';
actual_path++;
}
/* change path separators from '/' to '\\' for DOS, Windows and OS/2 */
- for (i=0; actual_path[i] != '\0'; ++i)
+ for(i=0; actual_path[i] != '\0'; ++i)
if(actual_path[i] == '/')
actual_path[i] = '\\';
- fd = open_readonly(actual_path, O_RDONLY|O_BINARY); /* no CR/LF translation */
+ fd = open_readonly(actual_path, O_RDONLY|O_BINARY);
file->path = actual_path;
#else
fd = open_readonly(real_path, O_RDONLY);
@@ -536,7 +536,7 @@ static CURLcode file_do(struct connectdata *conn, bool *done)
}
/* A high water mark has been specified so we obey... */
- if (data->req.maxdownload > 0)
+ if(data->req.maxdownload > 0)
expected_size = data->req.maxdownload;
if(fstated && (expected_size == 0))
@@ -565,7 +565,7 @@ static CURLcode file_do(struct connectdata *conn, bool *done)
if( nread > 0)
buf[nread] = 0;
- if (nread <= 0 || expected_size == 0)
+ if(nread <= 0 || expected_size == 0)
break;
bytecount += nread;
diff --git a/lib/formdata.c b/lib/formdata.c
index f221ae966..a94dca521 100644
--- a/lib/formdata.c
+++ b/lib/formdata.c
@@ -20,87 +20,6 @@
*
***************************************************************************/
-/*
- Debug the form generator stand-alone by compiling this source file with:
-
- gcc -DHAVE_CONFIG_H -I../ -g -D_FORM_DEBUG -DCURLDEBUG -o formdata \
- -I../include formdata.c strequal.c memdebug.c mprintf.c strerror.c
-
- (depending on circumstances you may need further externals added)
-
- run the 'formdata' executable the output should end with:
- All Tests seem to have worked ...
- and the following parts should be there:
-
-Content-Disposition: form-data; name="simple_COPYCONTENTS"
-value for simple COPYCONTENTS
-
-Content-Disposition: form-data; name="COPYCONTENTS_+_CONTENTTYPE"
-Content-Type: image/gif
-value for COPYCONTENTS + CONTENTTYPE
-
-Content-Disposition: form-data; name="PRNAME_+_NAMELENGTH_+_COPYNAME_+_CONTENTSLENGTH"
-vlue for PTRNAME + NAMELENGTH + COPYNAME + CONTENTSLENGTH
-(or you might see P^@RNAME and v^@lue at the start)
-
-Content-Disposition: form-data; name="simple_PTRCONTENTS"
-value for simple PTRCONTENTS
-
-Content-Disposition: form-data; name="PTRCONTENTS_+_CONTENTSLENGTH"
-vlue for PTRCONTENTS + CONTENTSLENGTH
-(or you might see v^@lue at the start)
-
-Content-Disposition: form-data; name="PTRCONTENTS_+_CONTENTSLENGTH_+_CONTENTTYPE"
-Content-Type: application/octet-stream
-vlue for PTRCONTENTS + CONTENTSLENGTH + CONTENTTYPE
-(or you might see v^@lue at the start)
-
-Content-Disposition: form-data; name="FILE1_+_CONTENTTYPE"; filename="formdata.h"
-Content-Type: text/html
-...
-
-Content-Disposition: form-data; name="FILE1_+_FILE2"
-Content-Type: multipart/mixed, boundary=curlz1s0dkticx49MV1KGcYP5cvfSsz
-...
-Content-Disposition: attachment; filename="formdata.h"
-Content-Type: application/octet-stream
-...
-Content-Disposition: attachment; filename="Makefile.b32"
-Content-Type: application/octet-stream
-...
-
-Content-Disposition: form-data; name="FILE1_+_FILE2_+_FILE3"
-Content-Type: multipart/mixed, boundary=curlirkYPmPwu6FrJ1vJ1u1BmtIufh1
-...
-Content-Disposition: attachment; filename="formdata.h"
-Content-Type: application/octet-stream
-...
-Content-Disposition: attachment; filename="Makefile.b32"
-Content-Type: application/octet-stream
-...
-Content-Disposition: attachment; filename="formdata.h"
-Content-Type: application/octet-stream
-...
-
-
-Content-Disposition: form-data; name="ARRAY: FILE1_+_FILE2_+_FILE3"
-Content-Type: multipart/mixed, boundary=curlirkYPmPwu6FrJ1vJ1u1BmtIufh1
-...
-Content-Disposition: attachment; filename="formdata.h"
-Content-Type: application/octet-stream
-...
-Content-Disposition: attachment; filename="Makefile.b32"
-Content-Type: application/octet-stream
-...
-Content-Disposition: attachment; filename="formdata.h"
-Content-Type: application/octet-stream
-...
-
-Content-Disposition: form-data; name="FILECONTENT"
-...
-
- */
-
#include "setup.h"
#include <curl/curl.h>
@@ -382,7 +301,7 @@ static char *memdup(const char *src, size_t buffer_length)
* CURL_FORMADD_NULL if a null pointer was given for a char
* CURL_FORMADD_MEMORY if the allocation of a FormInfo struct failed
* CURL_FORMADD_UNKNOWN_OPTION if an unknown option was used
- * CURL_FORMADD_INCOMPLETE if the some FormInfo is not complete (or an error)
+ * CURL_FORMADD_INCOMPLETE if the some FormInfo is not complete (or error)
* CURL_FORMADD_MEMORY if a HttpPost struct cannot be allocated
* CURL_FORMADD_MEMORY if some allocation for string copying failed.
* CURL_FORMADD_ILLEGAL_ARRAY if an illegal option is used in an array
@@ -951,7 +870,7 @@ int curl_formget(struct curl_httppost *form, void *arg,
if(rc != CURLE_OK)
return (int)rc;
- for (ptr = data; ptr; ptr = ptr->next) {
+ for(ptr = data; ptr; ptr = ptr->next) {
if(ptr->type == FORM_FILE) {
char buffer[8192];
size_t nread;
@@ -1478,168 +1397,6 @@ char *Curl_formpostheader(void *formp, size_t *len)
return header;
}
-
-#ifdef _FORM_DEBUG
-int FormAddTest(const char * errormsg,
- struct curl_httppost **httppost,
- struct curl_httppost **last_post,
- ...)
-{
- int result;
- va_list arg;
- va_start(arg, last_post);
- if((result = FormAdd(httppost, last_post, arg)))
- fprintf (stderr, "ERROR doing FormAdd ret: %d action: %s\n", result,
- errormsg);
- va_end(arg);
- return result;
-}
-
-
-int main(int argc, argv_item_t argv[])
-{
- char name1[] = "simple_COPYCONTENTS";
- char name2[] = "COPYCONTENTS_+_CONTENTTYPE";
- char name3[] = "PTRNAME_+_NAMELENGTH_+_COPYNAME_+_CONTENTSLENGTH";
- char name4[] = "simple_PTRCONTENTS";
- char name5[] = "PTRCONTENTS_+_CONTENTSLENGTH";
- char name6[] = "PTRCONTENTS_+_CONTENTSLENGTH_+_CONTENTTYPE";
- char name7[] = "FILE1_+_CONTENTTYPE";
- char name8[] = "FILE1_+_FILE2";
- char name9[] = "FILE1_+_FILE2_+_FILE3";
- char name10[] = "ARRAY: FILE1_+_FILE2_+_FILE3";
- char name11[] = "FILECONTENT";
- char value1[] = "value for simple COPYCONTENTS";
- char value2[] = "value for COPYCONTENTS + CONTENTTYPE";
- char value3[] = "value for PTRNAME + NAMELENGTH + COPYNAME + CONTENTSLENGTH";
- char value4[] = "value for simple PTRCONTENTS";
- char value5[] = "value for PTRCONTENTS + CONTENTSLENGTH";
- char value6[] = "value for PTRCONTENTS + CONTENTSLENGTH + CONTENTTYPE";
- char value7[] = "formdata.h";
- char value8[] = "Makefile.b32";
- char type2[] = "image/gif";
- char type6[] = "text/plain";
- char type7[] = "text/html";
- int name3length = strlen(name3);
- int value3length = strlen(value3);
- int value5length = strlen(value5);
- int value6length = strlen(value6);
- int errors = 0;
- CURLcode rc;
- curl_off_t size;
- size_t nread;
- char buffer[4096];
- struct curl_httppost *httppost=NULL;
- struct curl_httppost *last_post=NULL;
- struct curl_forms forms[4];
-
- struct FormData *form;
- struct Form formread;
-
- (void) argc;
- (void) argv;
-
- Curl_srand(); /* Because we do not call curl_global_init() here. */
-
- 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,
- CURLFORM_COPYNAME, name2, CURLFORM_COPYCONTENTS, value2,
- CURLFORM_CONTENTTYPE, type2, CURLFORM_END))
- ++errors;
- /* make null character at start to check that contentslength works
- correctly */
- name3[1] = '\0';
- value3[1] = '\0';
- 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,
- 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,
- 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",
- &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,
- CURLFORM_COPYNAME, name7, CURLFORM_FILE, value7,
- CURLFORM_CONTENTTYPE, type7, CURLFORM_END))
- ++errors;
- 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,
- CURLFORM_COPYNAME, name9, CURLFORM_FILE, value7,
- CURLFORM_FILE, value8, CURLFORM_FILE, value7, CURLFORM_END))
- ++errors;
- forms[0].option = CURLFORM_FILE;
- forms[0].value = value7;
- forms[1].option = CURLFORM_FILE;
- forms[1].value = value8;
- forms[2].option = CURLFORM_FILE;
- forms[2].value = value7;
- forms[3].option = CURLFORM_END;
- 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,
- CURLFORM_COPYNAME, name11, CURLFORM_FILECONTENT, value7,
- CURLFORM_END))
- ++errors;
-
- rc = Curl_getformdata(NULL, &form, httppost, NULL, &size);
- if(rc != CURLE_OK) {
- if(rc != CURLE_READ_ERROR) {
- const char *errortext = curl_easy_strerror(rc);
- fprintf(stdout, "\n==> Curl_getformdata error: %s\n", errortext);
- }
- return 0;
- }
-
- Curl_FormInit(&formread, form);
-
- for(;;) {
- nread = Curl_FormReader(buffer, 1, sizeof(buffer),
- (FILE *)&formread);
-
- if(nread < 1)
- break;
- fwrite(buffer, nread, 1, stdout);
- }
-
- fprintf(stdout, "size: ");
- fprintf(stdout, "%" FORMAT_OFF_T, size);
- fprintf(stdout, "\n");
- if(errors)
- fprintf(stdout, "\n==> %d Test(s) failed!\n", errors);
- else
- fprintf(stdout, "\nAll Tests seem to have worked (please check output)\n");
-
- return 0;
-}
-
-#endif /* _FORM_DEBUG */
-
#else /* CURL_DISABLE_HTTP */
CURLFORMcode curl_formadd(struct curl_httppost **httppost,
struct curl_httppost **last_post,
diff --git a/lib/ftp.c b/lib/ftp.c
index c8180b8b1..e8a6a3156 100644
--- a/lib/ftp.c
+++ b/lib/ftp.c
@@ -274,7 +274,7 @@ static void freedirs(struct ftp_conn *ftpc)
{
int i;
if(ftpc->dirs) {
- for (i=0; i < ftpc->dirdepth; i++){
+ for(i=0; i < ftpc->dirdepth; i++){
if(ftpc->dirs[i]) {
free(ftpc->dirs[i]);
ftpc->dirs[i]=NULL;
@@ -741,7 +741,7 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
char *port_sep = NULL;
addr = calloc(addrlen+1, 1);
- if (!addr)
+ if(!addr)
return CURLE_OUT_OF_MEMORY;
#ifdef ENABLE_IPV6
@@ -765,12 +765,11 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
port_min = port_max = 0;
strcpy(addr, string_ftpport);
ip_end = NULL; /* this got no port ! */
- } else
+ }
+ else
#endif
- {
/* (ipv4|domain|interface):port(-range) */
strncpy(addr, string_ftpport, ip_end - ip_start );
- }
}
else
/* ipv4|interface */
@@ -819,20 +818,19 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
if(getsockname(conn->sock[FIRSTSOCKET], sa, &sslen)) {
failf(data, "getsockname() failed: %s",
Curl_strerror(conn, SOCKERRNO) );
- if (addr)
+ if(addr)
free(addr);
return CURLE_FTP_PORT_FAILED;
}
- switch(sa->sa_family)
- {
+ switch(sa->sa_family) {
#ifdef ENABLE_IPV6
- case AF_INET6:
- Curl_inet_ntop(sa->sa_family, &sa6->sin6_addr, hbuf, sizeof(hbuf));
- break;
+ case AF_INET6:
+ Curl_inet_ntop(sa->sa_family, &sa6->sin6_addr, hbuf, sizeof(hbuf));
+ break;
#endif
- default:
- Curl_inet_ntop(sa->sa_family, &sa4->sin_addr, hbuf, sizeof(hbuf));
- break;
+ default:
+ Curl_inet_ntop(sa->sa_family, &sa4->sin_addr, hbuf, sizeof(hbuf));
+ break;
}
host = hbuf; /* use this host name */
}
@@ -850,10 +848,10 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
else
res = NULL; /* failure! */
- if (addr)
+ if(addr)
free(addr);
- if (res == NULL) {
+ if(res == NULL) {
failf(data, "Curl_resolv failed, we can not recover!");
return CURLE_FTP_PORT_FAILED;
}
@@ -862,7 +860,7 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
portsock = CURL_SOCKET_BAD;
error = 0;
- for (ai = res; ai; ai = ai->ai_next) {
+ for(ai = res; ai; ai = ai->ai_next) {
/*
* Workaround for AIX5 getaddrinfo() problem (it doesn't set ai_socktype):
*/
@@ -929,7 +927,7 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
}
/* maybe all ports were in use already*/
- if (port > port_max) {
+ if(port > port_max) {
failf(data, "bind() failed, we ran out of ports!");
sclose(portsock);
return CURLE_FTP_PORT_FAILED;
@@ -966,7 +964,7 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
conn->bits.ftp_use_eprt = TRUE;
#endif
- for (; fcmd != DONE; fcmd++) {
+ for(; fcmd != DONE; fcmd++) {
if(!conn->bits.ftp_use_eprt && (EPRT == fcmd))
/* if disabled, goto next */
@@ -2171,7 +2169,7 @@ static CURLcode ftp_state_get_resp(struct connectdata *conn,
150 ASCII data connection for /bin/ls (137.167.104.91,37445) (0 bytes).
D:
- 150 Opening ASCII mode data connection for /linux/fisk/kpanelrc (0.0.0.0,0) (545 bytes).
+ 150 Opening ASCII mode data connection for [file] (0.0.0.0,0) (545 bytes)
E:
125 Data connection already open; Transfer starting. */
@@ -2583,7 +2581,7 @@ static CURLcode ftp_statemach_act(struct connectdata *conn)
if('\"' == *ptr) {
/* it started good */
ptr++;
- for (store = dir; *ptr;) {
+ for(store = dir; *ptr;) {
if('\"' == *ptr) {
if('\"' == ptr[1]) {
/* "quote-doubling" */
@@ -2649,9 +2647,9 @@ static CURLcode ftp_statemach_act(struct connectdata *conn)
/* Reply format is like
215<space><OS-name><space><commentary>
*/
- while (*ptr == ' ')
+ while(*ptr == ' ')
ptr++;
- for (store = os; *ptr && *ptr != ' ';)
+ for(store = os; *ptr && *ptr != ' ';)
*store++ = *ptr++;
*store = '\0'; /* zero terminate */
ftpc->server_os = os;
@@ -2770,7 +2768,7 @@ static CURLcode ftp_statemach_act(struct connectdata *conn)
case FTP_PRET:
if(ftpcode != 200) {
- /* there only is this one standard OK return code. */
+ /* there only is this one standard OK return code. */
failf(data, "PRET command not accepted: %03d", ftpcode);
return CURLE_FTP_PRET_FAILED;
}
@@ -3511,7 +3509,7 @@ static CURLcode init_wc_data(struct connectdata *conn)
}
else {
wildcard->pattern = strdup(last_slash);
- if (!wildcard->pattern)
+ if(!wildcard->pattern)
return CURLE_OUT_OF_MEMORY;
last_slash[0] = '\0'; /* cut file from path */
}
@@ -3519,7 +3517,7 @@ static CURLcode init_wc_data(struct connectdata *conn)
else { /* there is only 'wildcard pattern' or nothing */
if(path[0]) {
wildcard->pattern = strdup(path);
- if (!wildcard->pattern)
+ if(!wildcard->pattern)
return CURLE_OUT_OF_MEMORY;
path[0] = '\0';
}
@@ -3561,7 +3559,7 @@ static CURLcode init_wc_data(struct connectdata *conn)
/* backup old write_function */
ftp_tmp->backup.write_function = conn->data->set.fwrite_func;
- /* parsing write function (callback included directly from ftplistparser.c) */
+ /* parsing write function */
conn->data->set.fwrite_func = Curl_ftp_parselist;
/* backup old file descriptor */
ftp_tmp->backup.file_descriptor = conn->data->set.out;
diff --git a/lib/ftp.h b/lib/ftp.h
index d8ef34823..b5b3adadf 100644
--- a/lib/ftp.h
+++ b/lib/ftp.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -66,7 +66,7 @@ typedef enum {
FTP_STOR_TYPE, /* set type when about to STOR a file */
FTP_SIZE, /* get the remote file's size for head-like request */
FTP_RETR_SIZE, /* get the remote file's size for RETR */
- FTP_STOR_SIZE, /* get the size for (resumed) STOR */
+ FTP_STOR_SIZE, /* get the size for STOR */
FTP_REST, /* when used to check if the server supports it in head-like */
FTP_RETR_REST, /* when asking for "resume" in for RETR */
FTP_PORT, /* generic state for PORT, LPRT and EPRT, check count1 */
@@ -93,7 +93,8 @@ struct ftp_wc_tmpdata {
typedef enum {
FTPFILE_MULTICWD = 1, /* as defined by RFC1738 */
FTPFILE_NOCWD = 2, /* use SIZE / RETR / STOR on the full path */
- FTPFILE_SINGLECWD = 3 /* make one CWD, then SIZE / RETR / STOR on the file */
+ FTPFILE_SINGLECWD = 3 /* make one CWD, then SIZE / RETR / STOR on the
+ file */
} curl_ftpfile;
typedef enum {
@@ -147,7 +148,8 @@ struct ftp_conn {
ftpstate state; /* always use ftp.c:state() to change state! */
char * server_os; /* The target server operating system. */
curl_off_t known_filesize; /* file size is different from -1, if wildcard
- LIST parsing was done and wc_statemach set it */
+ LIST parsing was done and wc_statemach set
+ it */
};
#endif /* HEADER_CURL_FTP_H */
diff --git a/lib/ftplistparser.c b/lib/ftplistparser.c
index 6f7475337..a3fef3971 100644
--- a/lib/ftplistparser.c
+++ b/lib/ftplistparser.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -329,7 +329,8 @@ static CURLcode ftp_pl_insert_finfo(struct connectdata *conn,
compare = Curl_fnmatch;
/* filter pattern-corresponding filenames */
- if(compare(conn->data->set.fnmatch_data, wc->pattern, finfo->filename) == 0) {
+ if(compare(conn->data->set.fnmatch_data, wc->pattern,
+ finfo->filename) == 0) {
/* discard symlink which is containing multiple " -> " */
if((finfo->filetype == CURLFILETYPE_SYMLINK) && finfo->strings.target &&
(strstr(finfo->strings.target, " -> "))) {
@@ -645,7 +646,7 @@ size_t Curl_ftp_parselist(char *buffer, size_t size, size_t nmemb,
parser->state.UNIX.main = PL_UNIX_TIME;
parser->state.UNIX.sub.time = PL_UNIX_TIME_PREPART1;
}
- else if (!ISDIGIT(c)) {
+ else if(!ISDIGIT(c)) {
PL_ERROR(conn, CURLE_FTP_BAD_FILE_LIST);
return bufflen;
}
@@ -960,7 +961,8 @@ size_t Curl_ftp_parselist(char *buffer, size_t size, size_t nmemb,
}
else {
char *endptr;
- finfo->size = curlx_strtoofft(finfo->b_data + parser->item_offset,
+ finfo->size = curlx_strtoofft(finfo->b_data +
+ parser->item_offset,
&endptr, 10);
if(!*endptr) {
if(finfo->size == CURL_OFF_T_MAX ||
diff --git a/lib/gopher.c b/lib/gopher.c
index 6718bafb1..3ee8261b6 100644
--- a/lib/gopher.c
+++ b/lib/gopher.c
@@ -132,7 +132,7 @@ static CURLcode gopher_do(struct connectdata *conn, bool *done)
*done = TRUE; /* unconditionally */
/* Create selector. Degenerate cases: / and /1 => convert to "" */
- if (strlen(path) <= 2)
+ if(strlen(path) <= 2)
sel = (char *)"";
else {
char *newp;
@@ -151,7 +151,7 @@ static CURLcode gopher_do(struct connectdata *conn, bool *done)
/* ... and finally unescape */
sel = curl_easy_unescape(data, newp, 0, &len);
- if (!sel)
+ if(!sel)
return CURLE_OUT_OF_MEMORY;
sel_org = sel;
}
@@ -162,7 +162,7 @@ static CURLcode gopher_do(struct connectdata *conn, bool *done)
for(;;) {
result = Curl_write(conn, sockfd, sel, k, &amount);
- if (CURLE_OK == result) { /* Which may not have written it all! */
+ if(CURLE_OK == result) { /* Which may not have written it all! */
result = Curl_client_write(conn, CLIENTWRITE_HEADER, sel, amount);
if(result) {
Curl_safefree(sel_org);
@@ -170,7 +170,7 @@ static CURLcode gopher_do(struct connectdata *conn, bool *done)
}
k -= amount;
sel += amount;
- if (k < 1)
+ if(k < 1)
break; /* but it did write it all */
}
else {
@@ -195,7 +195,7 @@ static CURLcode gopher_do(struct connectdata *conn, bool *done)
/* We can use Curl_sendf to send the terminal \r\n relatively safely and
save allocing another string/doing another _write loop. */
result = Curl_sendf(sockfd, conn, "\r\n");
- if (result != CURLE_OK) {
+ if(result != CURLE_OK) {
failf(data, "Failed sending Gopher request");
return result;
}
diff --git a/lib/gtls.c b/lib/gtls.c
index 71ceb34d9..1a2dfd467 100644
--- a/lib/gtls.c
+++ b/lib/gtls.c
@@ -197,14 +197,14 @@ static gnutls_datum load_file (const char *file)
long filelen;
void *ptr;
- if (!(f = fopen(file, "r")))
+ if(!(f = fopen(file, "r")))
return loaded_file;
- if (fseek(f, 0, SEEK_END) != 0
- || (filelen = ftell(f)) < 0
- || fseek(f, 0, SEEK_SET) != 0
- || !(ptr = malloc((size_t)filelen)))
+ if(fseek(f, 0, SEEK_END) != 0
+ || (filelen = ftell(f)) < 0
+ || fseek(f, 0, SEEK_SET) != 0
+ || !(ptr = malloc((size_t)filelen)))
goto out;
- if (fread(ptr, 1, (size_t)filelen, f) < (size_t)filelen) {
+ if(fread(ptr, 1, (size_t)filelen, f) < (size_t)filelen) {
free(ptr);
goto out;
}
@@ -282,7 +282,7 @@ static CURLcode handshake(struct connectdata *conn,
if(nonblocking)
return CURLE_OK;
}
- else if (rc < 0) {
+ else if(rc < 0) {
failf(data, "gnutls_handshake() failed: %s", gnutls_strerror(rc));
return CURLE_SSL_CONNECT_ERROR;
}
@@ -357,7 +357,8 @@ gtls_connect_step1(struct connectdata *conn,
return CURLE_OUT_OF_MEMORY;
}
- rc = gnutls_srp_set_client_credentials(conn->ssl[sockindex].srp_client_cred,
+ rc = gnutls_srp_set_client_credentials(conn->ssl[sockindex].
+ srp_client_cred,
data->set.ssl.username,
data->set.ssl.password);
if(rc != GNUTLS_E_SUCCESS) {
@@ -412,13 +413,13 @@ gtls_connect_step1(struct connectdata *conn,
/* convenient assign */
session = conn->ssl[sockindex].session;
- if ((0 == Curl_inet_pton(AF_INET, conn->host.name, &addr)) &&
+ if((0 == Curl_inet_pton(AF_INET, conn->host.name, &addr)) &&
#ifdef ENABLE_IPV6
- (0 == Curl_inet_pton(AF_INET6, conn->host.name, &addr)) &&
+ (0 == Curl_inet_pton(AF_INET6, conn->host.name, &addr)) &&
#endif
- sni &&
- (gnutls_server_name_set(session, GNUTLS_NAME_DNS, conn->host.name,
- strlen(conn->host.name)) < 0))
+ sni &&
+ (gnutls_server_name_set(session, GNUTLS_NAME_DNS, conn->host.name,
+ strlen(conn->host.name)) < 0))
infof(data, "WARNING: failed to configure server name indication (SNI) "
"TLS extension\n");
@@ -447,7 +448,8 @@ gtls_connect_step1(struct connectdata *conn,
data->set.str[STRING_CERT],
data->set.str[STRING_KEY] ?
data->set.str[STRING_KEY] : data->set.str[STRING_CERT],
- do_file_type(data->set.str[STRING_CERT_TYPE]) ) != GNUTLS_E_SUCCESS) {
+ do_file_type(data->set.str[STRING_CERT_TYPE]) ) !=
+ GNUTLS_E_SUCCESS) {
failf(data, "error reading X.509 key or certificate file");
return CURLE_SSL_CONNECT_ERROR;
}
@@ -458,10 +460,10 @@ gtls_connect_step1(struct connectdata *conn,
if(data->set.ssl.authtype == CURL_TLSAUTH_SRP) {
rc = gnutls_credentials_set(session, GNUTLS_CRD_SRP,
conn->ssl[sockindex].srp_client_cred);
- if (rc != GNUTLS_E_SUCCESS) {
+ if(rc != GNUTLS_E_SUCCESS)
failf(data, "gnutls_credentials_set() failed: %s", gnutls_strerror(rc));
- }
- } else
+ }
+ else
#endif
rc = gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE,
conn->ssl[sockindex].cred);
@@ -586,13 +588,13 @@ gtls_connect_step3(struct connectdata *conn,
gnutls_x509_crt_t format */
gnutls_x509_crt_import(x509_cert, chainp, GNUTLS_X509_FMT_DER);
- if (data->set.ssl.issuercert) {
+ if(data->set.ssl.issuercert) {
gnutls_x509_crt_init(&x509_issuer);
issuerp = load_file(data->set.ssl.issuercert);
gnutls_x509_crt_import(x509_issuer, &issuerp, GNUTLS_X509_FMT_PEM);
rc = gnutls_x509_crt_check_issuer(x509_cert,x509_issuer);
unload_file(issuerp);
- if (rc <= 0) {
+ if(rc <= 0) {
failf(data, "server certificate issuer check failed (IssuerCert: %s)",
data->set.ssl.issuercert?data->set.ssl.issuercert:"none");
return CURLE_SSL_ISSUER_ERROR;
@@ -743,7 +745,7 @@ after_server_cert_verification:
gnutls_session_get_data(session, connect_sessionid, &connect_idsize);
incache = !(Curl_ssl_getsessionid(conn, &ssl_sessionid, NULL));
- if (incache) {
+ if(incache) {
/* there was one before in the cache, so instead of risking that the
previous one was rejected, we just kill that and store the new */
Curl_ssl_delsessionid(conn, ssl_sessionid);
@@ -869,7 +871,7 @@ static void close_one(struct connectdata *conn,
conn->ssl[idx].cred = NULL;
}
#ifdef USE_TLS_SRP
- if (conn->ssl[idx].srp_client_cred) {
+ if(conn->ssl[idx].srp_client_cred) {
gnutls_srp_free_client_credentials(conn->ssl[idx].srp_client_cred);
conn->ssl[idx].srp_client_cred = NULL;
}
diff --git a/lib/hash.c b/lib/hash.c
index cdcd26017..3a3a58e90 100644
--- a/lib/hash.c
+++ b/lib/hash.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2009, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -72,7 +72,7 @@ Curl_hash_init(struct curl_hash *h,
h->table = malloc(slots * sizeof(struct curl_llist *));
if(h->table) {
- for (i = 0; i < slots; ++i) {
+ for(i = 0; i < slots; ++i) {
h->table[i] = Curl_llist_alloc((curl_llist_dtor) hash_element_dtor);
if(!h->table[i]) {
while(i--)
@@ -148,7 +148,7 @@ Curl_hash_add(struct curl_hash *h, void *key, size_t key_len, void *p)
struct curl_llist_element *le;
struct curl_llist *l = FETCH_LIST (h, key, key_len);
- for (le = l->head; le; le = le->next) {
+ for(le = l->head; le; le = le->next) {
he = (struct curl_hash_element *) le->ptr;
if(h->comp_func(he->key, he->key_len, key, key_len)) {
Curl_llist_remove(l, le, (void *)h);
@@ -183,7 +183,7 @@ int Curl_hash_delete(struct curl_hash *h, void *key, size_t key_len)
struct curl_hash_element *he;
struct curl_llist *l = FETCH_LIST(h, key, key_len);
- for (le = l->head; le; le = le->next) {
+ for(le = l->head; le; le = le->next) {
he = le->ptr;
if(h->comp_func(he->key, he->key_len, key, key_len)) {
Curl_llist_remove(l, le, (void *) h);
@@ -200,7 +200,7 @@ Curl_hash_pick(struct curl_hash *h, void *key, size_t key_len)
struct curl_hash_element *he;
struct curl_llist *l = FETCH_LIST(h, key, key_len);
- for (le = l->head; le; le = le->next) {
+ for(le = l->head; le; le = le->next) {
he = le->ptr;
if(h->comp_func(he->key, he->key_len, key, key_len)) {
return he->ptr;
@@ -218,10 +218,10 @@ Curl_hash_apply(curl_hash *h, void *user,
struct curl_llist_element *le;
int i;
- for (i = 0; i < h->slots; ++i) {
- for (le = (h->table[i])->head;
- le;
- le = le->next) {
+ for(i = 0; i < h->slots; ++i) {
+ for(le = (h->table[i])->head;
+ le;
+ le = le->next) {
curl_hash_element *el = le->ptr;
cb(user, el->ptr);
}
@@ -234,7 +234,7 @@ Curl_hash_clean(struct curl_hash *h)
{
int i;
- for (i = 0; i < h->slots; ++i) {
+ for(i = 0; i < h->slots; ++i) {
Curl_llist_destroy(h->table[i], (void *) h);
h->table[i] = NULL;
}
@@ -251,7 +251,7 @@ Curl_hash_clean_with_criterium(struct curl_hash *h, void *user,
struct curl_llist *list;
int i;
- for (i = 0; i < h->slots; ++i) {
+ for(i = 0; i < h->slots; ++i) {
list = h->table[i];
le = list->head; /* get first list entry */
while(le) {
@@ -319,7 +319,7 @@ void Curl_hash_print(struct curl_hash *h,
fprintf(stderr, "=Hash dump=\n");
- for (i = 0; i < h->slots; i++) {
+ for(i = 0; i < h->slots; i++) {
list = h->table[i];
le = list->head; /* get first list entry */
if(le) {
diff --git a/lib/hmac.c b/lib/hmac.c
index 8cb5f2eaa..4df6f79ad 100644
--- a/lib/hmac.c
+++ b/lib/hmac.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -59,7 +59,8 @@ Curl_HMAC_init(const HMAC_params * hashparams,
unsigned char b;
/* Create HMAC context. */
- i = sizeof *ctxt + 2 * hashparams->hmac_ctxtsize + hashparams->hmac_resultlen;
+ i = sizeof *ctxt + 2 * hashparams->hmac_ctxtsize +
+ hashparams->hmac_resultlen;
ctxt = malloc(i);
if(!ctxt)
@@ -84,14 +85,14 @@ Curl_HMAC_init(const HMAC_params * hashparams,
(*hashparams->hmac_hinit)(ctxt->hmac_hashctxt1);
(*hashparams->hmac_hinit)(ctxt->hmac_hashctxt2);
- for (i = 0; i < keylen; i++) {
+ for(i = 0; i < keylen; i++) {
b = (unsigned char)(*key ^ hmac_ipad);
(*hashparams->hmac_hupdate)(ctxt->hmac_hashctxt1, &b, 1);
b = (unsigned char)(*key++ ^ hmac_opad);
(*hashparams->hmac_hupdate)(ctxt->hmac_hashctxt2, &b, 1);
}
- for (; i < hashparams->hmac_maxkeylen; i++) {
+ for(; i < hashparams->hmac_maxkeylen; i++) {
(*hashparams->hmac_hupdate)(ctxt->hmac_hashctxt1, &hmac_ipad, 1);
(*hashparams->hmac_hupdate)(ctxt->hmac_hashctxt2, &hmac_opad, 1);
}
@@ -114,7 +115,8 @@ int Curl_HMAC_final(HMAC_context * ctxt, unsigned char * result)
{
const HMAC_params * hashparams = ctxt->hmac_hash;
- /* Do not get result if called with a null parameter: only release storage. */
+ /* Do not get result if called with a null parameter: only release
+ storage. */
if(!result)
result = (unsigned char *) ctxt->hmac_hashctxt2 +
diff --git a/lib/hostip.c b/lib/hostip.c
index 0683f89a8..387cf2850 100644
--- a/lib/hostip.c
+++ b/lib/hostip.c
@@ -561,7 +561,7 @@ int Curl_resolv_timeout(struct connectdata *conn,
*entry = NULL;
#ifdef USE_ALARM_TIMEOUT
- if (data->set.no_signal)
+ if(data->set.no_signal)
/* Ignore the timeout when signals are disabled */
timeout = 0;
else
@@ -691,7 +691,7 @@ void Curl_resolv_unlock(struct SessionHandle *data, struct Curl_dns_entry *dns)
dns->inuse--;
/* only free if nobody is using AND it is not in hostcache (timestamp ==
0) */
- if (dns->inuse == 0 && dns->timestamp == 0) {
+ if(dns->inuse == 0 && dns->timestamp == 0) {
Curl_freeaddrinfo(dns->addr);
free(dns);
}
@@ -709,7 +709,7 @@ static void freednsentry(void *freethis)
/* mark the entry as not in hostcache */
p->timestamp = 0;
- if (p->inuse == 0) {
+ if(p->inuse == 0) {
Curl_freeaddrinfo(p->addr);
free(p);
}
diff --git a/lib/hostip6.c b/lib/hostip6.c
index 472f04a68..b847f5953 100644
--- a/lib/hostip6.c
+++ b/lib/hostip6.c
@@ -148,7 +148,7 @@ bool Curl_ipvalid(struct connectdata *conn)
static void dump_addrinfo(struct connectdata *conn, const Curl_addrinfo *ai)
{
printf("dump_addrinfo:\n");
- for ( ; ai; ai = ai->ai_next) {
+ for(; ai; ai = ai->ai_next) {
char buf[INET6_ADDRSTRLEN];
printf(" fam %2d, CNAME %s, ",
diff --git a/lib/http.c b/lib/http.c
index 1e463ee69..087c5ddcb 100644
--- a/lib/http.c
+++ b/lib/http.c
@@ -202,10 +202,10 @@ char *Curl_copy_header_value(const char *h)
DEBUGASSERT(h);
/* Find the end of the header name */
- while (*h && (*h != ':'))
+ while(*h && (*h != ':'))
++h;
- if (*h)
+ if(*h)
/* Skip over colon */
++h;
@@ -1485,7 +1485,7 @@ static CURLcode expect100(struct SessionHandle *data,
100-continue to the headers which actually speeds up post operations
(as there is one packet coming back from the web server) */
ptr = Curl_checkheaders(data, "Expect:");
- if (ptr) {
+ if(ptr) {
data->state.expect100header =
Curl_compareheader(ptr, "Expect:", "100-continue");
}
@@ -1797,14 +1797,14 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
redirected request is being out on thin ice. Except if the host name
is the same as the first one! */
char *cookiehost = Curl_copy_header_value(ptr);
- if (!cookiehost)
+ if(!cookiehost)
return CURLE_OUT_OF_MEMORY;
- if (!*cookiehost)
+ if(!*cookiehost)
/* ignore empty data */
free(cookiehost);
else {
char *colon = strchr(cookiehost, ':');
- if (colon)
+ if(colon)
*colon = 0; /* The host must not include an embedded port number */
Curl_safefree(conn->allocptr.cookiehost);
conn->allocptr.cookiehost = cookiehost;
@@ -1882,7 +1882,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
}
ppath = data->change.url;
if(checkprefix("ftp://", ppath)) {
- if (data->set.proxy_transfer_mode) {
+ if(data->set.proxy_transfer_mode) {
/* when doing ftp, append ;type=<a|i> if not present */
char *type = strstr(ppath, ";type=");
if(type && type[6] && type[7] == 0) {
@@ -1899,14 +1899,14 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
char *p = ftp_typecode;
/* avoid sending invalid URLs like ftp://example.com;type=i if the
* user specified ftp://example.com without the slash */
- if (!*data->state.path && ppath[strlen(ppath) - 1] != '/') {
+ if(!*data->state.path && ppath[strlen(ppath) - 1] != '/') {
*p++ = '/';
}
snprintf(p, sizeof(ftp_typecode) - 1, ";type=%c",
data->set.prefer_ascii ? 'a' : 'i');
}
}
- if (conn->bits.user_passwd && !conn->bits.userpwd_in_url)
+ if(conn->bits.user_passwd && !conn->bits.userpwd_in_url)
paste_ftp_userpwd = TRUE;
}
}
@@ -2062,17 +2062,17 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
/* add the main request stuff */
/* GET/HEAD/POST/PUT */
result = Curl_add_bufferf(req_buffer, "%s ", request);
- if (result)
+ if(result)
return result;
/* url */
- if (paste_ftp_userpwd)
+ if(paste_ftp_userpwd)
result = Curl_add_bufferf(req_buffer, "ftp://%s:%s@%s",
conn->user, conn->passwd,
ppath + sizeof("ftp://") - 1);
else
result = Curl_add_buffer(req_buffer, ppath, strlen(ppath));
- if (result)
+ if(result)
return result;
result = Curl_add_bufferf(req_buffer,
@@ -2983,8 +2983,8 @@ CURLcode Curl_http_readwrite_headers(struct SessionHandle *data,
data->info.httpcode = k->httpcode;
data->info.httpversion = conn->httpversion;
- if (!data->state.httpversion ||
- data->state.httpversion > conn->httpversion)
+ if(!data->state.httpversion ||
+ data->state.httpversion > conn->httpversion)
/* store the lowest server version we encounter */
data->state.httpversion = conn->httpversion;
@@ -3095,9 +3095,9 @@ CURLcode Curl_http_readwrite_headers(struct SessionHandle *data,
/* check for Content-Type: header lines to get the MIME-type */
else if(checkprefix("Content-Type:", k->p)) {
char *contenttype = Curl_copy_header_value(k->p);
- if (!contenttype)
+ if(!contenttype)
return CURLE_OUT_OF_MEMORY;
- if (!*contenttype)
+ if(!*contenttype)
/* ignore empty data */
free(contenttype);
else {
@@ -3301,9 +3301,9 @@ CURLcode Curl_http_readwrite_headers(struct SessionHandle *data,
!data->req.location) {
/* this is the URL that the server advises us to use instead */
char *location = Curl_copy_header_value(k->p);
- if (!location)
+ if(!location)
return CURLE_OUT_OF_MEMORY;
- if (!*location)
+ if(!*location)
/* ignore empty data */
free(location);
else {
diff --git a/lib/http_digest.c b/lib/http_digest.c
index 4993a987d..7fc84cd2e 100644
--- a/lib/http_digest.c
+++ b/lib/http_digest.c
@@ -88,8 +88,8 @@ static int get_pair(const char *str, char *value, char *content,
break;
case ',':
if(!starts_with_quote) {
- /* this signals the end of the content if we didn't get a starting quote
- and then we do "sloppy" parsing */
+ /* this signals the end of the content if we didn't get a starting
+ quote and then we do "sloppy" parsing */
c=0; /* the end */
continue;
}
diff --git a/lib/http_negotiate.c b/lib/http_negotiate.c
index 673f8c908..6f9c109c6 100644
--- a/lib/http_negotiate.c
+++ b/lib/http_negotiate.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -100,7 +100,8 @@ get_gss_name(struct connectdata *conn, bool proxy, gss_name_t *server)
}
static void
-log_gss_error(struct connectdata *conn, OM_uint32 error_status, const char *prefix)
+log_gss_error(struct connectdata *conn, OM_uint32 error_status,
+ const char *prefix)
{
OM_uint32 maj_stat, min_stat;
OM_uint32 msg_ctx = 0;
@@ -192,47 +193,47 @@ int Curl_input_negotiate(struct connectdata *conn, bool proxy,
#ifdef HAVE_SPNEGO /* Handle SPNEGO */
if(checkprefix("Negotiate", header)) {
- ASN1_OBJECT * object = NULL;
- int rc = 1;
- unsigned char * spnegoToken = NULL;
- size_t spnegoTokenLength = 0;
- unsigned char * mechToken = NULL;
- size_t mechTokenLength = 0;
+ ASN1_OBJECT * object = NULL;
+ int rc = 1;
+ unsigned char * spnegoToken = NULL;
+ size_t spnegoTokenLength = 0;
+ unsigned char * mechToken = NULL;
+ size_t mechTokenLength = 0;
+
+ if(input_token.value == NULL)
+ return CURLE_OUT_OF_MEMORY;
- if(input_token.value == NULL)
- return CURLE_OUT_OF_MEMORY;
+ spnegoToken = malloc(input_token.length);
+ if(spnegoToken == NULL)
+ return CURLE_OUT_OF_MEMORY;
- spnegoToken = malloc(input_token.length);
- if(spnegoToken == NULL)
+ spnegoTokenLength = input_token.length;
+
+ object = OBJ_txt2obj ("1.2.840.113554.1.2.2", 1);
+ if(!parseSpnegoTargetToken(spnegoToken,
+ spnegoTokenLength,
+ NULL,
+ NULL,
+ &mechToken,
+ &mechTokenLength,
+ NULL,
+ NULL)) {
+ free(spnegoToken);
+ spnegoToken = NULL;
+ infof(conn->data, "Parse SPNEGO Target Token failed\n");
+ }
+ else {
+ free(input_token.value);
+ input_token.value = malloc(mechTokenLength);
+ if(input_token.value == NULL)
return CURLE_OUT_OF_MEMORY;
- spnegoTokenLength = input_token.length;
-
- object = OBJ_txt2obj ("1.2.840.113554.1.2.2", 1);
- if(!parseSpnegoTargetToken(spnegoToken,
- spnegoTokenLength,
- NULL,
- NULL,
- &mechToken,
- &mechTokenLength,
- NULL,
- NULL)) {
- free(spnegoToken);
- spnegoToken = NULL;
- infof(conn->data, "Parse SPNEGO Target Token failed\n");
- }
- else {
- free(input_token.value);
- input_token.value = malloc(mechTokenLength);
- if (input_token.value == NULL)
- return CURLE_OUT_OF_MEMORY;
-
- memcpy(input_token.value, mechToken,mechTokenLength);
- input_token.length = mechTokenLength;
- free(mechToken);
- mechToken = NULL;
- infof(conn->data, "Parse SPNEGO Target Token succeeded\n");
- }
+ memcpy(input_token.value, mechToken,mechTokenLength);
+ input_token.length = mechTokenLength;
+ free(mechToken);
+ mechToken = NULL;
+ infof(conn->data, "Parse SPNEGO Target Token succeeded\n");
+ }
}
#endif
}
diff --git a/lib/http_negotiate_sspi.c b/lib/http_negotiate_sspi.c
index 5843ab251..7e431965b 100644
--- a/lib/http_negotiate_sspi.c
+++ b/lib/http_negotiate_sspi.c
@@ -133,11 +133,11 @@ int Curl_input_negotiate(struct connectdata *conn, bool proxy,
(ret = get_gss_name(conn, proxy, neg_ctx->server_name)))
return ret;
- if (!neg_ctx->max_token_length) {
+ if(!neg_ctx->max_token_length) {
PSecPkgInfo SecurityPackage;
ret = s_pSecFn->QuerySecurityPackageInfo((SEC_CHAR *)"Negotiate",
&SecurityPackage);
- if (ret != SEC_E_OK)
+ if(ret != SEC_E_OK)
return -1;
/* Allocate input and output buffers according to the max token size
@@ -164,14 +164,14 @@ int Curl_input_negotiate(struct connectdata *conn, bool proxy,
return -1;
}
- if ( !input_token ) {
- /* first call in a new negotiation, we have to require credentials,
+ if(!input_token) {
+ /* first call in a new negotation, we have to require credentials,
and allocate memory for the context */
neg_ctx->credentials = (CredHandle *)malloc(sizeof(CredHandle));
neg_ctx->context = (CtxtHandle *)malloc(sizeof(CtxtHandle));
- if ( !neg_ctx->credentials || !neg_ctx->context)
+ if( !neg_ctx->credentials || !neg_ctx->context)
return -1;
neg_ctx->status =
@@ -179,7 +179,7 @@ int Curl_input_negotiate(struct connectdata *conn, bool proxy,
SECPKG_CRED_OUTBOUND, NULL, NULL,
NULL, NULL, neg_ctx->credentials,
&lifetime);
- if ( neg_ctx->status != SEC_E_OK )
+ if( neg_ctx->status != SEC_E_OK )
return -1;
}
@@ -193,7 +193,7 @@ int Curl_input_negotiate(struct connectdata *conn, bool proxy,
out_sec_buff.pvBuffer = neg_ctx->output_token;
- if (input_token) {
+ if(input_token) {
in_buff_desc.ulVersion = 0;
in_buff_desc.cBuffers = 1;
in_buff_desc.pBuffers = &out_sec_buff;
@@ -217,14 +217,14 @@ int Curl_input_negotiate(struct connectdata *conn, bool proxy,
&context_attributes,
&lifetime);
- if ( GSS_ERROR(neg_ctx->status) )
+ if( GSS_ERROR(neg_ctx->status) )
return -1;
- if ( neg_ctx->status == SEC_I_COMPLETE_NEEDED ||
+ if( neg_ctx->status == SEC_I_COMPLETE_NEEDED ||
neg_ctx->status == SEC_I_COMPLETE_AND_CONTINUE ) {
neg_ctx->status = s_pSecFn->CompleteAuthToken(neg_ctx->context,
&out_buff_desc);
- if ( GSS_ERROR(neg_ctx->status) )
+ if( GSS_ERROR(neg_ctx->status) )
return -1;
}
diff --git a/lib/http_ntlm.c b/lib/http_ntlm.c
index 3900f401a..e279fd07b 100644
--- a/lib/http_ntlm.c
+++ b/lib/http_ntlm.c
@@ -25,10 +25,6 @@
http://davenport.sourceforge.net/ntlm.html
http://www.innovation.ch/java/ntlm.html
-
- Another implementation:
- http://lxr.mozilla.org/mozilla/source/security/manager/ssl/src/nsNTLMAuthModule.cpp
-
*/
#ifndef CURL_DISABLE_HTTP
@@ -137,7 +133,7 @@
/* The last #include file should be: */
#include "memdebug.h"
-#ifndef USE_NTRESPONSES
+#ifndef USE_NTRESPONSES
/* Define this to make the type-3 message include the NT response message */
#define USE_NTRESPONSES 1
@@ -571,7 +567,7 @@ static void ascii_to_unicode_le(unsigned char *dest, const char *src,
size_t srclen)
{
size_t i;
- for (i=0; i<srclen; i++) {
+ for(i=0; i<srclen; i++) {
dest[2*i] = (unsigned char)src[i];
dest[2*i+1] = '\0';
}
@@ -732,10 +728,10 @@ CURLcode Curl_output_ntlm(struct connectdata *conn,
passwdp="";
#ifdef USE_WINDOWS_SSPI
- if (s_hSecDll == NULL) {
+ if(s_hSecDll == NULL) {
/* not thread safe and leaks - use curl_global_init() to avoid */
CURLcode err = Curl_sspi_global_init();
- if (s_hSecDll == NULL)
+ if(s_hSecDll == NULL)
return err;
}
#endif
@@ -889,25 +885,26 @@ CURLcode Curl_output_ntlm(struct connectdata *conn,
#endif
DEBUG_OUT({
- fprintf(stderr, "**** TYPE1 header flags=0x%02.2x%02.2x%02.2x%02.2x 0x%08.8x ",
- LONGQUARTET(NTLMFLAG_NEGOTIATE_OEM|
- NTLMFLAG_REQUEST_TARGET|
- NTLMFLAG_NEGOTIATE_NTLM_KEY|
- NTLM2FLAG|
- NTLMFLAG_NEGOTIATE_ALWAYS_SIGN),
- NTLMFLAG_NEGOTIATE_OEM|
- NTLMFLAG_REQUEST_TARGET|
- NTLMFLAG_NEGOTIATE_NTLM_KEY|
- NTLM2FLAG|
- NTLMFLAG_NEGOTIATE_ALWAYS_SIGN);
- print_flags(stderr,
- NTLMFLAG_NEGOTIATE_OEM|
- NTLMFLAG_REQUEST_TARGET|
- NTLMFLAG_NEGOTIATE_NTLM_KEY|
- NTLM2FLAG|
- NTLMFLAG_NEGOTIATE_ALWAYS_SIGN);
- fprintf(stderr, "\n****\n");
- });
+ fprintf(stderr, "* TYPE1 header flags=0x%02.2x%02.2x%02.2x%02.2x "
+ "0x%08.8x ",
+ LONGQUARTET(NTLMFLAG_NEGOTIATE_OEM|
+ NTLMFLAG_REQUEST_TARGET|
+ NTLMFLAG_NEGOTIATE_NTLM_KEY|
+ NTLM2FLAG|
+ NTLMFLAG_NEGOTIATE_ALWAYS_SIGN),
+ NTLMFLAG_NEGOTIATE_OEM|
+ NTLMFLAG_REQUEST_TARGET|
+ NTLMFLAG_NEGOTIATE_NTLM_KEY|
+ NTLM2FLAG|
+ NTLMFLAG_NEGOTIATE_ALWAYS_SIGN);
+ print_flags(stderr,
+ NTLMFLAG_NEGOTIATE_OEM|
+ NTLMFLAG_REQUEST_TARGET|
+ NTLMFLAG_NEGOTIATE_NTLM_KEY|
+ NTLM2FLAG|
+ NTLMFLAG_NEGOTIATE_ALWAYS_SIGN);
+ fprintf(stderr, "\n****\n");
+ });
/* now size is the size of the base64 encoded package size */
size = Curl_base64_encode(NULL, (char *)ntlmbuf, size, &base64);
@@ -963,14 +960,17 @@ CURLcode Curl_output_ntlm(struct connectdata *conn,
type_3.pvBuffer = ntlmbuf;
type_3.cbBuffer = sizeof(ntlmbuf);
- status = s_pSecFn->InitializeSecurityContextA(&ntlm->handle, &ntlm->c_handle,
- (char *) host,
- ISC_REQ_CONFIDENTIALITY |
- ISC_REQ_REPLAY_DETECT |
- ISC_REQ_CONNECTION,
- 0, SECURITY_NETWORK_DREP, &type_2_desc,
- 0, &ntlm->c_handle, &type_3_desc,
- &attrs, &tsDummy);
+ status = s_pSecFn->InitializeSecurityContextA(&ntlm->handle,
+ &ntlm->c_handle,
+ (char *) host,
+ ISC_REQ_CONFIDENTIALITY |
+ ISC_REQ_REPLAY_DETECT |
+ ISC_REQ_CONNECTION,
+ 0, SECURITY_NETWORK_DREP,
+ &type_2_desc,
+ 0, &ntlm->c_handle,
+ &type_3_desc,
+ &attrs, &tsDummy);
if(status != SEC_E_OK)
return CURLE_RECV_ERROR;
@@ -1084,7 +1084,7 @@ CURLcode Curl_output_ntlm(struct connectdata *conn,
}
else
#endif
- {
+ {
#if USE_NTRESPONSES
unsigned char ntbuffer[0x18];
@@ -1219,14 +1219,14 @@ CURLcode Curl_output_ntlm(struct connectdata *conn,
}
DEBUG_OUT({
- fprintf(stderr, "\n ntresp=");
+ fprintf(stderr, "\n ntresp=");
print_hex(stderr, (char *)&ntlmbuf[ntrespoff], 0x18);
});
#endif
DEBUG_OUT({
- fprintf(stderr, "\n flags=0x%02.2x%02.2x%02.2x%02.2x 0x%08.8x ",
+ fprintf(stderr, "\n flags=0x%02.2x%02.2x%02.2x%02.2x 0x%08.8x ",
LONGQUARTET(ntlm->flags), ntlm->flags);
print_flags(stderr, ntlm->flags);
fprintf(stderr, "\n****\n");
diff --git a/lib/http_proxy.c b/lib/http_proxy.c
index 89cfb72c8..523f4aea8 100644
--- a/lib/http_proxy.c
+++ b/lib/http_proxy.c
@@ -164,8 +164,9 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn,
if(CURLE_OK == result) {
/* Now send off the request */
- result = Curl_add_buffer_send(req_buffer, conn,
- &data->info.request_size, 0, sockindex);
+ result =
+ Curl_add_buffer_send(req_buffer, conn,
+ &data->info.request_size, 0, sockindex);
}
req_buffer = NULL;
if(result)
diff --git a/lib/idn_win32.c b/lib/idn_win32.c
index 0c791ae60..74abfb6d0 100644
--- a/lib/idn_win32.c
+++ b/lib/idn_win32.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -39,13 +39,13 @@ static wchar_t *_curl_win32_UTF8_to_wchar(const char *str_utf8)
{
wchar_t *str_w = NULL;
- if (str_utf8) {
+ if(str_utf8) {
int str_w_len = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS,
str_utf8, -1, NULL, 0);
- if (str_w_len) {
+ if(str_w_len) {
str_w = (wchar_t *) malloc(str_w_len * sizeof(wchar_t));
- if (str_w) {
- if (MultiByteToWideChar(CP_UTF8, 0, str_utf8, -1, str_w,
+ if(str_w) {
+ if(MultiByteToWideChar(CP_UTF8, 0, str_utf8, -1, str_w,
str_w_len) == 0) {
free(str_w);
str_w = NULL;
@@ -61,13 +61,13 @@ static const char *_curl_win32_wchar_to_UTF8(const wchar_t *str_w)
{
char *str_utf8 = NULL;
- if (str_w) {
+ if(str_w) {
size_t str_utf8_len = WideCharToMultiByte(CP_UTF8, 0, str_w, -1, NULL,
0, NULL, NULL);
- if (str_utf8_len) {
+ if(str_utf8_len) {
str_utf8 = (char *) malloc(str_utf8_len * sizeof(wchar_t));
- if (str_utf8) {
- if (WideCharToMultiByte(CP_UTF8, 0, str_w, -1, str_utf8, str_utf8_len,
+ if(str_utf8) {
+ if(WideCharToMultiByte(CP_UTF8, 0, str_w, -1, str_utf8, str_utf8_len,
NULL, FALSE) == 0) {
(void) GetLastError();
free((void *)str_utf8);
@@ -86,9 +86,9 @@ static const char *_curl_win32_wchar_to_UTF8(const wchar_t *str_w)
int curl_win32_idn_to_ascii(const char *in, char **out)
{
wchar_t *in_w = _curl_win32_UTF8_to_wchar(in);
- if (in_w) {
+ if(in_w) {
wchar_t punycode[IDN_MAX_LENGTH];
- if (IdnToAscii(0, in_w, -1, punycode, IDN_MAX_LENGTH) == 0) {
+ if(IdnToAscii(0, in_w, -1, punycode, IDN_MAX_LENGTH) == 0) {
wprintf(L"ERROR %d converting to Punycode\n", GetLastError());
free(in_w);
return 0;
@@ -96,7 +96,7 @@ int curl_win32_idn_to_ascii(const char *in, char **out)
free(in_w);
*out = (char *)_curl_win32_wchar_to_UTF8(punycode);
- if (!(*out)) {
+ if(!(*out)) {
return 0;
}
}
@@ -105,16 +105,16 @@ int curl_win32_idn_to_ascii(const char *in, char **out)
int curl_win32_ascii_to_idn(const char *in, size_t in_len, char **out_utf8)
{
- if (in) {
+ if(in) {
WCHAR unicode[IDN_MAX_LENGTH];
- if (IdnToUnicode(0, (wchar_t *)in, -1, unicode, IDN_MAX_LENGTH) == 0) {
+ if(IdnToUnicode(0, (wchar_t *)in, -1, unicode, IDN_MAX_LENGTH) == 0) {
wprintf(L"ERROR %d converting to Punycode\n", GetLastError());
return 0;
}
else {
const char *out_utf8 = _curl_win32_wchar_to_UTF8(unicode);
- if (!out_utf8) {
+ if(!out_utf8) {
return 0;
}
}
diff --git a/lib/if2ip.c b/lib/if2ip.c
index 19504d1fd..4924f7301 100644
--- a/lib/if2ip.c
+++ b/lib/if2ip.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2009, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -76,22 +76,22 @@ char *Curl_if2ip(int af, const char *interface, char *buf, int buf_size)
struct ifaddrs *iface, *head;
char *ip=NULL;
- if (getifaddrs(&head) >= 0) {
- for (iface=head; iface != NULL; iface=iface->ifa_next) {
- if ((iface->ifa_addr != NULL) &&
- (iface->ifa_addr->sa_family == af) &&
- curl_strequal(iface->ifa_name, interface)) {
+ if(getifaddrs(&head) >= 0) {
+ for(iface=head; iface != NULL; iface=iface->ifa_next) {
+ if((iface->ifa_addr != NULL) &&
+ (iface->ifa_addr->sa_family == af) &&
+ curl_strequal(iface->ifa_name, interface)) {
void *addr;
char scope[12]="";
#ifdef ENABLE_IPV6
- if (af == AF_INET6) {
+ if(af == AF_INET6) {
unsigned int scopeid = 0;
addr = &((struct sockaddr_in6 *)iface->ifa_addr)->sin6_addr;
#ifdef HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID
/* Include the scope of this interface as part of the address */
scopeid = ((struct sockaddr_in6 *)iface->ifa_addr)->sin6_scope_id;
#endif
- if (scopeid)
+ if(scopeid)
snprintf(scope, sizeof(scope), "%%%u", scopeid);
}
else
diff --git a/lib/imap.c b/lib/imap.c
index 78c412e13..06135a309 100644
--- a/lib/imap.c
+++ b/lib/imap.c
@@ -99,7 +99,7 @@ static CURLcode imap_do(struct connectdata *conn, bool *done);
static CURLcode imap_done(struct connectdata *conn,
CURLcode, bool premature);
static CURLcode imap_connect(struct connectdata *conn, bool *done);
-static CURLcode imap_disconnect(struct connectdata *conn, bool dead_connection);
+static CURLcode imap_disconnect(struct connectdata *conn, bool dead);
static CURLcode imap_multi_statemach(struct connectdata *conn, bool *done);
static int imap_getsock(struct connectdata *conn,
curl_socket_t *socks,
diff --git a/lib/imap.h b/lib/imap.h
index c1395160a..e56c7643e 100644
--- a/lib/imap.h
+++ b/lib/imap.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 2009, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 2009 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -33,7 +33,8 @@ typedef enum {
a connect */
IMAP_LOGIN,
IMAP_STARTTLS,
- IMAP_UPGRADETLS, /* asynchronously upgrade the connection to SSL/TLS (multi mode only) */
+ IMAP_UPGRADETLS, /* asynchronously upgrade the connection to SSL/TLS
+ (multi mode only) */
IMAP_SELECT,
IMAP_FETCH,
IMAP_LOGOUT,
@@ -48,7 +49,7 @@ struct imap_conn {
imapstate state; /* always use imap.c:state() to change state! */
int cmdid; /* id number/index */
const char *idstr; /* pointer to a string for which to wait for as id */
- bool ssldone; /* is connect() over SSL done? only relevant in multi mode */
+ bool ssldone; /* connect() over SSL? only relevant in multi mode */
};
extern const struct Curl_handler Curl_handler_imap;
diff --git a/lib/inet_ntop.c b/lib/inet_ntop.c
index 5012fbc4c..34cae801a 100644
--- a/lib/inet_ntop.c
+++ b/lib/inet_ntop.c
@@ -69,8 +69,7 @@ static char *inet_ntop4 (const unsigned char *src, char *dst, size_t size)
((int)((unsigned char)src[3])) & 0xff);
len = strlen(tmp);
- if(len == 0 || len >= size)
- {
+ if(len == 0 || len >= size) {
SET_ERRNO(ENOSPC);
return (NULL);
}
@@ -105,61 +104,51 @@ static char *inet_ntop6 (const unsigned char *src, char *dst, size_t size)
* Find the longest run of 0x00's in src[] for :: shorthanding.
*/
memset(words, '\0', sizeof(words));
- for (i = 0; i < IN6ADDRSZ; i++)
- words[i/2] |= (src[i] << ((1 - (i % 2)) << 3));
+ for(i = 0; i < IN6ADDRSZ; i++)
+ words[i/2] |= (src[i] << ((1 - (i % 2)) << 3));
best.base = -1;
cur.base = -1;
best.len = 0;
cur.len = 0;
- for (i = 0; i < (IN6ADDRSZ / INT16SZ); i++)
- {
- if(words[i] == 0)
- {
+ for(i = 0; i < (IN6ADDRSZ / INT16SZ); i++) {
+ if(words[i] == 0) {
if(cur.base == -1)
cur.base = i, cur.len = 1;
else
cur.len++;
}
- else if(cur.base != -1)
- {
+ else if(cur.base != -1) {
if(best.base == -1 || cur.len > best.len)
- best = cur;
+ best = cur;
cur.base = -1;
}
}
if((cur.base != -1) && (best.base == -1 || cur.len > best.len))
- best = cur;
+ best = cur;
if(best.base != -1 && best.len < 2)
- best.base = -1;
-
- /* Format the result.
- */
+ best.base = -1;
+ /* Format the result. */
tp = tmp;
- for (i = 0; i < (IN6ADDRSZ / INT16SZ); i++)
- {
- /* Are we inside the best run of 0x00's?
- */
- if(best.base != -1 && i >= best.base && i < (best.base + best.len))
- {
+ for(i = 0; i < (IN6ADDRSZ / INT16SZ); i++) {
+ /* Are we inside the best run of 0x00's? */
+ if(best.base != -1 && i >= best.base && i < (best.base + best.len)) {
if(i == best.base)
- *tp++ = ':';
+ *tp++ = ':';
continue;
}
/* Are we following an initial run of 0x00s or any real hex?
*/
if(i != 0)
- *tp++ = ':';
+ *tp++ = ':';
/* Is this address an encapsulated IPv4?
*/
if(i == 6 && best.base == 0 &&
- (best.len == 6 || (best.len == 5 && words[5] == 0xffff)))
- {
- if(!inet_ntop4(src+12, tp, sizeof(tmp) - (tp - tmp)))
- {
+ (best.len == 6 || (best.len == 5 && words[5] == 0xffff))) {
+ if(!inet_ntop4(src+12, tp, sizeof(tmp) - (tp - tmp))) {
SET_ERRNO(ENOSPC);
return (NULL);
}
@@ -177,8 +166,7 @@ static char *inet_ntop6 (const unsigned char *src, char *dst, size_t size)
/* Check for overflow, copy, and we're done.
*/
- if((size_t)(tp - tmp) > size)
- {
+ if((size_t)(tp - tmp) > size) {
SET_ERRNO(ENOSPC);
return (NULL);
}
diff --git a/lib/inet_pton.c b/lib/inet_pton.c
index d2a54e9f3..d08c7c666 100644
--- a/lib/inet_pton.c
+++ b/lib/inet_pton.c
@@ -223,7 +223,7 @@ inet_pton6(const char *src, unsigned char *dst)
if(tp == endp)
return (0);
- for (i = 1; i <= n; i++) {
+ for(i = 1; i <= n; i++) {
*(endp - i) = *(colonp + n - i);
*(colonp + n - i) = 0;
}
diff --git a/lib/krb4.c b/lib/krb4.c
index 2895cedaa..7da47f31f 100644
--- a/lib/krb4.c
+++ b/lib/krb4.c
@@ -7,7 +7,7 @@
*
* Copyright (c) 1995, 1996, 1997, 1998, 1999 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
- * Copyright (c) 2004 - 2010 Daniel Stenberg
+ * Copyright (c) 2004 - 2011 Daniel Stenberg
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -88,9 +88,9 @@ strlcpy (char *dst, const char *src, size_t dst_sz)
size_t n;
char *p;
- for (p = dst, n = 0;
- n + 1 < dst_sz && *src != '\0';
- ++p, ++src, ++n)
+ for(p = dst, n = 0;
+ n + 1 < dst_sz && *src != '\0';
+ ++p, ++src, ++n)
*p = *src;
*p = '\0';
if(*src == '\0')
diff --git a/lib/krb4.h b/lib/krb4.h
index b3b5ea763..b0307122c 100644
--- a/lib/krb4.h
+++ b/lib/krb4.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -47,7 +47,8 @@ extern struct Curl_sec_client_mech Curl_krb5_client_mech;
#endif
CURLcode Curl_krb_kauth(struct connectdata *conn);
-int Curl_sec_read_msg (struct connectdata *conn, char *, enum protection_level);
+int Curl_sec_read_msg (struct connectdata *conn, char *,
+ enum protection_level);
void Curl_sec_end (struct connectdata *);
CURLcode Curl_sec_login (struct connectdata *);
int Curl_sec_request_prot (struct connectdata *conn, const char *level);
diff --git a/lib/krb5.c b/lib/krb5.c
index e711431cc..f128d515f 100644
--- a/lib/krb5.c
+++ b/lib/krb5.c
@@ -157,7 +157,8 @@ krb5_encode(void *app_data, const void *from, int length, int level, void **to,
if(maj != GSS_S_COMPLETE)
return -1;
- /* malloc a new buffer, in case gss_release_buffer doesn't work as expected */
+ /* malloc a new buffer, in case gss_release_buffer doesn't work as
+ expected */
*to = malloc(enc.length);
if(!*to)
return -1;
@@ -222,7 +223,8 @@ krb5_auth(void *app_data, struct connectdata *conn)
if(maj != GSS_S_COMPLETE) {
gss_release_name(&min, &gssname);
if(service == srv_host) {
- Curl_failf(data, "Error importing service name %s", input_buffer.value);
+ Curl_failf(data, "Error importing service name %s",
+ input_buffer.value);
return AUTH_ERROR;
}
service = srv_host;
@@ -327,7 +329,7 @@ static void krb5_end(void *app_data)
{
OM_uint32 maj, min;
gss_ctx_id_t *context = app_data;
- if (*context != GSS_C_NO_CONTEXT) {
+ if(*context != GSS_C_NO_CONTEXT) {
maj = gss_delete_sec_context(&min, context, GSS_C_NO_BUFFER);
DEBUGASSERT(maj == GSS_S_COMPLETE);
}
diff --git a/lib/ldap.c b/lib/ldap.c
index 3f067230f..69667fdf8 100644
--- a/lib/ldap.c
+++ b/lib/ldap.c
@@ -46,7 +46,8 @@
#ifdef CURL_LDAP_WIN /* Use Windows LDAP implementation. */
# include <winldap.h>
# ifndef LDAP_VENDOR_NAME
-# error Your Platform SDK is NOT sufficient for LDAP support! Update your Platform SDK, or disable LDAP support!
+# error Your Platform SDK is NOT sufficient for LDAP support! \
+ Update your Platform SDK, or disable LDAP support!
# else
# include <winber.h>
# endif
@@ -255,9 +256,9 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
goto quit;
}
ldap_option = LDAPSSL_VERIFY_SERVER;
- } else {
- ldap_option = LDAPSSL_VERIFY_NONE;
}
+ else
+ ldap_option = LDAPSSL_VERIFY_NONE;
rc = ldapssl_set_verify_mode(ldap_option);
if(rc != LDAP_SUCCESS) {
failf(data, "LDAP local: ERROR setting cert verify mode: %s",
@@ -277,7 +278,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
/* OpenLDAP SDK supports BASE64 files. */
if((data->set.str[STRING_CERT_TYPE]) &&
(!Curl_raw_equal(data->set.str[STRING_CERT_TYPE], "PEM"))) {
- failf(data, "LDAP local: ERROR OpenLDAP does only support PEM cert-type!");
+ failf(data, "LDAP local: ERROR OpenLDAP only supports PEM cert-type!");
status = CURLE_SSL_CERTPROBLEM;
goto quit;
}
@@ -295,9 +296,10 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
goto quit;
}
ldap_option = LDAP_OPT_X_TLS_DEMAND;
- } else {
- ldap_option = LDAP_OPT_X_TLS_NEVER;
}
+ else
+ ldap_option = LDAP_OPT_X_TLS_NEVER;
+
rc = ldap_set_option(NULL, LDAP_OPT_X_TLS_REQUIRE_CERT, &ldap_option);
if(rc != LDAP_SUCCESS) {
failf(data, "LDAP local: ERROR setting cert verify mode: %s",
@@ -339,7 +341,8 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
#endif
#endif
#endif /* CURL_LDAP_USE_SSL */
- } else {
+ }
+ else {
server = ldap_init(conn->host.name, (int)conn->port);
if(server == NULL) {
failf(data, "LDAP local: Cannot connect to %s:%hu",
@@ -363,9 +366,9 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
conn->bits.user_passwd ? conn->passwd : NULL);
}
if(rc != 0) {
- failf(data, "LDAP local: ldap_simple_bind_s %s", ldap_err2string(rc));
- status = CURLE_LDAP_CANNOT_BIND;
- goto quit;
+ failf(data, "LDAP local: ldap_simple_bind_s %s", ldap_err2string(rc));
+ status = CURLE_LDAP_CANNOT_BIND;
+ goto quit;
}
rc = ldap_search_s(server, ludp->lud_dn, ludp->lud_scope,
@@ -379,8 +382,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
for(num = 0, entryIterator = ldap_first_entry(server, result);
entryIterator;
- entryIterator = ldap_next_entry(server, entryIterator), num++)
- {
+ entryIterator = ldap_next_entry(server, entryIterator), num++) {
BerElement *ber = NULL;
char *attribute; /*! suspicious that this isn't 'const' */
char *dn = ldap_get_dn(server, entryIterator);
@@ -392,16 +394,13 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
dlsize += strlen(dn)+5;
- for (attribute = ldap_first_attribute(server, entryIterator, &ber);
- attribute;
- attribute = ldap_next_attribute(server, entryIterator, ber))
- {
+ for(attribute = ldap_first_attribute(server, entryIterator, &ber);
+ attribute;
+ attribute = ldap_next_attribute(server, entryIterator, ber)) {
BerValue **vals = ldap_get_values_len(server, entryIterator, attribute);
- if(vals != NULL)
- {
- for (i = 0; (vals[i] != NULL); i++)
- {
+ 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);
@@ -515,15 +514,15 @@ static char **split_str (char *str)
char **res, *lasts, *s;
int i;
- for (i = 2, s = strchr(str,','); s; i++)
- s = strchr(++s,',');
+ for(i = 2, s = strchr(str,','); s; i++)
+ s = strchr(++s,',');
res = calloc(i, sizeof(char*));
if(!res)
return NULL;
- for (i = 0, s = strtok_r(str, ",", &lasts); s;
- s = strtok_r(NULL, ",", &lasts), i++)
+ for(i = 0, s = strtok_r(str, ",", &lasts); s;
+ s = strtok_r(NULL, ",", &lasts), i++)
res[i] = s;
return res;
}
@@ -541,16 +540,16 @@ static bool unescape_elements (void *data, LDAPURLDesc *ludp)
return (FALSE);
}
- for (i = 0; ludp->lud_attrs && ludp->lud_attrs[i]; i++) {
+ 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])
- return (FALSE);
+ return (FALSE);
}
- for (i = 0; ludp->lud_exts && ludp->lud_exts[i]; i++) {
+ 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])
- return (FALSE);
+ return (FALSE);
}
if(ludp->lud_dn) {
@@ -620,7 +619,7 @@ static int _ldap_url_parse2 (const struct connectdata *conn, LDAPURLDesc *ludp)
if(!ludp->lud_attrs)
return LDAP_NO_MEMORY;
- for (i = 0; ludp->lud_attrs[i]; i++)
+ for(i = 0; ludp->lud_attrs[i]; i++)
LDAP_TRACE (("attr[%d] '%s'\n", i, ludp->lud_attrs[i]));
}
@@ -666,7 +665,7 @@ static int _ldap_url_parse2 (const struct connectdata *conn, LDAPURLDesc *ludp)
if(!ludp->lud_exts)
return LDAP_NO_MEMORY;
- for (i = 0; ludp->lud_exts[i]; i++)
+ for(i = 0; ludp->lud_exts[i]; i++)
LDAP_TRACE (("exts[%d] '%s'\n", i, ludp->lud_exts[i]));
success:
@@ -699,23 +698,23 @@ static void _ldap_free_urldesc (LDAPURLDesc *ludp)
int i;
if(!ludp)
- return;
+ return;
if(ludp->lud_dn)
- free(ludp->lud_dn);
+ free(ludp->lud_dn);
if(ludp->lud_filter)
- free(ludp->lud_filter);
+ free(ludp->lud_filter);
if(ludp->lud_attrs) {
- for (i = 0; ludp->lud_attrs[i]; i++)
- free(ludp->lud_attrs[i]);
+ for(i = 0; ludp->lud_attrs[i]; i++)
+ free(ludp->lud_attrs[i]);
free(ludp->lud_attrs);
}
if(ludp->lud_exts) {
- for (i = 0; ludp->lud_exts[i]; i++)
- free(ludp->lud_exts[i]);
+ for(i = 0; ludp->lud_exts[i]; i++)
+ free(ludp->lud_exts[i]);
free(ludp->lud_exts);
}
free (ludp);
diff --git a/lib/llist.c b/lib/llist.c
index 71238fa73..42364b121 100644
--- a/lib/llist.c
+++ b/lib/llist.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -115,7 +115,8 @@ Curl_llist_remove(struct curl_llist *list, struct curl_llist_element *e,
list->tail = NULL;
else
e->next->prev = NULL;
- } else {
+ }
+ else {
e->prev->next = e->next;
if(!e->next)
list->tail = e->prev;
@@ -149,7 +150,8 @@ Curl_llist_count(struct curl_llist *list)
}
int Curl_llist_move(struct curl_llist *list, struct curl_llist_element *e,
- struct curl_llist *to_list, struct curl_llist_element *to_e)
+ struct curl_llist *to_list,
+ struct curl_llist_element *to_e)
{
/* Remove element from list */
if(e == NULL || list->size == 0)
diff --git a/lib/md4.c b/lib/md4.c
index ecf3bfcd8..84c520210 100644
--- a/lib/md4.c
+++ b/lib/md4.c
@@ -113,19 +113,19 @@ static void MD4Update(MD4_CTX *context, const unsigned char *input,
/* Compute number of bytes mod 64 */
bufindex = (unsigned int)((context->count[0] >> 3) & 0x3F);
/* Update number of bits */
- if ((context->count[0] += ((UINT4)inputLen << 3))
- < ((UINT4)inputLen << 3))
+ if((context->count[0] += ((UINT4)inputLen << 3))
+ < ((UINT4)inputLen << 3))
context->count[1]++;
context->count[1] += ((UINT4)inputLen >> 29);
partLen = 64 - bufindex;
/* Transform as many times as possible.
*/
- if (inputLen >= partLen) {
+ if(inputLen >= partLen) {
memcpy(&context->buffer[bufindex], input, partLen);
MD4Transform (context->state, context->buffer);
- for (i = partLen; i + 63 < inputLen; i += 64)
+ for(i = partLen; i + 63 < inputLen; i += 64)
MD4Transform (context->state, &input[i]);
bufindex = 0;
@@ -251,7 +251,7 @@ static void Encode(unsigned char *output, UINT4 *input, unsigned int len)
{
unsigned int i, j;
- for (i = 0, j = 0; j < len; i++, j += 4) {
+ for(i = 0, j = 0; j < len; i++, j += 4) {
output[j] = (unsigned char)(input[i] & 0xff);
output[j+1] = (unsigned char)((input[i] >> 8) & 0xff);
output[j+2] = (unsigned char)((input[i] >> 16) & 0xff);
@@ -262,11 +262,12 @@ static void Encode(unsigned char *output, UINT4 *input, unsigned int len)
/* Decodes input (unsigned char) into output (UINT4). Assumes len is
a multiple of 4.
*/
-static void Decode (UINT4 *output, const unsigned char *input, unsigned int len)
+static void Decode (UINT4 *output, const unsigned char *input,
+ unsigned int len)
{
unsigned int i, j;
- for (i = 0, j = 0; j < len; i++, j += 4)
+ for(i = 0, j = 0; j < len; i++, j += 4)
output[i] = ((UINT4)input[j]) | (((UINT4)input[j+1]) << 8) |
(((UINT4)input[j+2]) << 16) | (((UINT4)input[j+3]) << 24);
}
diff --git a/lib/md5.c b/lib/md5.c
index b3912c583..8abcb2b1d 100644
--- a/lib/md5.c
+++ b/lib/md5.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -208,7 +208,7 @@ static void MD5_Update (struct md5_ctx *context, /* context */
memcpy(&context->buffer[bufindex], input, partLen);
MD5Transform(context->state, context->buffer);
- for (i = partLen; i + 63 < inputLen; i += 64)
+ for(i = partLen; i + 63 < inputLen; i += 64)
MD5Transform(context->state, &input[i]);
bufindex = 0;
@@ -345,7 +345,7 @@ static void Encode (unsigned char *output,
{
unsigned int i, j;
- for (i = 0, j = 0; j < len; i++, j += 4) {
+ for(i = 0, j = 0; j < len; i++, j += 4) {
output[j] = (unsigned char)(input[i] & 0xff);
output[j+1] = (unsigned char)((input[i] >> 8) & 0xff);
output[j+2] = (unsigned char)((input[i] >> 16) & 0xff);
@@ -362,7 +362,7 @@ static void Decode (UINT4 *output,
{
unsigned int i, j;
- for (i = 0, j = 0; j < len; i++, j += 4)
+ for(i = 0, j = 0; j < len; i++, j += 4)
output[i] = ((UINT4)input[j]) | (((UINT4)input[j+1]) << 8) |
(((UINT4)input[j+2]) << 16) | (((UINT4)input[j+3]) << 24);
}
diff --git a/lib/memdebug.h b/lib/memdebug.h
index 56b9f12b2..77a4f4774 100644
--- a/lib/memdebug.h
+++ b/lib/memdebug.h
@@ -8,7 +8,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -47,8 +47,10 @@ extern FILE *logfile;
/* memory functions */
CURL_EXTERN void *curl_domalloc(size_t size, int line, const char *source);
-CURL_EXTERN void *curl_docalloc(size_t elements, size_t size, int line, const char *source);
-CURL_EXTERN void *curl_dorealloc(void *ptr, size_t size, int line, const char *source);
+CURL_EXTERN void *curl_docalloc(size_t elements, size_t size, int line,
+ const char *source);
+CURL_EXTERN void *curl_dorealloc(void *ptr, size_t size, int line,
+ const char *source);
CURL_EXTERN void curl_dofree(void *ptr, int line, const char *source);
CURL_EXTERN char *curl_dostrdup(const char *str, int line, const char *source);
CURL_EXTERN void curl_memdebug(const char *logname);
diff --git a/lib/mprintf.c b/lib/mprintf.c
index b02b50253..ca8e7ff2a 100644
--- a/lib/mprintf.c
+++ b/lib/mprintf.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1999 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1999 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -547,67 +547,65 @@ static long dprintf_Pass1(const char *format, va_stack_t *vto, char **endpos,
#endif
/* 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))
- {
- /* Width/precision arguments must be read before the main argument
- * they are attached to
- */
- vto[i + 1].data.num.as_signed = (mp_intmax_t)va_arg(arglist, int);
- }
+ for(i=0; i<max_param; i++) {
+ 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
+ */
+ vto[i + 1].data.num.as_signed = (mp_intmax_t)va_arg(arglist, int);
+ }
- switch (vto[i].type)
- {
- case FORMAT_STRING:
- vto[i].data.str = va_arg(arglist, char *);
- break;
+ switch (vto[i].type) {
+ case FORMAT_STRING:
+ vto[i].data.str = va_arg(arglist, char *);
+ break;
- case FORMAT_INTPTR:
- case FORMAT_UNKNOWN:
- case FORMAT_PTR:
- vto[i].data.ptr = va_arg(arglist, void *);
- break;
+ case FORMAT_INTPTR:
+ case FORMAT_UNKNOWN:
+ case FORMAT_PTR:
+ vto[i].data.ptr = va_arg(arglist, void *);
+ break;
- case FORMAT_INT:
+ case FORMAT_INT:
#ifdef HAVE_LONG_LONG_TYPE
- if((vto[i].flags & FLAGS_LONGLONG) && (vto[i].flags & FLAGS_UNSIGNED))
+ if((vto[i].flags & FLAGS_LONGLONG) && (vto[i].flags & FLAGS_UNSIGNED))
+ vto[i].data.num.as_unsigned =
+ (mp_uintmax_t)va_arg(arglist, mp_uintmax_t);
+ else if(vto[i].flags & FLAGS_LONGLONG)
+ vto[i].data.num.as_signed =
+ (mp_intmax_t)va_arg(arglist, mp_intmax_t);
+ else
+#endif
+ {
+ if((vto[i].flags & FLAGS_LONG) && (vto[i].flags & FLAGS_UNSIGNED))
vto[i].data.num.as_unsigned =
- (mp_uintmax_t)va_arg(arglist, mp_uintmax_t);
- else if(vto[i].flags & FLAGS_LONGLONG)
+ (mp_uintmax_t)va_arg(arglist, unsigned long);
+ else if(vto[i].flags & FLAGS_LONG)
vto[i].data.num.as_signed =
- (mp_intmax_t)va_arg(arglist, mp_intmax_t);
+ (mp_intmax_t)va_arg(arglist, long);
+ else if(vto[i].flags & FLAGS_UNSIGNED)
+ vto[i].data.num.as_unsigned =
+ (mp_uintmax_t)va_arg(arglist, unsigned int);
else
-#endif
- {
- if((vto[i].flags & FLAGS_LONG) && (vto[i].flags & FLAGS_UNSIGNED))
- vto[i].data.num.as_unsigned =
- (mp_uintmax_t)va_arg(arglist, unsigned long);
- else if(vto[i].flags & FLAGS_LONG)
- vto[i].data.num.as_signed =
- (mp_intmax_t)va_arg(arglist, long);
- else if(vto[i].flags & FLAGS_UNSIGNED)
- vto[i].data.num.as_unsigned =
- (mp_uintmax_t)va_arg(arglist, unsigned int);
- else
- vto[i].data.num.as_signed =
- (mp_intmax_t)va_arg(arglist, int);
- }
- break;
+ vto[i].data.num.as_signed =
+ (mp_intmax_t)va_arg(arglist, int);
+ }
+ break;
- case FORMAT_DOUBLE:
- vto[i].data.dnum = va_arg(arglist, double);
- break;
+ case FORMAT_DOUBLE:
+ vto[i].data.dnum = va_arg(arglist, double);
+ break;
- case FORMAT_WIDTH:
- /* Argument has been read. Silently convert it into an integer
- * for later use
- */
- vto[i].type = FORMAT_INT;
- break;
+ case FORMAT_WIDTH:
+ /* Argument has been read. Silently convert it into an integer
+ * for later use
+ */
+ vto[i].type = FORMAT_INT;
+ break;
- default:
- break;
- }
+ default:
+ break;
+ }
}
return max_param;
@@ -914,7 +912,7 @@ static int dprintf_formatf(
if(p->flags & FLAGS_LEFT)
while(width-- > 0)
OUTCHAR(' ');
- for (point = strnil; *point != '\0'; ++point)
+ for(point = strnil; *point != '\0'; ++point)
OUTCHAR(*point);
if(! (p->flags & FLAGS_LEFT))
while(width-- > 0)
@@ -1202,45 +1200,3 @@ int curl_mvfprintf(FILE *whereto, const char *format, va_list ap_save)
{
return dprintf_formatf(whereto, fputc, format, ap_save);
}
-
-#ifdef DPRINTF_DEBUG
-int main()
-{
- char buffer[129];
- char *ptr;
-#ifdef HAVE_LONG_LONG_TYPE
- LONG_LONG_TYPE one=99;
- LONG_LONG_TYPE two=100;
- LONG_LONG_TYPE test = 0x1000000000LL;
- curl_mprintf("%lld %lld %lld\n", one, two, test);
-#endif
-
- curl_mprintf("%3d %5d\n", 10, 1998);
-
- ptr=curl_maprintf("test this then baby %s%s%s%s%s%s %d %d %d loser baby get a kiss in yer face now!", "", "pretty long string pretty long string pretty long string pretty long string pretty long string", "/", "/", "/", "pretty long string", 1998, 1999, 2001);
-
- puts(ptr);
-
- memset(ptr, 55, strlen(ptr)+1);
-
- free(ptr);
-
-#if 1
- curl_mprintf(buffer, "%s %s %d", "daniel", "stenberg", 19988);
- puts(buffer);
-
- curl_mfprintf(stderr, "%s %#08x\n", "dummy", 65);
-
- printf("%s %#08x\n", "dummy", 65);
- {
- double tryout = 3.14156592;
- curl_mprintf(buffer, "%.2g %G %f %e %E", tryout, tryout, tryout, tryout, tryout);
- puts(buffer);
- printf("%.2g %G %f %e %E\n", tryout, tryout, tryout, tryout, tryout);
- }
-#endif
-
- return 0;
-}
-
-#endif
diff --git a/lib/multi.c b/lib/multi.c
index 650be6836..89e6ed74c 100644
--- a/lib/multi.c
+++ b/lib/multi.c
@@ -674,7 +674,7 @@ CURLMcode curl_multi_remove_handle(CURLM *multi_handle,
/* we must call Curl_done() here (if we still "own it") so that we don't
leave a half-baked one around */
- if (easy_owns_conn) {
+ if(easy_owns_conn) {
/* Curl_done() clears the conn->data field to lose the association
between the easy handle and the connection
@@ -1128,7 +1128,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
result = CURLM_CALL_MULTI_PERFORM;
multistate(easy, CURLM_STATE_CONNECT);
}
- else if (CURLE_OK == easy->result) {
+ else if(CURLE_OK == easy->result) {
if(!easy->easy_conn->bits.tunnel_connecting)
multistate(easy, CURLM_STATE_WAITCONNECT);
}
@@ -1265,8 +1265,8 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
result = CURLM_CALL_MULTI_PERFORM;
}
}
- else if ((CURLE_SEND_ERROR == easy->result) &&
- easy->easy_conn->bits.reuse) {
+ else if((CURLE_SEND_ERROR == easy->result) &&
+ easy->easy_conn->bits.reuse) {
/*
* In this situation, a connection that we were trying to use
* may have unexpectedly died. If possible, send the connection
@@ -1292,7 +1292,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
/* When set to retry the connection, we must to go back to
* the CONNECT state */
if(retry) {
- if ((drc == CURLE_OK) || (drc == CURLE_SEND_ERROR)) {
+ if((drc == CURLE_OK) || (drc == CURLE_SEND_ERROR)) {
follow = FOLLOW_RETRY;
drc = Curl_follow(data, newurl, follow);
if(drc == CURLE_OK) {
@@ -1535,11 +1535,11 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
/* but first check to see if we got a location info even though we're
not following redirects */
- if (data->req.location) {
+ if(data->req.location) {
newurl = data->req.location;
data->req.location = NULL;
easy->result = Curl_follow(data, newurl, FOLLOW_FAKE);
- if (easy->result)
+ if(easy->result)
free(newurl);
}
@@ -1577,7 +1577,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
* access free'd data, if the connection is free'd and the handle
* removed before we perform the processing in CURLM_STATE_COMPLETED
*/
- if (easy->easy_conn)
+ if(easy->easy_conn)
easy->easy_conn = NULL;
}
@@ -1710,7 +1710,7 @@ CURLMcode curl_multi_perform(CURLM *multi_handle, int *running_handles)
do
result = multi_runsingle(multi, now, easy);
- while (CURLM_CALL_MULTI_PERFORM == result);
+ while(CURLM_CALL_MULTI_PERFORM == result);
if(easy->easy_handle->set.wildcardmatch) {
/* destruct wildcard structures if it is needed */
@@ -1954,29 +1954,29 @@ static void singlesocket(struct Curl_multi *multi,
easy_by_hash = entry->easy->multi_pos;
easy_conn = easy_by_hash->easy_conn;
if(easy_conn) {
- if (easy_conn->recv_pipe && easy_conn->recv_pipe->size > 1) {
+ if(easy_conn->recv_pipe && easy_conn->recv_pipe->size > 1) {
/* the handle should not be removed from the pipe yet */
remove_sock_from_hash = FALSE;
/* Update the sockhash entry to instead point to the next in line
for the recv_pipe, or the first (in case this particular easy
isn't already) */
- if (entry->easy == easy->easy_handle) {
- if (isHandleAtHead(easy->easy_handle, easy_conn->recv_pipe))
+ if(entry->easy == easy->easy_handle) {
+ if(isHandleAtHead(easy->easy_handle, easy_conn->recv_pipe))
entry->easy = easy_conn->recv_pipe->head->next->ptr;
else
entry->easy = easy_conn->recv_pipe->head->ptr;
}
}
- if (easy_conn->send_pipe && easy_conn->send_pipe->size > 1) {
+ if(easy_conn->send_pipe && easy_conn->send_pipe->size > 1) {
/* the handle should not be removed from the pipe yet */
remove_sock_from_hash = FALSE;
/* Update the sockhash entry to instead point to the next in line
for the send_pipe, or the first (in case this particular easy
isn't already) */
- if (entry->easy == easy->easy_handle) {
- if (isHandleAtHead(easy->easy_handle, easy_conn->send_pipe))
+ if(entry->easy == easy->easy_handle) {
+ if(isHandleAtHead(easy->easy_handle, easy_conn->send_pipe))
entry->easy = easy_conn->send_pipe->head->next->ptr;
else
entry->easy = easy_conn->send_pipe->head->ptr;
@@ -1994,7 +1994,7 @@ static void singlesocket(struct Curl_multi *multi,
either since it never got to know about it */
remove_sock_from_hash = FALSE;
- if (remove_sock_from_hash) {
+ if(remove_sock_from_hash) {
multi->socket_cb(easy->easy_handle,
s,
CURL_POLL_REMOVE,
@@ -2116,13 +2116,13 @@ static CURLMcode multi_socket(struct Curl_multi *multi,
the pipeline. If we should write into the socket, take the send_pipe
head. If we should read from the socket, take the recv_pipe head. */
if(data->set.one_easy->easy_conn) {
- if ((ev_bitmask & CURL_POLL_OUT) &&
- data->set.one_easy->easy_conn->send_pipe &&
- data->set.one_easy->easy_conn->send_pipe->head)
+ if((ev_bitmask & CURL_POLL_OUT) &&
+ data->set.one_easy->easy_conn->send_pipe &&
+ data->set.one_easy->easy_conn->send_pipe->head)
data = data->set.one_easy->easy_conn->send_pipe->head->ptr;
- else if ((ev_bitmask & CURL_POLL_IN) &&
- data->set.one_easy->easy_conn->recv_pipe &&
- data->set.one_easy->easy_conn->recv_pipe->head)
+ else if((ev_bitmask & CURL_POLL_IN) &&
+ data->set.one_easy->easy_conn->recv_pipe &&
+ data->set.one_easy->easy_conn->recv_pipe->head)
data = data->set.one_easy->easy_conn->recv_pipe->head->ptr;
}
@@ -2133,7 +2133,7 @@ static CURLMcode multi_socket(struct Curl_multi *multi,
do
result = multi_runsingle(multi, now, data->set.one_easy);
- while (CURLM_CALL_MULTI_PERFORM == result);
+ while(CURLM_CALL_MULTI_PERFORM == result);
if(data->set.one_easy->easy_conn &&
!(data->set.one_easy->easy_conn->handler->flags & PROTOPT_DIRLOCK))
@@ -2171,7 +2171,7 @@ static CURLMcode multi_socket(struct Curl_multi *multi,
if(data) {
do
result = multi_runsingle(multi, now, data->set.one_easy);
- while (CURLM_CALL_MULTI_PERFORM == result);
+ while(CURLM_CALL_MULTI_PERFORM == result);
if(CURLM_OK >= result)
/* get the socket(s) and check if the state has been changed since
@@ -2371,14 +2371,14 @@ static CURLcode addHandleToSendOrPendPipeline(struct SessionHandle *handle,
rc = Curl_addHandleToPipeline(handle, pipeline);
- if (pipeline == conn->send_pipe && sendhead != conn->send_pipe->head) {
- /* this is a new one as head, expire it */
- conn->writechannel_inuse = FALSE; /* not in use yet */
+ if(pipeline == conn->send_pipe && sendhead != conn->send_pipe->head) {
+ /* this is a new one as head, expire it */
+ conn->writechannel_inuse = FALSE; /* not in use yet */
#ifdef DEBUGBUILD
- infof(conn->data, "%p is at send pipe head!\n",
- conn->send_pipe->head->ptr);
+ infof(conn->data, "%p is at send pipe head!\n",
+ conn->send_pipe->head->ptr);
#endif
- Curl_expire(conn->send_pipe->head->ptr, 1);
+ Curl_expire(conn->send_pipe->head->ptr, 1);
}
return rc;
@@ -2390,7 +2390,7 @@ static int checkPendPipeline(struct connectdata *conn)
struct curl_llist_element *sendhead = conn->send_pipe->head;
size_t pipeLen = conn->send_pipe->size + conn->recv_pipe->size;
- if (conn->server_supports_pipelining || pipeLen == 0) {
+ if(conn->server_supports_pipelining || pipeLen == 0) {
struct curl_llist_element *curr = conn->pend_pipe->head;
const size_t maxPipeLen =
conn->server_supports_pipelining ? MAX_PIPELINE_LENGTH : 1;
@@ -2405,7 +2405,7 @@ static int checkPendPipeline(struct connectdata *conn)
}
}
- if (result) {
+ if(result) {
conn->now = Curl_tvnow();
/* something moved, check for a new send pipeline leader */
if(sendhead != conn->send_pipe->head) {
@@ -2746,7 +2746,8 @@ static CURLMcode add_closure(struct Curl_multi *multi,
else
multi->closure = n;
free(cl);
- } else {
+ }
+ else {
if(cl->easy_handle == data)
add = FALSE;
@@ -2756,7 +2757,7 @@ static CURLMcode add_closure(struct Curl_multi *multi,
cl = n;
}
- if (add) {
+ if(add) {
cl = calloc(1, sizeof(struct closure));
if(!cl)
return CURLM_OUT_OF_MEMORY;
diff --git a/lib/non-ascii.c b/lib/non-ascii.c
index 7e6ad37bf..a38680cc1 100644
--- a/lib/non-ascii.c
+++ b/lib/non-ascii.c
@@ -180,7 +180,7 @@ CURLcode Curl_convert_from_network(struct SessionHandle *data,
if((rc == ICONV_ERROR) || (in_bytes != 0)) {
error = ERRNO;
failf(data,
- "The Curl_convert_from_network iconv call failed with errno %i: %s",
+ "Curl_convert_from_network iconv call failed with errno %i: %s",
error, strerror(error));
return CURLE_CONV_FAILED;
}
@@ -296,13 +296,13 @@ void Curl_convert_close(struct SessionHandle *data)
#ifdef HAVE_ICONV
/* close iconv conversion descriptors */
if(data->inbound_cd != (iconv_t)-1) {
- iconv_close(data->inbound_cd);
+ iconv_close(data->inbound_cd);
}
if(data->outbound_cd != (iconv_t)-1) {
- iconv_close(data->outbound_cd);
+ iconv_close(data->outbound_cd);
}
if(data->utf8_cd != (iconv_t)-1) {
- iconv_close(data->utf8_cd);
+ iconv_close(data->utf8_cd);
}
#else
(void)data;
diff --git a/lib/nss.c b/lib/nss.c
index 3677043f0..3dc0ba61c 100644
--- a/lib/nss.c
+++ b/lib/nss.c
@@ -282,9 +282,9 @@ static int is_file(const char *filename)
}
/* Return on heap allocated filename/nickname of a certificate. The returned
- * string should be later deallocated using free(). *is_nickname is set to TRUE
- * if the given string is treated as nickname; FALSE if the given string is
- * treated as file name.
+ * string should be later deallocated using free(). *is_nickname is set to
+ * TRUE if the given string is treated as nickname; FALSE if the given string
+ * is treated as file name.
*/
static char *fmt_nickname(struct SessionHandle *data, enum dupstring cert_kind,
bool *is_nickname)
@@ -662,7 +662,8 @@ static SECStatus BadCertHandler(void *arg, PRFileDesc *sock)
if(conn->data->set.ssl.verifyhost) {
failf(conn->data, "SSL: certificate subject name '%s' does not match "
"target host name '%s'", subject_cn, conn->host.dispname);
- } else {
+ }
+ else {
result = SECSuccess;
infof(conn->data, "warning: SSL: certificate subject name '%s' does not "
"match target host name '%s'\n", subject_cn, conn->host.dispname);
@@ -778,10 +779,10 @@ static SECStatus check_issuer_cert(PRFileDesc *sock,
issuer = NULL;
issuer = PK11_FindCertFromNickname(issuer_nickname, proto_win);
- if ((!cert_issuer) || (!issuer))
+ if((!cert_issuer) || (!issuer))
res = SECFailure;
- else if (SECITEM_CompareItem(&cert_issuer->derCert,
- &issuer->derCert)!=SECEqual)
+ else if(SECITEM_CompareItem(&cert_issuer->derCert,
+ &issuer->derCert)!=SECEqual)
res = SECFailure;
CERT_DestroyCertificate(cert);
@@ -806,8 +807,8 @@ static SECStatus SelectClientCert(void *arg, PRFileDesc *sock,
struct SessionHandle *data = connssl->data;
const char *nickname = connssl->client_nickname;
- if (mod && nickname &&
- 0 == strncmp(nickname, pem_nickname, /* length of "PEM Token" */ 9)) {
+ if(mod && nickname &&
+ 0 == strncmp(nickname, pem_nickname, /* length of "PEM Token" */ 9)) {
/* use the cert/key provided by PEM reader */
PK11SlotInfo *slot;
@@ -815,20 +816,20 @@ static SECStatus SelectClientCert(void *arg, PRFileDesc *sock,
*pRetKey = NULL;
*pRetCert = PK11_FindCertFromNickname(nickname, proto_win);
- if (NULL == *pRetCert) {
+ if(NULL == *pRetCert) {
failf(data, "NSS: client certificate not found: %s", nickname);
return SECFailure;
}
slot = PK11_FindSlotByName(pem_slotname);
- if (NULL == slot) {
+ if(NULL == slot) {
failf(data, "NSS: PK11 slot not found: %s", pem_slotname);
return SECFailure;
}
*pRetKey = PK11_FindPrivateKeyFromCert(slot, *pRetCert, NULL);
PK11_FreeSlot(slot);
- if (NULL == *pRetKey) {
+ if(NULL == *pRetKey) {
failf(data, "NSS: private key not found for certificate: %s", nickname);
return SECFailure;
}
@@ -839,11 +840,11 @@ static SECStatus SelectClientCert(void *arg, PRFileDesc *sock,
}
/* use the default NSS hook */
- if (SECSuccess != NSS_GetClientAuthData((void *)nickname, sock, caNames,
+ if(SECSuccess != NSS_GetClientAuthData((void *)nickname, sock, caNames,
pRetCert, pRetKey)
|| NULL == *pRetCert) {
- if (NULL == nickname)
+ if(NULL == nickname)
failf(data, "NSS: client certificate not found (nickname not "
"specified)");
else
@@ -854,10 +855,10 @@ static SECStatus SelectClientCert(void *arg, PRFileDesc *sock,
/* get certificate nickname if any */
nickname = (*pRetCert)->nickname;
- if (NULL == nickname)
+ if(NULL == nickname)
nickname = "[unknown]";
- if (NULL == *pRetKey) {
+ if(NULL == *pRetKey) {
failf(data, "NSS: private key not found for certificate: %s", nickname);
return SECFailure;
}
@@ -931,7 +932,8 @@ static CURLcode init_nss(struct SessionHandle *data)
}
else {
char *certpath =
- PR_smprintf("%s%s", NSS_VersionCheck("3.12.0") ? "sql:" : "", cert_dir);
+ PR_smprintf("%s%s", NSS_VersionCheck("3.12.0") ? "sql:" : "",
+ cert_dir);
rv = NSS_Initialize(certpath, "", "", "", NSS_INIT_READONLY);
PR_smprintf_free(certpath);
}
@@ -957,7 +959,7 @@ static CURLcode init_nss(struct SessionHandle *data)
int Curl_nss_init(void)
{
/* curl_global_init() is not thread-safe so this test is ok */
- if (nss_initlock == NULL) {
+ if(nss_initlock == NULL) {
PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 256);
nss_initlock = PR_NewLock();
nss_crllock = PR_NewLock();
@@ -972,9 +974,10 @@ CURLcode Curl_nss_force_init(struct SessionHandle *data)
{
CURLcode rv;
if(!nss_initlock) {
- failf(data, "unable to initialize NSS, curl_global_init() should have been "
- "called with CURL_GLOBAL_SSL or CURL_GLOBAL_ALL");
- return CURLE_OUT_OF_MEMORY;
+ failf(data,
+ "unable to initialize NSS, curl_global_init() should have been "
+ "called with CURL_GLOBAL_SSL or CURL_GLOBAL_ALL");
+ return CURLE_FAILED_INIT;
}
PR_Lock(nss_initlock);
@@ -990,7 +993,7 @@ void Curl_nss_cleanup(void)
* as a safety feature.
*/
PR_Lock(nss_initlock);
- if (initialized) {
+ if(initialized) {
/* Free references to client certificates held in the SSL session cache.
* Omitting this hampers destruction of the security module owning
* the certificates. */
@@ -1167,7 +1170,7 @@ CURLcode Curl_nss_connect(struct connectdata *conn, int sockindex)
long time_left;
PRUint32 timeout;
- if (connssl->state == ssl_connection_complete)
+ if(connssl->state == ssl_connection_complete)
return CURLE_OK;
connssl->data = data;
@@ -1240,7 +1243,7 @@ CURLcode Curl_nss_connect(struct connectdata *conn, int sockindex)
default:
case CURL_SSLVERSION_DEFAULT:
ssl3 = PR_TRUE;
- if (data->state.ssl_connect_retry)
+ if(data->state.ssl_connect_retry)
infof(data, "TLS disabled due to previous handshake failure\n");
else
tlsv1 = PR_TRUE;
@@ -1271,8 +1274,8 @@ CURLcode Curl_nss_connect(struct connectdata *conn, int sockindex)
/* enable all ciphers from enable_ciphers_by_default */
cipher_to_enable = enable_ciphers_by_default;
- while (SSL_NULL_WITH_NULL_NULL != *cipher_to_enable) {
- if (SSL_CipherPrefSet(model, *cipher_to_enable, PR_TRUE) != SECSuccess) {
+ while(SSL_NULL_WITH_NULL_NULL != *cipher_to_enable) {
+ if(SSL_CipherPrefSet(model, *cipher_to_enable, PR_TRUE) != SECSuccess) {
curlerr = CURLE_SSL_CIPHER;
goto error;
}
@@ -1313,7 +1316,7 @@ CURLcode Curl_nss_connect(struct connectdata *conn, int sockindex)
}
}
- if (data->set.ssl.CRLfile) {
+ if(data->set.ssl.CRLfile) {
if(SECSuccess != nss_load_crl(data->set.ssl.CRLfile)) {
curlerr = CURLE_SSL_CRL_BADFILE;
goto error;
@@ -1358,7 +1361,7 @@ CURLcode Curl_nss_connect(struct connectdata *conn, int sockindex)
model = NULL;
/* This is the password associated with the cert that we're using */
- if (data->set.str[STRING_KEY_PASSWD]) {
+ if(data->set.str[STRING_KEY_PASSWD]) {
SSL_SetPKCS11PinArg(connssl->handle, data->set.str[STRING_KEY_PASSWD]);
}
@@ -1390,7 +1393,7 @@ CURLcode Curl_nss_connect(struct connectdata *conn, int sockindex)
display_conn_info(conn, connssl->handle);
- if (data->set.str[STRING_SSL_ISSUERCERT]) {
+ if(data->set.str[STRING_SSL_ISSUERCERT]) {
SECStatus ret = SECFailure;
bool is_nickname;
char *nickname = fmt_nickname(data, STRING_SSL_ISSUERCERT, &is_nickname);
@@ -1434,7 +1437,7 @@ CURLcode Curl_nss_connect(struct connectdata *conn, int sockindex)
connssl->obj_list = NULL;
#endif
- if (ssl3 && tlsv1 && isTLSIntoleranceError(err)) {
+ if(ssl3 && tlsv1 && isTLSIntoleranceError(err)) {
/* schedule reconnect through Curl_retry_request() */
data->state.ssl_connect_retry = TRUE;
infof(data, "Error in TLS handshake, trying SSLv3...\n");
diff --git a/lib/openldap.c b/lib/openldap.c
index 3cb796380..80dc284ac 100644
--- a/lib/openldap.c
+++ b/lib/openldap.c
@@ -55,7 +55,8 @@
#ifndef _LDAP_PVT_H
extern int ldap_pvt_url_scheme2proto(const char *);
-extern int ldap_init_fd(ber_socket_t fd, int proto, const char *url, LDAP **ld);
+extern int ldap_init_fd(ber_socket_t fd, int proto, const char *url,
+ LDAP **ld);
#endif
static CURLcode ldap_setup(struct connectdata *conn);
@@ -63,7 +64,7 @@ static CURLcode ldap_do(struct connectdata *conn, bool *done);
static CURLcode ldap_done(struct connectdata *conn, CURLcode, bool);
static CURLcode ldap_connect(struct connectdata *conn, bool *done);
static CURLcode ldap_connecting(struct connectdata *conn, bool *done);
-static CURLcode ldap_disconnect(struct connectdata *conn, bool dead_connection);
+static CURLcode ldap_disconnect(struct connectdata *conn, bool dead);
static Curl_recv ldap_recv;
@@ -152,11 +153,11 @@ static CURLcode ldap_setup(struct connectdata *conn)
CURLcode status;
rc = ldap_url_parse(data->change.url, &lud);
- if (rc != LDAP_URL_SUCCESS) {
+ if(rc != LDAP_URL_SUCCESS) {
const char *msg = "url parsing problem";
status = CURLE_URL_MALFORMAT;
- if (rc > LDAP_URL_SUCCESS && rc <= LDAP_URL_ERR_BADEXTS) {
- if (rc == LDAP_URL_ERR_MEM)
+ if(rc > LDAP_URL_SUCCESS && rc <= LDAP_URL_ERR_BADEXTS) {
+ if(rc == LDAP_URL_ERR_MEM)
status = CURLE_OUT_OF_MEMORY;
msg = url_errs[rc];
}
@@ -189,13 +190,13 @@ static CURLcode ldap_connect(struct connectdata *conn, bool *done)
strcpy(hosturl, "ldap");
ptr = hosturl+4;
- if (conn->handler->flags & PROTOPT_SSL)
+ if(conn->handler->flags & PROTOPT_SSL)
*ptr++ = 's';
snprintf(ptr, sizeof(hosturl)-(ptr-hosturl), "://%s:%d",
conn->host.name, conn->remote_port);
rc = ldap_init_fd(conn->sock[FIRSTSOCKET], li->proto, hosturl, &li->ld);
- if (rc) {
+ if(rc) {
failf(data, "LDAP local: Cannot connect to %s, %s",
hosturl, ldap_err2string(rc));
return CURLE_COULDNT_CONNECT;
@@ -231,22 +232,23 @@ static CURLcode ldap_connect(struct connectdata *conn, bool *done)
}
#ifdef USE_SSL
- if (conn->handler->flags & PROTOPT_SSL) {
+ if(conn->handler->flags & PROTOPT_SSL) {
CURLcode res;
- if (data->state.used_interface == Curl_if_easy) {
+ if(data->state.used_interface == Curl_if_easy) {
res = Curl_ssl_connect(conn, FIRSTSOCKET);
- if (res)
+ if(res)
return res;
li->ssldone = TRUE;
- } else {
+ }
+ else {
res = Curl_ssl_connect_nonblocking(conn, FIRSTSOCKET, &li->ssldone);
- if (res)
+ if(res)
return res;
}
}
#endif
- if (data->state.used_interface == Curl_if_easy)
+ if(data->state.used_interface == Curl_if_easy)
return ldap_connecting(conn, done);
return CURLE_OK;
@@ -262,15 +264,16 @@ static CURLcode ldap_connecting(struct connectdata *conn, bool *done)
char *info = NULL;
#ifdef USE_SSL
- if (conn->handler->flags & PROTOPT_SSL) {
+ if(conn->handler->flags & PROTOPT_SSL) {
/* Is the SSL handshake complete yet? */
- if (!li->ssldone) {
- CURLcode res = Curl_ssl_connect_nonblocking(conn, FIRSTSOCKET, &li->ssldone);
- if (res || !li->ssldone)
+ if(!li->ssldone) {
+ CURLcode res = Curl_ssl_connect_nonblocking(conn, FIRSTSOCKET,
+ &li->ssldone);
+ if(res || !li->ssldone)
return res;
}
/* Have we installed the libcurl SSL handlers into the sockbuf yet? */
- if (!li->sslinst) {
+ if(!li->sslinst) {
Sockbuf *sb;
ldap_get_option(li->ld, LDAP_OPT_SOCKBUF, &sb);
ber_sockbuf_add_io(sb, &ldapsb_tls, LBER_SBIOD_LEVEL_TRANSPORT, conn);
@@ -281,53 +284,54 @@ static CURLcode ldap_connecting(struct connectdata *conn, bool *done)
}
#endif
- if (data->state.used_interface == Curl_if_easy)
+ if(data->state.used_interface == Curl_if_easy)
tvp = NULL; /* let ldap_result block indefinitely */
else
tvp = &tv;
retry:
- if (!li->didbind) {
+ if(!li->didbind) {
char *binddn;
struct berval passwd;
- if (conn->bits.user_passwd) {
+ if(conn->bits.user_passwd) {
binddn = conn->user;
passwd.bv_val = conn->passwd;
passwd.bv_len = strlen(passwd.bv_val);
- } else {
+ }
+ else {
binddn = NULL;
passwd.bv_val = NULL;
passwd.bv_len = 0;
}
rc = ldap_sasl_bind(li->ld, binddn, LDAP_SASL_SIMPLE, &passwd,
NULL, NULL, &li->msgid);
- if (rc)
+ if(rc)
return CURLE_LDAP_CANNOT_BIND;
li->didbind = TRUE;
- if (tvp)
+ if(tvp)
return CURLE_OK;
}
rc = ldap_result(li->ld, li->msgid, LDAP_MSG_ONE, tvp, &result);
- if (rc < 0) {
+ if(rc < 0) {
failf(data, "LDAP local: bind ldap_result %s", ldap_err2string(rc));
return CURLE_LDAP_CANNOT_BIND;
}
- if (rc == 0) {
+ if(rc == 0) {
/* timed out */
return CURLE_OK;
}
rc = ldap_parse_result(li->ld, result, &err, NULL, &info, NULL, NULL, 1);
- if (rc) {
+ if(rc) {
failf(data, "LDAP local: bind ldap_parse_result %s", ldap_err2string(rc));
return CURLE_LDAP_CANNOT_BIND;
}
/* Try to fallback to LDAPv2? */
- if (err == LDAP_PROTOCOL_ERROR) {
+ if(err == LDAP_PROTOCOL_ERROR) {
int proto;
ldap_get_option(li->ld, LDAP_OPT_PROTOCOL_VERSION, &proto);
- if (proto == LDAP_VERSION3) {
+ if(proto == LDAP_VERSION3) {
ldap_memfree(info);
proto = LDAP_VERSION2;
ldap_set_option(li->ld, LDAP_OPT_PROTOCOL_VERSION, &proto);
@@ -336,7 +340,7 @@ retry:
}
}
- if (err) {
+ if(err) {
failf(data, "LDAP remote: bind failed %s %s", ldap_err2string(rc),
info ? info : "");
return CURLE_LOGIN_DENIED;
@@ -351,8 +355,8 @@ static CURLcode ldap_disconnect(struct connectdata *conn, bool dead_connection)
ldapconninfo *li = conn->proto.generic;
(void) dead_connection;
- if (li) {
- if (li->ld) {
+ if(li) {
+ if(li->ld) {
ldap_unbind_ext(li->ld, NULL, NULL);
li->ld = NULL;
}
@@ -377,11 +381,11 @@ static CURLcode ldap_do(struct connectdata *conn, bool *done)
infof(data, "LDAP local: %s\n", data->change.url);
rc = ldap_url_parse(data->change.url, &ludp);
- if (rc != LDAP_URL_SUCCESS) {
+ if(rc != LDAP_URL_SUCCESS) {
const char *msg = "url parsing problem";
status = CURLE_URL_MALFORMAT;
- if (rc > LDAP_URL_SUCCESS && rc <= LDAP_URL_ERR_BADEXTS) {
- if (rc == LDAP_URL_ERR_MEM)
+ if(rc > LDAP_URL_SUCCESS && rc <= LDAP_URL_ERR_BADEXTS) {
+ if(rc == LDAP_URL_ERR_MEM)
status = CURLE_OUT_OF_MEMORY;
msg = url_errs[rc];
}
@@ -393,7 +397,7 @@ static CURLcode ldap_do(struct connectdata *conn, bool *done)
ludp->lud_filter, ludp->lud_attrs, 0,
NULL, NULL, NULL, 0, &msgid);
ldap_free_urldesc(ludp);
- if (rc != LDAP_SUCCESS) {
+ if(rc != LDAP_SUCCESS) {
failf(data, "LDAP local: ldap_search_ext %s", ldap_err2string(rc));
return CURLE_LDAP_SEARCH_FAILED;
}
@@ -412,9 +416,9 @@ static CURLcode ldap_done(struct connectdata *conn, CURLcode res,
(void)res;
(void)premature;
- if (lr) {
+ if(lr) {
/* if there was a search in progress, abandon it */
- if (lr->msgid) {
+ if(lr->msgid) {
ldapconninfo *li = conn->proto.generic;
ldap_abandon_ext(li->ld, lr->msgid, NULL, NULL);
lr->msgid = 0;
@@ -441,7 +445,7 @@ static ssize_t ldap_recv(struct connectdata *conn, int sockindex, char *buf,
(void)sockindex;
rc = ldap_result(li->ld, lr->msgid, LDAP_MSG_RECEIVED, &tv, &result);
- if (rc < 0) {
+ if(rc < 0) {
failf(data, "LDAP local: search ldap_result %s", ldap_err2string(rc));
*err = CURLE_RECV_ERROR;
return -1;
@@ -451,30 +455,32 @@ static ssize_t ldap_recv(struct connectdata *conn, int sockindex, char *buf,
ret = -1;
/* timed out */
- if (result == NULL)
+ if(result == NULL)
return ret;
- for (ent = ldap_first_message(li->ld, result); ent;
+ for(ent = ldap_first_message(li->ld, result); ent;
ent = ldap_next_message(li->ld, ent)) {
struct berval bv, *bvals, **bvp = &bvals;
int binary = 0, msgtype;
msgtype = ldap_msgtype(ent);
- if (msgtype == LDAP_RES_SEARCH_RESULT) {
+ if(msgtype == LDAP_RES_SEARCH_RESULT) {
int code;
char *info = NULL;
rc = ldap_parse_result(li->ld, ent, &code, NULL, &info, NULL, NULL, 0);
- if (rc) {
+ if(rc) {
failf(data, "LDAP local: search ldap_parse_result %s",
ldap_err2string(rc));
*err = CURLE_LDAP_SEARCH_FAILED;
- } else if (code && code != LDAP_SIZELIMIT_EXCEEDED) {
+ }
+ else if(code && code != LDAP_SIZELIMIT_EXCEEDED) {
failf(data, "LDAP remote: search failed %s %s", ldap_err2string(rc),
- info ? info : "");
+ info ? info : "");
*err = CURLE_LDAP_SEARCH_FAILED;
- } else {
+ }
+ else {
/* successful */
- if (code == LDAP_SIZELIMIT_EXCEEDED)
+ if(code == LDAP_SIZELIMIT_EXCEEDED)
infof(data, "There are more than %d entries\n", lr->nument);
data->req.size = data->req.bytecount;
*err = CURLE_OK;
@@ -483,9 +489,9 @@ static ssize_t ldap_recv(struct connectdata *conn, int sockindex, char *buf,
lr->msgid = 0;
ldap_memfree(info);
break;
- } else if (msgtype != LDAP_RES_SEARCH_ENTRY) {
- continue;
}
+ else if(msgtype != LDAP_RES_SEARCH_ENTRY)
+ continue;
lr->nument++;
rc = ldap_get_dn_ber(li->ld, ent, &ber, &bv);
@@ -500,41 +506,42 @@ static ssize_t ldap_recv(struct connectdata *conn, int sockindex, char *buf,
Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\n", 1);
data->req.bytecount += bv.bv_len + 5;
- for (rc = ldap_get_attribute_ber(li->ld, ent, ber, &bv, bvp);
+ for(rc = ldap_get_attribute_ber(li->ld, ent, ber, &bv, bvp);
rc == LDAP_SUCCESS;
rc = ldap_get_attribute_ber(li->ld, ent, ber, &bv, bvp)) {
int i;
- if (bv.bv_val == NULL) break;
+ if(bv.bv_val == NULL) break;
- if (bv.bv_len > 7 && !strncmp(bv.bv_val + bv.bv_len - 7, ";binary", 7))
+ if(bv.bv_len > 7 && !strncmp(bv.bv_val + bv.bv_len - 7, ";binary", 7))
binary = 1;
else
binary = 0;
- for (i=0; bvals[i].bv_val != NULL; i++) {
+ for(i=0; bvals[i].bv_val != NULL; i++) {
int binval = 0;
Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\t", 1);
- Curl_client_write(conn, CLIENTWRITE_BODY, (char *)bv.bv_val, bv.bv_len);
+ Curl_client_write(conn, CLIENTWRITE_BODY, (char *)bv.bv_val,
+ bv.bv_len);
Curl_client_write(conn, CLIENTWRITE_BODY, (char *)":", 1);
data->req.bytecount += bv.bv_len + 2;
- if (!binary) {
+ if(!binary) {
/* check for leading or trailing whitespace */
- if (ISSPACE(bvals[i].bv_val[0]) ||
- ISSPACE(bvals[i].bv_val[bvals[i].bv_len-1])) {
+ if(ISSPACE(bvals[i].bv_val[0]) ||
+ ISSPACE(bvals[i].bv_val[bvals[i].bv_len-1]))
binval = 1;
- } else {
+ else {
/* check for unprintable characters */
unsigned int j;
- for (j=0; j<bvals[i].bv_len; j++)
- if (!ISPRINT(bvals[i].bv_val[j])) {
+ for(j=0; j<bvals[i].bv_len; j++)
+ if(!ISPRINT(bvals[i].bv_val[j])) {
binval = 1;
break;
}
}
}
- if (binary || binval) {
+ if(binary || binval) {
char *val_b64;
/* Binary value, encode to base64. */
size_t val_b64_sz = Curl_base64_encode(data,
@@ -548,7 +555,8 @@ static ssize_t ldap_recv(struct connectdata *conn, int sockindex, char *buf,
free(val_b64);
data->req.bytecount += val_b64_sz;
}
- } else {
+ }
+ else {
Curl_client_write(conn, CLIENTWRITE_BODY, (char *)" ", 1);
Curl_client_write(conn, CLIENTWRITE_BODY, bvals[i].bv_val,
bvals[i].bv_len);
@@ -596,7 +604,7 @@ static int
ldapsb_tls_ctrl(Sockbuf_IO_Desc *sbiod, int opt, void *arg)
{
(void)arg;
- if (opt == LBER_SB_OPT_DATA_READY) {
+ if(opt == LBER_SB_OPT_DATA_READY) {
struct connectdata *conn = sbiod->sbiod_pvt;
return Curl_ssl_data_pending(conn, FIRSTSOCKET);
}
@@ -612,7 +620,7 @@ ldapsb_tls_read(Sockbuf_IO_Desc *sbiod, void *buf, ber_len_t len)
CURLcode err = CURLE_RECV_ERROR;
ret = li->recv(conn, FIRSTSOCKET, buf, len, &err);
- if (ret < 0 && err == CURLE_AGAIN) {
+ if(ret < 0 && err == CURLE_AGAIN) {
SET_SOCKERRNO(EWOULDBLOCK);
}
return ret;
@@ -627,7 +635,7 @@ ldapsb_tls_write(Sockbuf_IO_Desc *sbiod, void *buf, ber_len_t len)
CURLcode err = CURLE_SEND_ERROR;
ret = li->send(conn, FIRSTSOCKET, buf, len, &err);
- if (ret < 0 && err == CURLE_AGAIN) {
+ if(ret < 0 && err == CURLE_AGAIN) {
SET_SOCKERRNO(EWOULDBLOCK);
}
return ret;
diff --git a/lib/parsedate.c b/lib/parsedate.c
index 298481701..60a584530 100644
--- a/lib/parsedate.c
+++ b/lib/parsedate.c
@@ -160,7 +160,8 @@ static const struct tzinfo tz[]= {
{"G", +7 * 60}, /* Golf */
{"H", +8 * 60}, /* Hotel */
{"I", +9 * 60}, /* India */
- /* "J", Juliet is not used as a timezone, to indicate the observer's local time */
+ /* "J", Juliet is not used as a timezone, to indicate the observer's local
+ time */
{"K", +10 * 60}, /* Kilo */
{"L", +11 * 60}, /* Lima */
{"M", +12 * 60}, /* Mike */
@@ -282,11 +283,11 @@ static time_t my_timegm(struct my_tm *tm)
year = tm->tm_year + 1900;
month = tm->tm_mon;
- if (month < 0) {
+ if(month < 0) {
year += (11 - month) / 12;
month = 11 - (11 - month) % 12;
}
- else if (month >= 12) {
+ else if(month >= 12) {
year -= month / 12;
month = month % 12;
}
diff --git a/lib/pingpong.c b/lib/pingpong.c
index a49aad960..8f0266760 100644
--- a/lib/pingpong.c
+++ b/lib/pingpong.c
@@ -431,8 +431,8 @@ CURLcode Curl_pp_readresp(curl_socket_t sockfd,
/* We got an excessive line without newlines and we need to deal
with it. We keep the first bytes of the line then we throw
away the rest. */
- infof(data, "Excessive server response line length received, %zd bytes."
- " Stripping\n", gotbytes);
+ infof(data, "Excessive server response line length received, "
+ "%zd bytes. Stripping\n", gotbytes);
restart = TRUE;
/* we keep 40 bytes since all our pingpong protocols are only
@@ -440,9 +440,9 @@ CURLcode Curl_pp_readresp(curl_socket_t sockfd,
clipamount = 40;
}
else if(pp->nread_resp > BUFSIZE/2) {
- /* We got a large chunk of data and there's potentially still trailing
- data to take care of, so we put any such part in the "cache", clear
- the buffer to make space and restart. */
+ /* We got a large chunk of data and there's potentially still
+ trailing data to take care of, so we put any such part in the
+ "cache", clear the buffer to make space and restart. */
clipamount = perline;
restart = TRUE;
}
diff --git a/lib/polarssl.c b/lib/polarssl.c
index 51e35db87..370b8c64c 100644
--- a/lib/polarssl.c
+++ b/lib/polarssl.c
@@ -106,9 +106,9 @@ Curl_polarssl_connect(struct connectdata *conn,
if(data->set.ssl.version == CURL_SSLVERSION_SSLv2) {
failf(data, "PolarSSL does not support SSLv2");
return CURLE_SSL_CONNECT_ERROR;
- } else if(data->set.ssl.version == CURL_SSLVERSION_SSLv3) {
- sni = FALSE; /* SSLv3 has no SNI */
}
+ else if(data->set.ssl.version == CURL_SSLVERSION_SSLv3)
+ sni = FALSE; /* SSLv3 has no SNI */
havege_init(&conn->ssl[sockindex].hs);
@@ -222,12 +222,13 @@ Curl_polarssl_connect(struct connectdata *conn,
#endif
for(;;) {
- if (!(ret = ssl_handshake(&conn->ssl[sockindex].ssl))) {
+ if(!(ret = ssl_handshake(&conn->ssl[sockindex].ssl)))
break;
- } else if(ret != POLARSSL_ERR_NET_TRY_AGAIN) {
+ else if(ret != POLARSSL_ERR_NET_TRY_AGAIN) {
failf(data, "ssl_handshake returned -0x%04X", -ret);
return CURLE_SSL_CONNECT_ERROR;
- } else {
+ }
+ else {
/* wait for data from server... */
long timeout_ms = Curl_timeleft(data, NULL, TRUE);
diff --git a/lib/pop3.c b/lib/pop3.c
index d0aba352b..e4fd03b45 100644
--- a/lib/pop3.c
+++ b/lib/pop3.c
@@ -100,7 +100,7 @@ static CURLcode pop3_do(struct connectdata *conn, bool *done);
static CURLcode pop3_done(struct connectdata *conn,
CURLcode, bool premature);
static CURLcode pop3_connect(struct connectdata *conn, bool *done);
-static CURLcode pop3_disconnect(struct connectdata *conn, bool dead_connection);
+static CURLcode pop3_disconnect(struct connectdata *conn, bool dead);
static CURLcode pop3_multi_statemach(struct connectdata *conn, bool *done);
static int pop3_getsock(struct connectdata *conn,
curl_socket_t *socks,
@@ -481,7 +481,7 @@ static CURLcode pop3_list(struct connectdata *conn)
if(result)
return result;
- if (strlen(pop3c->mailbox))
+ if(strlen(pop3c->mailbox))
state(conn, POP3_LIST_SINGLE);
else
state(conn, POP3_LIST);
@@ -773,7 +773,7 @@ CURLcode pop3_perform(struct connectdata *conn,
/* If mailbox is empty, then assume user wants listing for mail IDs,
* otherwise, attempt to retrieve the mail-id stored in mailbox
*/
- if (strlen(pop3c->mailbox) && !conn->data->set.ftp_list_only)
+ if(strlen(pop3c->mailbox) && !conn->data->set.ftp_list_only)
result = pop3_retr(conn);
else
result = pop3_list(conn);
@@ -896,7 +896,7 @@ static CURLcode pop3_parse_url_path(struct connectdata *conn)
/* url decode the path and use this mailbox */
pop3c->mailbox = curl_easy_unescape(data, path, 0, NULL);
- if (!pop3c->mailbox)
+ if(!pop3c->mailbox)
return CURLE_OUT_OF_MEMORY;
return CURLE_OK;
diff --git a/lib/progress.c b/lib/progress.c
index e37c34d99..8655dc4c2 100644
--- a/lib/progress.c
+++ b/lib/progress.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2009, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -369,8 +369,10 @@ int Curl_pgrsUpdate(struct connectdata *conn)
data->state.resume_from);
}
fprintf(data->set.err,
- " %% Total %% Received %% Xferd Average Speed Time Time Time Current\n"
- " Dload Upload Total Spent Left Speed\n");
+ " %% Total %% Received %% Xferd Average Speed "
+ "Time Time Time Current\n"
+ " Dload Upload "
+ "Total Spent Left Speed\n");
data->progress.flags |= PGRS_HEADERS_OUT; /* headers are shown */
}
diff --git a/lib/qssl.c b/lib/qssl.c
index 55031491e..60ea6da23 100644
--- a/lib/qssl.c
+++ b/lib/qssl.c
@@ -266,7 +266,7 @@ CURLcode Curl_qsossl_connect(struct connectdata * conn, int sockindex)
connssl->state = ssl_connection_none;
}
}
- if (rc == CURLE_OK) {
+ if(rc == CURLE_OK) {
connssl->state = ssl_connection_complete;
conn->recv[sockindex] = qsossl_recv;
conn->send[sockindex] = qsossl_send;
@@ -347,7 +347,7 @@ int Curl_qsossl_shutdown(struct connectdata * conn, int sockindex)
what = Curl_socket_ready(conn->sock[sockindex],
CURL_SOCKET_BAD, SSL_SHUTDOWN_TIMEOUT);
- for (;;) {
+ for(;;) {
if(what < 0) {
/* anything that gets here is fatally bad */
failf(data, "select/poll on SSL socket, errno: %d", SOCKERRNO);
diff --git a/lib/rawstr.c b/lib/rawstr.c
index f3b302dc1..2cf2fe7cb 100644
--- a/lib/rawstr.c
+++ b/lib/rawstr.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2009, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -133,10 +133,10 @@ int Curl_raw_nequal(const char *first, const char *second, size_t max)
*/
void Curl_strntoupper(char *dest, const char *src, size_t n)
{
- if (n < 1)
+ if(n < 1)
return;
do {
*dest++ = Curl_raw_toupper(*src);
- } while (*src++ && --n);
+ } while(*src++ && --n);
}
diff --git a/lib/rawstr.h b/lib/rawstr.h
index 59633b7f5..d73dbc2c0 100644
--- a/lib/rawstr.h
+++ b/lib/rawstr.h
@@ -29,7 +29,8 @@
* to be locale independent and only compare strings we know are safe for
* this.
*
- * The function is capable of comparing a-z case insensitively even for non-ascii.
+ * The function is capable of comparing a-z case insensitively even for
+ * non-ascii.
*/
int Curl_raw_equal(const char *first, const char *second);
int Curl_raw_nequal(const char *first, const char *second, size_t max);
diff --git a/lib/rtsp.c b/lib/rtsp.c
index 14f430c88..a408476f4 100644
--- a/lib/rtsp.c
+++ b/lib/rtsp.c
@@ -119,11 +119,11 @@ bool Curl_rtsp_connisdead(struct connectdata *check)
/* timeout */
ret_val = FALSE;
}
- else if (sval & CURL_CSELECT_ERR) {
+ else if(sval & CURL_CSELECT_ERR) {
/* socket is in an error state */
ret_val = TRUE;
}
- else if ((sval & CURL_CSELECT_IN) && check->data) {
+ else if((sval & CURL_CSELECT_IN) && check->data) {
/* readable with no error. could be closed or could be alive but we can
only check if we have a proper SessionHandle for the connection */
curl_socket_t connectinfo = Curl_getconnectinfo(check->data, &check);
@@ -180,7 +180,8 @@ CURLcode Curl_rtsp_done(struct connectdata *conn,
CSeq_sent = rtsp->CSeq_sent;
CSeq_recv = rtsp->CSeq_recv;
if((data->set.rtspreq != RTSPREQ_RECEIVE) && (CSeq_sent != CSeq_recv)) {
- failf(data, "The CSeq of this request %ld did not match the response %ld",
+ failf(data,
+ "The CSeq of this request %ld did not match the response %ld",
CSeq_sent, CSeq_recv);
return CURLE_RTSP_CSEQ_ERROR;
}
@@ -510,8 +511,9 @@ CURLcode Curl_rtsp(struct connectdata *conn, bool *done)
}
}
- data->state.expect100header = FALSE; /* RTSP posts are simple/small */
- } else if(rtspreq == RTSPREQ_GET_PARAMETER) {
+ data->state.expect100header = FALSE; /* RTSP posts are simple/small */
+ }
+ else if(rtspreq == RTSPREQ_GET_PARAMETER) {
/* Check for an empty GET_PARAMETER (heartbeat) request */
data->set.httpreq = HTTPREQ_HEAD;
data->set.opt_no_body = TRUE;
diff --git a/lib/security.c b/lib/security.c
index c4fc88af8..010a5504e 100644
--- a/lib/security.c
+++ b/lib/security.c
@@ -10,7 +10,7 @@
* Copyright (c) 1998, 1999 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
*
- * Copyright (C) 2001 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 2001 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* All rights reserved.
*
@@ -208,17 +208,17 @@ static CURLcode read_data(struct connectdata *conn,
CURLcode ret;
ret = socket_read(fd, &len, sizeof(len));
- if (ret != CURLE_OK)
+ if(ret != CURLE_OK)
return ret;
len = ntohl(len);
tmp = realloc(buf->data, len);
- if (tmp == NULL)
+ if(tmp == NULL)
return CURLE_OUT_OF_MEMORY;
buf->data = tmp;
ret = socket_read(fd, buf->data, len);
- if (ret != CURLE_OK)
+ if(ret != CURLE_OK)
return ret;
buf->size = conn->mech->decode(conn->app_data, buf->data, len,
conn->data_prot, conn);
@@ -522,7 +522,7 @@ static CURLcode choose_mech(struct connectdata *conn)
break;
default:
if(ret/100 == 5) {
- infof(data, "The server does not support the security extensions.\n");
+ infof(data, "server does not support the security extensions\n");
return CURLE_USE_SSL_FAILED;
}
break;
diff --git a/lib/select.c b/lib/select.c
index e6882da7a..65682f134 100644
--- a/lib/select.c
+++ b/lib/select.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2009, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -355,7 +355,7 @@ int Curl_poll(struct pollfd ufds[], unsigned int nfds, int timeout_ms)
int r;
if(ufds) {
- for (i = 0; i < nfds; i++) {
+ for(i = 0; i < nfds; i++) {
if(ufds[i].fd != CURL_SOCKET_BAD) {
fds_none = FALSE;
break;
@@ -402,7 +402,7 @@ int Curl_poll(struct pollfd ufds[], unsigned int nfds, int timeout_ms)
if(r == 0)
return 0;
- for (i = 0; i < nfds; i++) {
+ for(i = 0; i < nfds; i++) {
if(ufds[i].fd == CURL_SOCKET_BAD)
continue;
if(ufds[i].revents & POLLHUP)
@@ -418,7 +418,7 @@ int Curl_poll(struct pollfd ufds[], unsigned int nfds, int timeout_ms)
FD_ZERO(&fds_err);
maxfd = (curl_socket_t)-1;
- for (i = 0; i < nfds; i++) {
+ for(i = 0; i < nfds; i++) {
ufds[i].revents = 0;
if(ufds[i].fd == CURL_SOCKET_BAD)
continue;
@@ -466,7 +466,7 @@ int Curl_poll(struct pollfd ufds[], unsigned int nfds, int timeout_ms)
return 0;
r = 0;
- for (i = 0; i < nfds; i++) {
+ for(i = 0; i < nfds; i++) {
ufds[i].revents = 0;
if(ufds[i].fd == CURL_SOCKET_BAD)
continue;
diff --git a/lib/sendf.c b/lib/sendf.c
index 3edac5a90..3e71e1dc5 100644
--- a/lib/sendf.c
+++ b/lib/sendf.c
@@ -299,7 +299,8 @@ ssize_t Curl_send_plain(struct connectdata *conn, int num,
/* this is just a case of EWOULDBLOCK */
bytes_written=0;
*code = CURLE_AGAIN;
- } else {
+ }
+ else {
failf(conn->data, "Send failure: %s",
Curl_strerror(conn, err));
conn->data->state.os_errno = err;
@@ -354,7 +355,8 @@ ssize_t Curl_recv_plain(struct connectdata *conn, int num, char *buf,
) {
/* this is just a case of EWOULDBLOCK */
*code = CURLE_AGAIN;
- } else {
+ }
+ else {
failf(conn->data, "Recv failure: %s",
Curl_strerror(conn, err));
conn->data->state.os_errno = err;
diff --git a/lib/setup.h b/lib/setup.h
index 477d4690b..1e96c76dd 100644
--- a/lib/setup.h
+++ b/lib/setup.h
@@ -26,7 +26,8 @@
* Define WIN32 when build target is Win32 API
*/
-#if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32) && !defined(__SYMBIAN32__)
+#if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32) && \
+ !defined(__SYMBIAN32__)
#define WIN32
#endif
@@ -523,7 +524,8 @@
#if defined(_MSC_VER) && !defined(__POCC__)
# if !defined(HAVE_WINDOWS_H) || ((_MSC_VER < 1300) && !defined(_FILETIME_))
# if !defined(ALLOW_MSVC6_WITHOUT_PSDK)
-# error MSVC 6.0 requires "February 2003 Platform SDK" a.k.a. "Windows Server 2003 PSDK"
+# error MSVC 6.0 requires "February 2003 Platform SDK" a.k.a. \
+ "Windows Server 2003 PSDK"
# else
# define CURL_DISABLE_LDAP 1
# endif
@@ -551,7 +553,9 @@ int netware_init(void);
#define LIBIDN_REQUIRED_VERSION "0.4.1"
-#if defined(USE_GNUTLS) || defined(USE_SSLEAY) || defined(USE_NSS) || defined(USE_QSOSSL) || defined(USE_POLARSSL) || defined(USE_AXTLS) || defined(USE_CYASSL)
+#if defined(USE_GNUTLS) || defined(USE_SSLEAY) || defined(USE_NSS) || \
+ defined(USE_QSOSSL) || defined(USE_POLARSSL) || defined(USE_AXTLS) || \
+ defined(USE_CYASSL)
#define USE_SSL /* SSL support has been enabled */
#endif
@@ -560,7 +564,8 @@ int netware_init(void);
#endif
#if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_NTLM)
-#if defined(USE_SSLEAY) || defined(USE_WINDOWS_SSPI) || defined(USE_GNUTLS) || defined(USE_NSS)
+#if defined(USE_SSLEAY) || defined(USE_WINDOWS_SSPI) || \
+ defined(USE_GNUTLS) || defined(USE_NSS)
#define USE_NTLM
#endif
#endif
diff --git a/lib/share.c b/lib/share.c
index 146228551..33dcecf4c 100644
--- a/lib/share.c
+++ b/lib/share.c
@@ -96,32 +96,31 @@ curl_share_setopt(CURLSH *sh, CURLSHoption option, ...)
/* this is a type this share will no longer share */
type = va_arg(param, int);
share->specifier &= ~(1<<type);
- switch( type )
- {
- case CURL_LOCK_DATA_DNS:
- if(share->hostcache) {
- Curl_hash_destroy(share->hostcache);
- share->hostcache = NULL;
- }
- break;
+ switch( type ) {
+ case CURL_LOCK_DATA_DNS:
+ if(share->hostcache) {
+ Curl_hash_destroy(share->hostcache);
+ share->hostcache = NULL;
+ }
+ break;
#if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_COOKIES)
- case CURL_LOCK_DATA_COOKIE:
- if(share->cookies) {
- Curl_cookie_cleanup(share->cookies);
- share->cookies = NULL;
- }
- break;
+ case CURL_LOCK_DATA_COOKIE:
+ if(share->cookies) {
+ Curl_cookie_cleanup(share->cookies);
+ share->cookies = NULL;
+ }
+ break;
#endif /* CURL_DISABLE_HTTP */
- case CURL_LOCK_DATA_SSL_SESSION:
- break;
+ case CURL_LOCK_DATA_SSL_SESSION:
+ break;
- case CURL_LOCK_DATA_CONNECT:
- break;
+ case CURL_LOCK_DATA_CONNECT:
+ break;
- default:
- return CURLSHE_BAD_OPTION;
+ default:
+ return CURLSHE_BAD_OPTION;
}
break;
diff --git a/lib/slist.c b/lib/slist.c
index 7c0f67b1c..e2006f4be 100644
--- a/lib/slist.c
+++ b/lib/slist.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2009, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -101,7 +101,7 @@ struct curl_slist *Curl_slist_duplicate(struct curl_slist *inlist)
while(inlist) {
tmp = curl_slist_append(outlist, inlist->data);
- if (!tmp) {
+ if(!tmp) {
curl_slist_free_all(outlist);
return NULL;
}
diff --git a/lib/smtp.c b/lib/smtp.c
index 5790fe744..170c32dbb 100644
--- a/lib/smtp.c
+++ b/lib/smtp.c
@@ -106,7 +106,7 @@ static CURLcode smtp_do(struct connectdata *conn, bool *done);
static CURLcode smtp_done(struct connectdata *conn,
CURLcode, bool premature);
static CURLcode smtp_connect(struct connectdata *conn, bool *done);
-static CURLcode smtp_disconnect(struct connectdata *conn, bool dead_connection);
+static CURLcode smtp_disconnect(struct connectdata *conn, bool dead);
static CURLcode smtp_multi_statemach(struct connectdata *conn, bool *done);
static int smtp_getsock(struct connectdata *conn,
curl_socket_t *socks,
@@ -240,10 +240,10 @@ static int smtp_endofresp(struct pingpong *pp, int *resp)
line += 5;
len -= 5;
- for (;;) {
- while (len &&
- (*line == ' ' || *line == '\t' ||
- *line == '\r' || *line == '\n')) {
+ for(;;) {
+ while(len &&
+ (*line == ' ' || *line == '\t' ||
+ *line == '\r' || *line == '\n')) {
line++;
len--;
}
@@ -251,9 +251,9 @@ static int smtp_endofresp(struct pingpong *pp, int *resp)
if(!len)
break;
- for (wordlen = 0; wordlen < len && line[wordlen] != ' ' &&
- line[wordlen] != '\t' && line[wordlen] != '\r' &&
- line[wordlen] != '\n';)
+ for(wordlen = 0; wordlen < len && line[wordlen] != ' ' &&
+ line[wordlen] != '\t' && line[wordlen] != '\r' &&
+ line[wordlen] != '\n';)
wordlen++;
if(wordlen == 5 && !memcmp(line, "LOGIN", 5))
@@ -359,7 +359,8 @@ static size_t smtp_auth_plain_data(struct connectdata * conn, char * * outptr)
memcpy(plainauth + ulen + 1, conn->user, ulen);
plainauth[2 * ulen + 1] = '\0';
memcpy(plainauth + 2 * ulen + 2, conn->passwd, plen);
- return Curl_base64_encode(conn->data, plainauth, 2 * ulen + plen + 2, outptr);
+ return Curl_base64_encode(conn->data, plainauth, 2 * ulen + plen + 2,
+ outptr);
}
static size_t smtp_auth_login_user(struct connectdata * conn, char * * outptr)
@@ -696,16 +697,16 @@ static CURLcode smtp_state_authcram_resp(struct connectdata *conn,
}
/* Get the challenge. */
- for (chlg64 += 4; *chlg64 == ' ' || *chlg64 == '\t'; chlg64++)
+ for(chlg64 += 4; *chlg64 == ' ' || *chlg64 == '\t'; chlg64++)
;
chlg = (unsigned char *) NULL;
chlglen = 0;
if(*chlg64 != '=') {
- for (l = strlen(chlg64); l--;)
+ for(l = strlen(chlg64); l--;)
if(chlg64[l] != '\r' && chlg64[l] != '\n' && chlg64[l] != ' ' &&
- chlg64[l] != '\t')
+ chlg64[l] != '\t')
break;
if(++l) {
@@ -740,9 +741,10 @@ static CURLcode smtp_state_authcram_resp(struct connectdata *conn,
/* Prepare the reply. */
snprintf(reply, sizeof reply,
"%s %02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
- conn->user, digest[0], digest[1], digest[2], digest[3], digest[4], digest[5],
- digest[6], digest[7], digest[8], digest[9], digest[10], digest[11],
- digest[12], digest[13], digest[14], digest[15]);
+ conn->user, digest[0], digest[1], digest[2], digest[3], digest[4],
+ digest[5],
+ digest[6], digest[7], digest[8], digest[9], digest[10], digest[11],
+ digest[12], digest[13], digest[14], digest[15]);
/* Encode it to base64 and send it. */
l = Curl_base64_encode(data, reply, 0, &rplyb64);
@@ -789,7 +791,7 @@ static CURLcode smtp_mail(struct connectdata *conn)
struct SessionHandle *data = conn->data;
/* send MAIL FROM */
- if (data->set.str[STRING_MAIL_FROM][0] == '<')
+ if(data->set.str[STRING_MAIL_FROM][0] == '<')
result = Curl_pp_sendf(&conn->proto.smtpc.pp, "MAIL FROM:%s",
data->set.str[STRING_MAIL_FROM]);
else
@@ -1217,7 +1219,8 @@ static CURLcode smtp_done(struct connectdata *conn, CURLcode status,
result = status; /* use the already set error code */
}
else
- /* TODO: make this work even when the socket is EWOULDBLOCK in this call! */
+ /* TODO: make this work even when the socket is EWOULDBLOCK in this
+ call! */
/* write to socket (send away data) */
result = Curl_write(conn,
diff --git a/lib/smtp.h b/lib/smtp.h
index 0f527142c..bc4b91eaa 100644
--- a/lib/smtp.h
+++ b/lib/smtp.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 2009 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 2009 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -34,7 +34,8 @@ typedef enum {
SMTP_EHLO,
SMTP_HELO,
SMTP_STARTTLS,
- SMTP_UPGRADETLS, /* asynchronously upgrade the connection to SSL/TLS (multi mode only) */
+ SMTP_UPGRADETLS, /* asynchronously upgrade the connection to SSL/TLS
+ (multi mode only) */
SMTP_AUTHPLAIN,
SMTP_AUTHLOGIN,
SMTP_AUTHPASSWD,
diff --git a/lib/socks.c b/lib/socks.c
index 5424d54af..14f8a2db2 100644
--- a/lib/socks.c
+++ b/lib/socks.c
@@ -163,7 +163,7 @@ CURLcode Curl_SOCKS4(const char *proxy_name,
*((unsigned short*)&socksreq[2]) = htons((unsigned short)remote_port);
/* DNS resolve only for SOCKS4, not SOCKS4a */
- if (!protocol4a) {
+ if(!protocol4a) {
struct Curl_dns_entry *dns;
Curl_addrinfo *hp=NULL;
int rc;
@@ -227,14 +227,14 @@ CURLcode Curl_SOCKS4(const char *proxy_name,
(int)strlen((char*)socksreq + 8); /* size including NUL */
/* If SOCKS4a, set special invalid IP address 0.0.0.x */
- if (protocol4a) {
+ if(protocol4a) {
socksreq[4] = 0;
socksreq[5] = 0;
socksreq[6] = 0;
socksreq[7] = 1;
/* If still enough room in buffer, also append hostname */
hostnamelen = (ssize_t)strlen(hostname) + 1; /* length including NUL */
- if (packetsize + hostnamelen <= SOCKS4REQLEN)
+ if(packetsize + hostnamelen <= SOCKS4REQLEN)
strcpy((char*)socksreq + packetsize, hostname);
else
hostnamelen = 0; /* Flag: hostname did not fit in buffer */
@@ -248,7 +248,7 @@ CURLcode Curl_SOCKS4(const char *proxy_name,
failf(data, "Failed to send SOCKS4 connect request.");
return CURLE_COULDNT_CONNECT;
}
- if (protocol4a && hostnamelen == 0) {
+ if(protocol4a && hostnamelen == 0) {
/* SOCKS4a with very long hostname - send that name separately */
hostnamelen = (ssize_t)strlen(hostname) + 1;
code = Curl_write_plain(conn, sock, (char *)hostname, hostnamelen,
@@ -296,10 +296,9 @@ CURLcode Curl_SOCKS4(const char *proxy_name,
}
/* Result */
- switch(socksreq[1])
- {
+ switch(socksreq[1]) {
case 90:
- if (protocol4a)
+ if(protocol4a)
infof(data, "SOCKS4a request granted.\n");
else
infof(data, "SOCKS4 request granted.\n");
@@ -391,8 +390,7 @@ CURLcode Curl_SOCKS5(const char *proxy_name,
ssize_t packetsize = 0;
/* RFC1928 chapter 5 specifies max 255 chars for domain name in packet */
- if(!socks5_resolve_local && hostname_len > 255)
- {
+ if(!socks5_resolve_local && hostname_len > 255) {
infof(conn->data,"SOCKS5: server resolving disabled for hostnames of "
"length > 255 [actual len=%zu]\n", hostname_len);
socks5_resolve_local = TRUE;
@@ -643,9 +641,11 @@ CURLcode Curl_SOCKS5(const char *proxy_name,
#if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
if(conn->socks5_gssapi_enctype) {
failf(data, "SOCKS5 gssapi protection not yet implemented.");
- } else
+ }
+ else
#endif
- code = Curl_write_plain(conn, sock, (char *)socksreq, packetsize, &written);
+ code = Curl_write_plain(conn, sock, (char *)socksreq, packetsize,
+ &written);
if((code != CURLE_OK) || (written != packetsize)) {
failf(data, "Failed to send SOCKS5 connect request.");
return CURLE_COULDNT_CONNECT;
@@ -656,7 +656,8 @@ CURLcode Curl_SOCKS5(const char *proxy_name,
#if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
if(conn->socks5_gssapi_enctype) {
failf(data, "SOCKS5 gssapi protection not yet implemented.");
- } else
+ }
+ else
#endif
result = Curl_blockread_all(conn, sock, (char *)socksreq, packetsize,
&actualread, timeout);
diff --git a/lib/socks_gssapi.c b/lib/socks_gssapi.c
index b509c7132..f0d503c91 100644
--- a/lib/socks_gssapi.c
+++ b/lib/socks_gssapi.c
@@ -148,7 +148,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
*/
/* prepare service name */
- if (strchr(serviceptr,'/')) {
+ if(strchr(serviceptr,'/')) {
service.value = malloc(strlen(serviceptr));
if(!service.value)
return CURLE_OUT_OF_MEMORY;
@@ -438,7 +438,8 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
gss_delete_sec_context(&gss_status, &gss_context, NULL);
return CURLE_COULDNT_CONNECT;
}
- } else {
+ }
+ else {
code = Curl_write_plain(conn, sock, (char *)gss_w_token.value,
gss_w_token.length, &written);
if((code != CURLE_OK) || ((ssize_t)gss_w_token.length != written)) {
diff --git a/lib/socks_sspi.c b/lib/socks_sspi.c
index aaaed5e95..2532eda23 100644
--- a/lib/socks_sspi.c
+++ b/lib/socks_sspi.c
@@ -197,7 +197,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
*/
/* prepare service name */
- if (strchr(service, '/')) {
+ if(strchr(service, '/')) {
service_name = malloc(strlen(service));
if(!service_name)
return CURLE_OUT_OF_MEMORY;
@@ -234,15 +234,16 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
cred_handle.dwLower = 0;
cred_handle.dwUpper = 0;
- sspi_major_status = s_pSecFn->AcquireCredentialsHandleA( NULL,
- (char *)"Kerberos",
- SECPKG_CRED_OUTBOUND,
- NULL,
- NULL,
- NULL,
- NULL,
- &cred_handle,
- &expiry);
+ sspi_major_status =
+ s_pSecFn->AcquireCredentialsHandleA( NULL,
+ (char *)"Kerberos",
+ SECPKG_CRED_OUTBOUND,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ &cred_handle,
+ &expiry);
if(check_sspi_err(data, sspi_major_status,sspi_minor_status,
"AcquireCredentialsHandleA") ) {
@@ -408,9 +409,10 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
service_name=NULL;
/* Everything is good so far, user was authenticated! */
- sspi_major_status = s_pSecFn->QueryCredentialsAttributes( &cred_handle,
- SECPKG_CRED_ATTR_NAMES,
- &names);
+ sspi_major_status =
+ s_pSecFn->QueryCredentialsAttributes( &cred_handle,
+ SECPKG_CRED_ATTR_NAMES,
+ &names);
s_pSecFn->FreeCredentialsHandle(&cred_handle);
if(check_sspi_err(data,sspi_major_status,sspi_minor_status,
"QueryCredentialAttributes") ){
@@ -576,7 +578,8 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
s_pSecFn->DeleteSecurityContext(&sspi_context);
return CURLE_COULDNT_CONNECT;
}
- } else {
+ }
+ else {
code = Curl_write_plain(conn, sock, (char *)sspi_send_token.pvBuffer,
sspi_send_token.cbBuffer, &written);
if((code != CURLE_OK) || (sspi_send_token.cbBuffer != (size_t)written)) {
@@ -666,7 +669,8 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
memcpy(socksreq,sspi_w_token[1].pvBuffer,sspi_w_token[1].cbBuffer);
s_pSecFn->FreeContextBuffer(sspi_w_token[0].pvBuffer);
s_pSecFn->FreeContextBuffer(sspi_w_token[1].pvBuffer);
- } else {
+ }
+ else {
if(sspi_w_token[0].cbBuffer != 1) {
failf(data, "Invalid SSPI encryption response length (%d).",
sspi_w_token[0].cbBuffer);
@@ -684,7 +688,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
/* For later use if encryption is required
conn->socks5_gssapi_enctype = socksreq[0];
- if (socksreq[0] != 0)
+ if(socksreq[0] != 0)
conn->socks5_sspi_context = sspi_context;
else {
s_pSecFn->DeleteSecurityContext(&sspi_context);
diff --git a/lib/splay.c b/lib/splay.c
index dcc42cf26..ce8a8a57b 100644
--- a/lib/splay.c
+++ b/lib/splay.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1997 - 2009, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1997 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -48,7 +48,7 @@ struct Curl_tree *Curl_splay(struct timeval i,
N.smaller = N.larger = NULL;
l = r = &N;
- for (;;) {
+ for(;;) {
comp = compare(i, t->key);
if(comp < 0) {
if(t->smaller == NULL)
@@ -98,7 +98,7 @@ struct Curl_tree *Curl_splayinsert(struct timeval i,
struct Curl_tree *t,
struct Curl_tree *node)
{
- static struct timeval KEY_NOTUSED = {-1,-1}; /* key that will *NEVER* appear */
+ static struct timeval KEY_NOTUSED = {-1,-1}; /* will *NEVER* appear */
if(node == NULL)
return t;
@@ -268,7 +268,7 @@ int Curl_splayremovebyaddr(struct Curl_tree *t,
struct Curl_tree *removenode,
struct Curl_tree **newroot)
{
- static struct timeval KEY_NOTUSED = {-1,-1}; /* key that will *NEVER* appear */
+ static struct timeval KEY_NOTUSED = {-1,-1}; /* will *NEVER* appear */
struct Curl_tree *x;
if(!t || !removenode)
@@ -342,7 +342,7 @@ void Curl_splayprint(struct Curl_tree * t, int d, char output)
return;
Curl_splayprint(t->larger, d+1, output);
- for (i=0; i<d; i++)
+ for(i=0; i<d; i++)
if(output)
fprintf(stderr, " ");
@@ -350,7 +350,8 @@ void Curl_splayprint(struct Curl_tree * t, int d, char output)
#ifdef TEST_SPLAY
fprintf(stderr, "%ld[%d]", (long)t->key.tv_usec, i);
#else
- fprintf(stderr, "%ld.%ld[%d]", (long)t->key.tv_sec, (long)t->key.tv_usec, i);
+ fprintf(stderr, "%ld.%ld[%d]", (long)t->key.tv_sec,
+ (long)t->key.tv_usec, i);
#endif
}
@@ -391,7 +392,7 @@ int main(int argc, argv_item_t argv[])
int i;
root = NULL; /* the empty tree */
- for (i = 0; i < MAX; i++) {
+ for(i = 0; i < MAX; i++) {
struct timeval key;
ptrs[i] = t = malloc(sizeof(struct Curl_tree));
if(!t) {
@@ -418,7 +419,7 @@ int main(int argc, argv_item_t argv[])
#endif
#if 1
- for (i = 0; i < MAX; i++) {
+ for(i = 0; i < MAX; i++) {
int rem = (i+7)%MAX;
struct Curl_tree *r;
printf("Tree look:\n");
diff --git a/lib/ssh.c b/lib/ssh.c
index cc2e1d919..81e3b3fa1 100644
--- a/lib/ssh.c
+++ b/lib/ssh.c
@@ -139,7 +139,7 @@ static CURLcode sftp_done(struct connectdata *conn,
CURLcode, bool premature);
static CURLcode sftp_doing(struct connectdata *conn,
bool *dophase_done);
-static CURLcode sftp_disconnect(struct connectdata *conn, bool dead_connection);
+static CURLcode sftp_disconnect(struct connectdata *conn, bool dead);
static
CURLcode sftp_perform(struct connectdata *conn,
bool *connected,
@@ -567,9 +567,8 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
/* The fingerprint points to static storage (!), don't free() it. */
infof(data, "Fingerprint: ");
- for (rc = 0; rc < 16; rc++) {
+ for(rc = 0; rc < 16; rc++)
infof(data, "%02X ", (unsigned char) fingerprint[rc]);
- }
infof(data, "\n");
#endif /* CURL_LIBSSH2_DEBUG */
@@ -582,7 +581,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
char buf[33];
host_public_key_md5 = libssh2_hostkey_hash(sshc->ssh_session,
LIBSSH2_HOSTKEY_HASH_MD5);
- for (i = 0; i < 16; i++)
+ for(i = 0; i < 16; i++)
snprintf(&buf[i*2], 3, "%02x",
(unsigned char) host_public_key_md5[i]);
if(!strequal(buf, data->set.str[STRING_SSH_HOST_PUBLIC_KEY_MD5])) {
@@ -1490,7 +1489,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
if(data->set.ftp_append)
/* Try to open for append, but create if nonexisting */
flags = LIBSSH2_FXF_WRITE|LIBSSH2_FXF_CREAT|LIBSSH2_FXF_APPEND;
- else if (data->state.resume_from > 0)
+ else if(data->state.resume_from > 0)
/* If we have restart position then open for append */
flags = LIBSSH2_FXF_WRITE|LIBSSH2_FXF_APPEND;
else
@@ -2521,12 +2520,10 @@ static CURLcode ssh_easy_statemach(struct connectdata *conn,
curl_socket_t sock = conn->sock[FIRSTSOCKET];
curl_socket_t fd_read = CURL_SOCKET_BAD;
curl_socket_t fd_write = CURL_SOCKET_BAD;
- if (LIBSSH2_SESSION_BLOCK_INBOUND & dir) {
+ if(LIBSSH2_SESSION_BLOCK_INBOUND & dir)
fd_read = sock;
- }
- if (LIBSSH2_SESSION_BLOCK_OUTBOUND & dir) {
+ if(LIBSSH2_SESSION_BLOCK_OUTBOUND & dir)
fd_write = sock;
- }
/* wait for the socket to become ready */
Curl_socket_ready(fd_read, fd_write,
(int)(left>1000?1000:left)); /* ignore result */
@@ -2594,7 +2591,8 @@ static CURLcode ssh_connect(struct connectdata *conn, bool *done)
if(conn->handler->protocol & CURLPROTO_SCP) {
conn->recv[FIRSTSOCKET] = scp_recv;
conn->send[FIRSTSOCKET] = scp_send;
- } else {
+ }
+ else {
conn->recv[FIRSTSOCKET] = sftp_recv;
conn->send[FIRSTSOCKET] = sftp_send;
}
@@ -2850,7 +2848,7 @@ static ssize_t scp_recv(struct connectdata *conn, int sockindex,
libssh2_channel_read(conn->proto.sshc.ssh_channel, mem, len);
ssh_block2waitfor(conn, (nread == LIBSSH2_ERROR_EAGAIN)?TRUE:FALSE);
- if (nread == LIBSSH2_ERROR_EAGAIN) {
+ if(nread == LIBSSH2_ERROR_EAGAIN) {
*err = CURLE_AGAIN;
nread = -1;
}
@@ -3041,7 +3039,7 @@ get_pathname(const char **cpp, char **path)
quot = *cp++;
/* Search for terminating quote, unescape some chars */
- for (i = j = 0; i <= strlen(cp); i++) {
+ for(i = j = 0; i <= strlen(cp); i++) {
if(cp[i] == quot) { /* Found quote */
i++;
(*path)[j] = '\0';
diff --git a/lib/sslgen.c b/lib/sslgen.c
index a1b65ae74..779d9e9c3 100644
--- a/lib/sslgen.c
+++ b/lib/sslgen.c
@@ -294,7 +294,7 @@ void Curl_ssl_delsessionid(struct connectdata *conn, void *ssl_sessionid)
for(i=0; i< conn->data->set.ssl.numsessions; i++) {
struct curl_ssl_session *check = &conn->data->state.session[i];
- if (check->sessionid == ssl_sessionid) {
+ if(check->sessionid == ssl_sessionid) {
kill_session(check);
break;
}
@@ -346,7 +346,7 @@ CURLcode Curl_ssl_addsessionid(struct connectdata *conn,
store->sessionid = ssl_sessionid;
store->idsize = idsize;
store->age = data->state.sessionage; /* set current age */
- if (store->name)
+ if(store->name)
/* free it if there's one already present */
free(store->name);
store->name = clone_host; /* clone host name */
diff --git a/lib/ssluse.c b/lib/ssluse.c
index 1b53f2589..cd138bb6e 100644
--- a/lib/ssluse.c
+++ b/lib/ssluse.c
@@ -378,22 +378,22 @@ int cert_stuff(struct connectdata *conn,
params.cert = NULL;
/* Does the engine supports LOAD_CERT_CTRL ? */
- if (!ENGINE_ctrl(data->state.engine, ENGINE_CTRL_GET_CMD_FROM_NAME,
- 0, (void *)cmd_name, NULL)) {
+ if(!ENGINE_ctrl(data->state.engine, ENGINE_CTRL_GET_CMD_FROM_NAME,
+ 0, (void *)cmd_name, NULL)) {
failf(data, "ssl engine does not support loading certificates");
return 0;
}
/* Load the certificate from the engine */
- if (!ENGINE_ctrl_cmd(data->state.engine, cmd_name,
- 0, &params, NULL, 1)) {
+ if(!ENGINE_ctrl_cmd(data->state.engine, cmd_name,
+ 0, &params, NULL, 1)) {
failf(data, "ssl engine cannot load client cert with id"
" '%s' [%s]", cert_file,
ERR_error_string(ERR_get_error(), NULL));
return 0;
}
- if (!params.cert) {
+ if(!params.cert) {
failf(data, "ssl engine didn't initialized the certificate "
"properly.");
return 0;
@@ -467,7 +467,7 @@ int cert_stuff(struct connectdata *conn,
return 0;
}
- if (!SSL_CTX_check_private_key (ctx)) {
+ if(!SSL_CTX_check_private_key (ctx)) {
failf(data, "private key from PKCS12 file '%s' "
"does not match certificate in same file", cert_file);
EVP_PKEY_free(pri);
@@ -475,15 +475,15 @@ int cert_stuff(struct connectdata *conn,
return 0;
}
/* Set Certificate Verification chain */
- if (ca && sk_X509_num(ca)) {
- for (i = 0; i < sk_X509_num(ca); i++) {
- if (!SSL_CTX_add_extra_chain_cert(ctx,sk_X509_value(ca, i))) {
+ if(ca && sk_X509_num(ca)) {
+ for(i = 0; i < sk_X509_num(ca); i++) {
+ if(!SSL_CTX_add_extra_chain_cert(ctx,sk_X509_value(ca, i))) {
failf(data, "cannot add certificate to certificate chain");
EVP_PKEY_free(pri);
X509_free(x509);
return 0;
}
- if (!SSL_CTX_add_client_CA(ctx, sk_X509_value(ca, i))) {
+ if(!SSL_CTX_add_client_CA(ctx, sk_X509_value(ca, i))) {
failf(data, "cannot add certificate to client CA list");
EVP_PKEY_free(pri);
X509_free(x509);
@@ -788,10 +788,12 @@ 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) {
- infof(data,"set default crypto engine '%s'\n", ENGINE_get_id(data->state.engine));
+ infof(data,"set default crypto engine '%s'\n",
+ ENGINE_get_id(data->state.engine));
}
else {
- failf(data, "set default crypto engine '%s' failed", ENGINE_get_id(data->state.engine));
+ failf(data, "set default crypto engine '%s' failed",
+ ENGINE_get_id(data->state.engine));
return CURLE_SSL_ENGINE_SETFAILED;
}
}
@@ -810,7 +812,7 @@ struct curl_slist *Curl_ossl_engines_list(struct SessionHandle *data)
struct curl_slist *beg = NULL;
ENGINE *e;
- for (e = ENGINE_get_first(); e; e = ENGINE_get_next(e)) {
+ for(e = ENGINE_get_first(); e; e = ENGINE_get_next(e)) {
list = curl_slist_append(list, ENGINE_get_id(e));
if(list == NULL) {
curl_slist_free_all(beg);
@@ -998,7 +1000,7 @@ static int asn1_output(const ASN1_UTCTIME *tm,
return 1;
if(asn1_string[i-1] == 'Z')
gmt=TRUE;
- for (i=0; i<10; i++)
+ for(i=0; i<10; i++)
if((asn1_string[i] > '9') || (asn1_string[i] < '0'))
return 2;
@@ -1145,7 +1147,7 @@ static CURLcode verifyhost(struct connectdata *conn,
numalts = sk_GENERAL_NAME_num(altnames);
/* loop through all alternatives while none has matched */
- for (i=0; (i<numalts) && (matched != 1); i++) {
+ for(i=0; (i<numalts) && (matched != 1); i++) {
/* get a handle to alternative name number i */
const GENERAL_NAME *check = sk_GENERAL_NAME_value(altnames, i);
@@ -1439,10 +1441,11 @@ ossl_connect_step1(struct connectdata *conn,
default:
case CURL_SSLVERSION_DEFAULT:
#ifdef USE_TLS_SRP
- if (data->set.ssl.authtype == CURL_TLSAUTH_SRP) {
+ if(data->set.ssl.authtype == CURL_TLSAUTH_SRP) {
infof(data, "Set version TLSv1 for SRP authorisation\n");
req_method = TLSv1_client_method() ;
- } else
+ }
+ else
#endif
/* we try to figure out version */
req_method = SSLv23_client_method();
@@ -1458,7 +1461,7 @@ ossl_connect_step1(struct connectdata *conn,
return CURLE_NOT_BUILT_IN;
#else
#ifdef USE_TLS_SRP
- if (data->set.ssl.authtype == CURL_TLSAUTH_SRP)
+ if(data->set.ssl.authtype == CURL_TLSAUTH_SRP)
return CURLE_SSL_CONNECT_ERROR;
#endif
req_method = SSLv2_client_method();
@@ -1467,7 +1470,7 @@ ossl_connect_step1(struct connectdata *conn,
#endif
case CURL_SSLVERSION_SSLv3:
#ifdef USE_TLS_SRP
- if (data->set.ssl.authtype == CURL_TLSAUTH_SRP)
+ if(data->set.ssl.authtype == CURL_TLSAUTH_SRP)
return CURLE_SSL_CONNECT_ERROR;
#endif
req_method = SSLv3_client_method();
@@ -1568,11 +1571,11 @@ ossl_connect_step1(struct connectdata *conn,
if(data->set.ssl.authtype == CURL_TLSAUTH_SRP) {
infof(data, "Using TLS-SRP username: %s\n", data->set.ssl.username);
- if (!SSL_CTX_set_srp_username(connssl->ctx, data->set.ssl.username)) {
+ if(!SSL_CTX_set_srp_username(connssl->ctx, data->set.ssl.username)) {
failf(data, "Unable to set SRP user name");
return CURLE_BAD_FUNCTION_ARGUMENT;
}
- if (!SSL_CTX_set_srp_password(connssl->ctx,data->set.ssl.password)) {
+ if(!SSL_CTX_set_srp_password(connssl->ctx,data->set.ssl.password)) {
failf(data, "failed setting SRP password");
return CURLE_BAD_FUNCTION_ARGUMENT;
}
@@ -1622,13 +1625,13 @@ ossl_connect_step1(struct connectdata *conn,
"none");
}
- if (data->set.str[STRING_SSL_CRLFILE]) {
+ if(data->set.str[STRING_SSL_CRLFILE]) {
/* tell SSL where to find CRL file that is used to check certificate
* revocation */
lookup=X509_STORE_add_lookup(connssl->ctx->cert_store,X509_LOOKUP_file());
- if ( !lookup ||
- (!X509_load_crl_file(lookup,data->set.str[STRING_SSL_CRLFILE],
- X509_FILETYPE_PEM)) ) {
+ if(!lookup ||
+ (!X509_load_crl_file(lookup,data->set.str[STRING_SSL_CRLFILE],
+ X509_FILETYPE_PEM)) ) {
failf(data,"error loading CRL file: %s\n",
data->set.str[STRING_SSL_CRLFILE]);
return CURLE_SSL_CRL_BADFILE;
@@ -1675,12 +1678,12 @@ ossl_connect_step1(struct connectdata *conn,
connssl->server_cert = 0x0;
#ifdef SSL_CTRL_SET_TLSEXT_HOSTNAME
- if ((0 == Curl_inet_pton(AF_INET, conn->host.name, &addr)) &&
+ if((0 == Curl_inet_pton(AF_INET, conn->host.name, &addr)) &&
#ifdef ENABLE_IPV6
- (0 == Curl_inet_pton(AF_INET6, conn->host.name, &addr)) &&
+ (0 == Curl_inet_pton(AF_INET6, conn->host.name, &addr)) &&
#endif
- sni &&
- !SSL_set_tlsext_host_name(connssl->handle, conn->host.name))
+ sni &&
+ !SSL_set_tlsext_host_name(connssl->handle, conn->host.name))
infof(data, "WARNING: failed to configure server name indication (SNI) "
"TLS extension\n");
#endif
@@ -1699,9 +1702,9 @@ ossl_connect_step1(struct connectdata *conn,
/* pass the raw socket into the SSL layers */
if(!SSL_set_fd(connssl->handle, (int)sockfd)) {
- failf(data, "SSL: SSL_set_fd failed: %s",
- ERR_error_string(ERR_get_error(),NULL));
- return CURLE_SSL_CONNECT_ERROR;
+ failf(data, "SSL: SSL_set_fd failed: %s",
+ ERR_error_string(ERR_get_error(),NULL));
+ return CURLE_SSL_CONNECT_ERROR;
}
connssl->connecting_state = ssl_connect_2;
@@ -1903,15 +1906,15 @@ static void pubkey_show(struct SessionHandle *data,
#define print_pubkey_BN(_type, _name, _num) \
do { \
- if (pubkey->pkey._type->_name != NULL) { \
- int len = BN_num_bytes(pubkey->pkey._type->_name); \
- if(len < CERTBUFFERSIZE) { \
+ if(pubkey->pkey._type->_name != NULL) { \
+ int len = BN_num_bytes(pubkey->pkey._type->_name); \
+ if(len < CERTBUFFERSIZE) { \
BN_bn2bin(pubkey->pkey._type->_name, (unsigned char*)bufp); \
- bufp[len] = 0; \
+ bufp[len] = 0; \
pubkey_show(data, _num, #_type, #_name, (unsigned char*)bufp, len); \
} \
} \
-} while (0)
+} while(0)
static int X509V3_ext(struct SessionHandle *data,
int certnum,
@@ -1924,7 +1927,7 @@ static int X509V3_ext(struct SessionHandle *data,
/* no extensions, bail out */
return 1;
- for (i=0; i<sk_X509_EXTENSION_num(exts); i++) {
+ for(i=0; i<sk_X509_EXTENSION_num(exts); i++) {
ASN1_OBJECT *obj;
X509_EXTENSION *ext = sk_X509_EXTENSION_value(exts, i);
BUF_MEM *biomem;
@@ -1960,7 +1963,8 @@ static int X509V3_ext(struct SessionHandle *data,
while((biomem->data[j] == ' ') && (j<(size_t)biomem->length))
j++;
if(j<(size_t)biomem->length)
- ptr+=snprintf(ptr, sizeof(buf)-(ptr-buf), "%s%c", sep, biomem->data[j]);
+ ptr+=snprintf(ptr, sizeof(buf)-(ptr-buf), "%s%c", sep,
+ biomem->data[j]);
}
infof(data, " %s\n", buf);
@@ -1980,7 +1984,7 @@ static void X509_signature(struct SessionHandle *data,
char buf[1024];
char *ptr = buf;
int i;
- for (i=0; i<sig->length; i++)
+ for(i=0; i<sig->length; i++)
ptr+=snprintf(ptr, sizeof(buf)-(ptr-buf), "%02x:", sig->data[i]);
infof(data, " Signature: %s\n", buf);
@@ -2058,7 +2062,7 @@ static CURLcode get_cert_chain(struct connectdata *conn,
}
infof(data, "--- Certificate chain\n");
- for (i=0; i<numcerts; i++) {
+ for(i=0; i<numcerts; i++) {
long value;
ASN1_INTEGER *num;
ASN1_TIME *certdate;
@@ -2089,7 +2093,7 @@ static CURLcode get_cert_chain(struct connectdata *conn,
push_certinfo(data, i, "Version", bufp); /* hex */
num=X509_get_serialNumber(x);
- if (num->length <= 4) {
+ if(num->length <= 4) {
value = ASN1_INTEGER_get(num);
infof(data," Serial Number: %ld (0x%lx)\n", value, value);
snprintf(bufp, CERTBUFFERSIZE, "%lx", value);
@@ -2102,7 +2106,7 @@ static CURLcode get_cert_chain(struct connectdata *conn,
if(num->type == V_ASN1_NEG_INTEGER)
*ptr++='-';
- for (j=0; (j<num->length) && (left>=4); j++) {
+ for(j=0; (j<num->length) && (left>=4); j++) {
/* TODO: length restrictions */
snprintf(ptr, 3, "%02x%c",num->data[j],
((j+1 == num->length)?'\n':':'));
@@ -2272,9 +2276,10 @@ static CURLcode servercert(struct connectdata *conn,
deallocating the certificate. */
/* e.g. match issuer name with provided issuer certificate */
- if (data->set.str[STRING_SSL_ISSUERCERT]) {
- if (! (fp=fopen(data->set.str[STRING_SSL_ISSUERCERT],"r"))) {
- if (strict)
+ if(data->set.str[STRING_SSL_ISSUERCERT]) {
+ fp=fopen(data->set.str[STRING_SSL_ISSUERCERT],"r");
+ if(!fp) {
+ if(strict)
failf(data, "SSL: Unable to open issuer cert (%s)\n",
data->set.str[STRING_SSL_ISSUERCERT]);
X509_free(connssl->server_cert);
@@ -2282,8 +2287,8 @@ static CURLcode servercert(struct connectdata *conn,
return CURLE_SSL_ISSUER_ERROR;
}
issuer = PEM_read_X509(fp,NULL,ZERO_NULL,NULL);
- if (!issuer) {
- if (strict)
+ if(!issuer) {
+ if(strict)
failf(data, "SSL: Unable to read issuer cert (%s)\n",
data->set.str[STRING_SSL_ISSUERCERT]);
X509_free(connssl->server_cert);
@@ -2292,8 +2297,8 @@ static CURLcode servercert(struct connectdata *conn,
return CURLE_SSL_ISSUER_ERROR;
}
fclose(fp);
- if (X509_check_issued(issuer,connssl->server_cert) != X509_V_OK) {
- if (strict)
+ if(X509_check_issued(issuer,connssl->server_cert) != X509_V_OK) {
+ if(strict)
failf(data, "SSL: Certificate issuer check failed (%s)\n",
data->set.str[STRING_SSL_ISSUERCERT]);
X509_free(connssl->server_cert);
@@ -2368,14 +2373,14 @@ ossl_connect_step3(struct connectdata *conn,
#endif
incache = !(Curl_ssl_getsessionid(conn, &old_ssl_sessionid, NULL));
- if (incache) {
- if (old_ssl_sessionid != our_ssl_sessionid) {
+ if(incache) {
+ if(old_ssl_sessionid != our_ssl_sessionid) {
infof(data, "old SSL session ID is stale, removing\n");
Curl_ssl_delsessionid(conn, old_ssl_sessionid);
incache = FALSE;
}
}
- if (!incache) {
+ if(!incache) {
retcode = Curl_ssl_addsessionid(conn, our_ssl_sessionid,
0 /* unknown size */);
if(retcode) {
diff --git a/lib/strerror.c b/lib/strerror.c
index 59f2df5f7..0a883421e 100644
--- a/lib/strerror.c
+++ b/lib/strerror.c
@@ -29,7 +29,7 @@
(defined(HAVE_POSIX_STRERROR_R) && defined(HAVE_VXWORKS_STRERROR_R)) || \
(defined(HAVE_GLIBC_STRERROR_R) && defined(HAVE_VXWORKS_STRERROR_R)) || \
(defined(HAVE_POSIX_STRERROR_R) && defined(HAVE_GLIBC_STRERROR_R))
-# error "strerror_r MUST be either POSIX-style, glibc-style or vxworks-style"
+# error "strerror_r MUST be either POSIX, glibc or vxworks-style"
# endif
#endif
@@ -205,7 +205,8 @@ curl_easy_strerror(CURLcode error)
return "Couldn't use specified SSL cipher";
case CURLE_SSL_CACERT:
- return "Peer certificate cannot be authenticated with known CA certificates";
+ return "Peer certificate cannot be authenticated with given CA "
+ "certificates";
case CURLE_SSL_CACERT_BADFILE:
return "Problem with the SSL CA cert (path? access rights?)";
diff --git a/lib/strtoofft.c b/lib/strtoofft.c
index 61ff05bed..55a6ffd0d 100644
--- a/lib/strtoofft.c
+++ b/lib/strtoofft.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2007, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -110,9 +110,9 @@ curlx_strtoll(const char *nptr, char **endptr, int base)
/* Loop handling digits. */
value = 0;
overflow = 0;
- for (i = get_char(end[0], base);
- i != -1;
- end++, i = get_char(end[0], base)) {
+ for(i = get_char(end[0], base);
+ i != -1;
+ end++, i = get_char(end[0], base)) {
newval = base * value + i;
if(newval < value) {
/* We've overflowed. */
diff --git a/lib/telnet.c b/lib/telnet.c
index 53f33e9a2..0d810835a 100644
--- a/lib/telnet.c
+++ b/lib/telnet.c
@@ -271,8 +271,7 @@ static void negotiate(struct connectdata *conn)
int i;
struct TELNET *tn = (struct TELNET *) conn->data->state.proto.telnet;
- for(i = 0;i < CURL_NTELOPTS;i++)
- {
+ for(i = 0;i < CURL_NTELOPTS;i++) {
if(tn->us_preferred[i] == CURL_YES)
set_local_option(conn, i, CURL_YES);
@@ -288,21 +287,17 @@ static void printoption(struct SessionHandle *data,
const char *fmt;
const char *opt;
- if(data->set.verbose)
- {
- if(cmd == CURL_IAC)
- {
+ if(data->set.verbose) {
+ if(cmd == CURL_IAC) {
if(CURL_TELCMD_OK(option))
infof(data, "%s IAC %s\n", direction, CURL_TELCMD(option));
else
infof(data, "%s IAC %d\n", direction, option);
}
- else
- {
+ else {
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))
opt = CURL_TELOPT(option);
else if(option == CURL_TELOPT_EXOPL)
@@ -346,80 +341,72 @@ static
void set_remote_option(struct connectdata *conn, int option, int newstate)
{
struct TELNET *tn = (struct TELNET *)conn->data->state.proto.telnet;
- if(newstate == CURL_YES)
- {
- switch(tn->him[option])
- {
- case CURL_NO:
- tn->him[option] = CURL_WANTYES;
- send_negotiation(conn, CURL_DO, option);
- break;
+ if(newstate == CURL_YES) {
+ switch(tn->him[option]) {
+ case CURL_NO:
+ tn->him[option] = CURL_WANTYES;
+ send_negotiation(conn, CURL_DO, option);
+ break;
- case CURL_YES:
- /* Already enabled */
- break;
+ case CURL_YES:
+ /* Already enabled */
+ break;
- case CURL_WANTNO:
- switch(tn->himq[option])
- {
- case CURL_EMPTY:
- /* Already negotiating for CURL_YES, queue the request */
- tn->himq[option] = CURL_OPPOSITE;
- break;
- case CURL_OPPOSITE:
- /* Error: already queued an enable request */
- break;
- }
+ case CURL_WANTNO:
+ switch(tn->himq[option]) {
+ case CURL_EMPTY:
+ /* Already negotiating for CURL_YES, queue the request */
+ tn->himq[option] = CURL_OPPOSITE;
break;
+ case CURL_OPPOSITE:
+ /* Error: already queued an enable request */
+ break;
+ }
+ break;
- case CURL_WANTYES:
- switch(tn->himq[option])
- {
- case CURL_EMPTY:
- /* Error: already negotiating for enable */
- break;
- case CURL_OPPOSITE:
- tn->himq[option] = CURL_EMPTY;
- break;
- }
+ case CURL_WANTYES:
+ switch(tn->himq[option]) {
+ case CURL_EMPTY:
+ /* Error: already negotiating for enable */
break;
+ case CURL_OPPOSITE:
+ tn->himq[option] = CURL_EMPTY;
+ break;
+ }
+ break;
}
}
- else /* NO */
- {
- switch(tn->him[option])
- {
- case CURL_NO:
- /* Already disabled */
- break;
+ else { /* NO */
+ switch(tn->him[option]) {
+ case CURL_NO:
+ /* Already disabled */
+ break;
- case CURL_YES:
- tn->him[option] = CURL_WANTNO;
- send_negotiation(conn, CURL_DONT, option);
- break;
+ case CURL_YES:
+ tn->him[option] = CURL_WANTNO;
+ send_negotiation(conn, CURL_DONT, option);
+ break;
- case CURL_WANTNO:
- switch(tn->himq[option])
- {
- case CURL_EMPTY:
- /* Already negotiating for NO */
- break;
- case CURL_OPPOSITE:
- tn->himq[option] = CURL_EMPTY;
- break;
- }
+ case CURL_WANTNO:
+ switch(tn->himq[option]) {
+ case CURL_EMPTY:
+ /* Already negotiating for NO */
break;
+ case CURL_OPPOSITE:
+ tn->himq[option] = CURL_EMPTY;
+ break;
+ }
+ break;
- case CURL_WANTYES:
- switch(tn->himq[option])
- {
- case CURL_EMPTY:
- tn->himq[option] = CURL_OPPOSITE;
- break;
- case CURL_OPPOSITE:
- break;
- }
+ case CURL_WANTYES:
+ switch(tn->himq[option]) {
+ case CURL_EMPTY:
+ tn->himq[option] = CURL_OPPOSITE;
break;
+ case CURL_OPPOSITE:
+ break;
+ }
+ break;
}
}
}
@@ -428,52 +415,47 @@ static
void rec_will(struct connectdata *conn, int option)
{
struct TELNET *tn = (struct TELNET *)conn->data->state.proto.telnet;
- switch(tn->him[option])
- {
- case CURL_NO:
- if(tn->him_preferred[option] == CURL_YES)
- {
- tn->him[option] = CURL_YES;
- send_negotiation(conn, CURL_DO, option);
- }
- else
- {
- send_negotiation(conn, CURL_DONT, option);
- }
- break;
+ switch(tn->him[option]) {
+ case CURL_NO:
+ if(tn->him_preferred[option] == CURL_YES) {
+ tn->him[option] = CURL_YES;
+ send_negotiation(conn, CURL_DO, option);
+ }
+ else
+ send_negotiation(conn, CURL_DONT, option);
- case CURL_YES:
- /* Already enabled */
- break;
+ break;
- case CURL_WANTNO:
- switch(tn->himq[option])
- {
- case CURL_EMPTY:
- /* Error: DONT answered by WILL */
- tn->him[option] = CURL_NO;
- break;
- case CURL_OPPOSITE:
- /* Error: DONT answered by WILL */
- tn->him[option] = CURL_YES;
- tn->himq[option] = CURL_EMPTY;
- break;
- }
+ case CURL_YES:
+ /* Already enabled */
+ break;
+
+ case CURL_WANTNO:
+ switch(tn->himq[option]) {
+ case CURL_EMPTY:
+ /* Error: DONT answered by WILL */
+ tn->him[option] = CURL_NO;
+ break;
+ case CURL_OPPOSITE:
+ /* Error: DONT answered by WILL */
+ tn->him[option] = CURL_YES;
+ tn->himq[option] = CURL_EMPTY;
break;
+ }
+ break;
- case CURL_WANTYES:
- switch(tn->himq[option])
- {
- case CURL_EMPTY:
- tn->him[option] = CURL_YES;
- break;
- case CURL_OPPOSITE:
- tn->him[option] = CURL_WANTNO;
- tn->himq[option] = CURL_EMPTY;
- send_negotiation(conn, CURL_DONT, option);
- break;
- }
+ case CURL_WANTYES:
+ switch(tn->himq[option]) {
+ case CURL_EMPTY:
+ tn->him[option] = CURL_YES;
break;
+ case CURL_OPPOSITE:
+ tn->him[option] = CURL_WANTNO;
+ tn->himq[option] = CURL_EMPTY;
+ send_negotiation(conn, CURL_DONT, option);
+ break;
+ }
+ break;
}
}
@@ -481,44 +463,41 @@ static
void rec_wont(struct connectdata *conn, int option)
{
struct TELNET *tn = (struct TELNET *)conn->data->state.proto.telnet;
- switch(tn->him[option])
- {
- case CURL_NO:
- /* Already disabled */
- break;
+ switch(tn->him[option]) {
+ case CURL_NO:
+ /* Already disabled */
+ break;
- case CURL_YES:
+ case CURL_YES:
+ tn->him[option] = CURL_NO;
+ send_negotiation(conn, CURL_DONT, option);
+ break;
+
+ case CURL_WANTNO:
+ switch(tn->himq[option]) {
+ case CURL_EMPTY:
tn->him[option] = CURL_NO;
- send_negotiation(conn, CURL_DONT, option);
break;
- case CURL_WANTNO:
- switch(tn->himq[option])
- {
- case CURL_EMPTY:
- tn->him[option] = CURL_NO;
- break;
-
- case CURL_OPPOSITE:
- tn->him[option] = CURL_WANTYES;
- tn->himq[option] = CURL_EMPTY;
- send_negotiation(conn, CURL_DO, option);
- break;
- }
+ case CURL_OPPOSITE:
+ tn->him[option] = CURL_WANTYES;
+ tn->himq[option] = CURL_EMPTY;
+ send_negotiation(conn, CURL_DO, option);
break;
+ }
+ break;
- case CURL_WANTYES:
- switch(tn->himq[option])
- {
- case CURL_EMPTY:
- tn->him[option] = CURL_NO;
- break;
- case CURL_OPPOSITE:
- tn->him[option] = CURL_NO;
- tn->himq[option] = CURL_EMPTY;
- break;
- }
+ case CURL_WANTYES:
+ switch(tn->himq[option]) {
+ case CURL_EMPTY:
+ tn->him[option] = CURL_NO;
+ break;
+ case CURL_OPPOSITE:
+ tn->him[option] = CURL_NO;
+ tn->himq[option] = CURL_EMPTY;
break;
+ }
+ break;
}
}
@@ -526,80 +505,72 @@ static void
set_local_option(struct connectdata *conn, int option, int newstate)
{
struct TELNET *tn = (struct TELNET *)conn->data->state.proto.telnet;
- if(newstate == CURL_YES)
- {
- switch(tn->us[option])
- {
- case CURL_NO:
- tn->us[option] = CURL_WANTYES;
- send_negotiation(conn, CURL_WILL, option);
- break;
+ if(newstate == CURL_YES) {
+ switch(tn->us[option]) {
+ case CURL_NO:
+ tn->us[option] = CURL_WANTYES;
+ send_negotiation(conn, CURL_WILL, option);
+ break;
- case CURL_YES:
- /* Already enabled */
- break;
+ case CURL_YES:
+ /* Already enabled */
+ break;
- case CURL_WANTNO:
- switch(tn->usq[option])
- {
- case CURL_EMPTY:
- /* Already negotiating for CURL_YES, queue the request */
- tn->usq[option] = CURL_OPPOSITE;
- break;
- case CURL_OPPOSITE:
- /* Error: already queued an enable request */
- break;
- }
+ case CURL_WANTNO:
+ switch(tn->usq[option]) {
+ case CURL_EMPTY:
+ /* Already negotiating for CURL_YES, queue the request */
+ tn->usq[option] = CURL_OPPOSITE;
+ break;
+ case CURL_OPPOSITE:
+ /* Error: already queued an enable request */
break;
+ }
+ break;
- case CURL_WANTYES:
- switch(tn->usq[option])
- {
- case CURL_EMPTY:
- /* Error: already negotiating for enable */
- break;
- case CURL_OPPOSITE:
- tn->usq[option] = CURL_EMPTY;
- break;
- }
+ case CURL_WANTYES:
+ switch(tn->usq[option]) {
+ case CURL_EMPTY:
+ /* Error: already negotiating for enable */
+ break;
+ case CURL_OPPOSITE:
+ tn->usq[option] = CURL_EMPTY;
break;
+ }
+ break;
}
}
- else /* NO */
- {
- switch(tn->us[option])
- {
- case CURL_NO:
- /* Already disabled */
- break;
+ else { /* NO */
+ switch(tn->us[option]) {
+ case CURL_NO:
+ /* Already disabled */
+ break;
- case CURL_YES:
- tn->us[option] = CURL_WANTNO;
- send_negotiation(conn, CURL_WONT, option);
- break;
+ case CURL_YES:
+ tn->us[option] = CURL_WANTNO;
+ send_negotiation(conn, CURL_WONT, option);
+ break;
- case CURL_WANTNO:
- switch(tn->usq[option])
- {
- case CURL_EMPTY:
- /* Already negotiating for NO */
- break;
- case CURL_OPPOSITE:
- tn->usq[option] = CURL_EMPTY;
- break;
- }
+ case CURL_WANTNO:
+ switch(tn->usq[option]) {
+ case CURL_EMPTY:
+ /* Already negotiating for NO */
+ break;
+ case CURL_OPPOSITE:
+ tn->usq[option] = CURL_EMPTY;
break;
+ }
+ break;
- case CURL_WANTYES:
- switch(tn->usq[option])
- {
- case CURL_EMPTY:
- tn->usq[option] = CURL_OPPOSITE;
- break;
- case CURL_OPPOSITE:
- break;
- }
+ case CURL_WANTYES:
+ switch(tn->usq[option]) {
+ case CURL_EMPTY:
+ tn->usq[option] = CURL_OPPOSITE;
+ break;
+ case CURL_OPPOSITE:
break;
+ }
+ break;
}
}
}
@@ -608,52 +579,46 @@ static
void rec_do(struct connectdata *conn, int option)
{
struct TELNET *tn = (struct TELNET *)conn->data->state.proto.telnet;
- switch(tn->us[option])
- {
- case CURL_NO:
- if(tn->us_preferred[option] == CURL_YES)
- {
- tn->us[option] = CURL_YES;
- send_negotiation(conn, CURL_WILL, option);
- }
- else
- {
- send_negotiation(conn, CURL_WONT, option);
- }
- break;
+ switch(tn->us[option]) {
+ case CURL_NO:
+ if(tn->us_preferred[option] == CURL_YES) {
+ tn->us[option] = CURL_YES;
+ send_negotiation(conn, CURL_WILL, option);
+ }
+ else
+ send_negotiation(conn, CURL_WONT, option);
+ break;
- case CURL_YES:
- /* Already enabled */
- break;
+ case CURL_YES:
+ /* Already enabled */
+ break;
- case CURL_WANTNO:
- switch(tn->usq[option])
- {
- case CURL_EMPTY:
- /* Error: DONT answered by WILL */
- tn->us[option] = CURL_NO;
- break;
- case CURL_OPPOSITE:
- /* Error: DONT answered by WILL */
- tn->us[option] = CURL_YES;
- tn->usq[option] = CURL_EMPTY;
- break;
- }
+ case CURL_WANTNO:
+ switch(tn->usq[option]) {
+ case CURL_EMPTY:
+ /* Error: DONT answered by WILL */
+ tn->us[option] = CURL_NO;
+ break;
+ case CURL_OPPOSITE:
+ /* Error: DONT answered by WILL */
+ tn->us[option] = CURL_YES;
+ tn->usq[option] = CURL_EMPTY;
break;
+ }
+ break;
- case CURL_WANTYES:
- switch(tn->usq[option])
- {
- case CURL_EMPTY:
- tn->us[option] = CURL_YES;
- break;
- case CURL_OPPOSITE:
- tn->us[option] = CURL_WANTNO;
- tn->himq[option] = CURL_EMPTY;
- send_negotiation(conn, CURL_WONT, option);
- break;
- }
+ case CURL_WANTYES:
+ switch(tn->usq[option]) {
+ case CURL_EMPTY:
+ tn->us[option] = CURL_YES;
+ break;
+ case CURL_OPPOSITE:
+ tn->us[option] = CURL_WANTNO;
+ tn->himq[option] = CURL_EMPTY;
+ send_negotiation(conn, CURL_WONT, option);
break;
+ }
+ break;
}
}
@@ -661,44 +626,41 @@ static
void rec_dont(struct connectdata *conn, int option)
{
struct TELNET *tn = (struct TELNET *)conn->data->state.proto.telnet;
- switch(tn->us[option])
- {
- case CURL_NO:
- /* Already disabled */
- break;
+ switch(tn->us[option]) {
+ case CURL_NO:
+ /* Already disabled */
+ break;
- case CURL_YES:
+ case CURL_YES:
+ tn->us[option] = CURL_NO;
+ send_negotiation(conn, CURL_WONT, option);
+ break;
+
+ case CURL_WANTNO:
+ switch(tn->usq[option]) {
+ case CURL_EMPTY:
tn->us[option] = CURL_NO;
- send_negotiation(conn, CURL_WONT, option);
break;
- case CURL_WANTNO:
- switch(tn->usq[option])
- {
- case CURL_EMPTY:
- tn->us[option] = CURL_NO;
- break;
-
- case CURL_OPPOSITE:
- tn->us[option] = CURL_WANTYES;
- tn->usq[option] = CURL_EMPTY;
- send_negotiation(conn, CURL_WILL, option);
- break;
- }
+ case CURL_OPPOSITE:
+ tn->us[option] = CURL_WANTYES;
+ tn->usq[option] = CURL_EMPTY;
+ send_negotiation(conn, CURL_WILL, option);
break;
+ }
+ break;
- case CURL_WANTYES:
- switch(tn->usq[option])
- {
- case CURL_EMPTY:
- tn->us[option] = CURL_NO;
- break;
- case CURL_OPPOSITE:
- tn->us[option] = CURL_NO;
- tn->usq[option] = CURL_EMPTY;
- break;
- }
+ case CURL_WANTYES:
+ switch(tn->usq[option]) {
+ case CURL_EMPTY:
+ tn->us[option] = CURL_NO;
+ break;
+ case CURL_OPPOSITE:
+ tn->us[option] = CURL_NO;
+ tn->usq[option] = CURL_EMPTY;
break;
+ }
+ break;
}
}
@@ -710,20 +672,16 @@ static void printsub(struct SessionHandle *data,
{
unsigned int i = 0;
- if(data->set.verbose)
- {
- if(direction)
- {
+ if(data->set.verbose) {
+ 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))
infof(data, "%s ", CURL_TELOPT(i));
@@ -742,8 +700,7 @@ static void printsub(struct SessionHandle *data,
}
length -= 2;
}
- if(length < 1)
- {
+ if(length < 1) {
infof(data, "(Empty suboption?)");
return;
}
@@ -803,15 +760,13 @@ static void printsub(struct SessionHandle *data,
}
break;
default:
- for (i = 2; i < length; i++)
+ for(i = 2; i < length; i++)
infof(data, " %.2x", pointer[i]);
break;
}
if(direction)
- {
infof(data, "\n");
- }
}
}
@@ -826,8 +781,7 @@ static CURLcode check_telnet_options(struct connectdata *conn)
/* Add the user name as an environment variable if it
was given on the command line */
- if(conn->bits.user_passwd)
- {
+ if(conn->bits.user_passwd) {
snprintf(option_arg, sizeof(option_arg), "USER,%s", conn->user);
tn->telnet_vars = curl_slist_append(tn->telnet_vars, option_arg);
@@ -866,7 +820,8 @@ static CURLcode check_telnet_options(struct connectdata *conn)
failf(data, "Unknown telnet option %s", head->data);
return CURLE_UNKNOWN_TELNET_OPTION;
- } else {
+ }
+ else {
failf(data, "Syntax error in telnet option: %s", head->data);
return CURLE_TELNET_OPTION_SYNTAX;
}
@@ -981,69 +936,61 @@ CURLcode telrcv(struct connectdata *conn,
#define bufferflush() startskipping()
- while(count--)
- {
+ while(count--) {
c = inbuf[in];
- /*infof(data,"In rcv state %d char %d\n", tn->telrcv_state, c);*/
- switch (tn->telrcv_state)
- {
- case CURL_TS_CR:
- tn->telrcv_state = CURL_TS_DATA;
- if(c == '\0')
- {
- startskipping();
- break; /* Ignore \0 after CR */
- }
- writebyte();
- break;
+ switch (tn->telrcv_state) {
+ case CURL_TS_CR:
+ tn->telrcv_state = CURL_TS_DATA;
+ if(c == '\0') {
+ startskipping();
+ break; /* Ignore \0 after CR */
+ }
+ writebyte();
+ break;
- case CURL_TS_DATA:
- if(c == CURL_IAC)
- {
- tn->telrcv_state = CURL_TS_IAC;
- startskipping();
- break;
- }
- else if(c == '\r')
- {
- tn->telrcv_state = CURL_TS_CR;
- }
- writebyte();
+ case CURL_TS_DATA:
+ if(c == CURL_IAC) {
+ tn->telrcv_state = CURL_TS_IAC;
+ startskipping();
break;
+ }
+ else if(c == '\r')
+ tn->telrcv_state = CURL_TS_CR;
+ writebyte();
+ break;
- case CURL_TS_IAC:
- process_iac:
+ case CURL_TS_IAC:
+ process_iac:
DEBUGASSERT(startwrite < 0);
- switch (c)
- {
- case CURL_WILL:
- tn->telrcv_state = CURL_TS_WILL;
- break;
- case CURL_WONT:
- tn->telrcv_state = CURL_TS_WONT;
- break;
- case CURL_DO:
- tn->telrcv_state = CURL_TS_DO;
- break;
- case CURL_DONT:
- tn->telrcv_state = CURL_TS_DONT;
- break;
- case CURL_SB:
- CURL_SB_CLEAR(tn);
- tn->telrcv_state = CURL_TS_SB;
- break;
- case CURL_IAC:
- tn->telrcv_state = CURL_TS_DATA;
- writebyte();
- break;
- case CURL_DM:
- case CURL_NOP:
- case CURL_GA:
- default:
- tn->telrcv_state = CURL_TS_DATA;
- printoption(data, "RCVD", CURL_IAC, c);
- break;
+ switch (c) {
+ case CURL_WILL:
+ tn->telrcv_state = CURL_TS_WILL;
+ break;
+ case CURL_WONT:
+ tn->telrcv_state = CURL_TS_WONT;
+ break;
+ case CURL_DO:
+ tn->telrcv_state = CURL_TS_DO;
+ break;
+ case CURL_DONT:
+ tn->telrcv_state = CURL_TS_DONT;
+ break;
+ case CURL_SB:
+ CURL_SB_CLEAR(tn);
+ tn->telrcv_state = CURL_TS_SB;
+ break;
+ case CURL_IAC:
+ tn->telrcv_state = CURL_TS_DATA;
+ writebyte();
+ break;
+ case CURL_DM:
+ case CURL_NOP:
+ case CURL_GA:
+ default:
+ tn->telrcv_state = CURL_TS_DATA;
+ printoption(data, "RCVD", CURL_IAC, c);
+ break;
}
break;
@@ -1077,20 +1024,14 @@ CURLcode telrcv(struct connectdata *conn,
case CURL_TS_SB:
if(c == CURL_IAC)
- {
tn->telrcv_state = CURL_TS_SE;
- }
else
- {
CURL_SB_ACCUM(tn,c);
- }
break;
case CURL_TS_SE:
- if(c != CURL_SE)
- {
- if(c != CURL_IAC)
- {
+ if(c != CURL_SE) {
+ if(c != CURL_IAC) {
/*
* This is an error. We only expect to get "IAC IAC" or "IAC SE".
* Several things may have happened. An IAC was not doubled, the
@@ -1165,7 +1106,7 @@ static CURLcode send_telnet_data(struct connectdata *conn,
break;
}
/* handle partial write */
- } while (rc == CURLE_OK && total_written < out_count);
+ } while(rc == CURLE_OK && total_written < out_count);
}
return rc;
}
@@ -1304,7 +1245,8 @@ static CURLcode telnet_do(struct connectdata *conn, bool *done)
objs[1] = stdin_handle;
/* Tell winsock what events we want to listen to */
- if(event_select_func(sockfd, event_handle, FD_READ|FD_CLOSE) == SOCKET_ERROR) {
+ if(event_select_func(sockfd, event_handle, FD_READ|FD_CLOSE) ==
+ SOCKET_ERROR) {
close_event_func(event_handle);
FreeLibrary(wsock2);
return CURLE_OK;
@@ -1317,7 +1259,8 @@ static CURLcode telnet_do(struct connectdata *conn, bool *done)
obj_count = 1;
/* Check stdin_handle per 100 milliseconds */
wait_timeout = 100;
- } else {
+ }
+ else {
obj_count = 2;
wait_timeout = 1000;
}
@@ -1448,7 +1391,7 @@ static CURLcode telnet_do(struct connectdata *conn, bool *done)
pfd[0].fd = sockfd;
pfd[0].events = POLLIN;
- if (data->set.is_fread_set) {
+ if(data->set.is_fread_set) {
poll_cnt = 1;
interval_ms = 100; /* poll user-supplied read function */
}
@@ -1505,7 +1448,7 @@ static CURLcode telnet_do(struct connectdata *conn, bool *done)
}
nread = 0;
- if (poll_cnt == 2) {
+ if(poll_cnt == 2) {
if(pfd[1].revents & POLLIN) { /* read from stdin */
nread = read(0, buf, BUFSIZE - 1);
}
@@ -1513,15 +1456,15 @@ static CURLcode telnet_do(struct connectdata *conn, bool *done)
else {
/* read from user-supplied method */
nread = (int)conn->fread_func(buf, 1, BUFSIZE - 1, conn->fread_in);
- if (nread == CURL_READFUNC_ABORT) {
+ if(nread == CURL_READFUNC_ABORT) {
keepon = FALSE;
break;
}
- if (nread == CURL_READFUNC_PAUSE)
+ if(nread == CURL_READFUNC_PAUSE)
break;
}
- if (nread > 0) {
+ if(nread > 0) {
code = send_telnet_data(conn, buf, nread);
if(code) {
keepon = FALSE;
@@ -1530,7 +1473,7 @@ static CURLcode telnet_do(struct connectdata *conn, bool *done)
total_ul += nread;
Curl_pgrsSetUploadCounter(data, total_ul);
}
- else if (nread < 0)
+ else if(nread < 0)
keepon = FALSE;
break;
@@ -1546,8 +1489,8 @@ static CURLcode telnet_do(struct connectdata *conn, bool *done)
}
if(Curl_pgrsUpdate(conn)) {
- code = CURLE_ABORTED_BY_CALLBACK;
- break;
+ code = CURLE_ABORTED_BY_CALLBACK;
+ break;
}
}
#endif
diff --git a/lib/tftp.c b/lib/tftp.c
index a280330f9..d33d33b1c 100644
--- a/lib/tftp.c
+++ b/lib/tftp.c
@@ -166,7 +166,8 @@ typedef struct tftp_state_data {
static CURLcode tftp_rx(tftp_state_data_t *state, tftp_event_t event) ;
static CURLcode tftp_tx(tftp_state_data_t *state, tftp_event_t event) ;
static CURLcode tftp_connect(struct connectdata *conn, bool *done);
-static CURLcode tftp_disconnect(struct connectdata *conn, bool dead_connection);
+static CURLcode tftp_disconnect(struct connectdata *conn,
+ bool dead_connection);
static CURLcode tftp_do(struct connectdata *conn, bool *done);
static CURLcode tftp_done(struct connectdata *conn,
CURLcode, bool premature);
@@ -330,14 +331,14 @@ static const char *tftp_option_get(const char *buf, size_t len,
loc = Curl_strnlen( buf, len );
loc++; /* NULL term */
- if (loc >= len)
+ if(loc >= len)
return NULL;
*option = buf;
loc += Curl_strnlen( buf+loc, len-loc );
loc++; /* NULL term */
- if (loc > len)
+ if(loc > len)
return NULL;
*value = &buf[strlen(*option) + 1];
@@ -353,7 +354,7 @@ static CURLcode tftp_parse_option_ack(tftp_state_data_t *state,
/* if OACK doesn't contain blksize option, the default (512) must be used */
state->blksize = TFTP_BLKSIZE_DEFAULT;
- while (tmp < ptr + len) {
+ while(tmp < ptr + len) {
const char *option, *value;
tmp = tftp_option_get(tmp, ptr + len - tmp, &option, &value);
@@ -383,7 +384,7 @@ static CURLcode tftp_parse_option_ack(tftp_state_data_t *state,
TFTP_BLKSIZE_MIN);
return CURLE_TFTP_ILLEGAL;
}
- else if (blksize > state->requested_blksize) {
+ else if(blksize > state->requested_blksize) {
/* could realloc pkt buffers here, but the spec doesn't call out
* support for the server requesting a bigger blksize than the client
* requests */
@@ -404,7 +405,7 @@ static CURLcode tftp_parse_option_ack(tftp_state_data_t *state,
/* tsize should be ignored on upload: Who cares about the size of the
remote file? */
- if (!data->set.upload) {
+ if(!data->set.upload) {
if(!tsize) {
failf(data, "invalid tsize -:%s:- value in OACK packet", value);
return CURLE_TFTP_ILLEGAL;
@@ -716,7 +717,7 @@ static CURLcode tftp_tx(tftp_state_data_t *state, tftp_event_t event)
case TFTP_EVENT_ACK:
case TFTP_EVENT_OACK:
- if (event == TFTP_EVENT_ACK) {
+ if(event == TFTP_EVENT_ACK) {
/* Ack the packet */
rblock = getrpacketblock(&state->rpacket);
@@ -1170,7 +1171,7 @@ static long tftp_state_timeout(struct connectdata *conn, tftp_event_t *event)
time_t current;
tftp_state_data_t *state = (tftp_state_data_t *)conn->proto.tftpc;
- if (event)
+ if(event)
*event = TFTP_EVENT_NONE;
time(&current);
@@ -1181,8 +1182,8 @@ static long tftp_state_timeout(struct connectdata *conn, tftp_event_t *event)
state->state = TFTP_STATE_FIN;
return 0;
}
- else if (current > state->rx_time+state->retry_time) {
- if (event)
+ else if(current > state->rx_time+state->retry_time) {
+ if(event)
*event = TFTP_EVENT_TIMEOUT;
time(&state->rx_time); /* update even though we received nothing */
}
@@ -1221,8 +1222,8 @@ static CURLcode tftp_easy_statemach(struct connectdata *conn)
timeout_ms = state->retry_time * 1000;
- if (data->set.upload) {
- if (data->set.max_send_speed &&
+ if(data->set.upload) {
+ if(data->set.max_send_speed &&
(data->progress.ulspeed > data->set.max_send_speed)) {
fd_read = CURL_SOCKET_BAD;
timeout_ms = Curl_sleep_time(data->set.max_send_speed,
@@ -1233,20 +1234,19 @@ static CURLcode tftp_easy_statemach(struct connectdata *conn)
}
}
else {
- if (data->set.max_recv_speed &&
- (data->progress.dlspeed > data->set.max_recv_speed)) {
+ if(data->set.max_recv_speed &&
+ (data->progress.dlspeed > data->set.max_recv_speed)) {
fd_read = CURL_SOCKET_BAD;
timeout_ms = Curl_sleep_time(data->set.max_recv_speed,
data->progress.dlspeed, state->blksize);
}
- else {
+ else
fd_read = state->sockfd;
- }
}
if(data->set.timeout) {
timeout_ms = data->set.timeout - Curl_tvdiff(k->now, k->start);
- if (timeout_ms > state->retry_time * 1000)
+ if(timeout_ms > state->retry_time * 1000)
timeout_ms = state->retry_time * 1000;
else if(timeout_ms < 0)
timeout_ms = 0;
@@ -1259,7 +1259,7 @@ static CURLcode tftp_easy_statemach(struct connectdata *conn)
k->now = Curl_tvnow();
/* Force a progress callback if it's been too long */
- if (Curl_tvdiff(k->now, k->start) >= data->set.timeout) {
+ if(Curl_tvdiff(k->now, k->start) >= data->set.timeout) {
if(Curl_pgrsUpdate(conn)) {
tftp_state_machine(state, TFTP_EVENT_ERROR);
return CURLE_ABORTED_BY_CALLBACK;
@@ -1279,7 +1279,7 @@ static CURLcode tftp_easy_statemach(struct connectdata *conn)
/* A timeout occurred, but our timeout is variable, so maybe
just continue? */
long rtms = state->retry_time * 1000;
- if (Curl_tvdiff(k->now, transaction_start) > rtms) {
+ if(Curl_tvdiff(k->now, transaction_start) > rtms) {
state->event = TFTP_EVENT_TIMEOUT;
/* Force a look at transfer timeouts */
check_time = 1;
@@ -1290,7 +1290,7 @@ static CURLcode tftp_easy_statemach(struct connectdata *conn)
}
else {
result = tftp_receive_packet(conn);
- if (result == CURLE_OK)
+ if(result == CURLE_OK)
transaction_start = Curl_tvnow();
if(k->bytecountp)
@@ -1339,7 +1339,7 @@ static CURLcode tftp_multi_statemach(struct connectdata *conn, bool *done)
failf(data, "TFTP response timeout");
return CURLE_OPERATION_TIMEDOUT;
}
- else if (event != TFTP_EVENT_NONE) {
+ else if(event != TFTP_EVENT_NONE) {
result = tftp_state_machine(state, event);
if(result != CURLE_OK)
return(result);
@@ -1463,7 +1463,7 @@ static CURLcode tftp_do(struct connectdata *conn, bool *done)
/* If tftp_perform() returned an error, use that for return code. If it
was OK, see if tftp_translate_code() has an error. */
- if (code == CURLE_OK)
+ if(code == CURLE_OK)
/* If we have encountered an internal tftp error, translate it. */
code = tftp_translate_code(state->error);
diff --git a/lib/transfer.c b/lib/transfer.c
index ee817568c..41f0de4ed 100644
--- a/lib/transfer.c
+++ b/lib/transfer.c
@@ -509,18 +509,18 @@ static CURLcode readwrite_data(struct SessionHandle *data,
"Rewinding stream by : %zd"
" bytes on url %s (zero-length body)\n",
nread, data->state.path);
- read_rewind(conn, (size_t)nread);
+ read_rewind(conn, (size_t)nread);
}
- else {
+ else {
infof(data,
"Excess found in a non pipelined read:"
" excess = %zd"
- " url = %s (zero-length body)\n",
+ " url = %s (zero-length body)\n",
nread, data->state.path);
- }
- }
+ }
+ }
- break;
+ break;
}
}
#endif /* CURL_DISABLE_HTTP */
@@ -629,7 +629,8 @@ static CURLcode readwrite_data(struct SessionHandle *data,
dataleft = conn->chunk.dataleft;
if(dataleft != 0) {
infof(conn->data, "Leftovers after chunking: %zu bytes", dataleft);
- if(conn->data->multi && Curl_multi_canPipeline(conn->data->multi)) {
+ if(conn->data->multi &&
+ Curl_multi_canPipeline(conn->data->multi)) {
/* only attempt the rewind if we truly are pipelining */
infof(conn->data, "Rewinding %zu bytes\n",dataleft);
read_rewind(conn, dataleft);
@@ -1235,19 +1236,19 @@ long Curl_sleep_time(curl_off_t rate_bps, curl_off_t cur_rate_bps,
curl_off_t min_sleep = 0;
curl_off_t rv = 0;
- if (rate_bps == 0)
+ if(rate_bps == 0)
return 0;
/* If running faster than about .1% of the desired speed, slow
* us down a bit. Use shift instead of division as the 0.1%
* cutoff is arbitrary anyway.
*/
- if (cur_rate_bps > (rate_bps + (rate_bps >> 10))) {
+ if(cur_rate_bps > (rate_bps + (rate_bps >> 10))) {
/* running too fast, decrease target rate by 1/64th of rate */
rate_bps -= rate_bps >> 6;
min_sleep = 1;
}
- else if (cur_rate_bps < (rate_bps - (rate_bps >> 10))) {
+ else if(cur_rate_bps < (rate_bps - (rate_bps >> 10))) {
/* running too slow, increase target rate by 1/64th of rate */
rate_bps += rate_bps >> 6;
}
@@ -1261,7 +1262,7 @@ long Curl_sleep_time(curl_off_t rate_bps, curl_off_t cur_rate_bps,
/* Catch rounding errors and always slow down at least 1ms if
* we are running too fast.
*/
- if (rv < min_sleep)
+ if(rv < min_sleep)
rv = min_sleep;
/* Bound value to fit in 'long' on 32-bit platform. That's
@@ -1329,14 +1330,14 @@ Transfer(struct connectdata *conn)
k->keepon &= ~KEEP_SEND_HOLD;
}
else {
- if (data->set.upload && data->set.max_send_speed &&
- (data->progress.ulspeed > data->set.max_send_speed) ) {
+ if(data->set.upload && data->set.max_send_speed &&
+ (data->progress.ulspeed > data->set.max_send_speed) ) {
/* calculate upload rate-limitation timeout. */
buffersize = (int)(data->set.buffer_size ?
data->set.buffer_size : BUFSIZE);
totmp = (int)Curl_sleep_time(data->set.max_send_speed,
data->progress.ulspeed, buffersize);
- if (totmp < timeout_ms)
+ if(totmp < timeout_ms)
timeout_ms = totmp;
}
fd_write = CURL_SOCKET_BAD;
@@ -1350,14 +1351,14 @@ Transfer(struct connectdata *conn)
k->keepon &= ~KEEP_RECV_HOLD;
}
else {
- if ((!data->set.upload) && data->set.max_recv_speed &&
- (data->progress.dlspeed > data->set.max_recv_speed)) {
+ if((!data->set.upload) && data->set.max_recv_speed &&
+ (data->progress.dlspeed > data->set.max_recv_speed)) {
/* Calculate download rate-limitation timeout. */
buffersize = (int)(data->set.buffer_size ?
data->set.buffer_size : BUFSIZE);
totmp = (int)Curl_sleep_time(data->set.max_recv_speed,
data->progress.dlspeed, buffersize);
- if (totmp < timeout_ms)
+ if(totmp < timeout_ms)
timeout_ms = totmp;
}
fd_read = CURL_SOCKET_BAD;
@@ -1393,7 +1394,7 @@ Transfer(struct connectdata *conn)
else if(!totmp)
totmp = 1000;
- if (totmp < timeout_ms)
+ if(totmp < timeout_ms)
timeout_ms = totmp;
}
@@ -1815,7 +1816,7 @@ CURLcode Curl_follow(struct SessionHandle *data,
free(data->change.referer);
data->change.referer = strdup(data->change.url);
- if (!data->change.referer) {
+ if(!data->change.referer) {
data->change.referer_alloc = FALSE;
return CURLE_OUT_OF_MEMORY;
}
@@ -1829,7 +1830,7 @@ CURLcode Curl_follow(struct SessionHandle *data,
to be absolute and this doesn't seem to be that!
*/
char *absolute = concat_url(data->change.url, newurl);
- if (!absolute)
+ if(!absolute)
return CURLE_OUT_OF_MEMORY;
free(newurl);
newurl = absolute;
@@ -1845,7 +1846,7 @@ CURLcode Curl_follow(struct SessionHandle *data,
size_t newlen = strlen_url(newurl);
newest = malloc(newlen+1); /* get memory for this */
- if (!newest)
+ if(!newest)
return CURLE_OUT_OF_MEMORY;
strcpy_url(newest, newurl); /* create a space-free URL */
@@ -2164,7 +2165,7 @@ static CURLcode Curl_do_perform(struct SessionHandle *data)
res = CURLE_OK;
follow = FOLLOW_RETRY;
}
- else if (res == CURLE_OK) {
+ else if(res == CURLE_OK) {
/*
* We must duplicate the new URL here as the connection data may
* be free()ed in the Curl_done() function. We prefer the newurl
@@ -2174,13 +2175,13 @@ static CURLcode Curl_do_perform(struct SessionHandle *data)
if(data->req.newurl) {
follow = FOLLOW_REDIR;
newurl = strdup(data->req.newurl);
- if (!newurl)
+ if(!newurl)
res = CURLE_OUT_OF_MEMORY;
}
else if(data->req.location) {
follow = FOLLOW_FAKE;
newurl = strdup(data->req.location);
- if (!newurl)
+ if(!newurl)
res = CURLE_OUT_OF_MEMORY;
}
}
diff --git a/lib/transfer.h b/lib/transfer.h
index f60937cbf..68a31c67e 100644
--- a/lib/transfer.h
+++ b/lib/transfer.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -36,7 +36,8 @@ typedef enum {
FOLLOW_LAST /* never used */
} followtype;
-CURLcode Curl_follow(struct SessionHandle *data, char *newurl, followtype type);
+CURLcode Curl_follow(struct SessionHandle *data, char *newurl,
+ followtype type);
CURLcode Curl_readwrite(struct connectdata *conn, bool *done);
diff --git a/lib/url.c b/lib/url.c
index 054b866ae..d8642e31b 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -331,7 +331,7 @@ static CURLcode setstropt_userpwd(char *option, char **user_storage,
}
separator = strchr(option, ':');
- if (separator != NULL) {
+ if(separator != NULL) {
/* store username part of option */
char * p;
@@ -347,9 +347,8 @@ static CURLcode setstropt_userpwd(char *option, char **user_storage,
}
/* store password part of option */
- if (result == CURLE_OK) {
+ if(result == CURLE_OK)
result = setstropt(pwd_storage, separator+1);
- }
}
else {
result = setstropt(user_storage, option);
@@ -411,7 +410,7 @@ CURLcode Curl_close(struct SessionHandle *data)
pipeline = connptr->send_pipe;
if(pipeline) {
- for (curr = pipeline->head; curr; curr=curr->next) {
+ for(curr = pipeline->head; curr; curr=curr->next) {
if(data == (struct SessionHandle *) curr->ptr) {
fprintf(stderr,
"problem we %p are still in send pipe for %p done %d\n",
@@ -421,7 +420,7 @@ CURLcode Curl_close(struct SessionHandle *data)
}
pipeline = connptr->recv_pipe;
if(pipeline) {
- for (curr = pipeline->head; curr; curr=curr->next) {
+ for(curr = pipeline->head; curr; curr=curr->next) {
if(data == (struct SessionHandle *) curr->ptr) {
fprintf(stderr,
"problem we %p are still in recv pipe for %p done %d\n",
@@ -431,7 +430,7 @@ CURLcode Curl_close(struct SessionHandle *data)
}
pipeline = connptr->done_pipe;
if(pipeline) {
- for (curr = pipeline->head; curr; curr=curr->next) {
+ for(curr = pipeline->head; curr; curr=curr->next) {
if(data == (struct SessionHandle *) curr->ptr) {
fprintf(stderr,
"problem we %p are still in done pipe for %p done %d\n",
@@ -441,7 +440,7 @@ CURLcode Curl_close(struct SessionHandle *data)
}
pipeline = connptr->pend_pipe;
if(pipeline) {
- for (curr = pipeline->head; curr; curr=curr->next) {
+ for(curr = pipeline->head; curr; curr=curr->next) {
if(data == (struct SessionHandle *) curr->ptr) {
fprintf(stderr,
"problem we %p are still in pend pipe for %p done %d\n",
@@ -736,7 +735,7 @@ CURLcode Curl_init_userdefined(struct UserDefined *set)
/* set default gssapi service name */
res = setstropt(&set->str[STRING_SOCKS5_GSSAPI_SERVICE],
(char *) CURL_DEFAULT_SOCKS5_GSSAPI_SERVICE);
- if (res != CURLE_OK)
+ if(res != CURLE_OK)
return res;
#endif
@@ -1408,7 +1407,8 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
auth &= ~CURLAUTH_NTLM; /* no NTLM without SSL */
#endif
#ifndef USE_HTTP_NEGOTIATE
- auth &= ~CURLAUTH_GSSNEGOTIATE; /* no GSS-Negotiate without GSSAPI or WINDOWS_SSPI */
+ auth &= ~CURLAUTH_GSSNEGOTIATE; /* no GSS-Negotiate without GSSAPI or
+ WINDOWS_SSPI */
#endif
if(!auth)
return CURLE_NOT_BUILT_IN; /* no supported types left! */
@@ -1468,7 +1468,8 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
auth &= ~CURLAUTH_NTLM; /* no NTLM without SSL */
#endif
#ifndef USE_HTTP_NEGOTIATE
- auth &= ~CURLAUTH_GSSNEGOTIATE; /* no GSS-Negotiate without GSSAPI or WINDOWS_SSPI */
+ auth &= ~CURLAUTH_GSSNEGOTIATE; /* no GSS-Negotiate without GSSAPI or
+ WINDOWS_SSPI */
#endif
if(!auth)
return CURLE_NOT_BUILT_IN; /* no supported types left! */
@@ -2483,17 +2484,17 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
case CURLOPT_TLSAUTH_USERNAME:
result = setstropt(&data->set.str[STRING_TLSAUTH_USERNAME],
va_arg(param, char *));
- if (data->set.str[STRING_TLSAUTH_USERNAME] && !data->set.ssl.authtype)
+ if(data->set.str[STRING_TLSAUTH_USERNAME] && !data->set.ssl.authtype)
data->set.ssl.authtype = CURL_TLSAUTH_SRP; /* default to SRP */
break;
case CURLOPT_TLSAUTH_PASSWORD:
result = setstropt(&data->set.str[STRING_TLSAUTH_PASSWORD],
va_arg(param, char *));
- if (data->set.str[STRING_TLSAUTH_USERNAME] && !data->set.ssl.authtype)
+ if(data->set.str[STRING_TLSAUTH_USERNAME] && !data->set.ssl.authtype)
data->set.ssl.authtype = CURL_TLSAUTH_SRP; /* default to SRP */
break;
case CURLOPT_TLSAUTH_TYPE:
- if (strncmp((char *)va_arg(param, char *), "SRP", strlen("SRP")) == 0)
+ if(strncmp((char *)va_arg(param, char *), "SRP", strlen("SRP")) == 0)
data->set.ssl.authtype = CURL_TLSAUTH_SRP;
else
data->set.ssl.authtype = CURL_TLSAUTH_NONE;
@@ -2590,19 +2591,19 @@ CURLcode Curl_disconnect(struct connectdata *conn, bool dead_connection)
related stuff. NTLM is connection-related so when we close the shop
we shall forget. */
- if (has_host_ntlm) {
+ if(has_host_ntlm) {
data->state.authhost.done = FALSE;
data->state.authhost.picked =
data->state.authhost.want;
}
- if (has_proxy_ntlm) {
+ if(has_proxy_ntlm) {
data->state.authproxy.done = FALSE;
data->state.authproxy.picked =
data->state.authproxy.want;
}
- if (has_host_ntlm || has_proxy_ntlm) {
+ if(has_host_ntlm || has_proxy_ntlm) {
data->state.authproblem = FALSE;
Curl_ntlm_cleanup(conn);
@@ -2789,8 +2790,8 @@ static void signalPipeClose(struct curl_llist *pipeline, bool pipe_broke)
}
#endif
- if (pipe_broke)
- data->state.pipe_broke = TRUE;
+ if(pipe_broke)
+ data->state.pipe_broke = TRUE;
Curl_multi_handlePipeBreak(data);
Curl_llist_remove(pipeline, curr, NULL);
curr = next;
@@ -3437,7 +3438,7 @@ static void fix_hostname(struct SessionHandle *data,
host->name = host->encalloc;
}
#else
- infof (data, "IDN support not present, can't parse Unicode (UTF-8) domains");
+ infof (data, "IDN support not present, can't parse Unicode domains");
#endif
}
}
@@ -3564,7 +3565,7 @@ static CURLcode findprotocol(struct SessionHandle *data,
/* Scan protocol handler table and match against 'protostr' to set a few
variables based on the URL. Now that the handler may be changed later
when the protocol specific setup function is called. */
- for (pp = protocols; (p = *pp) != NULL; pp++) {
+ for(pp = protocols; (p = *pp) != NULL; pp++) {
if(Curl_raw_equal(p->scheme, protostr)) {
/* Protocol found in table. Check if allowed */
if(!(data->set.allowed_protocols & p->protocol))
@@ -3692,7 +3693,7 @@ static CURLcode parseurlandfillconn(struct SessionHandle *data,
* assigned, but the return value is EOF!
*/
#if defined(__DJGPP__) && (DJGPP_MINOR == 4)
- if (!(rc == -1 && *conn->host.name))
+ if(!(rc == -1 && *conn->host.name))
#endif
{
failf(data, "<url> malformed");
@@ -3776,21 +3777,22 @@ static CURLcode parseurlandfillconn(struct SessionHandle *data,
path[0] = '/';
}
- if (conn->host.name[0] == '[') {
+ if(conn->host.name[0] == '[') {
/* This looks like an IPv6 address literal. See if there is an address
scope. */
char *percent = strstr (conn->host.name, "%25");
- if (percent) {
+ if(percent) {
char *endp;
unsigned long scope = strtoul (percent + 3, &endp, 10);
- if (*endp == ']') {
+ if(*endp == ']') {
/* The address scope was well formed. Knock it out of the
hostname. */
memmove(percent, endp, strlen(endp)+1);
- if (!data->state.this_is_a_follow)
+ if(!data->state.this_is_a_follow)
/* Don't honour a scope given in a Location: header */
conn->scope = (unsigned int)scope;
- } else
+ }
+ else
infof(data, "Invalid IPv6 address format\n");
}
}
@@ -3915,9 +3917,9 @@ static bool check_noproxy(const char* name, const char* no_proxy)
else
namelen = strlen(name);
- for (tok_start = 0; tok_start < no_proxy_len; tok_start = tok_end + 1) {
- while (tok_start < no_proxy_len &&
- strchr(separator, no_proxy[tok_start]) != NULL) {
+ for(tok_start = 0; tok_start < no_proxy_len; tok_start = tok_end + 1) {
+ while(tok_start < no_proxy_len &&
+ strchr(separator, no_proxy[tok_start]) != NULL) {
/* Look for the beginning of the token. */
++tok_start;
}
@@ -3925,10 +3927,10 @@ static bool check_noproxy(const char* name, const char* no_proxy)
if(tok_start == no_proxy_len)
break; /* It was all trailing separator chars, no more tokens. */
- for (tok_end = tok_start; tok_end < no_proxy_len &&
- strchr(separator, no_proxy[tok_end]) == NULL; ++tok_end) {
+ for(tok_end = tok_start; tok_end < no_proxy_len &&
+ strchr(separator, no_proxy[tok_end]) == NULL; ++tok_end)
/* Look for the end of the token. */
- }
+ ;
/* To match previous behaviour, where it was necessary to specify
* ".local.com" to prevent matching "notlocal.com", we will leave
@@ -3950,7 +3952,7 @@ static bool check_noproxy(const char* name, const char* no_proxy)
}
}
} /* if((tok_end - tok_start) <= namelen) */
- } /* for (tok_start = 0; tok_start < no_proxy_len;
+ } /* for(tok_start = 0; tok_start < no_proxy_len;
tok_start = tok_end + 1) */
} /* NO_PROXY was specified and it wasn't just an asterisk */
@@ -4133,10 +4135,10 @@ static CURLcode parse_proxy(struct SessionHandle *data,
while(*ptr && (ISXDIGIT(*ptr) || (*ptr == ':') || (*ptr == '%') ||
(*ptr == '.')))
ptr++;
- if(*ptr == ']') {
+ if(*ptr == ']')
/* yeps, it ended nicely with a bracket as well */
*ptr++ = 0;
- } else
+ else
infof(data, "Invalid IPv6 address format\n");
portptr = ptr;
/* Note that if this didn't end with a bracket, we still advanced the
@@ -4508,7 +4510,7 @@ static CURLcode resolve_server(struct SessionHandle *data,
if(rc == CURLRESOLV_PENDING)
*async = TRUE;
- else if (rc == CURLRESOLV_TIMEDOUT)
+ else if(rc == CURLRESOLV_TIMEDOUT)
result = CURLE_OPERATION_TIMEDOUT;
else if(!hostaddr) {
@@ -4530,7 +4532,7 @@ static CURLcode resolve_server(struct SessionHandle *data,
if(rc == CURLRESOLV_PENDING)
*async = TRUE;
- else if (rc == CURLRESOLV_TIMEDOUT)
+ else if(rc == CURLRESOLV_TIMEDOUT)
result = CURLE_OPERATION_TIMEDOUT;
else if(!hostaddr) {
@@ -4698,9 +4700,8 @@ static CURLcode create_conn(struct SessionHandle *data,
conn->host.name[0] = 0;
result = parseurlandfillconn(data, conn, &prot_missing);
- if(result != CURLE_OK) {
- return result;
- }
+ if(result != CURLE_OK)
+ return result;
/*************************************************************
* No protocol part in URL was used, add it!
@@ -5094,7 +5095,7 @@ CURLcode Curl_connect(struct SessionHandle *data,
if((*in_connect)->send_pipe->size || (*in_connect)->recv_pipe->size)
/* pipelining */
*protocol_done = TRUE;
- else if (!*asyncp) {
+ else if(!*asyncp) {
/* DNS resolution is done: that's either because this is a reused
connection, in which case DNS was unnecessary, or because DNS
really did finish already (synch resolver/fast async resolve) */
@@ -5191,7 +5192,7 @@ CURLcode Curl_done(struct connectdata **connp,
*/
if(data->set.reuse_forbid || conn->bits.close || premature ||
(-1 == conn->connectindex)) {
- CURLcode res2 = Curl_disconnect(conn, premature); /* close the connection */
+ CURLcode res2 = Curl_disconnect(conn, premature); /* close connection */
/* If we had an error already, make sure we return that one. But
if we got a new error, return that. */
@@ -5296,23 +5297,23 @@ CURLcode Curl_do(struct connectdata **connp, bool *done)
/* This was formerly done in transfer.c, but we better do it here */
if((CURLE_SEND_ERROR == result) && conn->bits.reuse) {
- /*
- * If the connection is using an easy handle, call reconnect
- * to re-establish the connection. Otherwise, let the multi logic
- * figure out how to re-establish the connection.
- */
- if(!data->multi) {
- result = Curl_reconnect_request(connp);
-
- if(result == CURLE_OK) {
- /* ... finally back to actually retry the DO phase */
- conn = *connp; /* re-assign conn since Curl_reconnect_request
- creates a new connection */
- result = conn->handler->do_it(conn, done);
- }
+ /*
+ * If the connection is using an easy handle, call reconnect
+ * to re-establish the connection. Otherwise, let the multi logic
+ * figure out how to re-establish the connection.
+ */
+ if(!data->multi) {
+ result = Curl_reconnect_request(connp);
+
+ if(result == CURLE_OK) {
+ /* ... finally back to actually retry the DO phase */
+ conn = *connp; /* re-assign conn since Curl_reconnect_request
+ creates a new connection */
+ result = conn->handler->do_it(conn, done);
}
- else
- return result;
+ }
+ else
+ return result;
}
if((result == CURLE_OK) && *done)
diff --git a/lib/url.h b/lib/url.h
index bf5d2042f..8a5434cef 100644
--- a/lib/url.h
+++ b/lib/url.h
@@ -82,7 +82,8 @@ void Curl_close_connections(struct SessionHandle *data);
void Curl_reset_reqproto(struct connectdata *conn);
#define CURL_DEFAULT_PROXY_PORT 1080 /* default proxy port unless specified */
-#define CURL_DEFAULT_SOCKS5_GSSAPI_SERVICE "rcmd" /* default socks5 gssapi service */
+#define CURL_DEFAULT_SOCKS5_GSSAPI_SERVICE "rcmd" /* default socks5 gssapi
+ service */
CURLcode Curl_connected_proxy(struct connectdata *conn);
diff --git a/lib/urldata.h b/lib/urldata.h
index 01f4ffddf..3067df4f9 100644
--- a/lib/urldata.h
+++ b/lib/urldata.h
@@ -1358,7 +1358,8 @@ struct UserDefined {
curl_sockopt_callback fsockopt; /* function for setting socket options */
void *sockopt_client; /* pointer to pass to the socket options callback */
curl_opensocket_callback fopensocket; /* function for checking/translating
- the address and opening the socket */
+ the address and opening the
+ socket */
void* opensocket_client;
void *seek_client; /* pointer to pass to the seek callback */
@@ -1380,7 +1381,8 @@ struct UserDefined {
long low_speed_limit; /* bytes/second */
long low_speed_time; /* number of seconds */
curl_off_t max_send_speed; /* high speed limit in bytes/second for upload */
- curl_off_t max_recv_speed; /* high speed limit in bytes/second for download */
+ curl_off_t max_recv_speed; /* high speed limit in bytes/second for
+ download */
curl_off_t set_resume_from; /* continue [ftp] transfer from here */
struct curl_slist *headers; /* linked list of extra headers */
struct curl_httppost *httppost; /* linked list of POST data */
@@ -1494,7 +1496,8 @@ struct UserDefined {
Curl_RtspReq rtspreq; /* RTSP request type */
long rtspversion; /* like httpversion, for RTSP */
bool wildcardmatch; /* enable wildcard matching */
- curl_chunk_bgn_callback chunk_bgn; /* called before part of transfer starts */
+ curl_chunk_bgn_callback chunk_bgn; /* called before part of transfer
+ starts */
curl_chunk_end_callback chunk_end; /* called after part transferring
stopped */
curl_fnmatch_callback fnmatch; /* callback to decide which file corresponds
diff --git a/lib/version.c b/lib/version.c
index 7c19c9c80..7d13c3453 100644
--- a/lib/version.c
+++ b/lib/version.c
@@ -123,12 +123,13 @@ char *curl_version(void)
#ifdef USE_LIBRTMP
{
char suff[2];
- if (RTMP_LIB_VERSION & 0xff) {
+ if(RTMP_LIB_VERSION & 0xff) {
suff[0] = (RTMP_LIB_VERSION & 0xff) + 'a' - 1;
suff[1] = '\0';
- } else {
- suff[0] = '\0';
}
+ else
+ suff[0] = '\0';
+
len = snprintf(ptr, left, " librtmp/%d.%d%s",
RTMP_LIB_VERSION >> 16, (RTMP_LIB_VERSION >> 8) & 0xff, suff);
/*