checksrc: whitespace and code style cleanup

Make everything adhere to the standards upheld by checksrc.pl and now
run checksrc from the makefile on debug builds.
This commit is contained in:
Daniel Stenberg 2011-04-25 22:44:39 +02:00
parent 6a6981503e
commit aa87f0ab15
11 changed files with 148 additions and 122 deletions

View File

@ -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 # This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms # you should have received as part of this distribution. The terms
@ -95,3 +95,11 @@ $(HUGE):
echo '#include "hugehelp.h"' >> $(HUGE) echo '#include "hugehelp.h"' >> $(HUGE)
echo "void hugehelp(void) {}" >>$(HUGE) echo "void hugehelp(void) {}" >>$(HUGE)
endif endif
if CURLDEBUG
# for debug builds, we scan the sources on all regular make invokes
# ignore hugehelp.c since it is generated source code and it plays by slightly
# different rules!
all-local:
@@PERL@ $(top_srcdir)/lib/checksrc.pl -D$(top_srcdir)/src -Whugehelp.c $(curl_SOURCES)
endif

View File

@ -1,4 +1,3 @@
/* curl_config.h.in. Generated automatically from configure.in by autoheader. */
/*************************************************************************** /***************************************************************************
* _ _ ____ _ * _ _ ____ _
* Project ___| | | | _ \| | * Project ___| | | | _ \| |

View File

@ -323,7 +323,8 @@
2000 as a supported build target. VS2008 default installations provide an 2000 as a supported build target. VS2008 default installations provide an
embedded Windows SDK v6.0A along with the claim that Windows 2000 is a embedded Windows SDK v6.0A along with the claim that Windows 2000 is a
valid build target for VS2008. Popular belief is that binaries built using valid build target for VS2008. Popular belief is that binaries built using
Windows SDK versions 6.X and Windows 2000 as a build target are functional */ Windows SDK versions 6.X and Windows 2000 as a build target are
functional */
#if defined(_MSC_VER) && (_MSC_VER >= 1500) #if defined(_MSC_VER) && (_MSC_VER >= 1500)
# define VS2008_MINIMUM_TARGET 0x0500 # define VS2008_MINIMUM_TARGET 0x0500
#endif #endif
@ -344,7 +345,8 @@
# ifndef WINVER # ifndef WINVER
# define WINVER VS2008_DEFAULT_TARGET # define WINVER VS2008_DEFAULT_TARGET
# endif # endif
# if (_WIN32_WINNT < VS2008_MINIMUM_TARGET) || (WINVER < VS2008_MINIMUM_TARGET) # if (_WIN32_WINNT < VS2008_MINIMUM_TARGET) || \
(WINVER < VS2008_MINIMUM_TARGET)
# error VS2008 does not support Windows build targets prior to Windows 2000 # error VS2008 does not support Windows build targets prior to Windows 2000
# endif # endif
#endif #endif

View File

@ -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 * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -78,7 +78,7 @@ char *getpass_r(const char *prompt, char *buffer, size_t buflen)
buffer[0]='\0'; buffer[0]='\0';
sts = sys$assign(&ttdesc, &chan,0,0); sts = sys$assign(&ttdesc, &chan,0,0);
if (sts & 1) { if(sts & 1) {
sts = sys$qiow(0, chan, sts = sys$qiow(0, chan,
IO$_READPROMPT | IO$M_NOECHO, IO$_READPROMPT | IO$M_NOECHO,
&iosb, 0, 0, buffer, buflen, 0, 0, &iosb, 0, 0, buffer, buflen, 0, 0,
@ -113,12 +113,12 @@ char *getpass_r(const char *prompt, char *buffer, size_t buflen)
for(i=0; i<buflen; i++) { for(i=0; i<buflen; i++) {
buffer[i] = (char)getch(); buffer[i] = (char)getch();
if ( buffer[i] == '\r' || buffer[i] == '\n' ) { if(buffer[i] == '\r' || buffer[i] == '\n') {
buffer[i] = 0; buffer[i] = 0;
break; break;
} }
else else
if ( buffer[i] == '\b') if(buffer[i] == '\b')
/* remove this letter and if this is not the first key, remove the /* remove this letter and if this is not the first key, remove the
previous one as well */ previous one as well */
i = i - (i>=1?2:1); i = i - (i>=1?2:1);
@ -128,7 +128,7 @@ char *getpass_r(const char *prompt, char *buffer, size_t buflen)
fputs("\n", stderr); fputs("\n", stderr);
#endif #endif
/* if user didn't hit ENTER, terminate buffer */ /* if user didn't hit ENTER, terminate buffer */
if (i==buflen) if(i==buflen)
buffer[buflen-1]=0; buffer[buflen-1]=0;
return buffer; /* we always return success */ return buffer; /* we always return success */
@ -153,20 +153,22 @@ char *getpass_r(const char *prompt, char *buffer, size_t buflen)
printf("%s", prompt); printf("%s", prompt);
do { do {
buffer[i++] = getch(); buffer[i++] = getch();
if (buffer[i-1] == '\b') { if(buffer[i-1] == '\b') {
/* remove this letter and if this is not the first key, /* remove this letter and if this is not the first key,
remove the previous one as well */ remove the previous one as well */
if (i > 1) { if(i > 1) {
printf("\b \b"); printf("\b \b");
i = i - 2; i = i - 2;
} else { }
else {
RingTheBell(); RingTheBell();
i = i - 1; i = i - 1;
} }
} else if (buffer[i-1] != 13) {
putchar('*');
} }
} while ((buffer[i-1] != 13) && (i < buflen)); else if(buffer[i-1] != 13)
putchar('*');
} while((buffer[i-1] != 13) && (i < buflen));
buffer[i-1] = 0; buffer[i-1] = 0;
printf("\r\n"); printf("\r\n");
return buffer; return buffer;
@ -194,8 +196,8 @@ static bool ttyecho(bool enable, int fd)
static struct_term noecho; static struct_term noecho;
#endif #endif
if(!enable) { if(!enable) {
/* disable echo by extracting the current 'withecho' mode and remove the /* disable echo by extracting the current 'withecho' mode and remove the
ECHO bit and set back the struct */ ECHO bit and set back the struct */
#ifdef HAVE_TERMIOS_H #ifdef HAVE_TERMIOS_H
tcgetattr(fd, &withecho); tcgetattr(fd, &withecho);
noecho = withecho; noecho = withecho;

View File

@ -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 * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -54,23 +54,23 @@ char *GetEnv(const char *variable, char do_expand)
* started. Don't accept truncated results (i.e. rc >= sizeof(buf1)). */ * started. Don't accept truncated results (i.e. rc >= sizeof(buf1)). */
rc = GetEnvironmentVariable(variable, buf1, sizeof(buf1)); rc = GetEnvironmentVariable(variable, buf1, sizeof(buf1));
if (rc > 0 && rc < sizeof(buf1)) { if(rc > 0 && rc < sizeof(buf1)) {
env = buf1; env = buf1;
variable = buf1; variable = buf1;
} }
if (do_expand && strchr(variable,'%')) { if(do_expand && strchr(variable,'%')) {
/* buf2 == variable if not expanded */ /* buf2 == variable if not expanded */
rc = ExpandEnvironmentStrings (variable, buf2, sizeof(buf2)); rc = ExpandEnvironmentStrings (variable, buf2, sizeof(buf2));
if (rc > 0 && rc < sizeof(buf2) && if(rc > 0 && rc < sizeof(buf2) &&
!strchr(buf2,'%')) /* no vars still unexpanded */ !strchr(buf2,'%')) /* no vars still unexpanded */
env = buf2; env = buf2;
} }
#else #else
(void)do_expand; (void)do_expand;
#ifdef __VMS #ifdef __VMS
env = getenv(variable); env = getenv(variable);
if (env && strcmp("HOME",variable) == 0) { if(env && strcmp("HOME",variable) == 0) {
env = decc_translate_vms(env); env = decc_translate_vms(env);
} }
#else #else
/* no length control */ /* no length control */
@ -97,13 +97,13 @@ char *homedir(void)
{ {
struct passwd *pw = getpwuid(geteuid()); struct passwd *pw = getpwuid(geteuid());
if (pw) { if(pw) {
#ifdef __VMS #ifdef __VMS
home = decc_translate_vms(pw->pw_dir); home = decc_translate_vms(pw->pw_dir);
#else #else
home = pw->pw_dir; home = pw->pw_dir;
#endif #endif
if (home && home[0]) if(home && home[0])
home = strdup(home); home = strdup(home);
else else
home = NULL; home = NULL;

View File

@ -303,6 +303,22 @@ typedef enum {
# endif # endif
#endif #endif
#define CURL_CA_CERT_ERRORMSG1 \
"More details here: http://curl.haxx.se/docs/sslcerts.html\n\n" \
"curl performs SSL certificate verification by default, " \
"using a \"bundle\"\n" \
" of Certificate Authority (CA) public keys (CA certs). If the default\n" \
" bundle file isn't adequate, you can specify an alternate file\n" \
" using the --cacert option.\n"
#define CURL_CA_CERT_ERRORMSG2 \
"If this HTTPS server uses a certificate signed by a CA represented in\n" \
" the bundle, the certificate verification probably failed due to a\n" \
" problem with the certificate (it might be expired, or the name might\n" \
" not match the domain name in the URL).\n" \
"If you'd like to turn off curl's verification of the certificate, use\n" \
" the -k (or --insecure) option.\n"
#ifdef CURL_DOES_CONVERSIONS #ifdef CURL_DOES_CONVERSIONS
#ifdef HAVE_ICONV #ifdef HAVE_ICONV
iconv_t inbound_cd = (iconv_t)-1; iconv_t inbound_cd = (iconv_t)-1;
@ -778,7 +794,7 @@ static void help(void)
" -K/--config <file> Specify which config file to read", " -K/--config <file> Specify which config file to read",
" --connect-timeout <seconds> Maximum time allowed for connection", " --connect-timeout <seconds> Maximum time allowed for connection",
" -C/--continue-at <offset> Resumed transfer offset", " -C/--continue-at <offset> Resumed transfer offset",
" -b/--cookie <name=string/file> Cookie string or file to read cookies from (H)", " -b/--cookie <name=string/file> String or file to read cookies from (H)",
" -c/--cookie-jar <file> Write cookies to this file after operation (H)", " -c/--cookie-jar <file> Write cookies to this file after operation (H)",
" --create-dirs Create necessary local directory hierarchy", " --create-dirs Create necessary local directory hierarchy",
" --crlf Convert LF to CRLF in upload", " --crlf Convert LF to CRLF in upload",
@ -786,21 +802,23 @@ static void help(void)
" -d/--data <data> HTTP POST data (H)", " -d/--data <data> HTTP POST data (H)",
" --data-ascii <data> HTTP POST ASCII data (H)", " --data-ascii <data> HTTP POST ASCII data (H)",
" --data-binary <data> HTTP POST binary data (H)", " --data-binary <data> HTTP POST binary data (H)",
" --data-urlencode <name=data/name@filename> HTTP POST data url encoded (H)", " --data-urlencode <name=data/name@filename> "
"HTTP POST data url encoded (H)",
" --digest Use HTTP Digest Authentication (H)", " --digest Use HTTP Digest Authentication (H)",
" --disable-eprt Inhibit using EPRT or LPRT (F)", " --disable-eprt Inhibit using EPRT or LPRT (F)",
" --disable-epsv Inhibit using EPSV (F)", " --disable-epsv Inhibit using EPSV (F)",
" -D/--dump-header <file> Write the headers to this file", " -D/--dump-header <file> Write the headers to this file",
" --egd-file <file> EGD socket path for random data (SSL)", " --egd-file <file> EGD socket path for random data (SSL)",
" --engine <eng> Crypto engine to use (SSL). \"--engine list\" for list", " --engine <eng> Crypto engine (SSL). \"--engine list\" for list",
#ifdef USE_ENVIRONMENT #ifdef USE_ENVIRONMENT
" --environment Write results to environment variables (RISC OS)", " --environment Write results to environment variables (RISC OS)",
#endif #endif
" -f/--fail Fail silently (no output at all) on HTTP errors (H)", " -f/--fail Fail silently (no output at all) on HTTP errors (H)",
" -F/--form <name=content> Specify HTTP multipart POST data (H)", " -F/--form <name=content> Specify HTTP multipart POST data (H)",
" --form-string <name=string> Specify HTTP multipart POST data (H)", " --form-string <name=string> Specify HTTP multipart POST data (H)",
" --ftp-account <data> Account data to send when requested by server (F)", " --ftp-account <data> Account data string (F)",
" --ftp-alternative-to-user <cmd> String to replace \"USER [name]\" (F)", " --ftp-alternative-to-user <cmd> "
"String to replace \"USER [name]\" (F)",
" --ftp-create-dirs Create the remote dirs if not present (F)", " --ftp-create-dirs Create the remote dirs if not present (F)",
" --ftp-method [multicwd/nocwd/singlecwd] Control CWD usage (F)", " --ftp-method [multicwd/nocwd/singlecwd] Control CWD usage (F)",
" --ftp-pasv Use PASV/EPSV instead of PORT (F)", " --ftp-pasv Use PASV/EPSV instead of PORT (F)",
@ -809,13 +827,15 @@ static void help(void)
" --ftp-pret Send PRET before PASV (for drftpd) (F)", " --ftp-pret Send PRET before PASV (for drftpd) (F)",
" --ftp-ssl-ccc Send CCC after authenticating (F)", " --ftp-ssl-ccc Send CCC after authenticating (F)",
" --ftp-ssl-ccc-mode [active/passive] Set CCC mode (F)", " --ftp-ssl-ccc-mode [active/passive] Set CCC mode (F)",
" --ftp-ssl-control Require SSL/TLS for ftp login, clear for transfer (F)", " --ftp-ssl-control Require SSL/TLS for ftp login, "
"clear for transfer (F)",
" -G/--get Send the -d data with a HTTP GET (H)", " -G/--get Send the -d data with a HTTP GET (H)",
" -g/--globoff Disable URL sequences and ranges using {} and []", " -g/--globoff Disable URL sequences and ranges using {} and []",
" -H/--header <line> Custom header to pass to server (H)", " -H/--header <line> Custom header to pass to server (H)",
" -I/--head Show document info only", " -I/--head Show document info only",
" -h/--help This help text", " -h/--help This help text",
" --hostpubmd5 <md5> Hex encoded MD5 string of the host public key. (SSH)", " --hostpubmd5 <md5> "
"Hex encoded MD5 string of the host public key. (SSH)",
" -0/--http1.0 Use HTTP 1.0 (H)", " -0/--http1.0 Use HTTP 1.0 (H)",
" --ignore-content-length Ignore the HTTP Content-Length header", " --ignore-content-length Ignore the HTTP Content-Length header",
" -i/--include Include protocol headers in the output (H/F)", " -i/--include Include protocol headers in the output (H/F)",
@ -852,11 +872,14 @@ static void help(void)
" --ntlm Use HTTP NTLM authentication (H)", " --ntlm Use HTTP NTLM authentication (H)",
" -o/--output <file> Write output to <file> instead of stdout", " -o/--output <file> Write output to <file> instead of stdout",
" --pass <pass> Pass phrase for the private key (SSL/SSH)", " --pass <pass> Pass phrase for the private key (SSL/SSH)",
" --post301 Do not switch to GET after following a 301 redirect (H)", " --post301 "
" --post302 Do not switch to GET after following a 302 redirect (H)", "Do not switch to GET after following a 301 redirect (H)",
" --post302 "
"Do not switch to GET after following a 302 redirect (H)",
" -#/--progress-bar Display transfer progress as a progress bar", " -#/--progress-bar Display transfer progress as a progress bar",
" --proto <protocols> Enable/disable specified protocols", " --proto <protocols> Enable/disable specified protocols",
" --proto-redir <protocols> Enable/disable specified protocols on redirect", " --proto-redir <protocols> "
"Enable/disable specified protocols on redirect",
" -x/--proxy <host[:port]> Use HTTP proxy on given port", " -x/--proxy <host[:port]> Use HTTP proxy on given port",
" --proxy-anyauth Pick \"any\" proxy authentication method (H)", " --proxy-anyauth Pick \"any\" proxy authentication method (H)",
" --proxy-basic Use Basic authentication on the proxy (H)", " --proxy-basic Use Basic authentication on the proxy (H)",
@ -867,7 +890,7 @@ static void help(void)
" --proxy1.0 <host[:port]> Use HTTP/1.0 proxy on given port", " --proxy1.0 <host[:port]> Use HTTP/1.0 proxy on given port",
" -p/--proxytunnel Operate through a HTTP proxy tunnel (using CONNECT)", " -p/--proxytunnel Operate through a HTTP proxy tunnel (using CONNECT)",
" --pubkey <key> Public key file name (SSH)", " --pubkey <key> Public key file name (SSH)",
" -Q/--quote <cmd> Send command(s) to server before file transfer (F/SFTP)", " -Q/--quote <cmd> Send command(s) to server before transfer (F/SFTP)",
" --random-file <file> File for reading random data from (SSL)", " --random-file <file> File for reading random data from (SSL)",
" -r/--range <range> Retrieve only the bytes within a range", " -r/--range <range> Retrieve only the bytes within a range",
" --raw Pass HTTP \"raw\", without any transfer decoding (H)", " --raw Pass HTTP \"raw\", without any transfer decoding (H)",
@ -877,21 +900,27 @@ static void help(void)
" -R/--remote-time Set the remote file's time on the local output", " -R/--remote-time Set the remote file's time on the local output",
" -X/--request <command> Specify request command to use", " -X/--request <command> Specify request command to use",
" --resolve <host:port:address> Force resolve of HOST:PORT to ADDRESS", " --resolve <host:port:address> Force resolve of HOST:PORT to ADDRESS",
" --retry <num> Retry request <num> times if transient problems occur", " --retry <num> "
" --retry-delay <seconds> When retrying, wait this many seconds between each", "Retry request <num> times if transient problems occur",
" --retry-delay <seconds> "
"When retrying, wait this many seconds between each",
" --retry-max-time <seconds> Retry only within this period", " --retry-max-time <seconds> Retry only within this period",
" -S/--show-error Show error. With -s, make curl show errors when they occur", " -S/--show-error "
"Show error. With -s, make curl show errors when they occur",
" -s/--silent Silent mode. Don't output anything", " -s/--silent Silent mode. Don't output anything",
" --socks4 <host[:port]> SOCKS4 proxy on given host + port", " --socks4 <host[:port]> SOCKS4 proxy on given host + port",
" --socks4a <host[:port]> SOCKS4a proxy on given host + port", " --socks4a <host[:port]> SOCKS4a proxy on given host + port",
" --socks5 <host[:port]> SOCKS5 proxy on given host + port", " --socks5 <host[:port]> SOCKS5 proxy on given host + port",
" --socks5-hostname <host[:port]> SOCKS5 proxy, pass host name to proxy", " --socks5-hostname <host[:port]> "
"SOCKS5 proxy, pass host name to proxy",
#if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI) #if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
" --socks5-gssapi-service <name> SOCKS5 proxy service name for gssapi", " --socks5-gssapi-service <name> SOCKS5 proxy service name for gssapi",
" --socks5-gssapi-nec Compatibility with NEC SOCKS5 server", " --socks5-gssapi-nec Compatibility with NEC SOCKS5 server",
#endif #endif
" -Y/--speed-limit Stop transfer if below speed-limit for 'speed-time' secs", " -Y/--speed-limit "
" -y/--speed-time Time needed to trig speed-limit abort. Defaults to 30", "Stop transfer if below speed-limit for 'speed-time' secs",
" -y/--speed-time "
"Time needed to trig speed-limit abort. Defaults to 30",
" --ssl Try SSL/TLS (FTP, IMAP, POP3, SMTP)", " --ssl Try SSL/TLS (FTP, IMAP, POP3, SMTP)",
" --ssl-reqd Require SSL/TLS (FTP, IMAP, POP3, SMTP)", " --ssl-reqd Require SSL/TLS (FTP, IMAP, POP3, SMTP)",
" -2/--sslv2 Use SSLv2 (SSL)", " -2/--sslv2 Use SSLv2 (SSL)",
@ -1092,7 +1121,7 @@ static void list_engines(const struct curl_slist *engines)
puts(" <none>"); puts(" <none>");
return; return;
} }
for( ; engines; engines = engines->next) for(; engines; engines = engines->next)
printf(" %s\n", engines->data); printf(" %s\n", engines->data);
} }
@ -1294,15 +1323,13 @@ static int formparse(struct Configurable *config,
++count; ++count;
} }
forms = malloc((count+1)*sizeof(struct curl_forms)); forms = malloc((count+1)*sizeof(struct curl_forms));
if(!forms) if(!forms) {
{
fprintf(config->errors, "Error building form post!\n"); fprintf(config->errors, "Error building form post!\n");
free(contents); free(contents);
FreeMultiInfo(multi_start); FreeMultiInfo(multi_start);
return 4; return 4;
} }
for(i = 0, ptr = multi_start; i < count; ++i, ptr = ptr->next) for(i = 0, ptr = multi_start; i < count; ++i, ptr = ptr->next) {
{
forms[i].option = ptr->form.option; forms[i].option = ptr->form.option;
forms[i].value = ptr->form.value; forms[i].value = ptr->form.value;
} }
@ -1335,7 +1362,7 @@ static int formparse(struct Configurable *config,
ct[0]=0; /* zero terminate here */ ct[0]=0; /* zero terminate here */
} }
if( contp[0]=='<' && !literal_value) { if(contp[0]=='<' && !literal_value) {
info[i].option = CURLFORM_FILECONTENT; info[i].option = CURLFORM_FILECONTENT;
info[i].value = contp+1; info[i].value = contp+1;
i++; i++;
@ -2782,7 +2809,7 @@ static ParameterError getparameter(char *flag, /* f or -long-flag */
case 'm': /* TLS authentication type */ case 'm': /* TLS authentication type */
if(curlinfo->features & CURL_VERSION_TLSAUTH_SRP) { if(curlinfo->features & CURL_VERSION_TLSAUTH_SRP) {
GetStr(&config->tls_authtype, nextarg); GetStr(&config->tls_authtype, nextarg);
if (!strequal(config->tls_authtype, "SRP")) if(!strequal(config->tls_authtype, "SRP"))
return PARAM_LIBCURL_DOESNT_SUPPORT; /* only support TLS-SRP */ return PARAM_LIBCURL_DOESNT_SUPPORT; /* only support TLS-SRP */
} }
else else
@ -3495,8 +3522,7 @@ static int parseconfig(const char *filename,
} }
} }
if(alloced_param) if(alloced_param) {
{
free(param); free(param);
param = NULL; param = NULL;
} }
@ -3714,7 +3740,7 @@ static int myprogress (void *clientp,
if(total < 1) { if(total < 1) {
curl_off_t prevblock = bar->prev / 1024; curl_off_t prevblock = bar->prev / 1024;
curl_off_t thisblock = point / 1024; curl_off_t thisblock = point / 1024;
while( thisblock > prevblock ) { while(thisblock > prevblock) {
fprintf( bar->out, "#" ); fprintf( bar->out, "#" );
prevblock++; prevblock++;
} }
@ -3724,9 +3750,8 @@ static int myprogress (void *clientp,
percent = frac * 100.0f; percent = frac * 100.0f;
barwidth = bar->width - 7; barwidth = bar->width - 7;
num = (int) (((double)barwidth) * frac); num = (int) (((double)barwidth) * frac);
for( i = 0; i < num; i++ ) { for(i = 0; i < num; i++)
line[i] = '#'; line[i] = '#';
}
line[i] = '\0'; line[i] = '\0';
snprintf( format, sizeof(format), "%%-%ds %%5.1f%%%%", barwidth ); snprintf( format, sizeof(format), "%%-%ds %%5.1f%%%%", barwidth );
snprintf( outline, sizeof(outline), format, line, percent ); snprintf( outline, sizeof(outline), format, line, percent );
@ -4448,9 +4473,9 @@ parse_filename(char *ptr, size_t len)
is that even systems that don't handle backslashes as path separators is that even systems that don't handle backslashes as path separators
probably want the path removed for convenience. */ probably want the path removed for convenience. */
q = strrchr(p, '\\'); q = strrchr(p, '\\');
if (q) { if(q) {
p = q+1; p = q+1;
if (!*p) { if(!*p) {
free(copy); free(copy);
return NULL; return NULL;
} }
@ -5692,21 +5717,6 @@ operate(struct Configurable *config, int argc, argv_item_t argv[])
errorbuffer[0]? errorbuffer: errorbuffer[0]? errorbuffer:
curl_easy_strerror((CURLcode)res)); curl_easy_strerror((CURLcode)res));
if(CURLE_SSL_CACERT == res) { if(CURLE_SSL_CACERT == res) {
#define CURL_CA_CERT_ERRORMSG1 \
"More details here: http://curl.haxx.se/docs/sslcerts.html\n\n" \
"curl performs SSL certificate verification by default, using a \"bundle\"\n" \
" of Certificate Authority (CA) public keys (CA certs). If the default\n" \
" bundle file isn't adequate, you can specify an alternate file\n" \
" using the --cacert option.\n"
#define CURL_CA_CERT_ERRORMSG2 \
"If this HTTPS server uses a certificate signed by a CA represented in\n" \
" the bundle, the certificate verification probably failed due to a\n" \
" problem with the certificate (it might be expired, or the name might\n" \
" not match the domain name in the URL).\n" \
"If you'd like to turn off curl's verification of the certificate, use\n" \
" the -k (or --insecure) option.\n"
fprintf(config->errors, "%s%s", fprintf(config->errors, "%s%s",
CURL_CA_CERT_ERRORMSG1, CURL_CA_CERT_ERRORMSG1,
CURL_CA_CERT_ERRORMSG2 ); CURL_CA_CERT_ERRORMSG2 );
@ -5749,7 +5759,7 @@ operate(struct Configurable *config, int argc, argv_item_t argv[])
#ifdef __AMIGA__ #ifdef __AMIGA__
/* Set the url as comment for the file. (up to 80 chars are allowed) /* Set the url as comment for the file. (up to 80 chars are allowed)
*/ */
if( strlen(url) > 78 ) if(strlen(url) > 78)
url[79] = '\0'; url[79] = '\0';
SetComment( outs.filename, url); SetComment( outs.filename, url);
@ -5845,12 +5855,12 @@ static void checkfds(void)
{ {
#ifdef HAVE_PIPE #ifdef HAVE_PIPE
int fd[2] = { STDIN_FILENO, STDIN_FILENO }; int fd[2] = { STDIN_FILENO, STDIN_FILENO };
while( fd[0] == STDIN_FILENO || while(fd[0] == STDIN_FILENO ||
fd[0] == STDOUT_FILENO || fd[0] == STDOUT_FILENO ||
fd[0] == STDERR_FILENO || fd[0] == STDERR_FILENO ||
fd[1] == STDIN_FILENO || fd[1] == STDIN_FILENO ||
fd[1] == STDOUT_FILENO || fd[1] == STDOUT_FILENO ||
fd[1] == STDERR_FILENO ) fd[1] == STDERR_FILENO)
if(pipe(fd) < 0) if(pipe(fd) < 0)
return; /* Out of handles. This isn't really a big problem now, but return; /* Out of handles. This isn't really a big problem now, but
will be when we try to create a socket later. */ will be when we try to create a socket later. */

View File

@ -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 * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -28,7 +28,8 @@
* Define WIN32 when build target is Win32 API * 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 #define WIN32
#endif #endif

View File

@ -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 * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -74,7 +74,7 @@ static GlobCode glob_set(URLGlob *glob, char *pattern,
pat->content.Set.elements = (char**)malloc(0); pat->content.Set.elements = (char**)malloc(0);
++glob->size; ++glob->size;
while (!done) { while(!done) {
switch (*pattern) { switch (*pattern) {
case '\0': /* URL ended while set was still open */ case '\0': /* URL ended while set was still open */
snprintf(glob->errormsg, sizeof(glob->errormsg), snprintf(glob->errormsg, sizeof(glob->errormsg),
@ -93,7 +93,7 @@ static GlobCode glob_set(URLGlob *glob, char *pattern,
pat->content.Set.elements = pat->content.Set.elements =
realloc(pat->content.Set.elements, realloc(pat->content.Set.elements,
(pat->content.Set.size + 1) * sizeof(char*)); (pat->content.Set.size + 1) * sizeof(char*));
if (!pat->content.Set.elements) { if(!pat->content.Set.elements) {
snprintf(glob->errormsg, sizeof(glob->errormsg), "out of memory"); snprintf(glob->errormsg, sizeof(glob->errormsg), "out of memory");
return GLOB_ERROR; return GLOB_ERROR;
} }
@ -101,7 +101,7 @@ static GlobCode glob_set(URLGlob *glob, char *pattern,
strdup(glob->glob_buffer); strdup(glob->glob_buffer);
++pat->content.Set.size; ++pat->content.Set.size;
if (*pattern == '}') { if(*pattern == '}') {
/* entire set pattern completed */ /* entire set pattern completed */
int wordamount; int wordamount;
@ -159,13 +159,13 @@ static GlobCode glob_range(URLGlob *glob, char *pattern,
/* patterns 0,1,2,... correspond to size=1,3,5,... */ /* patterns 0,1,2,... correspond to size=1,3,5,... */
++glob->size; ++glob->size;
if (ISALPHA(*pattern)) { /* character range detected */ if(ISALPHA(*pattern)) { /* character range detected */
char min_c; char min_c;
char max_c; char max_c;
pat->type = UPTCharRange; pat->type = UPTCharRange;
rc = sscanf(pattern, "%c-%c%c%d%c", &min_c, &max_c, &sep, &step, &sep2); rc = sscanf(pattern, "%c-%c%c%d%c", &min_c, &max_c, &sep, &step, &sep2);
if ((rc < 3) || (min_c >= max_c) || ((max_c - min_c) > ('z' - 'a'))) { if((rc < 3) || (min_c >= max_c) || ((max_c - min_c) > ('z' - 'a'))) {
/* the pattern is not well-formed */ /* the pattern is not well-formed */
snprintf(glob->errormsg, sizeof(glob->errormsg), snprintf(glob->errormsg, sizeof(glob->errormsg),
"error: bad range specification after pos %zu\n", pos); "error: bad range specification after pos %zu\n", pos);
@ -187,7 +187,7 @@ static GlobCode glob_range(URLGlob *glob, char *pattern,
pat->content.CharRange.ptr_c = pat->content.CharRange.min_c = min_c; pat->content.CharRange.ptr_c = pat->content.CharRange.min_c = min_c;
pat->content.CharRange.max_c = max_c; pat->content.CharRange.max_c = max_c;
} }
else if (ISDIGIT(*pattern)) { /* numeric range detected */ else if(ISDIGIT(*pattern)) { /* numeric range detected */
int min_n; int min_n;
int max_n; int max_n;
@ -196,7 +196,7 @@ static GlobCode glob_range(URLGlob *glob, char *pattern,
rc = sscanf(pattern, "%d-%d%c%d%c", &min_n, &max_n, &sep, &step, &sep2); rc = sscanf(pattern, "%d-%d%c%d%c", &min_n, &max_n, &sep, &step, &sep2);
if ((rc < 2) || (min_n > max_n)) { if((rc < 2) || (min_n > max_n)) {
/* the pattern is not well-formed */ /* the pattern is not well-formed */
snprintf(glob->errormsg, sizeof(glob->errormsg), snprintf(glob->errormsg, sizeof(glob->errormsg),
"error: bad range specification after pos %zu\n", pos); "error: bad range specification after pos %zu\n", pos);
@ -209,9 +209,9 @@ static GlobCode glob_range(URLGlob *glob, char *pattern,
pat->content.NumRange.step = pat->content.NumRange.step =
((sep == ':') && (rc == 5) && (sep2 == ']'))?step:1; ((sep == ':') && (rc == 5) && (sep2 == ']'))?step:1;
if (*pattern == '0') { /* leading zero specified */ if(*pattern == '0') { /* leading zero specified */
c = pattern; c = pattern;
while (ISDIGIT(*c)) { while(ISDIGIT(*c)) {
c++; c++;
++pat->content.NumRange.padlength; /* padding length is set for all ++pat->content.NumRange.padlength; /* padding length is set for all
instances of this pattern */ instances of this pattern */
@ -261,15 +261,15 @@ static GlobCode glob_word(URLGlob *glob, char *pattern,
*amount = 1; /* default is one single string */ *amount = 1; /* default is one single string */
while (*pattern != '\0' && *pattern != '{' && *pattern != '[') { while(*pattern != '\0' && *pattern != '{' && *pattern != '[') {
if (*pattern == '}' || *pattern == ']') { if(*pattern == '}' || *pattern == ']') {
snprintf(glob->errormsg, sizeof(glob->errormsg), snprintf(glob->errormsg, sizeof(glob->errormsg),
"unmatched close brace/bracket at pos %zu\n", pos); "unmatched close brace/bracket at pos %zu\n", pos);
return GLOB_ERROR; return GLOB_ERROR;
} }
/* only allow \ to escape known "special letters" */ /* only allow \ to escape known "special letters" */
if (*pattern == '\\' && if(*pattern == '\\' &&
(*(pattern+1) == '{' || *(pattern+1) == '[' || (*(pattern+1) == '{' || *(pattern+1) == '[' ||
*(pattern+1) == '}' || *(pattern+1) == ']') ) { *(pattern+1) == '}' || *(pattern+1) == ']') ) {
@ -358,13 +358,13 @@ void glob_cleanup(URLGlob* glob)
size_t i; size_t i;
int elem; int elem;
for (i = glob->size - 1; i < glob->size; --i) { for(i = glob->size - 1; i < glob->size; --i) {
if (!(i & 1)) { /* even indexes contain literals */ if(!(i & 1)) { /* even indexes contain literals */
free(glob->literal[i/2]); free(glob->literal[i/2]);
} }
else { /* odd indexes contain sets or ranges */ else { /* odd indexes contain sets or ranges */
if (glob->pattern[i/2].type == UPTSet) { if(glob->pattern[i/2].type == UPTSet) {
for (elem = glob->pattern[i/2].content.Set.size - 1; for(elem = glob->pattern[i/2].content.Set.size - 1;
elem >= 0; elem >= 0;
--elem) { --elem) {
free(glob->pattern[i/2].content.Set.elements[elem]); free(glob->pattern[i/2].content.Set.elements[elem]);
@ -387,19 +387,19 @@ char *glob_next_url(URLGlob *glob)
size_t buflen = glob->urllen+1; size_t buflen = glob->urllen+1;
size_t len; size_t len;
if (!glob->beenhere) if(!glob->beenhere)
glob->beenhere = 1; glob->beenhere = 1;
else { else {
bool carry = TRUE; bool carry = TRUE;
/* implement a counter over the index ranges of all patterns, /* implement a counter over the index ranges of all patterns,
starting with the rightmost pattern */ starting with the rightmost pattern */
for (i = glob->size / 2 - 1; carry && i < glob->size; --i) { for(i = glob->size / 2 - 1; carry && i < glob->size; --i) {
carry = FALSE; carry = FALSE;
pat = &glob->pattern[i]; pat = &glob->pattern[i];
switch (pat->type) { switch (pat->type) {
case UPTSet: case UPTSet:
if (++pat->content.Set.ptr_s == pat->content.Set.size) { if(++pat->content.Set.ptr_s == pat->content.Set.size) {
pat->content.Set.ptr_s = 0; pat->content.Set.ptr_s = 0;
carry = TRUE; carry = TRUE;
} }
@ -407,14 +407,14 @@ char *glob_next_url(URLGlob *glob)
case UPTCharRange: case UPTCharRange:
pat->content.CharRange.ptr_c = (char)(pat->content.CharRange.step + pat->content.CharRange.ptr_c = (char)(pat->content.CharRange.step +
(int)((unsigned char)pat->content.CharRange.ptr_c)); (int)((unsigned char)pat->content.CharRange.ptr_c));
if (pat->content.CharRange.ptr_c > pat->content.CharRange.max_c) { if(pat->content.CharRange.ptr_c > pat->content.CharRange.max_c) {
pat->content.CharRange.ptr_c = pat->content.CharRange.min_c; pat->content.CharRange.ptr_c = pat->content.CharRange.min_c;
carry = TRUE; carry = TRUE;
} }
break; break;
case UPTNumRange: case UPTNumRange:
pat->content.NumRange.ptr_n += pat->content.NumRange.step; pat->content.NumRange.ptr_n += pat->content.NumRange.step;
if (pat->content.NumRange.ptr_n > pat->content.NumRange.max_n) { if(pat->content.NumRange.ptr_n > pat->content.NumRange.max_n) {
pat->content.NumRange.ptr_n = pat->content.NumRange.min_n; pat->content.NumRange.ptr_n = pat->content.NumRange.min_n;
carry = TRUE; carry = TRUE;
} }
@ -424,12 +424,12 @@ char *glob_next_url(URLGlob *glob)
exit (CURLE_FAILED_INIT); exit (CURLE_FAILED_INIT);
} }
} }
if (carry) /* first pattern ptr has run into overflow, done! */ if(carry) /* first pattern ptr has run into overflow, done! */
return NULL; return NULL;
} }
for (j = 0; j < glob->size; ++j) { for(j = 0; j < glob->size; ++j) {
if (!(j&1)) { /* every other term (j even) is a literal */ if(!(j&1)) { /* every other term (j even) is a literal */
lit = glob->literal[j/2]; lit = glob->literal[j/2];
len = snprintf(buf, buflen, "%s", lit); len = snprintf(buf, buflen, "%s", lit);
buf += len; buf += len;
@ -484,14 +484,14 @@ char *glob_match_url(char *filename, URLGlob *glob)
if(NULL == target) if(NULL == target)
return NULL; /* major failure */ return NULL; /* major failure */
while (*filename) { while(*filename) {
if (*filename == '#' && ISDIGIT(filename[1])) { if(*filename == '#' && ISDIGIT(filename[1])) {
unsigned long i; unsigned long i;
char *ptr = filename; char *ptr = filename;
unsigned long num = strtoul(&filename[1], &filename, 10); unsigned long num = strtoul(&filename[1], &filename, 10);
i = num-1; i = num-1;
if (num && (i <= glob->size / 2)) { if(num && (i <= glob->size / 2)) {
URLPattern pat = glob->pattern[i]; URLPattern pat = glob->pattern[i];
switch (pat.type) { switch (pat.type) {
case UPTSet: case UPTSet:

View File

@ -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 * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -84,17 +84,17 @@ void ourWriteEnv(CURL *curl)
long longinfo; long longinfo;
double doubleinfo; double doubleinfo;
for (i=0; variables[i].name; i++) { for(i=0; variables[i].name; i++) {
switch (variables[i].type) { switch (variables[i].type) {
case writeenv_STRING: case writeenv_STRING:
if (curl_easy_getinfo(curl, variables[i].id, &string) == CURLE_OK) if(curl_easy_getinfo(curl, variables[i].id, &string) == CURLE_OK)
internalSetEnv(variables[i].name, string); internalSetEnv(variables[i].name, string);
else else
internalSetEnv(variables[i].name, NULL); internalSetEnv(variables[i].name, NULL);
break; break;
case writeenv_LONG: case writeenv_LONG:
if (curl_easy_getinfo(curl, variables[i].id, &longinfo) == CURLE_OK) { if(curl_easy_getinfo(curl, variables[i].id, &longinfo) == CURLE_OK) {
curl_msprintf(numtext, "%5ld", longinfo); curl_msprintf(numtext, "%5ld", longinfo);
internalSetEnv(variables[i].name, numtext); internalSetEnv(variables[i].name, numtext);
} }
@ -102,7 +102,7 @@ void ourWriteEnv(CURL *curl)
internalSetEnv(variables[i].name, NULL); internalSetEnv(variables[i].name, NULL);
break; break;
case writeenv_DOUBLE: case writeenv_DOUBLE:
if (curl_easy_getinfo(curl, variables[i].id, &doubleinfo) == CURLE_OK) { if(curl_easy_getinfo(curl, variables[i].id, &doubleinfo) == CURLE_OK) {
curl_msprintf(numtext, "%6.2f", doubleinfo); curl_msprintf(numtext, "%6.2f", doubleinfo);
internalSetEnv(variables[i].name, numtext); internalSetEnv(variables[i].name, numtext);
} }

View File

@ -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 * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -167,7 +167,8 @@ void ourWriteOut(CURL *curl, const char *writeinfo)
break; break;
case VAR_REDIRECT_TIME: case VAR_REDIRECT_TIME:
if(CURLE_OK == if(CURLE_OK ==
curl_easy_getinfo(curl, CURLINFO_REDIRECT_TIME, &doubleinfo)) curl_easy_getinfo(curl, CURLINFO_REDIRECT_TIME,
&doubleinfo))
fprintf(stream, "%.3f", doubleinfo); fprintf(stream, "%.3f", doubleinfo);
break; break;
case VAR_TOTAL_TIME: case VAR_TOTAL_TIME:
@ -211,12 +212,14 @@ void ourWriteOut(CURL *curl, const char *writeinfo)
break; break;
case VAR_SIZE_DOWNLOAD: case VAR_SIZE_DOWNLOAD:
if(CURLE_OK == if(CURLE_OK ==
curl_easy_getinfo(curl, CURLINFO_SIZE_DOWNLOAD, &doubleinfo)) curl_easy_getinfo(curl, CURLINFO_SIZE_DOWNLOAD,
&doubleinfo))
fprintf(stream, "%.0f", doubleinfo); fprintf(stream, "%.0f", doubleinfo);
break; break;
case VAR_SPEED_DOWNLOAD: case VAR_SPEED_DOWNLOAD:
if(CURLE_OK == if(CURLE_OK ==
curl_easy_getinfo(curl, CURLINFO_SPEED_DOWNLOAD, &doubleinfo)) curl_easy_getinfo(curl, CURLINFO_SPEED_DOWNLOAD,
&doubleinfo))
fprintf(stream, "%.3f", doubleinfo); fprintf(stream, "%.3f", doubleinfo);
break; break;
case VAR_SPEED_UPLOAD: case VAR_SPEED_UPLOAD:
@ -244,7 +247,8 @@ void ourWriteOut(CURL *curl, const char *writeinfo)
break; break;
case VAR_SSL_VERIFY_RESULT: case VAR_SSL_VERIFY_RESULT:
if(CURLE_OK == if(CURLE_OK ==
curl_easy_getinfo(curl, CURLINFO_SSL_VERIFYRESULT, &longinfo)) curl_easy_getinfo(curl, CURLINFO_SSL_VERIFYRESULT,
&longinfo))
fprintf(stream, "%ld", longinfo); fprintf(stream, "%ld", longinfo);
break; break;
default: default:

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 2010, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 2010, 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -51,10 +51,10 @@ int fwrite_xattr(CURL *curl, int fd)
int i = 0; int i = 0;
int err = 0; int err = 0;
/* loop through all xattr-curlinfo pairs and abort on a set error */ /* loop through all xattr-curlinfo pairs and abort on a set error */
while ( err == 0 && mappings[i].attr != NULL ) { while(err == 0 && mappings[i].attr != NULL) {
char *value = NULL; char *value = NULL;
CURLcode rc = curl_easy_getinfo(curl, mappings[i].info, &value); CURLcode rc = curl_easy_getinfo(curl, mappings[i].info, &value);
if ( rc == CURLE_OK && value ) { if(rc == CURLE_OK && value) {
#ifdef HAVE_FSETXATTR_6 #ifdef HAVE_FSETXATTR_6
err = fsetxattr( fd, mappings[i].attr, value, strlen(value), 0, 0 ); err = fsetxattr( fd, mappings[i].attr, value, strlen(value), 0, 0 );
#elif defined(HAVE_FSETXATTR_5) #elif defined(HAVE_FSETXATTR_5)