code style: use spaces around equals signs

This commit is contained in:
Daniel Stenberg 2017-09-09 23:09:06 +02:00
parent e155f38d1e
commit 6b84438d9a
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2
144 changed files with 995 additions and 990 deletions

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2017, 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
@ -114,7 +114,7 @@ int main(void)
CURLM *cm; CURLM *cm;
CURLMsg *msg; CURLMsg *msg;
long L; long L;
unsigned int C=0; unsigned int C = 0;
int M, Q, U = -1; int M, Q, U = -1;
fd_set R, W, E; fd_set R, W, E;
struct timeval T; struct timeval T;

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2017, 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
@ -106,7 +106,7 @@ int main(int argc, char **argv)
if(argc < 3) if(argc < 3)
return 1; return 1;
file= argv[1]; file = argv[1];
url = argv[2]; url = argv[2];
/* get the file size of the local file */ /* get the file size of the local file */

View File

@ -37,7 +37,7 @@ size_t writefunction(void *ptr, size_t size, size_t nmemb, void *stream)
static CURLcode sslctx_function(CURL *curl, void *sslctx, void *parm) static CURLcode sslctx_function(CURL *curl, void *sslctx, void *parm)
{ {
X509_STORE *store; X509_STORE *store;
X509 *cert=NULL; X509 *cert = NULL;
BIO *bio; BIO *bio;
char *mypem = /* www.cacert.org */ char *mypem = /* www.cacert.org */
"-----BEGIN CERTIFICATE-----\n"\ "-----BEGIN CERTIFICATE-----\n"\
@ -82,7 +82,7 @@ static CURLcode sslctx_function(CURL *curl, void *sslctx, void *parm)
"omTxJBzcoTWcFbLUvFUufQb1nA5V9FrWk9p2rSVzTMVD\n"\ "omTxJBzcoTWcFbLUvFUufQb1nA5V9FrWk9p2rSVzTMVD\n"\
"-----END CERTIFICATE-----\n"; "-----END CERTIFICATE-----\n";
/* get a BIO */ /* get a BIO */
bio=BIO_new_mem_buf(mypem, -1); bio = BIO_new_mem_buf(mypem, -1);
/* use it to read the PEM formatted certificate from memory into an X509 /* use it to read the PEM formatted certificate from memory into an X509
* structure that SSL can use * structure that SSL can use
*/ */
@ -91,10 +91,10 @@ static CURLcode sslctx_function(CURL *curl, void *sslctx, void *parm)
printf("PEM_read_bio_X509 failed...\n"); printf("PEM_read_bio_X509 failed...\n");
/* get a pointer to the X509 certificate store (which may be empty!) */ /* get a pointer to the X509 certificate store (which may be empty!) */
store=SSL_CTX_get_cert_store((SSL_CTX *)sslctx); store = SSL_CTX_get_cert_store((SSL_CTX *)sslctx);
/* add our certificate to this store */ /* add our certificate to this store */
if(X509_STORE_add_cert(store, cert)==0) if(X509_STORE_add_cert(store, cert) == 0)
printf("error adding certificate\n"); printf("error adding certificate\n");
/* decrease reference counts */ /* decrease reference counts */
@ -110,24 +110,24 @@ int main(void)
CURL *ch; CURL *ch;
CURLcode rv; CURLcode rv;
rv=curl_global_init(CURL_GLOBAL_ALL); rv = curl_global_init(CURL_GLOBAL_ALL);
ch=curl_easy_init(); ch = curl_easy_init();
rv=curl_easy_setopt(ch, CURLOPT_VERBOSE, 0L); rv = curl_easy_setopt(ch, CURLOPT_VERBOSE, 0L);
rv=curl_easy_setopt(ch, CURLOPT_HEADER, 0L); rv = curl_easy_setopt(ch, CURLOPT_HEADER, 0L);
rv=curl_easy_setopt(ch, CURLOPT_NOPROGRESS, 1L); rv = curl_easy_setopt(ch, CURLOPT_NOPROGRESS, 1L);
rv=curl_easy_setopt(ch, CURLOPT_NOSIGNAL, 1L); rv = curl_easy_setopt(ch, CURLOPT_NOSIGNAL, 1L);
rv=curl_easy_setopt(ch, CURLOPT_WRITEFUNCTION, *writefunction); rv = curl_easy_setopt(ch, CURLOPT_WRITEFUNCTION, *writefunction);
rv=curl_easy_setopt(ch, CURLOPT_WRITEDATA, stdout); rv = curl_easy_setopt(ch, CURLOPT_WRITEDATA, stdout);
rv=curl_easy_setopt(ch, CURLOPT_HEADERFUNCTION, *writefunction); rv = curl_easy_setopt(ch, CURLOPT_HEADERFUNCTION, *writefunction);
rv=curl_easy_setopt(ch, CURLOPT_HEADERDATA, stderr); rv = curl_easy_setopt(ch, CURLOPT_HEADERDATA, stderr);
rv=curl_easy_setopt(ch, CURLOPT_SSLCERTTYPE, "PEM"); rv = curl_easy_setopt(ch, CURLOPT_SSLCERTTYPE, "PEM");
rv=curl_easy_setopt(ch, CURLOPT_SSL_VERIFYPEER, 1L); rv = curl_easy_setopt(ch, CURLOPT_SSL_VERIFYPEER, 1L);
rv=curl_easy_setopt(ch, CURLOPT_URL, "https://www.example.com/"); rv = curl_easy_setopt(ch, CURLOPT_URL, "https://www.example.com/");
/* first try: retrieve page without cacerts' certificate -> will fail /* first try: retrieve page without cacerts' certificate -> will fail
*/ */
rv=curl_easy_perform(ch); rv = curl_easy_perform(ch);
if(rv==CURLE_OK) if(rv == CURLE_OK)
printf("*** transfer succeeded ***\n"); printf("*** transfer succeeded ***\n");
else else
printf("*** transfer failed ***\n"); printf("*** transfer failed ***\n");
@ -136,9 +136,9 @@ int main(void)
* load the certificate by installing a function doing the necessary * load the certificate by installing a function doing the necessary
* "modifications" to the SSL CONTEXT just before link init * "modifications" to the SSL CONTEXT just before link init
*/ */
rv=curl_easy_setopt(ch, CURLOPT_SSL_CTX_FUNCTION, *sslctx_function); rv = curl_easy_setopt(ch, CURLOPT_SSL_CTX_FUNCTION, *sslctx_function);
rv=curl_easy_perform(ch); rv = curl_easy_perform(ch);
if(rv==CURLE_OK) if(rv == CURLE_OK)
printf("*** transfer succeeded ***\n"); printf("*** transfer succeeded ***\n");
else else
printf("*** transfer failed ***\n"); printf("*** transfer failed ***\n");

View File

@ -195,7 +195,8 @@ static int ssl_app_verify_callback(X509_STORE_CTX *ctx, void *arg)
if(p->verbose > 2) if(p->verbose > 2)
BIO_printf(p->errorbio, "entering ssl_app_verify_callback\n"); BIO_printf(p->errorbio, "entering ssl_app_verify_callback\n");
if((ok= X509_verify_cert(ctx)) && ctx->cert) { ok = X509_verify_cert(ctx);
if(ok && ctx->cert) {
unsigned char *accessinfo; unsigned char *accessinfo;
if(p->verbose > 1) if(p->verbose > 1)
X509_print_ex(p->errorbio, ctx->cert, 0, 0); X509_print_ex(p->errorbio, ctx->cert, 0, 0);
@ -268,16 +269,16 @@ static CURLcode sslctxfun(CURL *curl, void *sslctx, void *parm)
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
BIO* in=NULL; BIO* in = NULL;
BIO* out=NULL; BIO* out = NULL;
char *outfile = NULL; char *outfile = NULL;
char *infile = NULL; char *infile = NULL;
int tabLength=100; int tabLength = 100;
char *binaryptr; char *binaryptr;
char *mimetype; char *mimetype;
char *mimetypeaccept=NULL; char *mimetypeaccept = NULL;
char *contenttype; char *contenttype;
const char **pp; const char **pp;
unsigned char *hostporturl = NULL; unsigned char *hostporturl = NULL;
@ -288,8 +289,8 @@ int main(int argc, char **argv)
char *response; char *response;
CURLcode res; CURLcode res;
struct curl_slist *headers=NULL; struct curl_slist *headers = NULL;
int badarg=0; int badarg = 0;
binaryptr = malloc(tabLength); binaryptr = malloc(tabLength);
@ -307,75 +308,75 @@ int main(int argc, char **argv)
while(*args && *args[0] == '-') { while(*args && *args[0] == '-') {
if(!strcmp (*args, "-in")) { if(!strcmp (*args, "-in")) {
if(args[1]) { if(args[1]) {
infile=*(++args); infile = *(++args);
} }
else else
badarg=1; badarg = 1;
} }
else if(!strcmp (*args, "-out")) { else if(!strcmp (*args, "-out")) {
if(args[1]) { if(args[1]) {
outfile=*(++args); outfile = *(++args);
} }
else else
badarg=1; badarg = 1;
} }
else if(!strcmp (*args, "-p12")) { else if(!strcmp (*args, "-p12")) {
if(args[1]) { if(args[1]) {
p.p12file = *(++args); p.p12file = *(++args);
} }
else else
badarg=1; badarg = 1;
} }
else if(strcmp(*args, "-envpass") == 0) { else if(strcmp(*args, "-envpass") == 0) {
if(args[1]) { if(args[1]) {
p.pst = getenv(*(++args)); p.pst = getenv(*(++args));
} }
else else
badarg=1; badarg = 1;
} }
else if(strcmp(*args, "-connect") == 0) { else if(strcmp(*args, "-connect") == 0) {
if(args[1]) { if(args[1]) {
hostporturl = *(++args); hostporturl = *(++args);
} }
else else
badarg=1; badarg = 1;
} }
else if(strcmp(*args, "-mimetype") == 0) { else if(strcmp(*args, "-mimetype") == 0) {
if(args[1]) { if(args[1]) {
mimetype = *(++args); mimetype = *(++args);
} }
else else
badarg=1; badarg = 1;
} }
else if(strcmp(*args, "-acceptmime") == 0) { else if(strcmp(*args, "-acceptmime") == 0) {
if(args[1]) { if(args[1]) {
mimetypeaccept = *(++args); mimetypeaccept = *(++args);
} }
else else
badarg=1; badarg = 1;
} }
else if(strcmp(*args, "-accesstype") == 0) { else if(strcmp(*args, "-accesstype") == 0) {
if(args[1]) { if(args[1]) {
p.accesstype = OBJ_obj2nid(OBJ_txt2obj(*++args, 0)); p.accesstype = OBJ_obj2nid(OBJ_txt2obj(*++args, 0));
if(p.accesstype == 0) if(p.accesstype == 0)
badarg=1; badarg = 1;
} }
else else
badarg=1; badarg = 1;
} }
else if(strcmp(*args, "-verbose") == 0) { else if(strcmp(*args, "-verbose") == 0) {
p.verbose++; p.verbose++;
} }
else else
badarg=1; badarg = 1;
args++; args++;
} }
if(mimetype==NULL || mimetypeaccept == NULL) if(mimetype == NULL || mimetypeaccept == NULL)
badarg = 1; badarg = 1;
if(badarg) { if(badarg) {
for(pp=curlx_usage; (*pp != NULL); pp++) for(pp = curlx_usage; (*pp != NULL); pp++)
BIO_printf(p.errorbio, "%s\n", *pp); BIO_printf(p.errorbio, "%s\n", *pp);
BIO_printf(p.errorbio, "\n"); BIO_printf(p.errorbio, "\n");
goto err; goto err;
@ -383,7 +384,8 @@ int main(int argc, char **argv)
/* set input */ /* set input */
if((in=BIO_new(BIO_s_file())) == NULL) { in = BIO_new(BIO_s_file());
if(in == NULL) {
BIO_printf(p.errorbio, "Error setting input bio\n"); BIO_printf(p.errorbio, "Error setting input bio\n");
goto err; goto err;
} }
@ -397,7 +399,8 @@ int main(int argc, char **argv)
/* set output */ /* set output */
if((out=BIO_new(BIO_s_file())) == NULL) { out = BIO_new(BIO_s_file());
if(out == NULL) {
BIO_printf(p.errorbio, "Error setting output bio.\n"); BIO_printf(p.errorbio, "Error setting output bio.\n");
goto err; goto err;
} }
@ -429,7 +432,7 @@ int main(int argc, char **argv)
goto err; goto err;
} }
p.ca= NULL; p.ca = NULL;
if(!(PKCS12_parse (p.p12, p.pst, &(p.pkey), &(p.usercert), &(p.ca) ) )) { if(!(PKCS12_parse (p.p12, p.pst, &(p.pkey), &(p.usercert), &(p.ca) ) )) {
BIO_printf(p.errorbio, "Invalid P12 structure in %s\n", p.p12file); BIO_printf(p.errorbio, "Invalid P12 structure in %s\n", p.p12file);
goto err; goto err;
@ -454,10 +457,10 @@ int main(int argc, char **argv)
given access type */ given access type */
serverurl = my_get_ext(p.usercert, p.accesstype, NID_info_access); serverurl = my_get_ext(p.usercert, p.accesstype, NID_info_access);
if(!serverurl) { if(!serverurl) {
int j=0; int j = 0;
BIO_printf(p.errorbio, "no service URL in user cert " BIO_printf(p.errorbio, "no service URL in user cert "
"cherching in others certificats\n"); "cherching in others certificats\n");
for(j=0; j<sk_X509_num(p.ca); j++) { for(j = 0; j<sk_X509_num(p.ca); j++) {
serverurl = my_get_ext(sk_X509_value(p.ca, j), p.accesstype, serverurl = my_get_ext(sk_X509_value(p.ca, j), p.accesstype,
NID_info_access); NID_info_access);
if(serverurl) if(serverurl)
@ -512,12 +515,12 @@ int main(int argc, char **argv)
curl_easy_setopt(p.curl, CURLOPT_SSL_CTX_DATA, &p); curl_easy_setopt(p.curl, CURLOPT_SSL_CTX_DATA, &p);
{ {
int lu; int i=0; int lu; int i = 0;
while((lu = BIO_read(in, &binaryptr[i], tabLength-i)) >0) { while((lu = BIO_read(in, &binaryptr[i], tabLength-i)) >0) {
i+=lu; i += lu;
if(i== tabLength) { if(i == tabLength) {
tabLength+=100; tabLength += 100;
binaryptr=realloc(binaryptr, tabLength); /* should be more careful */ binaryptr = realloc(binaryptr, tabLength); /* should be more careful */
} }
} }
tabLength = i; tabLength = i;
@ -533,7 +536,7 @@ int main(int argc, char **argv)
BIO_printf(p.errorbio, "%d %s %d\n", __LINE__, "curl_easy_perform", BIO_printf(p.errorbio, "%d %s %d\n", __LINE__, "curl_easy_perform",
res = curl_easy_perform(p.curl)); res = curl_easy_perform(p.curl));
{ {
int result =curl_easy_getinfo(p.curl, CURLINFO_CONTENT_TYPE, &response); int result = curl_easy_getinfo(p.curl, CURLINFO_CONTENT_TYPE, &response);
if(mimetypeaccept && p.verbose) if(mimetypeaccept && p.verbose)
if(!strcmp(mimetypeaccept, response)) if(!strcmp(mimetypeaccept, response))
BIO_printf(p.errorbio, "the response has a correct mimetype : %s\n", BIO_printf(p.errorbio, "the response has a correct mimetype : %s\n",

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2017, 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
@ -38,7 +38,7 @@ void dump(const char *text,
size_t i; size_t i;
size_t c; size_t c;
unsigned int width=0x10; unsigned int width = 0x10;
if(nohex) if(nohex)
/* without the hex output, we can fit more on screen */ /* without the hex output, we can fit more on screen */
@ -47,7 +47,7 @@ void dump(const char *text,
fprintf(stream, "%s, %10.10ld bytes (0x%8.8lx)\n", fprintf(stream, "%s, %10.10ld bytes (0x%8.8lx)\n",
text, (long)size, (long)size); text, (long)size, (long)size);
for(i=0; i<size; i+= width) { for(i = 0; i<size; i+= width) {
fprintf(stream, "%4.4lx: ", (long)i); fprintf(stream, "%4.4lx: ", (long)i);
@ -62,14 +62,14 @@ void dump(const char *text,
for(c = 0; (c < width) && (i+c < size); c++) { for(c = 0; (c < width) && (i+c < size); c++) {
/* check for 0D0A; if found, skip past and start a new line of output */ /* check for 0D0A; if found, skip past and start a new line of output */
if(nohex && (i+c+1 < size) && ptr[i+c]==0x0D && ptr[i+c+1]==0x0A) { if(nohex && (i+c+1 < size) && ptr[i+c] == 0x0D && ptr[i+c+1] == 0x0A) {
i+=(c+2-width); i+=(c+2-width);
break; break;
} }
fprintf(stream, "%c", fprintf(stream, "%c",
(ptr[i+c]>=0x20) && (ptr[i+c]<0x80)?ptr[i+c]:'.'); (ptr[i+c] >= 0x20) && (ptr[i+c]<0x80)?ptr[i+c]:'.');
/* check again for 0D0A, to avoid an extra \n if it's at width */ /* check again for 0D0A, to avoid an extra \n if it's at width */
if(nohex && (i+c+2 < size) && ptr[i+c+1]==0x0D && ptr[i+c+2]==0x0A) { if(nohex && (i+c+2 < size) && ptr[i+c+1] == 0x0D && ptr[i+c+2] == 0x0A) {
i+=(c+3-width); i+=(c+3-width);
break; break;
} }

View File

@ -136,28 +136,28 @@ static void mcode_or_die(const char *where, CURLMcode code)
const char *s; const char *s;
switch(code) { switch(code) {
case CURLM_BAD_HANDLE: case CURLM_BAD_HANDLE:
s="CURLM_BAD_HANDLE"; s = "CURLM_BAD_HANDLE";
break; break;
case CURLM_BAD_EASY_HANDLE: case CURLM_BAD_EASY_HANDLE:
s="CURLM_BAD_EASY_HANDLE"; s = "CURLM_BAD_EASY_HANDLE";
break; break;
case CURLM_OUT_OF_MEMORY: case CURLM_OUT_OF_MEMORY:
s="CURLM_OUT_OF_MEMORY"; s = "CURLM_OUT_OF_MEMORY";
break; break;
case CURLM_INTERNAL_ERROR: case CURLM_INTERNAL_ERROR:
s="CURLM_INTERNAL_ERROR"; s = "CURLM_INTERNAL_ERROR";
break; break;
case CURLM_UNKNOWN_OPTION: case CURLM_UNKNOWN_OPTION:
s="CURLM_UNKNOWN_OPTION"; s = "CURLM_UNKNOWN_OPTION";
break; break;
case CURLM_LAST: case CURLM_LAST:
s="CURLM_LAST"; s = "CURLM_LAST";
break; break;
default: default:
s="CURLM_unknown"; s = "CURLM_unknown";
break; break;
case CURLM_BAD_SOCKET: case CURLM_BAD_SOCKET:
s="CURLM_BAD_SOCKET"; s = "CURLM_BAD_SOCKET";
fprintf(MSG_OUT, "ERROR: %s returns %s\n", where, s); fprintf(MSG_OUT, "ERROR: %s returns %s\n", where, s);
/* ignore this error */ /* ignore this error */
return; return;
@ -257,7 +257,7 @@ static void setsock(SockInfo *f, curl_socket_t s, CURL *e, int act,
ev_io_stop(g->loop, &f->ev); ev_io_stop(g->loop, &f->ev);
ev_io_init(&f->ev, event_cb, f->sockfd, kind); ev_io_init(&f->ev, event_cb, f->sockfd, kind);
f->ev.data = g; f->ev.data = g;
f->evset=1; f->evset = 1;
ev_io_start(g->loop, &f->ev); ev_io_start(g->loop, &f->ev);
} }
@ -371,13 +371,13 @@ static void new_conn(char *url, GlobalInfo *g)
static void fifo_cb(EV_P_ struct ev_io *w, int revents) static void fifo_cb(EV_P_ struct ev_io *w, int revents)
{ {
char s[1024]; char s[1024];
long int rv=0; long int rv = 0;
int n=0; int n = 0;
GlobalInfo *g = (GlobalInfo *)w->data; GlobalInfo *g = (GlobalInfo *)w->data;
do { do {
s[0]='\0'; s[0]='\0';
rv=fscanf(g->input, "%1023s%n", s, &n); rv = fscanf(g->input, "%1023s%n", s, &n);
s[n]='\0'; s[n]='\0';
if(n && s[0]) { if(n && s[0]) {
new_conn(s, g); /* if we read a URL, go get it! */ new_conn(s, g); /* if we read a URL, go get it! */

View File

@ -13,7 +13,7 @@
* See the main() function at the bottom that shows an app that retrieves from * See the main() function at the bottom that shows an app that retrieves from
* a specified url using fgets() and fread() and saves as two output files. * a specified url using fgets() and fread() and saves as two output files.
* *
* Copyright (c) 2003 Simtec Electronics * Copyright (c) 2003, 2017 Simtec Electronics
* *
* Re-implemented by Vincent Sanders <vince@kyllikki.org> with extensive * Re-implemented by Vincent Sanders <vince@kyllikki.org> with extensive
* reference to original curl example code * reference to original curl example code
@ -58,9 +58,9 @@
#include <curl/curl.h> #include <curl/curl.h>
enum fcurl_type_e { enum fcurl_type_e {
CFTYPE_NONE=0, CFTYPE_NONE = 0,
CFTYPE_FILE=1, CFTYPE_FILE = 1,
CFTYPE_CURL=2 CFTYPE_CURL = 2
}; };
struct fcurl_data struct fcurl_data
@ -102,19 +102,19 @@ static size_t write_callback(char *buffer,
URL_FILE *url = (URL_FILE *)userp; URL_FILE *url = (URL_FILE *)userp;
size *= nitems; size *= nitems;
rembuff=url->buffer_len - url->buffer_pos; /* remaining space in buffer */ rembuff = url->buffer_len - url->buffer_pos; /* remaining space in buffer */
if(size > rembuff) { if(size > rembuff) {
/* not enough space in buffer */ /* not enough space in buffer */
newbuff=realloc(url->buffer, url->buffer_len + (size - rembuff)); newbuff = realloc(url->buffer, url->buffer_len + (size - rembuff));
if(newbuff==NULL) { if(newbuff == NULL) {
fprintf(stderr, "callback buffer grow failed\n"); fprintf(stderr, "callback buffer grow failed\n");
size=rembuff; size = rembuff;
} }
else { else {
/* realloc succeeded increase buffer size*/ /* realloc succeeded increase buffer size*/
url->buffer_len+=size - rembuff; url->buffer_len += size - rembuff;
url->buffer=newbuff; url->buffer = newbuff;
} }
} }
@ -211,12 +211,12 @@ static int fill_buffer(URL_FILE *file, size_t want)
static int use_buffer(URL_FILE *file, size_t want) static int use_buffer(URL_FILE *file, size_t want)
{ {
/* sort out buffer */ /* sort out buffer */
if((file->buffer_pos - want) <=0) { if((file->buffer_pos - want) <= 0) {
/* ditch buffer - write will recreate */ /* ditch buffer - write will recreate */
free(file->buffer); free(file->buffer);
file->buffer=NULL; file->buffer = NULL;
file->buffer_pos=0; file->buffer_pos = 0;
file->buffer_len=0; file->buffer_len = 0;
} }
else { else {
/* move rest down make it available for later */ /* move rest down make it available for later */
@ -243,7 +243,8 @@ URL_FILE *url_fopen(const char *url, const char *operation)
memset(file, 0, sizeof(URL_FILE)); memset(file, 0, sizeof(URL_FILE));
if((file->handle.file=fopen(url, operation))) file->handle.file = fopen(url, operation);
if(file->handle.file)
file->type = CFTYPE_FILE; /* marked as URL */ file->type = CFTYPE_FILE; /* marked as URL */
else { else {
@ -282,11 +283,11 @@ URL_FILE *url_fopen(const char *url, const char *operation)
int url_fclose(URL_FILE *file) int url_fclose(URL_FILE *file)
{ {
int ret=0;/* default is good return */ int ret = 0;/* default is good return */
switch(file->type) { switch(file->type) {
case CFTYPE_FILE: case CFTYPE_FILE:
ret=fclose(file->handle.file); /* passthrough */ ret = fclose(file->handle.file); /* passthrough */
break; break;
case CFTYPE_CURL: case CFTYPE_CURL:
@ -298,8 +299,8 @@ int url_fclose(URL_FILE *file)
break; break;
default: /* unknown or supported type - oh dear */ default: /* unknown or supported type - oh dear */
ret=EOF; ret = EOF;
errno=EBADF; errno = EBADF;
break; break;
} }
@ -311,11 +312,11 @@ int url_fclose(URL_FILE *file)
int url_feof(URL_FILE *file) int url_feof(URL_FILE *file)
{ {
int ret=0; int ret = 0;
switch(file->type) { switch(file->type) {
case CFTYPE_FILE: case CFTYPE_FILE:
ret=feof(file->handle.file); ret = feof(file->handle.file);
break; break;
case CFTYPE_CURL: case CFTYPE_CURL:
@ -324,8 +325,8 @@ int url_feof(URL_FILE *file)
break; break;
default: /* unknown or supported type - oh dear */ default: /* unknown or supported type - oh dear */
ret=-1; ret = -1;
errno=EBADF; errno = EBADF;
break; break;
} }
return ret; return ret;
@ -337,7 +338,7 @@ size_t url_fread(void *ptr, size_t size, size_t nmemb, URL_FILE *file)
switch(file->type) { switch(file->type) {
case CFTYPE_FILE: case CFTYPE_FILE:
want=fread(ptr, size, nmemb, file->handle.file); want = fread(ptr, size, nmemb, file->handle.file);
break; break;
case CFTYPE_CURL: case CFTYPE_CURL:
@ -363,8 +364,8 @@ size_t url_fread(void *ptr, size_t size, size_t nmemb, URL_FILE *file)
break; break;
default: /* unknown or supported type - oh dear */ default: /* unknown or supported type - oh dear */
want=0; want = 0;
errno=EBADF; errno = EBADF;
break; break;
} }
@ -395,24 +396,24 @@ char *url_fgets(char *ptr, size_t size, URL_FILE *file)
/*buffer contains data */ /*buffer contains data */
/* look for newline or eof */ /* look for newline or eof */
for(loop=0;loop < want;loop++) { for(loop = 0;loop < want;loop++) {
if(file->buffer[loop] == '\n') { if(file->buffer[loop] == '\n') {
want=loop+1;/* include newline */ want = loop+1;/* include newline */
break; break;
} }
} }
/* xfer data to caller */ /* xfer data to caller */
memcpy(ptr, file->buffer, want); memcpy(ptr, file->buffer, want);
ptr[want]=0;/* always null terminate */ ptr[want] = 0;/* always null terminate */
use_buffer(file, want); use_buffer(file, want);
break; break;
default: /* unknown or supported type - oh dear */ default: /* unknown or supported type - oh dear */
ptr=NULL; ptr = NULL;
errno=EBADF; errno = EBADF;
break; break;
} }
@ -435,9 +436,9 @@ void url_rewind(URL_FILE *file)
/* ditch buffer - write will recreate - resets stream pos*/ /* ditch buffer - write will recreate - resets stream pos*/
free(file->buffer); free(file->buffer);
file->buffer=NULL; file->buffer = NULL;
file->buffer_pos=0; file->buffer_pos = 0;
file->buffer_len=0; file->buffer_len = 0;
break; break;
@ -463,12 +464,12 @@ int main(int argc, char *argv[])
const char *url; const char *url;
if(argc < 2) if(argc < 2)
url="http://192.168.7.3/testfile";/* default to testurl */ url = "http://192.168.7.3/testfile";/* default to testurl */
else else
url=argv[1];/* use passed url */ url = argv[1];/* use passed url */
/* copy from url line by line with fgets */ /* copy from url line by line with fgets */
outf=fopen(FGETSFILE, "wb+"); outf = fopen(FGETSFILE, "wb+");
if(!outf) { if(!outf) {
perror("couldn't open fgets output file\n"); perror("couldn't open fgets output file\n");
return 1; return 1;
@ -492,7 +493,7 @@ int main(int argc, char *argv[])
/* Copy from url with fread */ /* Copy from url with fread */
outf=fopen(FREADFILE, "wb+"); outf = fopen(FREADFILE, "wb+");
if(!outf) { if(!outf) {
perror("couldn't open fread output file\n"); perror("couldn't open fread output file\n");
return 1; return 1;
@ -516,7 +517,7 @@ int main(int argc, char *argv[])
/* Test rewind */ /* Test rewind */
outf=fopen(REWINDFILE, "wb+"); outf = fopen(REWINDFILE, "wb+");
if(!outf) { if(!outf) {
perror("couldn't open fread output file\n"); perror("couldn't open fread output file\n");
return 1; return 1;

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2017, 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
@ -35,10 +35,10 @@ struct FtpFile {
static size_t my_fwrite(void *buffer, size_t size, size_t nmemb, void *stream) static size_t my_fwrite(void *buffer, size_t size, size_t nmemb, void *stream)
{ {
struct FtpFile *out=(struct FtpFile *)stream; struct FtpFile *out = (struct FtpFile *)stream;
if(out && !out->stream) { if(out && !out->stream) {
/* open file for writing */ /* open file for writing */
out->stream=fopen(out->filename, "wb"); out->stream = fopen(out->filename, "wb");
if(!out->stream) if(!out->stream)
return -1; /* failure, can't open file to write */ return -1; /* failure, can't open file to write */
} }
@ -50,7 +50,7 @@ int main(void)
{ {
CURL *curl; CURL *curl;
CURLcode res; CURLcode res;
struct FtpFile ftpfile={ struct FtpFile ftpfile = {
"curl.tar.gz", /* name to store the file as if successful */ "curl.tar.gz", /* name to store the file as if successful */
NULL NULL
}; };

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2015, 2017, 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
@ -37,10 +37,10 @@ struct FtpFile {
static size_t my_fwrite(void *buffer, size_t size, size_t nmemb, static size_t my_fwrite(void *buffer, size_t size, size_t nmemb,
void *stream) void *stream)
{ {
struct FtpFile *out=(struct FtpFile *)stream; struct FtpFile *out = (struct FtpFile *)stream;
if(out && !out->stream) { if(out && !out->stream) {
/* open file for writing */ /* open file for writing */
out->stream=fopen(out->filename, "wb"); out->stream = fopen(out->filename, "wb");
if(!out->stream) if(!out->stream)
return -1; /* failure, can't open file to write */ return -1; /* failure, can't open file to write */
} }
@ -52,7 +52,7 @@ int main(void)
{ {
CURL *curl; CURL *curl;
CURLcode res; CURLcode res;
struct FtpFile ftpfile={ struct FtpFile ftpfile = {
"yourfile.bin", /* name to store the file as if successful */ "yourfile.bin", /* name to store the file as if successful */
NULL NULL
}; };

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2017, 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
@ -71,7 +71,7 @@ int main(void)
struct stat file_info; struct stat file_info;
curl_off_t fsize; curl_off_t fsize;
struct curl_slist *headerlist=NULL; struct curl_slist *headerlist = NULL;
static const char buf_1 [] = "RNFR " UPLOAD_FILE_AS; static const char buf_1 [] = "RNFR " UPLOAD_FILE_AS;
static const char buf_2 [] = "RNTO " RENAME_FILE_TO; static const char buf_2 [] = "RNTO " RENAME_FILE_TO;

View File

@ -99,14 +99,14 @@ static void mcode_or_die(const char *where, CURLMcode code)
if(CURLM_OK != code) { if(CURLM_OK != code) {
const char *s; const char *s;
switch(code) { switch(code) {
case CURLM_BAD_HANDLE: s="CURLM_BAD_HANDLE"; break; case CURLM_BAD_HANDLE: s = "CURLM_BAD_HANDLE"; break;
case CURLM_BAD_EASY_HANDLE: s="CURLM_BAD_EASY_HANDLE"; break; case CURLM_BAD_EASY_HANDLE: s = "CURLM_BAD_EASY_HANDLE"; break;
case CURLM_OUT_OF_MEMORY: s="CURLM_OUT_OF_MEMORY"; break; case CURLM_OUT_OF_MEMORY: s = "CURLM_OUT_OF_MEMORY"; break;
case CURLM_INTERNAL_ERROR: s="CURLM_INTERNAL_ERROR"; break; case CURLM_INTERNAL_ERROR: s = "CURLM_INTERNAL_ERROR"; break;
case CURLM_BAD_SOCKET: s="CURLM_BAD_SOCKET"; break; case CURLM_BAD_SOCKET: s = "CURLM_BAD_SOCKET"; break;
case CURLM_UNKNOWN_OPTION: s="CURLM_UNKNOWN_OPTION"; break; case CURLM_UNKNOWN_OPTION: s = "CURLM_UNKNOWN_OPTION"; break;
case CURLM_LAST: s="CURLM_LAST"; break; case CURLM_LAST: s = "CURLM_LAST"; break;
default: s="CURLM_unknown"; default: s = "CURLM_unknown";
} }
MSG_OUT("ERROR: %s returns %s\n", where, s); MSG_OUT("ERROR: %s returns %s\n", where, s);
exit(code); exit(code);
@ -156,7 +156,7 @@ static gboolean timer_cb(gpointer data)
static int update_timeout_cb(CURLM *multi, long timeout_ms, void *userp) static int update_timeout_cb(CURLM *multi, long timeout_ms, void *userp)
{ {
struct timeval timeout; struct timeval timeout;
GlobalInfo *g=(GlobalInfo *)userp; GlobalInfo *g = (GlobalInfo *)userp;
timeout.tv_sec = timeout_ms/1000; timeout.tv_sec = timeout_ms/1000;
timeout.tv_usec = (timeout_ms%1000)*1000; timeout.tv_usec = (timeout_ms%1000)*1000;
@ -181,7 +181,7 @@ static gboolean event_cb(GIOChannel *ch, GIOCondition condition, gpointer data)
{ {
GlobalInfo *g = (GlobalInfo*) data; GlobalInfo *g = (GlobalInfo*) data;
CURLMcode rc; CURLMcode rc;
int fd=g_io_channel_unix_get_fd(ch); int fd = g_io_channel_unix_get_fd(ch);
int action = int action =
(condition & G_IO_IN ? CURL_CSELECT_IN : 0) | (condition & G_IO_IN ? CURL_CSELECT_IN : 0) |
@ -228,7 +228,7 @@ static void setsock(SockInfo *f, curl_socket_t s, CURL *e, int act,
if(f->ev) { if(f->ev) {
g_source_remove(f->ev); g_source_remove(f->ev);
} }
f->ev=g_io_add_watch(f->ch, kind, event_cb, g); f->ev = g_io_add_watch(f->ch, kind, event_cb, g);
} }
/* Initialize a new SockInfo structure */ /* Initialize a new SockInfo structure */
@ -237,7 +237,7 @@ static void addsock(curl_socket_t s, CURL *easy, int action, GlobalInfo *g)
SockInfo *fdp = g_malloc0(sizeof(SockInfo)); SockInfo *fdp = g_malloc0(sizeof(SockInfo));
fdp->global = g; fdp->global = g;
fdp->ch=g_io_channel_unix_new(s); fdp->ch = g_io_channel_unix_new(s);
setsock(fdp, s, easy, action, g); setsock(fdp, s, easy, action, g);
curl_multi_assign(g->multi, s, fdp); curl_multi_assign(g->multi, s, fdp);
} }
@ -319,7 +319,7 @@ static void new_conn(char *url, GlobalInfo *g)
curl_easy_setopt(conn->easy, CURLOPT_LOW_SPEED_TIME, 30L); curl_easy_setopt(conn->easy, CURLOPT_LOW_SPEED_TIME, 30L);
MSG_OUT("Adding easy %p to multi %p (%s)\n", conn->easy, g->multi, url); MSG_OUT("Adding easy %p to multi %p (%s)\n", conn->easy, g->multi, url);
rc =curl_multi_add_handle(g->multi, conn->easy); rc = curl_multi_add_handle(g->multi, conn->easy);
mcode_or_die("new_conn: curl_multi_add_handle", rc); mcode_or_die("new_conn: curl_multi_add_handle", rc);
/* note that the add_handle() will set a time-out to trigger very soon so /* note that the add_handle() will set a time-out to trigger very soon so
@ -331,11 +331,11 @@ static gboolean fifo_cb(GIOChannel *ch, GIOCondition condition, gpointer data)
{ {
#define BUF_SIZE 1024 #define BUF_SIZE 1024
gsize len, tp; gsize len, tp;
gchar *buf, *tmp, *all=NULL; gchar *buf, *tmp, *all = NULL;
GIOStatus rv; GIOStatus rv;
do { do {
GError *err=NULL; GError *err = NULL;
rv = g_io_channel_read_line(ch, &buf, &len, &tp, &err); rv = g_io_channel_read_line(ch, &buf, &len, &tp, &err);
if(buf) { if(buf) {
if(tp) { if(tp) {
@ -352,8 +352,8 @@ static gboolean fifo_cb(GIOChannel *ch, GIOCondition condition, gpointer data)
if(len) { if(len) {
buf[len]='\0'; buf[len]='\0';
if(all) { if(all) {
tmp=all; tmp = all;
all=g_strdup_printf("%s%s", tmp, buf); all = g_strdup_printf("%s%s", tmp, buf);
g_free(tmp); g_free(tmp);
} }
else { else {
@ -417,12 +417,12 @@ int main(int argc, char **argv)
GMainLoop*gmain; GMainLoop*gmain;
int fd; int fd;
GIOChannel* ch; GIOChannel* ch;
g=g_malloc0(sizeof(GlobalInfo)); g = g_malloc0(sizeof(GlobalInfo));
fd=init_fifo(); fd = init_fifo();
ch=g_io_channel_unix_new(fd); ch = g_io_channel_unix_new(fd);
g_io_add_watch(ch, G_IO_IN, fifo_cb, g); g_io_add_watch(ch, G_IO_IN, fifo_cb, g);
gmain=g_main_loop_new(NULL, FALSE); gmain = g_main_loop_new(NULL, FALSE);
g->multi = curl_multi_init(); g->multi = curl_multi_init();
curl_multi_setopt(g->multi, CURLMOPT_SOCKETFUNCTION, sock_cb); curl_multi_setopt(g->multi, CURLMOPT_SOCKETFUNCTION, sock_cb);
curl_multi_setopt(g->multi, CURLMOPT_SOCKETDATA, g); curl_multi_setopt(g->multi, CURLMOPT_SOCKETDATA, g);

View File

@ -137,15 +137,15 @@ static void mcode_or_die(const char *where, CURLMcode code)
if(CURLM_OK != code) { if(CURLM_OK != code) {
const char *s; const char *s;
switch(code) { switch(code) {
case CURLM_BAD_HANDLE: s="CURLM_BAD_HANDLE"; break; case CURLM_BAD_HANDLE: s = "CURLM_BAD_HANDLE"; break;
case CURLM_BAD_EASY_HANDLE: s="CURLM_BAD_EASY_HANDLE"; break; case CURLM_BAD_EASY_HANDLE: s = "CURLM_BAD_EASY_HANDLE"; break;
case CURLM_OUT_OF_MEMORY: s="CURLM_OUT_OF_MEMORY"; break; case CURLM_OUT_OF_MEMORY: s = "CURLM_OUT_OF_MEMORY"; break;
case CURLM_INTERNAL_ERROR: s="CURLM_INTERNAL_ERROR"; break; case CURLM_INTERNAL_ERROR: s = "CURLM_INTERNAL_ERROR"; break;
case CURLM_UNKNOWN_OPTION: s="CURLM_UNKNOWN_OPTION"; break; case CURLM_UNKNOWN_OPTION: s = "CURLM_UNKNOWN_OPTION"; break;
case CURLM_LAST: s="CURLM_LAST"; break; case CURLM_LAST: s = "CURLM_LAST"; break;
default: s="CURLM_unknown"; default: s = "CURLM_unknown";
break; break;
case CURLM_BAD_SOCKET: s="CURLM_BAD_SOCKET"; case CURLM_BAD_SOCKET: s = "CURLM_BAD_SOCKET";
fprintf(MSG_OUT, "ERROR: %s returns %s\n", where, s); fprintf(MSG_OUT, "ERROR: %s returns %s\n", where, s);
/* ignore this error */ /* ignore this error */
return; return;
@ -359,15 +359,15 @@ static void new_conn(char *url, GlobalInfo *g)
static void fifo_cb(int fd, short event, void *arg) static void fifo_cb(int fd, short event, void *arg)
{ {
char s[1024]; char s[1024];
long int rv=0; long int rv = 0;
int n=0; int n = 0;
GlobalInfo *g = (GlobalInfo *)arg; GlobalInfo *g = (GlobalInfo *)arg;
(void)fd; /* unused */ (void)fd; /* unused */
(void)event; /* unused */ (void)event; /* unused */
do { do {
s[0]='\0'; s[0]='\0';
rv=fscanf(g->input, "%1023s%n", s, &n); rv = fscanf(g->input, "%1023s%n", s, &n);
s[n]='\0'; s[n]='\0';
if(n && s[0]) { if(n && s[0]) {
new_conn(s, arg); /* if we read a URL, go get it! */ new_conn(s, arg); /* if we read a URL, go get it! */

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2017, 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
@ -52,7 +52,7 @@ void dumpNode(TidyDoc doc, TidyNode tnod, int indent)
TidyAttr attr; TidyAttr attr;
printf("%*.*s%s ", indent, indent, "<", name); printf("%*.*s%s ", indent, indent, "<", name);
/* walk the attribute list */ /* walk the attribute list */
for(attr=tidyAttrFirst(child); attr; attr=tidyAttrNext(attr) ) { for(attr = tidyAttrFirst(child); attr; attr = tidyAttrNext(attr) ) {
printf(tidyAttrName(attr)); printf(tidyAttrName(attr));
tidyAttrValue(attr)?printf("=\"%s\" ", tidyAttrValue(attr)?printf("=\"%s\" ",
tidyAttrValue(attr)):printf(" "); tidyAttrValue(attr)):printf(" ");
@ -95,7 +95,7 @@ int main(int argc, char **argv)
tidyBufInit(&docbuf); tidyBufInit(&docbuf);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &docbuf); curl_easy_setopt(curl, CURLOPT_WRITEDATA, &docbuf);
err=curl_easy_perform(curl); err = curl_easy_perform(curl);
if(!err) { if(!err) {
err = tidyParseBuffer(tdoc, &docbuf); /* parse the input */ err = tidyParseBuffer(tdoc, &docbuf); /* parse the input */
if(err >= 0) { if(err >= 0) {

View File

@ -51,7 +51,7 @@ static int num_transfers;
static int hnd2num(CURL *hnd) static int hnd2num(CURL *hnd)
{ {
int i; int i;
for(i=0; i< num_transfers; i++) { for(i = 0; i< num_transfers; i++) {
if(curl_hnd[i] == hnd) if(curl_hnd[i] == hnd)
return i; return i;
} }
@ -65,7 +65,7 @@ void dump(const char *text, int num, unsigned char *ptr, size_t size,
size_t i; size_t i;
size_t c; size_t c;
unsigned int width=0x10; unsigned int width = 0x10;
if(nohex) if(nohex)
/* without the hex output, we can fit more on screen */ /* without the hex output, we can fit more on screen */
@ -74,7 +74,7 @@ void dump(const char *text, int num, unsigned char *ptr, size_t size,
fprintf(stderr, "%d %s, %ld bytes (0x%lx)\n", fprintf(stderr, "%d %s, %ld bytes (0x%lx)\n",
num, text, (long)size, (long)size); num, text, (long)size, (long)size);
for(i=0; i<size; i+= width) { for(i = 0; i<size; i+= width) {
fprintf(stderr, "%4.4lx: ", (long)i); fprintf(stderr, "%4.4lx: ", (long)i);
@ -89,14 +89,14 @@ void dump(const char *text, int num, unsigned char *ptr, size_t size,
for(c = 0; (c < width) && (i+c < size); c++) { for(c = 0; (c < width) && (i+c < size); c++) {
/* check for 0D0A; if found, skip past and start a new line of output */ /* check for 0D0A; if found, skip past and start a new line of output */
if(nohex && (i+c+1 < size) && ptr[i+c]==0x0D && ptr[i+c+1]==0x0A) { if(nohex && (i+c+1 < size) && ptr[i+c] == 0x0D && ptr[i+c+1] == 0x0A) {
i+=(c+2-width); i+=(c+2-width);
break; break;
} }
fprintf(stderr, "%c", fprintf(stderr, "%c",
(ptr[i+c]>=0x20) && (ptr[i+c]<0x80)?ptr[i+c]:'.'); (ptr[i+c] >= 0x20) && (ptr[i+c]<0x80)?ptr[i+c]:'.');
/* check again for 0D0A, to avoid an extra \n if it's at width */ /* check again for 0D0A, to avoid an extra \n if it's at width */
if(nohex && (i+c+2 < size) && ptr[i+c+1]==0x0D && ptr[i+c+2]==0x0A) { if(nohex && (i+c+2 < size) && ptr[i+c+1] == 0x0D && ptr[i+c+2] == 0x0A) {
i+=(c+3-width); i+=(c+3-width);
break; break;
} }
@ -199,7 +199,7 @@ int main(int argc, char **argv)
/* init a multi stack */ /* init a multi stack */
multi_handle = curl_multi_init(); multi_handle = curl_multi_init();
for(i=0; i<num_transfers; i++) { for(i = 0; i<num_transfers; i++) {
easy[i] = curl_easy_init(); easy[i] = curl_easy_init();
/* set options */ /* set options */
setup(easy[i], i); setup(easy[i], i);
@ -286,7 +286,7 @@ int main(int argc, char **argv)
curl_multi_cleanup(multi_handle); curl_multi_cleanup(multi_handle);
for(i=0; i<num_transfers; i++) for(i = 0; i<num_transfers; i++)
curl_easy_cleanup(easy[i]); curl_easy_cleanup(easy[i]);
return 0; return 0;

View File

@ -45,7 +45,7 @@ void dump(const char *text, unsigned char *ptr, size_t size,
size_t i; size_t i;
size_t c; size_t c;
unsigned int width=0x10; unsigned int width = 0x10;
if(nohex) if(nohex)
/* without the hex output, we can fit more on screen */ /* without the hex output, we can fit more on screen */
@ -54,7 +54,7 @@ void dump(const char *text, unsigned char *ptr, size_t size,
fprintf(stderr, "%s, %ld bytes (0x%lx)\n", fprintf(stderr, "%s, %ld bytes (0x%lx)\n",
text, (long)size, (long)size); text, (long)size, (long)size);
for(i=0; i<size; i+= width) { for(i = 0; i<size; i+= width) {
fprintf(stderr, "%4.4lx: ", (long)i); fprintf(stderr, "%4.4lx: ", (long)i);
@ -69,14 +69,14 @@ void dump(const char *text, unsigned char *ptr, size_t size,
for(c = 0; (c < width) && (i+c < size); c++) { for(c = 0; (c < width) && (i+c < size); c++) {
/* check for 0D0A; if found, skip past and start a new line of output */ /* check for 0D0A; if found, skip past and start a new line of output */
if(nohex && (i+c+1 < size) && ptr[i+c]==0x0D && ptr[i+c+1]==0x0A) { if(nohex && (i+c+1 < size) && ptr[i+c] == 0x0D && ptr[i+c+1] == 0x0A) {
i+=(c+2-width); i+=(c+2-width);
break; break;
} }
fprintf(stderr, "%c", fprintf(stderr, "%c",
(ptr[i+c]>=0x20) && (ptr[i+c]<0x80)?ptr[i+c]:'.'); (ptr[i+c] >= 0x20) && (ptr[i+c]<0x80)?ptr[i+c]:'.');
/* check again for 0D0A, to avoid an extra \n if it's at width */ /* check again for 0D0A, to avoid an extra \n if it's at width */
if(nohex && (i+c+2 < size) && ptr[i+c+1]==0x0D && ptr[i+c+2]==0x0A) { if(nohex && (i+c+2 < size) && ptr[i+c+1] == 0x0D && ptr[i+c+2] == 0x0A) {
i+=(c+3-width); i+=(c+3-width);
break; break;
} }
@ -181,7 +181,7 @@ static int server_push_callback(CURL *parent,
fprintf(stderr, "**** push callback approves stream %u, got %d headers!\n", fprintf(stderr, "**** push callback approves stream %u, got %d headers!\n",
count, (int)num_headers); count, (int)num_headers);
for(i=0; i<num_headers; i++) { for(i = 0; i<num_headers; i++) {
headp = curl_pushheader_bynum(headers, i); headp = curl_pushheader_bynum(headers, i);
fprintf(stderr, "**** header %u: %s\n", (int)i, headp); fprintf(stderr, "**** header %u: %s\n", (int)i, headp);
} }
@ -204,7 +204,7 @@ int main(void)
CURL *easy; CURL *easy;
CURLM *multi_handle; CURLM *multi_handle;
int still_running; /* keep number of running handles */ int still_running; /* keep number of running handles */
int transfers=1; /* we start with one */ int transfers = 1; /* we start with one */
struct CURLMsg *m; struct CURLMsg *m;
/* init a multi stack */ /* init a multi stack */

View File

@ -53,7 +53,7 @@ static int num_transfers;
static int hnd2num(CURL *hnd) static int hnd2num(CURL *hnd)
{ {
int i; int i;
for(i=0; i< num_transfers; i++) { for(i = 0; i< num_transfers; i++) {
if(curl_hnd[i] == hnd) if(curl_hnd[i] == hnd)
return i; return i;
} }
@ -66,7 +66,7 @@ void dump(const char *text, int num, unsigned char *ptr, size_t size,
{ {
size_t i; size_t i;
size_t c; size_t c;
unsigned int width=0x10; unsigned int width = 0x10;
if(nohex) if(nohex)
/* without the hex output, we can fit more on screen */ /* without the hex output, we can fit more on screen */
@ -75,7 +75,7 @@ void dump(const char *text, int num, unsigned char *ptr, size_t size,
fprintf(stderr, "%d %s, %ld bytes (0x%lx)\n", fprintf(stderr, "%d %s, %ld bytes (0x%lx)\n",
num, text, (long)size, (long)size); num, text, (long)size, (long)size);
for(i=0; i<size; i+= width) { for(i = 0; i<size; i+= width) {
fprintf(stderr, "%4.4lx: ", (long)i); fprintf(stderr, "%4.4lx: ", (long)i);
@ -90,14 +90,14 @@ void dump(const char *text, int num, unsigned char *ptr, size_t size,
for(c = 0; (c < width) && (i+c < size); c++) { for(c = 0; (c < width) && (i+c < size); c++) {
/* check for 0D0A; if found, skip past and start a new line of output */ /* check for 0D0A; if found, skip past and start a new line of output */
if(nohex && (i+c+1 < size) && ptr[i+c]==0x0D && ptr[i+c+1]==0x0A) { if(nohex && (i+c+1 < size) && ptr[i+c] == 0x0D && ptr[i+c+1] == 0x0A) {
i+=(c+2-width); i+=(c+2-width);
break; break;
} }
fprintf(stderr, "%c", fprintf(stderr, "%c",
(ptr[i+c]>=0x20) && (ptr[i+c]<0x80)?ptr[i+c]:'.'); (ptr[i+c] >= 0x20) && (ptr[i+c]<0x80)?ptr[i+c]:'.');
/* check again for 0D0A, to avoid an extra \n if it's at width */ /* check again for 0D0A, to avoid an extra \n if it's at width */
if(nohex && (i+c+2 < size) && ptr[i+c+1]==0x0D && ptr[i+c+2]==0x0A) { if(nohex && (i+c+2 < size) && ptr[i+c+1] == 0x0D && ptr[i+c+2] == 0x0A) {
i+=(c+3-width); i+=(c+3-width);
break; break;
} }
@ -260,7 +260,7 @@ int main(int argc, char **argv)
/* init a multi stack */ /* init a multi stack */
multi_handle = curl_multi_init(); multi_handle = curl_multi_init();
for(i=0; i<num_transfers; i++) { for(i = 0; i<num_transfers; i++) {
easy[i] = curl_easy_init(); easy[i] = curl_easy_init();
/* set options */ /* set options */
setup(easy[i], i, filename); setup(easy[i], i, filename);
@ -350,7 +350,7 @@ int main(int argc, char **argv)
curl_multi_cleanup(multi_handle); curl_multi_cleanup(multi_handle);
for(i=0; i<num_transfers; i++) for(i = 0; i<num_transfers; i++)
curl_easy_cleanup(easy[i]); curl_easy_cleanup(easy[i]);
return 0; return 0;

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2017, 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
@ -69,7 +69,7 @@ int main(int argc, char **argv)
if(argc < 3) if(argc < 3)
return 1; return 1;
file= argv[1]; file = argv[1];
url = argv[2]; url = argv[2];
/* get the file size of the local file */ /* get the file size of the local file */

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2017, 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
@ -55,7 +55,7 @@ int main(void)
int msgs_left; /* how many messages are left */ int msgs_left; /* how many messages are left */
/* Allocate one CURL handle per transfer */ /* Allocate one CURL handle per transfer */
for(i=0; i<HANDLECOUNT; i++) for(i = 0; i<HANDLECOUNT; i++)
handles[i] = curl_easy_init(); handles[i] = curl_easy_init();
/* set the options (I left out a few, you'll get the point anyway) */ /* set the options (I left out a few, you'll get the point anyway) */
@ -68,7 +68,7 @@ int main(void)
multi_handle = curl_multi_init(); multi_handle = curl_multi_init();
/* add the individual transfers */ /* add the individual transfers */
for(i=0; i<HANDLECOUNT; i++) for(i = 0; i<HANDLECOUNT; i++)
curl_multi_add_handle(multi_handle, handles[i]); curl_multi_add_handle(multi_handle, handles[i]);
/* we start some action by calling perform right away */ /* we start some action by calling perform right away */
@ -150,7 +150,7 @@ int main(void)
int idx, found = 0; int idx, found = 0;
/* Find out which handle this message is about */ /* Find out which handle this message is about */
for(idx=0; idx<HANDLECOUNT; idx++) { for(idx = 0; idx<HANDLECOUNT; idx++) {
found = (msg->easy_handle == handles[idx]); found = (msg->easy_handle == handles[idx]);
if(found) if(found)
break; break;
@ -170,7 +170,7 @@ int main(void)
curl_multi_cleanup(multi_handle); curl_multi_cleanup(multi_handle);
/* Free the CURL handles */ /* Free the CURL handles */
for(i=0; i<HANDLECOUNT; i++) for(i = 0; i<HANDLECOUNT; i++)
curl_easy_cleanup(handles[i]); curl_easy_cleanup(handles[i]);
return 0; return 0;

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2017, 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
@ -45,7 +45,7 @@ void dump(const char *text,
size_t i; size_t i;
size_t c; size_t c;
unsigned int width=0x10; unsigned int width = 0x10;
if(nohex) if(nohex)
/* without the hex output, we can fit more on screen */ /* without the hex output, we can fit more on screen */
@ -54,7 +54,7 @@ void dump(const char *text,
fprintf(stream, "%s, %10.10ld bytes (0x%8.8lx)\n", fprintf(stream, "%s, %10.10ld bytes (0x%8.8lx)\n",
text, (long)size, (long)size); text, (long)size, (long)size);
for(i=0; i<size; i+= width) { for(i = 0; i<size; i+= width) {
fprintf(stream, "%4.4lx: ", (long)i); fprintf(stream, "%4.4lx: ", (long)i);
@ -69,14 +69,14 @@ void dump(const char *text,
for(c = 0; (c < width) && (i+c < size); c++) { for(c = 0; (c < width) && (i+c < size); c++) {
/* check for 0D0A; if found, skip past and start a new line of output */ /* check for 0D0A; if found, skip past and start a new line of output */
if(nohex && (i+c+1 < size) && ptr[i+c]==0x0D && ptr[i+c+1]==0x0A) { if(nohex && (i+c+1 < size) && ptr[i+c] == 0x0D && ptr[i+c+1] == 0x0A) {
i+=(c+2-width); i+=(c+2-width);
break; break;
} }
fprintf(stream, "%c", fprintf(stream, "%c",
(ptr[i+c]>=0x20) && (ptr[i+c]<0x80)?ptr[i+c]:'.'); (ptr[i+c] >= 0x20) && (ptr[i+c]<0x80)?ptr[i+c]:'.');
/* check again for 0D0A, to avoid an extra \n if it's at width */ /* check again for 0D0A, to avoid an extra \n if it's at width */
if(nohex && (i+c+2 < size) && ptr[i+c+1]==0x0D && ptr[i+c+2]==0x0A) { if(nohex && (i+c+2 < size) && ptr[i+c+1] == 0x0D && ptr[i+c+2] == 0x0A) {
i+=(c+3-width); i+=(c+3-width);
break; break;
} }

View File

@ -74,7 +74,7 @@ int main(int argc, char **argv)
/* Must initialize libcurl before any threads are started */ /* Must initialize libcurl before any threads are started */
curl_global_init(CURL_GLOBAL_ALL); curl_global_init(CURL_GLOBAL_ALL);
for(i=0; i< NUMT; i++) { for(i = 0; i< NUMT; i++) {
error = pthread_create(&tid[i], error = pthread_create(&tid[i],
NULL, /* default attributes please */ NULL, /* default attributes please */
pull_one_url, pull_one_url,
@ -86,7 +86,7 @@ int main(int argc, char **argv)
} }
/* now wait for all threads to terminate */ /* now wait for all threads to terminate */
for(i=0; i< NUMT; i++) { for(i = 0; i< NUMT; i++) {
error = pthread_join(tid[i], NULL); error = pthread_join(tid[i], NULL);
fprintf(stderr, "Thread %d terminated\n", i); fprintf(stderr, "Thread %d terminated\n", i);
} }

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2017, 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
@ -50,7 +50,7 @@ void handle_error(const char *file, int lineno, const char *msg)
} }
/* This array will store all of the mutexes available to OpenSSL. */ /* This array will store all of the mutexes available to OpenSSL. */
static MUTEX_TYPE *mutex_buf= NULL; static MUTEX_TYPE *mutex_buf = NULL;
static void locking_function(int mode, int n, const char *file, int line) static void locking_function(int mode, int n, const char *file, int line)
{ {

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2017, 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
@ -58,7 +58,7 @@ int main(void)
CURL *curl; CURL *curl;
CURLcode res; CURLcode res;
struct MemoryStruct chunk; struct MemoryStruct chunk;
static const char *postthis="Field=1&Field=2&Field=3"; static const char *postthis = "Field=1&Field=2&Field=3";
chunk.memory = malloc(1); /* will be grown as needed by realloc above */ chunk.memory = malloc(1); /* will be grown as needed by realloc above */
chunk.size = 0; /* no data at this point */ chunk.size = 0; /* no data at this point */

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2017, 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
@ -36,7 +36,7 @@ static int wait_on_socket(curl_socket_t sockfd, int for_recv, long timeout_ms)
int res; int res;
tv.tv_sec = timeout_ms / 1000; tv.tv_sec = timeout_ms / 1000;
tv.tv_usec= (timeout_ms % 1000) * 1000; tv.tv_usec = (timeout_ms % 1000) * 1000;
FD_ZERO(&infd); FD_ZERO(&infd);
FD_ZERO(&outfd); FD_ZERO(&outfd);

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2017, 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
@ -46,10 +46,10 @@ struct FtpFile {
static size_t my_fwrite(void *buffer, size_t size, size_t nmemb, static size_t my_fwrite(void *buffer, size_t size, size_t nmemb,
void *stream) void *stream)
{ {
struct FtpFile *out=(struct FtpFile *)stream; struct FtpFile *out = (struct FtpFile *)stream;
if(out && !out->stream) { if(out && !out->stream) {
/* open file for writing */ /* open file for writing */
out->stream=fopen(out->filename, "wb"); out->stream = fopen(out->filename, "wb");
if(!out->stream) if(!out->stream)
return -1; /* failure, can't open file to write */ return -1; /* failure, can't open file to write */
} }
@ -61,7 +61,7 @@ int main(void)
{ {
CURL *curl; CURL *curl;
CURLcode res; CURLcode res;
struct FtpFile ftpfile={ struct FtpFile ftpfile = {
"yourfile.bin", /* name to store the file as if successful */ "yourfile.bin", /* name to store the file as if successful */
NULL NULL
}; };

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2017, 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
@ -32,7 +32,7 @@ int main(void)
CURL *curl; CURL *curl;
CURLcode res; CURLcode res;
static const char *postthis="moo mooo moo moo"; static const char *postthis = "moo mooo moo moo";
curl = curl_easy_init(); curl = curl_easy_init();
if(curl) { if(curl) {

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2017, 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
@ -53,7 +53,7 @@ int main(void)
const char *pPassphrase = NULL; const char *pPassphrase = NULL;
static const char *pCertFile = "testcert.pem"; static const char *pCertFile = "testcert.pem";
static const char *pCACertFile="cacert.pem"; static const char *pCACertFile = "cacert.pem";
static const char *pHeaderFile = "dumpit"; static const char *pHeaderFile = "dumpit";
const char *pKeyName; const char *pKeyName;

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2017, 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
@ -134,7 +134,7 @@ void *create_thread(void *progress_bar)
int error; int error;
/* Make sure I don't create more threads than urls. */ /* Make sure I don't create more threads than urls. */
for(i=0; i < NUMT && i < num_urls ; i++) { for(i = 0; i < NUMT && i < num_urls ; i++) {
error = pthread_create(&tid[i], error = pthread_create(&tid[i],
NULL, /* default attributes please */ NULL, /* default attributes please */
pull_one_url, pull_one_url,
@ -146,7 +146,7 @@ void *create_thread(void *progress_bar)
} }
/* Wait for all threads to terminate. */ /* Wait for all threads to terminate. */
for(i=0; i < NUMT && i < num_urls; i++) { for(i = 0; i < NUMT && i < num_urls; i++) {
error = pthread_join(tid[i], NULL); error = pthread_join(tid[i], NULL);
fprintf(stderr, "Thread %d terminated\n", i); fprintf(stderr, "Thread %d terminated\n", i);
} }

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2017, 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
@ -158,7 +158,7 @@ size_t SyncTime_CURL_WriteHeader(void *ptr, size_t size, size_t nmemb,
if(RetVal == 7) { if(RetVal == 7) {
SYSTime.wMilliseconds = 500; /* adjust to midpoint, 0.5 sec */ SYSTime.wMilliseconds = 500; /* adjust to midpoint, 0.5 sec */
for(i=0; i<12; i++) { for(i = 0; i<12; i++) {
if(strcmp(MthStr[i], TmpStr2) == 0) { if(strcmp(MthStr[i], TmpStr2) == 0) {
SYSTime.wMonth = i+1; SYSTime.wMonth = i+1;
break; break;
@ -243,7 +243,7 @@ int conf_init(conf_t *conf)
int i; int i;
*conf->http_proxy = 0; *conf->http_proxy = 0;
for(i=0; i<MAX_STRING1; i++) for(i = 0; i<MAX_STRING1; i++)
conf->proxy_user[i] = 0; /* Clean up password from memory */ conf->proxy_user[i] = 0; /* Clean up password from memory */
*conf->timeserver = 0; *conf->timeserver = 0;
return 1; return 1;

View File

@ -63,7 +63,7 @@ static unsigned long thread_id(void)
{ {
unsigned long ret; unsigned long ret;
ret=(unsigned long)pthread_self(); ret = (unsigned long)pthread_self();
return ret; return ret;
} }
@ -71,9 +71,9 @@ static void init_locks(void)
{ {
int i; int i;
lockarray=(pthread_mutex_t *)OPENSSL_malloc(CRYPTO_num_locks() * lockarray = (pthread_mutex_t *)OPENSSL_malloc(CRYPTO_num_locks() *
sizeof(pthread_mutex_t)); sizeof(pthread_mutex_t));
for(i=0; i<CRYPTO_num_locks(); i++) { for(i = 0; i<CRYPTO_num_locks(); i++) {
pthread_mutex_init(&(lockarray[i]), NULL); pthread_mutex_init(&(lockarray[i]), NULL);
} }
@ -86,7 +86,7 @@ static void kill_locks(void)
int i; int i;
CRYPTO_set_locking_callback(NULL); CRYPTO_set_locking_callback(NULL);
for(i=0; i<CRYPTO_num_locks(); i++) for(i = 0; i<CRYPTO_num_locks(); i++)
pthread_mutex_destroy(&(lockarray[i])); pthread_mutex_destroy(&(lockarray[i]));
OPENSSL_free(lockarray); OPENSSL_free(lockarray);
@ -144,7 +144,7 @@ int main(int argc, char **argv)
init_locks(); init_locks();
for(i=0; i< NUMT; i++) { for(i = 0; i< NUMT; i++) {
error = pthread_create(&tid[i], error = pthread_create(&tid[i],
NULL, /* default attributes please */ NULL, /* default attributes please */
pull_one_url, pull_one_url,
@ -156,7 +156,7 @@ int main(int argc, char **argv)
} }
/* now wait for all threads to terminate */ /* now wait for all threads to terminate */
for(i=0; i< NUMT; i++) { for(i = 0; i< NUMT; i++) {
error = pthread_join(tid[i], NULL); error = pthread_join(tid[i], NULL);
fprintf(stderr, "Thread %d terminated\n", i); fprintf(stderr, "Thread %d terminated\n", i);
} }

View File

@ -200,7 +200,7 @@ int main(void)
/* first try: retrieve page without user certificate and key -> will fail /* first try: retrieve page without user certificate and key -> will fail
*/ */
rv = curl_easy_perform(ch); rv = curl_easy_perform(ch);
if(rv==CURLE_OK) { if(rv == CURLE_OK) {
printf("*** transfer succeeded ***\n"); printf("*** transfer succeeded ***\n");
} }
else { else {
@ -213,7 +213,7 @@ int main(void)
*/ */
rv = curl_easy_setopt(ch, CURLOPT_SSL_CTX_FUNCTION, *sslctx_function); rv = curl_easy_setopt(ch, CURLOPT_SSL_CTX_FUNCTION, *sslctx_function);
rv = curl_easy_perform(ch); rv = curl_easy_perform(ch);
if(rv==CURLE_OK) { if(rv == CURLE_OK) {
printf("*** transfer succeeded ***\n"); printf("*** transfer succeeded ***\n");
} }
else { else {

View File

@ -260,7 +260,7 @@ static int waitperform(struct connectdata *conn, int timeout_ms)
bitmask = ares_getsock((ares_channel)data->state.resolver, socks, bitmask = ares_getsock((ares_channel)data->state.resolver, socks,
ARES_GETSOCK_MAXNUM); ARES_GETSOCK_MAXNUM);
for(i=0; i < ARES_GETSOCK_MAXNUM; i++) { for(i = 0; i < ARES_GETSOCK_MAXNUM; i++) {
pfd[i].events = 0; pfd[i].events = 0;
pfd[i].revents = 0; pfd[i].revents = 0;
if(ARES_GETSOCK_READABLE(bitmask, i)) { if(ARES_GETSOCK_READABLE(bitmask, i)) {
@ -289,7 +289,7 @@ static int waitperform(struct connectdata *conn, int timeout_ms)
ARES_SOCKET_BAD); ARES_SOCKET_BAD);
else { else {
/* move through the descriptors and ask for processing on them */ /* move through the descriptors and ask for processing on them */
for(i=0; i < num; i++) for(i = 0; i < num; i++)
ares_process_fd((ares_channel)data->state.resolver, ares_process_fd((ares_channel)data->state.resolver,
pfd[i].revents & (POLLRDNORM|POLLIN)? pfd[i].revents & (POLLRDNORM|POLLIN)?
pfd[i].fd:ARES_SOCKET_BAD, pfd[i].fd:ARES_SOCKET_BAD,

View File

@ -249,7 +249,7 @@ static CURLcode bindlocal(struct connectdata *conn,
struct sockaddr_in6 *si6 = (struct sockaddr_in6 *)&sa; struct sockaddr_in6 *si6 = (struct sockaddr_in6 *)&sa;
#endif #endif
struct Curl_dns_entry *h=NULL; struct Curl_dns_entry *h = NULL;
unsigned short port = data->set.localport; /* use this port number, 0 for unsigned short port = data->set.localport; /* use this port number, 0 for
"random" */ "random" */
/* how many port numbers to try to bind to, increasing one at a time */ /* how many port numbers to try to bind to, increasing one at a time */
@ -748,7 +748,7 @@ CURLcode Curl_is_connected(struct connectdata *conn,
return CURLE_OPERATION_TIMEDOUT; return CURLE_OPERATION_TIMEDOUT;
} }
for(i=0; i<2; i++) { for(i = 0; i<2; i++) {
const int other = i ^ 1; const int other = i ^ 1;
if(conn->tempsock[i] == CURL_SOCKET_BAD) if(conn->tempsock[i] == CURL_SOCKET_BAD)
continue; continue;
@ -900,7 +900,7 @@ void Curl_tcpnodelay(struct connectdata *conn, curl_socket_t sockfd)
static void nosigpipe(struct connectdata *conn, static void nosigpipe(struct connectdata *conn,
curl_socket_t sockfd) curl_socket_t sockfd)
{ {
struct Curl_easy *data= conn->data; struct Curl_easy *data = conn->data;
int onoff = 1; int onoff = 1;
if(setsockopt(sockfd, SOL_SOCKET, SO_NOSIGPIPE, (void *)&onoff, if(setsockopt(sockfd, SOL_SOCKET, SO_NOSIGPIPE, (void *)&onoff,
sizeof(onoff)) < 0) sizeof(onoff)) < 0)
@ -1333,7 +1333,7 @@ CURLcode Curl_socket(struct connectdata *conn,
addr->family = ai->ai_family; addr->family = ai->ai_family;
addr->socktype = conn->socktype; addr->socktype = conn->socktype;
addr->protocol = conn->socktype==SOCK_DGRAM?IPPROTO_UDP:ai->ai_protocol; addr->protocol = conn->socktype == SOCK_DGRAM?IPPROTO_UDP:ai->ai_protocol;
addr->addrlen = ai->ai_addrlen; addr->addrlen = ai->ai_addrlen;
if(addr->addrlen > sizeof(struct Curl_sockaddr_storage)) if(addr->addrlen > sizeof(struct Curl_sockaddr_storage))

View File

@ -377,7 +377,7 @@ Curl_cookie_add(struct Curl_easy *data,
struct Cookie *clist; struct Cookie *clist;
char name[MAX_NAME]; char name[MAX_NAME];
struct Cookie *co; struct Cookie *co;
struct Cookie *lastc=NULL; struct Cookie *lastc = NULL;
time_t now = time(NULL); time_t now = time(NULL);
bool replace_old = FALSE; bool replace_old = FALSE;
bool badcookie = FALSE; /* cookies are good by default. mmmmm yummy */ bool badcookie = FALSE; /* cookies are good by default. mmmmm yummy */
@ -407,7 +407,7 @@ Curl_cookie_add(struct Curl_easy *data,
return NULL; return NULL;
} }
semiptr=strchr(lineptr, ';'); /* first, find a semicolon */ semiptr = strchr(lineptr, ';'); /* first, find a semicolon */
while(*lineptr && ISBLANK(*lineptr)) while(*lineptr && ISBLANK(*lineptr))
lineptr++; lineptr++;
@ -415,7 +415,7 @@ Curl_cookie_add(struct Curl_easy *data,
ptr = lineptr; ptr = lineptr;
do { do {
/* we have a <what>=<this> pair or a stand-alone word here */ /* we have a <what>=<this> pair or a stand-alone word here */
name[0]=what[0]=0; /* init the buffers */ name[0] = what[0] = 0; /* init the buffers */
if(1 <= sscanf(ptr, "%" MAX_NAME_TXT "[^;\r\n=] =%" if(1 <= sscanf(ptr, "%" MAX_NAME_TXT "[^;\r\n=] =%"
MAX_COOKIE_LINE_TXT "[^;\r\n]", MAX_COOKIE_LINE_TXT "[^;\r\n]",
name, what)) { name, what)) {
@ -425,7 +425,7 @@ Curl_cookie_add(struct Curl_easy *data,
const char *whatptr; const char *whatptr;
bool done = FALSE; bool done = FALSE;
bool sep; bool sep;
size_t len=strlen(what); size_t len = strlen(what);
size_t nlen = strlen(name); size_t nlen = strlen(name);
const char *endofn = &ptr[ nlen ]; const char *endofn = &ptr[ nlen ];
@ -440,18 +440,18 @@ Curl_cookie_add(struct Curl_easy *data,
endofn--; endofn--;
nlen--; nlen--;
} }
name[nlen]=0; /* new end of name */ name[nlen] = 0; /* new end of name */
} }
} }
/* Strip off trailing whitespace from the 'what' */ /* Strip off trailing whitespace from the 'what' */
while(len && ISBLANK(what[len-1])) { while(len && ISBLANK(what[len-1])) {
what[len-1]=0; what[len-1] = 0;
len--; len--;
} }
/* Skip leading whitespace from the 'what' */ /* Skip leading whitespace from the 'what' */
whatptr=what; whatptr = what;
while(*whatptr && ISBLANK(*whatptr)) while(*whatptr && ISBLANK(*whatptr))
whatptr++; whatptr++;
@ -510,7 +510,7 @@ Curl_cookie_add(struct Curl_easy *data,
/* check for more dots */ /* check for more dots */
dotp = strchr(whatptr, '.'); dotp = strchr(whatptr, '.');
if(!dotp && !strcasecompare("localhost", whatptr)) if(!dotp && !strcasecompare("localhost", whatptr))
domain=":"; domain = ":";
} }
#endif #endif
@ -525,14 +525,14 @@ Curl_cookie_add(struct Curl_easy *data,
break; break;
} }
if(!is_ip) if(!is_ip)
co->tailmatch=TRUE; /* we always do that if the domain name was co->tailmatch = TRUE; /* we always do that if the domain name was
given */ given */
} }
else { else {
/* we did not get a tailmatch and then the attempted set domain /* we did not get a tailmatch and then the attempted set domain
is not a domain to which the current host belongs. Mark as is not a domain to which the current host belongs. Mark as
bad. */ bad. */
badcookie=TRUE; badcookie = TRUE;
infof(data, "skipped cookie with bad tailmatch domain: %s\n", infof(data, "skipped cookie with bad tailmatch domain: %s\n",
whatptr); whatptr);
} }
@ -581,20 +581,20 @@ Curl_cookie_add(struct Curl_easy *data,
continue; continue;
} }
ptr=semiptr+1; ptr = semiptr+1;
while(*ptr && ISBLANK(*ptr)) while(*ptr && ISBLANK(*ptr))
ptr++; ptr++;
semiptr=strchr(ptr, ';'); /* now, find the next semicolon */ semiptr = strchr(ptr, ';'); /* now, find the next semicolon */
if(!semiptr && *ptr) if(!semiptr && *ptr)
/* There are no more semicolons, but there's a final name=value pair /* There are no more semicolons, but there's a final name=value pair
coming up */ coming up */
semiptr=strchr(ptr, '\0'); semiptr = strchr(ptr, '\0');
} while(semiptr); } while(semiptr);
if(co->maxage) { if(co->maxage) {
CURLofft offt; CURLofft offt;
offt = curlx_strtoofft((*co->maxage=='\"')? offt = curlx_strtoofft((*co->maxage == '\"')?
&co->maxage[1]:&co->maxage[0], NULL, 10, &co->maxage[1]:&co->maxage[0], NULL, 10,
&co->expires); &co->expires);
if(offt == CURL_OFFT_FLOW) if(offt == CURL_OFFT_FLOW)
@ -625,7 +625,7 @@ Curl_cookie_add(struct Curl_easy *data,
if(!badcookie && !co->domain) { if(!badcookie && !co->domain) {
if(domain) { if(domain) {
/* no domain was given in the header line, set the default */ /* no domain was given in the header line, set the default */
co->domain=strdup(domain); co->domain = strdup(domain);
if(!co->domain) if(!co->domain)
badcookie = TRUE; badcookie = TRUE;
} }
@ -646,10 +646,10 @@ Curl_cookie_add(struct Curl_easy *data,
endslash = memrchr(path, '/', (size_t)(queryp - path)); endslash = memrchr(path, '/', (size_t)(queryp - path));
if(endslash) { if(endslash) {
size_t pathlen = (size_t)(endslash-path+1); /* include ending slash */ size_t pathlen = (size_t)(endslash-path+1); /* include ending slash */
co->path=malloc(pathlen+1); /* one extra for the zero byte */ co->path = malloc(pathlen+1); /* one extra for the zero byte */
if(co->path) { if(co->path) {
memcpy(co->path, path, pathlen); memcpy(co->path, path, pathlen);
co->path[pathlen]=0; /* zero terminate */ co->path[pathlen] = 0; /* zero terminate */
co->spath = sanitize_cookie_path(co->path); co->spath = sanitize_cookie_path(co->path);
if(!co->spath) if(!co->spath)
badcookie = TRUE; /* out of memory bad */ badcookie = TRUE; /* out of memory bad */
@ -674,7 +674,7 @@ Curl_cookie_add(struct Curl_easy *data,
reading the odd netscape cookies-file format here */ reading the odd netscape cookies-file format here */
char *ptr; char *ptr;
char *firstptr; char *firstptr;
char *tok_buf=NULL; char *tok_buf = NULL;
int fields; int fields;
/* IE introduced HTTP-only cookies to prevent XSS attacks. Cookies /* IE introduced HTTP-only cookies to prevent XSS attacks. Cookies
@ -695,19 +695,19 @@ Curl_cookie_add(struct Curl_easy *data,
return NULL; return NULL;
} }
/* strip off the possible end-of-line characters */ /* strip off the possible end-of-line characters */
ptr=strchr(lineptr, '\r'); ptr = strchr(lineptr, '\r');
if(ptr) if(ptr)
*ptr=0; /* clear it */ *ptr = 0; /* clear it */
ptr=strchr(lineptr, '\n'); ptr = strchr(lineptr, '\n');
if(ptr) if(ptr)
*ptr=0; /* clear it */ *ptr = 0; /* clear it */
firstptr=strtok_r(lineptr, "\t", &tok_buf); /* tokenize it on the TAB */ firstptr = strtok_r(lineptr, "\t", &tok_buf); /* tokenize it on the TAB */
/* Now loop through the fields and init the struct we already have /* Now loop through the fields and init the struct we already have
allocated */ allocated */
for(ptr=firstptr, fields=0; ptr && !badcookie; for(ptr = firstptr, fields = 0; ptr && !badcookie;
ptr=strtok_r(NULL, "\t", &tok_buf), fields++) { ptr = strtok_r(NULL, "\t", &tok_buf), fields++) {
switch(fields) { switch(fields) {
case 0: case 0:
if(ptr[0]=='.') /* skip preceding dots */ if(ptr[0]=='.') /* skip preceding dots */
@ -835,7 +835,7 @@ Curl_cookie_add(struct Curl_easy *data,
if(strcasecompare(clist->domain, co->domain) && if(strcasecompare(clist->domain, co->domain) &&
(clist->tailmatch == co->tailmatch)) (clist->tailmatch == co->tailmatch))
/* The domains are identical */ /* The domains are identical */
replace_old=TRUE; replace_old = TRUE;
} }
else if(!clist->domain && !co->domain) else if(!clist->domain && !co->domain)
replace_old = TRUE; replace_old = TRUE;
@ -964,7 +964,7 @@ struct CookieInfo *Curl_cookie_init(struct Curl_easy *data,
{ {
struct CookieInfo *c; struct CookieInfo *c;
FILE *fp = NULL; FILE *fp = NULL;
bool fromfile=TRUE; bool fromfile = TRUE;
char *line = NULL; char *line = NULL;
if(NULL == inc) { if(NULL == inc) {
@ -984,7 +984,7 @@ struct CookieInfo *Curl_cookie_init(struct Curl_easy *data,
if(file && !strcmp(file, "-")) { if(file && !strcmp(file, "-")) {
fp = stdin; fp = stdin;
fromfile=FALSE; fromfile = FALSE;
} }
else if(file && !*file) { else if(file && !*file) {
/* points to a "" string */ /* points to a "" string */
@ -1005,12 +1005,12 @@ struct CookieInfo *Curl_cookie_init(struct Curl_easy *data,
while(get_line(line, MAX_COOKIE_LINE, fp)) { while(get_line(line, MAX_COOKIE_LINE, fp)) {
if(checkprefix("Set-Cookie:", line)) { if(checkprefix("Set-Cookie:", line)) {
/* This is a cookie line, get it! */ /* This is a cookie line, get it! */
lineptr=&line[11]; lineptr = &line[11];
headerline=TRUE; headerline = TRUE;
} }
else { else {
lineptr=line; lineptr = line;
headerline=FALSE; headerline = FALSE;
} }
while(*lineptr && ISBLANK(*lineptr)) while(*lineptr && ISBLANK(*lineptr))
lineptr++; lineptr++;
@ -1120,7 +1120,7 @@ struct Cookie *Curl_cookie_getlist(struct CookieInfo *c,
struct Cookie *newco; struct Cookie *newco;
struct Cookie *co; struct Cookie *co;
time_t now = time(NULL); time_t now = time(NULL);
struct Cookie *mainco=NULL; struct Cookie *mainco = NULL;
size_t matches = 0; size_t matches = 0;
bool is_ip; bool is_ip;
@ -1192,7 +1192,7 @@ struct Cookie *Curl_cookie_getlist(struct CookieInfo *c,
co = mainco; co = mainco;
for(i=0; co; co = co->next) for(i = 0; co; co = co->next)
array[i++] = co; array[i++] = co;
/* now sort the cookie pointers in path length order */ /* now sort the cookie pointers in path length order */
@ -1201,7 +1201,7 @@ struct Cookie *Curl_cookie_getlist(struct CookieInfo *c,
/* remake the linked list order according to the new order */ /* remake the linked list order according to the new order */
mainco = array[0]; /* start here */ mainco = array[0]; /* start here */
for(i=0; i<matches-1; i++) for(i = 0; i<matches-1; i++)
array[i]->next = array[i+1]; array[i]->next = array[i+1];
array[matches-1]->next = NULL; /* terminate the list */ array[matches-1]->next = NULL; /* terminate the list */
@ -1342,7 +1342,7 @@ static int cookie_output(struct CookieInfo *c, const char *dumphere)
{ {
struct Cookie *co; struct Cookie *co;
FILE *out; FILE *out;
bool use_stdout=FALSE; bool use_stdout = FALSE;
char *format_ptr; char *format_ptr;
if((NULL == c) || (0 == c->numcookies)) if((NULL == c) || (0 == c->numcookies))
@ -1356,7 +1356,7 @@ static int cookie_output(struct CookieInfo *c, const char *dumphere)
if(!strcmp("-", dumphere)) { if(!strcmp("-", dumphere)) {
/* use stdout */ /* use stdout */
out = stdout; out = stdout;
use_stdout=TRUE; use_stdout = TRUE;
} }
else { else {
out = fopen(dumphere, FOPEN_WRITETEXT); out = fopen(dumphere, FOPEN_WRITETEXT);

View File

@ -286,7 +286,7 @@ Curl_he2ai(const struct hostent *he, int port)
DEBUGASSERT((he->h_name != NULL) && (he->h_addr_list != NULL)); DEBUGASSERT((he->h_name != NULL) && (he->h_addr_list != NULL));
for(i=0; (curr = he->h_addr_list[i]) != NULL; i++) { for(i = 0; (curr = he->h_addr_list[i]) != NULL; i++) {
size_t ss_size; size_t ss_size;
#ifdef ENABLE_IPV6 #ifdef ENABLE_IPV6
@ -570,9 +570,9 @@ curl_dogetaddrinfo(const char *hostname,
int line, const char *source) int line, const char *source)
{ {
#ifdef USE_LWIPSOCK #ifdef USE_LWIPSOCK
int res=lwip_getaddrinfo(hostname, service, hints, result); int res = lwip_getaddrinfo(hostname, service, hints, result);
#else #else
int res=(getaddrinfo)(hostname, service, hints, result); int res = (getaddrinfo)(hostname, service, hints, result);
#endif #endif
if(0 == res) if(0 == res)
/* success */ /* success */

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2017, 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
@ -357,7 +357,7 @@ CURLcode Curl_output_ntlm_wb(struct connectdata *conn,
/* not set means empty */ /* not set means empty */
if(!userp) if(!userp)
userp=""; userp = "";
switch(ntlm->state) { switch(ntlm->state) {
case NTLMSTATE_TYPE1: case NTLMSTATE_TYPE1:
@ -413,7 +413,7 @@ CURLcode Curl_output_ntlm_wb(struct connectdata *conn,
/* connection is already authenticated, /* connection is already authenticated,
* don't send a header in future requests */ * don't send a header in future requests */
free(*allocuserpwd); free(*allocuserpwd);
*allocuserpwd=NULL; *allocuserpwd = NULL;
authp->done = TRUE; authp->done = TRUE;
break; break;
} }

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2017, 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
@ -98,7 +98,7 @@ static char *unescape_word(struct Curl_easy *data, const char *inputbuff)
char *ptr; char *ptr;
size_t len; size_t len;
char ch; char ch;
int olen=0; int olen = 0;
CURLcode result = Curl_urldecode(data, inputbuff, 0, &newp, &len, FALSE); CURLcode result = Curl_urldecode(data, inputbuff, 0, &newp, &len, FALSE);
if(!newp || result) if(!newp || result)
@ -117,7 +117,7 @@ static char *unescape_word(struct Curl_easy *data, const char *inputbuff)
} }
dictp[olen++] = ch; dictp[olen++] = ch;
} }
dictp[olen]=0; dictp[olen] = 0;
} }
free(newp); free(newp);
return dictp; return dictp;
@ -132,8 +132,8 @@ static CURLcode dict_do(struct connectdata *conn, bool *done)
char *strategy = NULL; char *strategy = NULL;
char *nthdef = NULL; /* This is not part of the protocol, but required char *nthdef = NULL; /* This is not part of the protocol, but required
by RFC 2229 */ by RFC 2229 */
CURLcode result=CURLE_OK; CURLcode result = CURLE_OK;
struct Curl_easy *data=conn->data; struct Curl_easy *data = conn->data;
curl_socket_t sockfd = conn->sock[FIRSTSOCKET]; curl_socket_t sockfd = conn->sock[FIRSTSOCKET];
char *path = data->state.path; char *path = data->state.path;
@ -168,7 +168,7 @@ static CURLcode dict_do(struct connectdata *conn, bool *done)
if((word == NULL) || (*word == (char)0)) { if((word == NULL) || (*word == (char)0)) {
infof(data, "lookup word is missing\n"); infof(data, "lookup word is missing\n");
word=(char *)"default"; word = (char *)"default";
} }
if((database == NULL) || (*database == (char)0)) { if((database == NULL) || (*database == (char)0)) {
database = (char *)"!"; database = (char *)"!";
@ -222,7 +222,7 @@ static CURLcode dict_do(struct connectdata *conn, bool *done)
if((word == NULL) || (*word == (char)0)) { if((word == NULL) || (*word == (char)0)) {
infof(data, "lookup word is missing\n"); infof(data, "lookup word is missing\n");
word=(char *)"default"; word = (char *)"default";
} }
if((database == NULL) || (*database == (char)0)) { if((database == NULL) || (*database == (char)0)) {
database = (char *)"!"; database = (char *)"!";

View File

@ -92,25 +92,25 @@ char *Curl_dedotdotify(const char *input)
remove that prefix from the input buffer; otherwise, */ remove that prefix from the input buffer; otherwise, */
if(!strncmp("./", clone, 2)) { if(!strncmp("./", clone, 2)) {
clone+=2; clone += 2;
clen-=2; clen -= 2;
} }
else if(!strncmp("../", clone, 3)) { else if(!strncmp("../", clone, 3)) {
clone+=3; clone += 3;
clen-=3; clen -= 3;
} }
/* B. if the input buffer begins with a prefix of "/./" or "/.", where /* B. if the input buffer begins with a prefix of "/./" or "/.", where
"." is a complete path segment, then replace that prefix with "/" in "." is a complete path segment, then replace that prefix with "/" in
the input buffer; otherwise, */ the input buffer; otherwise, */
else if(!strncmp("/./", clone, 3)) { else if(!strncmp("/./", clone, 3)) {
clone+=2; clone += 2;
clen-=2; clen -= 2;
} }
else if(!strcmp("/.", clone)) { else if(!strcmp("/.", clone)) {
clone[1]='/'; clone[1]='/';
clone++; clone++;
clen-=1; clen -= 1;
} }
/* C. if the input buffer begins with a prefix of "/../" or "/..", where /* C. if the input buffer begins with a prefix of "/../" or "/..", where
@ -119,8 +119,8 @@ char *Curl_dedotdotify(const char *input)
any) from the output buffer; otherwise, */ any) from the output buffer; otherwise, */
else if(!strncmp("/../", clone, 4)) { else if(!strncmp("/../", clone, 4)) {
clone+=3; clone += 3;
clen-=3; clen -= 3;
/* remove the last segment from the output buffer */ /* remove the last segment from the output buffer */
while(outptr > out) { while(outptr > out) {
outptr--; outptr--;
@ -131,8 +131,8 @@ char *Curl_dedotdotify(const char *input)
} }
else if(!strcmp("/..", clone)) { else if(!strcmp("/..", clone)) {
clone[2]='/'; clone[2]='/';
clone+=2; clone += 2;
clen-=2; clen -= 2;
/* remove the last segment from the output buffer */ /* remove the last segment from the output buffer */
while(outptr > out) { while(outptr > out) {
outptr--; outptr--;
@ -146,8 +146,8 @@ char *Curl_dedotdotify(const char *input)
that from the input buffer; otherwise, */ that from the input buffer; otherwise, */
else if(!strcmp(".", clone) || !strcmp("..", clone)) { else if(!strcmp(".", clone) || !strcmp("..", clone)) {
*clone=0; *clone = 0;
*out=0; *out = 0;
} }
else { else {

View File

@ -433,7 +433,7 @@ static int events_timer(struct Curl_multi *multi, /* multi handle */
*/ */
static int poll2cselect(int pollmask) static int poll2cselect(int pollmask)
{ {
int omask=0; int omask = 0;
if(pollmask & POLLIN) if(pollmask & POLLIN)
omask |= CURL_CSELECT_IN; omask |= CURL_CSELECT_IN;
if(pollmask & POLLOUT) if(pollmask & POLLOUT)
@ -450,7 +450,7 @@ static int poll2cselect(int pollmask)
*/ */
static short socketcb2poll(int pollmask) static short socketcb2poll(int pollmask)
{ {
short omask=0; short omask = 0;
if(pollmask & CURL_POLL_IN) if(pollmask & CURL_POLL_IN)
omask |= POLLIN; omask |= POLLIN;
if(pollmask & CURL_POLL_OUT) if(pollmask & CURL_POLL_OUT)
@ -473,7 +473,7 @@ static int events_socket(struct Curl_easy *easy, /* easy handle */
{ {
struct events *ev = userp; struct events *ev = userp;
struct socketmonitor *m; struct socketmonitor *m;
struct socketmonitor *prev=NULL; struct socketmonitor *prev = NULL;
#if defined(CURL_DISABLE_VERBOSE_STRINGS) #if defined(CURL_DISABLE_VERBOSE_STRINGS)
(void) easy; (void) easy;
@ -569,14 +569,14 @@ static CURLcode wait_or_timeout(struct Curl_multi *multi, struct events *ev)
struct socketmonitor *m; struct socketmonitor *m;
struct pollfd *f; struct pollfd *f;
struct pollfd fds[4]; struct pollfd fds[4];
int numfds=0; int numfds = 0;
int pollrc; int pollrc;
int i; int i;
struct curltime before; struct curltime before;
struct curltime after; struct curltime after;
/* populate the fds[] array */ /* populate the fds[] array */
for(m = ev->list, f=&fds[0]; m; m = m->next) { for(m = ev->list, f = &fds[0]; m; m = m->next) {
f->fd = m->socket.fd; f->fd = m->socket.fd;
f->events = m->socket.events; f->events = m->socket.events;
f->revents = 0; f->revents = 0;
@ -655,7 +655,7 @@ static CURLcode easy_events(struct Curl_multi *multi)
{ {
/* this struct is made static to allow it to be used after this function /* this struct is made static to allow it to be used after this function
returns and curl_multi_remove_handle() is called */ returns and curl_multi_remove_handle() is called */
static struct events evs= {2, FALSE, 0, NULL, 0}; static struct events evs = {2, FALSE, 0, NULL, 0};
/* if running event-based, do some further multi inits */ /* if running event-based, do some further multi inits */
events_setup(multi, &evs); events_setup(multi, &evs);
@ -1027,13 +1027,13 @@ CURLcode curl_easy_pause(struct Curl_easy *data, int action)
struct tempbuf writebuf[3]; /* there can only be three */ struct tempbuf writebuf[3]; /* there can only be three */
/* copy the structs to allow for immediate re-pausing */ /* copy the structs to allow for immediate re-pausing */
for(i=0; i < data->state.tempcount; i++) { for(i = 0; i < data->state.tempcount; i++) {
writebuf[i] = data->state.tempwrite[i]; writebuf[i] = data->state.tempwrite[i];
data->state.tempwrite[i].buf = NULL; data->state.tempwrite[i].buf = NULL;
} }
data->state.tempcount = 0; data->state.tempcount = 0;
for(i=0; i < count; i++) { for(i = 0; i < count; i++) {
/* even if one function returns error, this loops through and frees all /* even if one function returns error, this loops through and frees all
buffers */ buffers */
if(!result) if(!result)

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2017, 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,7 +84,7 @@ char *curl_easy_escape(struct Curl_easy *data, const char *string,
char *testing_ptr = NULL; char *testing_ptr = NULL;
unsigned char in; /* we need to treat the characters unsigned */ unsigned char in; /* we need to treat the characters unsigned */
size_t newlen; size_t newlen;
size_t strindex=0; size_t strindex = 0;
size_t length; size_t length;
CURLcode result; CURLcode result;
@ -104,7 +104,7 @@ char *curl_easy_escape(struct Curl_easy *data, const char *string,
if(Curl_isunreserved(in)) if(Curl_isunreserved(in))
/* just copy this */ /* just copy this */
ns[strindex++]=in; ns[strindex++] = in;
else { else {
/* encode it */ /* encode it */
newlen += 2; /* the size grows with two, since this'll become a %XX */ newlen += 2; /* the size grows with two, since this'll become a %XX */
@ -125,11 +125,11 @@ char *curl_easy_escape(struct Curl_easy *data, const char *string,
snprintf(&ns[strindex], 4, "%%%02X", in); snprintf(&ns[strindex], 4, "%%%02X", in);
strindex+=3; strindex += 3;
} }
string++; string++;
} }
ns[strindex]=0; /* terminate it */ ns[strindex] = 0; /* terminate it */
return ns; return ns;
} }
@ -151,7 +151,7 @@ CURLcode Curl_urldecode(struct Curl_easy *data,
size_t alloc = (length?length:strlen(string))+1; size_t alloc = (length?length:strlen(string))+1;
char *ns = malloc(alloc); char *ns = malloc(alloc);
unsigned char in; unsigned char in;
size_t strindex=0; size_t strindex = 0;
unsigned long hex; unsigned long hex;
CURLcode result; CURLcode result;
@ -180,8 +180,8 @@ CURLcode Curl_urldecode(struct Curl_easy *data,
return result; return result;
} }
string+=2; string += 2;
alloc-=2; alloc -= 2;
} }
if(reject_ctrl && (in < 0x20)) { if(reject_ctrl && (in < 0x20)) {
@ -192,7 +192,7 @@ CURLcode Curl_urldecode(struct Curl_easy *data,
ns[strindex++] = in; ns[strindex++] = in;
string++; string++;
} }
ns[strindex]=0; /* terminate it */ ns[strindex] = 0; /* terminate it */
if(olen) if(olen)
/* store output size */ /* store output size */

View File

@ -133,7 +133,7 @@ static CURLcode file_setup_connection(struct connectdata *conn)
static CURLcode file_range(struct connectdata *conn) static CURLcode file_range(struct connectdata *conn)
{ {
curl_off_t from, to; curl_off_t from, to;
curl_off_t totalsize=-1; curl_off_t totalsize = -1;
char *ptr; char *ptr;
char *ptr2; char *ptr2;
struct Curl_easy *data = conn->data; struct Curl_easy *data = conn->data;
@ -144,7 +144,7 @@ static CURLcode file_range(struct connectdata *conn)
from_t = curlx_strtoofft(data->state.range, &ptr, 0, &from); from_t = curlx_strtoofft(data->state.range, &ptr, 0, &from);
if(from_t == CURL_OFFT_FLOW) if(from_t == CURL_OFFT_FLOW)
return CURLE_RANGE_ERROR; return CURLE_RANGE_ERROR;
while(*ptr && (ISSPACE(*ptr) || (*ptr=='-'))) while(*ptr && (ISSPACE(*ptr) || (*ptr == '-')))
ptr++; ptr++;
to_t = curlx_strtoofft(ptr, &ptr2, 0, &to); to_t = curlx_strtoofft(ptr, &ptr2, 0, &to);
if(to_t == CURL_OFFT_FLOW) if(to_t == CURL_OFFT_FLOW)
@ -228,7 +228,7 @@ static CURLcode file_connect(struct connectdata *conn, bool *done)
} }
/* change path separators from '/' to '\\' for DOS, Windows and OS/2 */ /* change path separators from '/' to '\\' for DOS, Windows and OS/2 */
for(i=0; i < real_path_len; ++i) for(i = 0; i < real_path_len; ++i)
if(actual_path[i] == '/') if(actual_path[i] == '/')
actual_path[i] = '\\'; actual_path[i] = '\\';
else if(!actual_path[i]) { /* binary zero */ else if(!actual_path[i]) { /* binary zero */
@ -430,9 +430,9 @@ static CURLcode file_do(struct connectdata *conn, bool *done)
struct_stat statbuf; /* struct_stat instead of struct stat just to allow the struct_stat statbuf; /* struct_stat instead of struct stat just to allow the
Windows version to have a different struct without Windows version to have a different struct without
having to redefine the simple word 'stat' */ having to redefine the simple word 'stat' */
curl_off_t expected_size=0; curl_off_t expected_size = 0;
bool size_known; bool size_known;
bool fstated=FALSE; bool fstated = FALSE;
ssize_t nread; ssize_t nread;
struct Curl_easy *data = conn->data; struct Curl_easy *data = conn->data;
char *buf = data->state.buffer; char *buf = data->state.buffer;

View File

@ -192,7 +192,7 @@ static const char *ContentTypeForFilename(const char *filename,
contenttype = HTTPPOST_CONTENTTYPE_DEFAULT; contenttype = HTTPPOST_CONTENTTYPE_DEFAULT;
if(filename) { /* in case a NULL was passed in */ if(filename) { /* in case a NULL was passed in */
for(i=0; i<sizeof(ctts)/sizeof(ctts[0]); i++) { for(i = 0; i<sizeof(ctts)/sizeof(ctts[0]); i++) {
if(strlen(filename) >= strlen(ctts[i].extension)) { if(strlen(filename) >= strlen(ctts[i].extension)) {
if(strcasecompare(filename + if(strcasecompare(filename +
strlen(filename) - strlen(ctts[i].extension), strlen(filename) - strlen(ctts[i].extension),
@ -267,7 +267,7 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
struct curl_httppost *post = NULL; struct curl_httppost *post = NULL;
CURLformoption option; CURLformoption option;
struct curl_forms *forms = NULL; struct curl_forms *forms = NULL;
char *array_value=NULL; /* value read from an array */ char *array_value = NULL; /* value read from an array */
/* This is a state variable, that if TRUE means that we're parsing an /* This is a state variable, that if TRUE means that we're parsing an
array that we got passed to us. If FALSE we're parsing the input array that we got passed to us. If FALSE we're parsing the input
@ -795,7 +795,7 @@ void curl_formfree(struct curl_httppost *form)
return; return;
do { do {
next=form->next; /* the following form line */ next = form->next; /* the following form line */
/* recurse to sub-contents */ /* recurse to sub-contents */
curl_formfree(form->more); curl_formfree(form->more);

111
lib/ftp.c
View File

@ -239,9 +239,9 @@ static void freedirs(struct ftp_conn *ftpc)
{ {
int i; int i;
if(ftpc->dirs) { if(ftpc->dirs) {
for(i=0; i < ftpc->dirdepth; i++) { for(i = 0; i < ftpc->dirdepth; i++) {
free(ftpc->dirs[i]); free(ftpc->dirs[i]);
ftpc->dirs[i]=NULL; ftpc->dirs[i] = NULL;
} }
free(ftpc->dirs); free(ftpc->dirs);
ftpc->dirs = NULL; ftpc->dirs = NULL;
@ -288,7 +288,7 @@ static CURLcode AcceptServerConnect(struct connectdata *conn)
if(0 == getsockname(sock, (struct sockaddr *) &add, &size)) { if(0 == getsockname(sock, (struct sockaddr *) &add, &size)) {
size = sizeof(add); size = sizeof(add);
s=accept(sock, (struct sockaddr *) &add, &size); s = accept(sock, (struct sockaddr *) &add, &size);
} }
Curl_closesocket(conn, sock); /* close the first socket */ Curl_closesocket(conn, sock); /* close the first socket */
@ -457,7 +457,7 @@ static CURLcode InitiateTransfer(struct connectdata *conn)
} }
if(conn->proto.ftpc.state_saved == FTP_STOR) { if(conn->proto.ftpc.state_saved == FTP_STOR) {
*(ftp->bytecountp)=0; *(ftp->bytecountp) = 0;
/* When we know we're uploading a specified file, we can get the file /* When we know we're uploading a specified file, we can get the file
size prior to the actual upload. */ size prior to the actual upload. */
@ -592,7 +592,7 @@ static CURLcode ftp_readresp(curl_socket_t sockfd,
#endif #endif
/* store the latest code for later retrieval */ /* store the latest code for later retrieval */
data->info.httpcode=code; data->info.httpcode = code;
if(ftpcode) if(ftpcode)
*ftpcode = code; *ftpcode = code;
@ -640,8 +640,8 @@ CURLcode Curl_GetFTPResponse(ssize_t *nreadp, /* return number of bytes read */
struct ftp_conn *ftpc = &conn->proto.ftpc; struct ftp_conn *ftpc = &conn->proto.ftpc;
struct pingpong *pp = &ftpc->pp; struct pingpong *pp = &ftpc->pp;
size_t nread; size_t nread;
int cache_skip=0; int cache_skip = 0;
int value_to_be_ignored=0; int value_to_be_ignored = 0;
if(ftpcode) if(ftpcode)
*ftpcode = 0; /* 0 for errors */ *ftpcode = 0; /* 0 for errors */
@ -649,13 +649,13 @@ CURLcode Curl_GetFTPResponse(ssize_t *nreadp, /* return number of bytes read */
/* make the pointer point to something for the rest of this function */ /* make the pointer point to something for the rest of this function */
ftpcode = &value_to_be_ignored; ftpcode = &value_to_be_ignored;
*nreadp=0; *nreadp = 0;
while(!*ftpcode && !result) { while(!*ftpcode && !result) {
/* check and reset timeout value every lap */ /* check and reset timeout value every lap */
timeout = Curl_pp_state_timeout(pp); timeout = Curl_pp_state_timeout(pp);
if(timeout <=0) { if(timeout <= 0) {
failf(data, "FTP response timeout"); failf(data, "FTP response timeout");
return CURLE_OPERATION_TIMEDOUT; /* already too little time */ return CURLE_OPERATION_TIMEDOUT; /* already too little time */
} }
@ -713,7 +713,7 @@ CURLcode Curl_GetFTPResponse(ssize_t *nreadp, /* return number of bytes read */
else else
/* when we got data or there is no cache left, we reset the cache skip /* when we got data or there is no cache left, we reset the cache skip
counter */ counter */
cache_skip=0; cache_skip = 0;
*nreadp += nread; *nreadp += nread;
@ -848,7 +848,7 @@ static int ftp_domore_getsock(struct connectdata *conn, curl_socket_t *socks,
int i; int i;
/* PORT is used to tell the server to connect to us, and during that we /* PORT is used to tell the server to connect to us, and during that we
don't do happy eyeballs, but we do if we connect to the server */ don't do happy eyeballs, but we do if we connect to the server */
for(s=1, i=0; i<2; i++) { for(s = 1, i = 0; i<2; i++) {
if(conn->tempsock[i] != CURL_SOCKET_BAD) { if(conn->tempsock[i] != CURL_SOCKET_BAD) {
socks[s] = conn->tempsock[i]; socks[s] = conn->tempsock[i];
bits |= GETSOCK_WRITESOCK(s++); bits |= GETSOCK_WRITESOCK(s++);
@ -885,7 +885,7 @@ static CURLcode ftp_state_cwd(struct connectdata *conn)
/* count3 is set to allow a MKD to fail once. In the case when first CWD /* count3 is set to allow a MKD to fail once. In the case when first CWD
fails and then MKD fails (due to another session raced it to create the fails and then MKD fails (due to another session raced it to create the
dir) this then allows for a second try to CWD to it */ dir) this then allows for a second try to CWD to it */
ftpc->count3 = (conn->data->set.ftp_create_missing_dirs==2)?1:0; ftpc->count3 = (conn->data->set.ftp_create_missing_dirs == 2)?1:0;
if((conn->data->set.ftp_filemethod == FTPFILE_NOCWD) && !ftpc->cwdcount) if((conn->data->set.ftp_filemethod == FTPFILE_NOCWD) && !ftpc->cwdcount)
/* No CWD necessary */ /* No CWD necessary */
@ -928,15 +928,15 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
{ {
CURLcode result = CURLE_OK; CURLcode result = CURLE_OK;
struct ftp_conn *ftpc = &conn->proto.ftpc; struct ftp_conn *ftpc = &conn->proto.ftpc;
struct Curl_easy *data=conn->data; struct Curl_easy *data = conn->data;
curl_socket_t portsock= CURL_SOCKET_BAD; curl_socket_t portsock = CURL_SOCKET_BAD;
char myhost[256] = ""; char myhost[256] = "";
struct Curl_sockaddr_storage ss; struct Curl_sockaddr_storage ss;
Curl_addrinfo *res, *ai; Curl_addrinfo *res, *ai;
curl_socklen_t sslen; curl_socklen_t sslen;
char hbuf[NI_MAXHOST]; char hbuf[NI_MAXHOST];
struct sockaddr *sa=(struct sockaddr *)&ss; struct sockaddr *sa = (struct sockaddr *)&ss;
struct sockaddr_in * const sa4 = (void *)sa; struct sockaddr_in * const sa4 = (void *)sa;
#ifdef ENABLE_IPV6 #ifdef ENABLE_IPV6
struct sockaddr_in6 * const sa6 = (void *)sa; struct sockaddr_in6 * const sa6 = (void *)sa;
@ -947,7 +947,7 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
int error; int error;
char *host = NULL; char *host = NULL;
char *string_ftpport = data->set.str[STRING_FTPPORT]; char *string_ftpport = data->set.str[STRING_FTPPORT];
struct Curl_dns_entry *h=NULL; struct Curl_dns_entry *h = NULL;
unsigned short port_min = 0; unsigned short port_min = 0;
unsigned short port_max = 0; unsigned short port_max = 0;
unsigned short port; unsigned short port;
@ -1262,7 +1262,7 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
/* translate x.x.x.x to x,x,x,x */ /* translate x.x.x.x to x,x,x,x */
while(source && *source) { while(source && *source) {
if(*source == '.') if(*source == '.')
*dest=','; *dest = ',';
else else
*dest = *source; *dest = *source;
dest++; dest++;
@ -1622,7 +1622,7 @@ static CURLcode ftp_state_ul_setup(struct connectdata *conn,
} }
if(seekerr != CURL_SEEKFUNC_OK) { if(seekerr != CURL_SEEKFUNC_OK) {
curl_off_t passed=0; curl_off_t passed = 0;
if(seekerr != CURL_SEEKFUNC_CANTSEEK) { if(seekerr != CURL_SEEKFUNC_CANTSEEK) {
failf(data, "Could not seek stream"); failf(data, "Could not seek stream");
return CURLE_FTP_COULDNT_USE_REST; return CURLE_FTP_COULDNT_USE_REST;
@ -1684,7 +1684,7 @@ static CURLcode ftp_state_quote(struct connectdata *conn,
struct Curl_easy *data = conn->data; struct Curl_easy *data = conn->data;
struct FTP *ftp = data->req.protop; struct FTP *ftp = data->req.protop;
struct ftp_conn *ftpc = &conn->proto.ftpc; struct ftp_conn *ftpc = &conn->proto.ftpc;
bool quote=FALSE; bool quote = FALSE;
struct curl_slist *item; struct curl_slist *item;
switch(instate) { switch(instate) {
@ -1821,11 +1821,11 @@ static CURLcode ftp_state_pasv_resp(struct connectdata *conn,
{ {
struct ftp_conn *ftpc = &conn->proto.ftpc; struct ftp_conn *ftpc = &conn->proto.ftpc;
CURLcode result; CURLcode result;
struct Curl_easy *data=conn->data; struct Curl_easy *data = conn->data;
struct Curl_dns_entry *addr=NULL; struct Curl_dns_entry *addr = NULL;
int rc; int rc;
unsigned short connectport; /* the local port connect() should use! */ unsigned short connectport; /* the local port connect() should use! */
char *str=&data->state.buffer[4]; /* start on the first letter */ char *str = &data->state.buffer[4]; /* start on the first letter */
/* if we come here again, make sure the former name is cleared */ /* if we come here again, make sure the former name is cleared */
Curl_safefree(ftpc->newhost); Curl_safefree(ftpc->newhost);
@ -1849,9 +1849,9 @@ static CURLcode ftp_state_pasv_resp(struct connectdata *conn,
/* The four separators should be identical, or else this is an oddly /* The four separators should be identical, or else this is an oddly
formatted reply and we bail out immediately. */ formatted reply and we bail out immediately. */
for(i=1; i<4; i++) { for(i = 1; i<4; i++) {
if(separator[i] != sep1) { if(separator[i] != sep1) {
ptr=NULL; /* set to NULL to signal error */ ptr = NULL; /* set to NULL to signal error */
break; break;
} }
} }
@ -1867,7 +1867,7 @@ static CURLcode ftp_state_pasv_resp(struct connectdata *conn,
} }
} }
else else
ptr=NULL; ptr = NULL;
} }
if(!ptr) { if(!ptr) {
failf(data, "Weirdly formatted EPSV reply"); failf(data, "Weirdly formatted EPSV reply");
@ -2041,7 +2041,7 @@ static CURLcode ftp_state_mdtm_resp(struct connectdata *conn,
int ftpcode) int ftpcode)
{ {
CURLcode result = CURLE_OK; CURLcode result = CURLE_OK;
struct Curl_easy *data=conn->data; struct Curl_easy *data = conn->data;
struct FTP *ftp = data->req.protop; struct FTP *ftp = data->req.protop;
struct ftp_conn *ftpc = &conn->proto.ftpc; struct ftp_conn *ftpc = &conn->proto.ftpc;
@ -2055,7 +2055,7 @@ static CURLcode ftp_state_mdtm_resp(struct connectdata *conn,
&year, &month, &day, &hour, &minute, &second)) { &year, &month, &day, &hour, &minute, &second)) {
/* we have a time, reformat it */ /* we have a time, reformat it */
char timebuf[24]; char timebuf[24];
time_t secs=time(NULL); time_t secs = time(NULL);
snprintf(timebuf, sizeof(timebuf), snprintf(timebuf, sizeof(timebuf),
"%04d%02d%02d %02d:%02d:%02d GMT", "%04d%02d%02d %02d:%02d:%02d GMT",
@ -2071,7 +2071,7 @@ static CURLcode ftp_state_mdtm_resp(struct connectdata *conn,
if(data->set.opt_no_body && if(data->set.opt_no_body &&
ftpc->file && ftpc->file &&
data->set.get_filetime && data->set.get_filetime &&
(data->info.filetime>=0) ) { (data->info.filetime >= 0) ) {
char headerbuf[128]; char headerbuf[128];
time_t filetime = (time_t)data->info.filetime; time_t filetime = (time_t)data->info.filetime;
struct tm buffer; struct tm buffer;
@ -2147,7 +2147,7 @@ static CURLcode ftp_state_type_resp(struct connectdata *conn,
ftpstate instate) ftpstate instate)
{ {
CURLcode result = CURLE_OK; CURLcode result = CURLE_OK;
struct Curl_easy *data=conn->data; struct Curl_easy *data = conn->data;
if(ftpcode/100 != 2) { if(ftpcode/100 != 2) {
/* "sasserftpd" and "(u)r(x)bot ftpd" both responds with 226 after a /* "sasserftpd" and "(u)r(x)bot ftpd" both responds with 226 after a
@ -2176,7 +2176,7 @@ static CURLcode ftp_state_retr(struct connectdata *conn,
curl_off_t filesize) curl_off_t filesize)
{ {
CURLcode result = CURLE_OK; CURLcode result = CURLE_OK;
struct Curl_easy *data=conn->data; struct Curl_easy *data = conn->data;
struct FTP *ftp = data->req.protop; struct FTP *ftp = data->req.protop;
struct ftp_conn *ftpc = &conn->proto.ftpc; struct ftp_conn *ftpc = &conn->proto.ftpc;
@ -2259,7 +2259,7 @@ static CURLcode ftp_state_size_resp(struct connectdata *conn,
ftpstate instate) ftpstate instate)
{ {
CURLcode result = CURLE_OK; CURLcode result = CURLE_OK;
struct Curl_easy *data=conn->data; struct Curl_easy *data = conn->data;
curl_off_t filesize = -1; curl_off_t filesize = -1;
char *buf = data->state.buffer; char *buf = data->state.buffer;
@ -2336,7 +2336,7 @@ static CURLcode ftp_state_stor_resp(struct connectdata *conn,
CURLcode result = CURLE_OK; CURLcode result = CURLE_OK;
struct Curl_easy *data = conn->data; struct Curl_easy *data = conn->data;
if(ftpcode>=400) { if(ftpcode >= 400) {
failf(data, "Failed FTP upload: %0d", ftpcode); failf(data, "Failed FTP upload: %0d", ftpcode);
state(conn, FTP_STOP); state(conn, FTP_STOP);
/* oops, we never close the sockets! */ /* oops, we never close the sockets! */
@ -2394,7 +2394,7 @@ static CURLcode ftp_state_get_resp(struct connectdata *conn,
E: E:
125 Data connection already open; Transfer starting. */ 125 Data connection already open; Transfer starting. */
curl_off_t size=-1; /* default unknown size */ curl_off_t size = -1; /* default unknown size */
/* /*
@ -2418,9 +2418,9 @@ static CURLcode ftp_state_get_resp(struct connectdata *conn,
* Example D above makes this parsing a little tricky */ * Example D above makes this parsing a little tricky */
char *bytes; char *bytes;
char *buf = data->state.buffer; char *buf = data->state.buffer;
bytes=strstr(buf, " bytes"); bytes = strstr(buf, " bytes");
if(bytes--) { if(bytes--) {
long in=(long)(bytes-buf); long in = (long)(bytes-buf);
/* this is a hint there is size information in there! ;-) */ /* this is a hint there is size information in there! ;-) */
while(--in) { while(--in) {
/* scan for the left parenthesis and break there */ /* scan for the left parenthesis and break there */
@ -2428,7 +2428,7 @@ static CURLcode ftp_state_get_resp(struct connectdata *conn,
break; break;
/* skip only digits */ /* skip only digits */
if(!ISDIGIT(*bytes)) { if(!ISDIGIT(*bytes)) {
bytes=NULL; bytes = NULL;
break; break;
} }
/* one more estep backwards */ /* one more estep backwards */
@ -2600,7 +2600,7 @@ static CURLcode ftp_statemach_act(struct connectdata *conn)
{ {
CURLcode result; CURLcode result;
curl_socket_t sock = conn->sock[FIRSTSOCKET]; curl_socket_t sock = conn->sock[FIRSTSOCKET];
struct Curl_easy *data=conn->data; struct Curl_easy *data = conn->data;
int ftpcode; int ftpcode;
struct ftp_conn *ftpc = &conn->proto.ftpc; struct ftp_conn *ftpc = &conn->proto.ftpc;
struct pingpong *pp = &ftpc->pp; struct pingpong *pp = &ftpc->pp;
@ -2652,7 +2652,7 @@ static CURLcode ftp_statemach_act(struct connectdata *conn)
/* We don't have a SSL/TLS connection yet, but FTPS is /* We don't have a SSL/TLS connection yet, but FTPS is
requested. Try a FTPS connection now */ requested. Try a FTPS connection now */
ftpc->count3=0; ftpc->count3 = 0;
switch(data->set.ftpsslauth) { switch(data->set.ftpsslauth) {
case CURLFTPAUTH_DEFAULT: case CURLFTPAUTH_DEFAULT:
case CURLFTPAUTH_SSL: case CURLFTPAUTH_SSL:
@ -2775,7 +2775,7 @@ static CURLcode ftp_statemach_act(struct connectdata *conn)
case FTP_PWD: case FTP_PWD:
if(ftpcode == 257) { if(ftpcode == 257) {
char *ptr=&data->state.buffer[4]; /* start on the first letter */ char *ptr = &data->state.buffer[4]; /* start on the first letter */
const size_t buf_size = data->set.buffer_size; const size_t buf_size = data->set.buffer_size;
char *dir; char *dir;
char *store; char *store;
@ -2866,7 +2866,7 @@ static CURLcode ftp_statemach_act(struct connectdata *conn)
case FTP_SYST: case FTP_SYST:
if(ftpcode == 215) { if(ftpcode == 215) {
char *ptr=&data->state.buffer[4]; /* start on the first letter */ char *ptr = &data->state.buffer[4]; /* start on the first letter */
char *os; char *os;
char *store; char *store;
@ -2957,7 +2957,7 @@ static CURLcode ftp_statemach_act(struct connectdata *conn)
} }
else { else {
/* success */ /* success */
ftpc->count2=0; ftpc->count2 = 0;
if(++ftpc->cwdcount <= ftpc->dirdepth) { if(++ftpc->cwdcount <= ftpc->dirdepth) {
/* send next CWD */ /* send next CWD */
PPSENDF(&ftpc->pp, "CWD %s", ftpc->dirs[ftpc->cwdcount - 1]); PPSENDF(&ftpc->pp, "CWD %s", ftpc->dirs[ftpc->cwdcount - 1]);
@ -3202,11 +3202,11 @@ static CURLcode ftp_done(struct connectdata *conn, CURLcode status,
ftpc->prevpath = path; ftpc->prevpath = path;
if(flen) if(flen)
/* if 'path' is not the whole string */ /* if 'path' is not the whole string */
ftpc->prevpath[dlen]=0; /* terminate */ ftpc->prevpath[dlen] = 0; /* terminate */
} }
else { else {
/* we never changed dir */ /* we never changed dir */
ftpc->prevpath=strdup(""); ftpc->prevpath = strdup("");
free(path); free(path);
} }
if(ftpc->prevpath) if(ftpc->prevpath)
@ -3478,7 +3478,7 @@ static CURLcode ftp_range(struct connectdata *conn)
from_t = curlx_strtoofft(data->state.range, &ptr, 0, &from); from_t = curlx_strtoofft(data->state.range, &ptr, 0, &from);
if(from_t == CURL_OFFT_FLOW) if(from_t == CURL_OFFT_FLOW)
return CURLE_RANGE_ERROR; return CURLE_RANGE_ERROR;
while(*ptr && (ISSPACE(*ptr) || (*ptr=='-'))) while(*ptr && (ISSPACE(*ptr) || (*ptr == '-')))
ptr++; ptr++;
to_t = curlx_strtoofft(ptr, NULL, 0, &to); to_t = curlx_strtoofft(ptr, NULL, 0, &to);
if(to_t == CURL_OFFT_FLOW) if(to_t == CURL_OFFT_FLOW)
@ -3529,7 +3529,7 @@ static CURLcode ftp_range(struct connectdata *conn)
static CURLcode ftp_do_more(struct connectdata *conn, int *completep) static CURLcode ftp_do_more(struct connectdata *conn, int *completep)
{ {
struct Curl_easy *data=conn->data; struct Curl_easy *data = conn->data;
struct ftp_conn *ftpc = &conn->proto.ftpc; struct ftp_conn *ftpc = &conn->proto.ftpc;
CURLcode result = CURLE_OK; CURLcode result = CURLE_OK;
bool connected = FALSE; bool connected = FALSE;
@ -3696,7 +3696,7 @@ CURLcode ftp_perform(struct connectdata *conn,
bool *dophase_done) bool *dophase_done)
{ {
/* this is FTP and no proxy */ /* this is FTP and no proxy */
CURLcode result=CURLE_OK; CURLcode result = CURLE_OK;
DEBUGF(infof(conn->data, "DO phase starts\n")); DEBUGF(infof(conn->data, "DO phase starts\n"));
@ -3989,7 +3989,7 @@ CURLcode Curl_ftpsend(struct connectdata *conn, const char *cmd)
#define SBUF_SIZE 1024 #define SBUF_SIZE 1024
char s[SBUF_SIZE]; char s[SBUF_SIZE];
size_t write_len; size_t write_len;
char *sptr=s; char *sptr = s;
CURLcode result = CURLE_OK; CURLcode result = CURLE_OK;
#ifdef HAVE_GSSAPI #ifdef HAVE_GSSAPI
enum protection_level data_sec = conn->data_prot; enum protection_level data_sec = conn->data_prot;
@ -4000,9 +4000,8 @@ CURLcode Curl_ftpsend(struct connectdata *conn, const char *cmd)
return CURLE_BAD_FUNCTION_ARGUMENT; return CURLE_BAD_FUNCTION_ARGUMENT;
strcpy(&s[write_len], "\r\n"); /* append a trailing CRLF */ strcpy(&s[write_len], "\r\n"); /* append a trailing CRLF */
write_len +=2; write_len += 2;
bytes_written = 0;
bytes_written=0;
result = Curl_convert_to_network(conn->data, s, write_len); result = Curl_convert_to_network(conn->data, s, write_len);
/* Curl_convert_to_network calls failf if unsuccessful */ /* Curl_convert_to_network calls failf if unsuccessful */
@ -4080,7 +4079,7 @@ static CURLcode ftp_quit(struct connectdata *conn)
*/ */
static CURLcode ftp_disconnect(struct connectdata *conn, bool dead_connection) static CURLcode ftp_disconnect(struct connectdata *conn, bool dead_connection)
{ {
struct ftp_conn *ftpc= &conn->proto.ftpc; struct ftp_conn *ftpc = &conn->proto.ftpc;
struct pingpong *pp = &ftpc->pp; struct pingpong *pp = &ftpc->pp;
/* We cannot send quit unconditionally. If this connection is stale or /* We cannot send quit unconditionally. If this connection is stale or
@ -4176,7 +4175,7 @@ CURLcode ftp_parse_url_path(struct connectdata *conn)
ftpc->dirdepth = 0; ftpc->dirdepth = 0;
break; break;
} }
slash_pos=strrchr(cur_pos, '/'); slash_pos = strrchr(cur_pos, '/');
if(slash_pos || !*cur_pos) { if(slash_pos || !*cur_pos) {
size_t dirlen = slash_pos-cur_pos; size_t dirlen = slash_pos-cur_pos;
CURLcode result; CURLcode result;
@ -4281,8 +4280,8 @@ CURLcode ftp_parse_url_path(struct connectdata *conn)
} }
} }
else else
ftpc->file=NULL; /* instead of point to a zero byte, we make it a NULL ftpc->file = NULL; /* instead of point to a zero byte, we make it a NULL
pointer */ pointer */
if(data->set.upload && !ftpc->file && (ftp->transfer == FTPTRANSFER_BODY)) { if(data->set.upload && !ftpc->file && (ftp->transfer == FTPTRANSFER_BODY)) {
/* We need a file name when uploading. Return error! */ /* We need a file name when uploading. Return error! */
@ -4378,8 +4377,8 @@ static
CURLcode ftp_regular_transfer(struct connectdata *conn, CURLcode ftp_regular_transfer(struct connectdata *conn,
bool *dophase_done) bool *dophase_done)
{ {
CURLcode result=CURLE_OK; CURLcode result = CURLE_OK;
bool connected=FALSE; bool connected = FALSE;
struct Curl_easy *data = conn->data; struct Curl_easy *data = conn->data;
struct ftp_conn *ftpc = &conn->proto.ftpc; struct ftp_conn *ftpc = &conn->proto.ftpc;
data->req.size = -1; /* make sure this is unknown at this point */ data->req.size = -1; /* make sure this is unknown at this point */

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2017, 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
@ -73,8 +73,8 @@ const struct Curl_handler Curl_handler_gopher = {
static CURLcode gopher_do(struct connectdata *conn, bool *done) static CURLcode gopher_do(struct connectdata *conn, bool *done)
{ {
CURLcode result=CURLE_OK; CURLcode result = CURLE_OK;
struct Curl_easy *data=conn->data; struct Curl_easy *data = conn->data;
curl_socket_t sockfd = conn->sock[FIRSTSOCKET]; curl_socket_t sockfd = conn->sock[FIRSTSOCKET];
curl_off_t *bytecount = &data->req.bytecount; curl_off_t *bytecount = &data->req.bytecount;
@ -97,11 +97,11 @@ static CURLcode gopher_do(struct connectdata *conn, bool *done)
/* Otherwise, drop / and the first character (i.e., item type) ... */ /* Otherwise, drop / and the first character (i.e., item type) ... */
newp = path; newp = path;
newp+=2; newp += 2;
/* ... then turn ? into TAB for search servers, Veronica, etc. ... */ /* ... then turn ? into TAB for search servers, Veronica, etc. ... */
j = strlen(newp); j = strlen(newp);
for(i=0; i<j; i++) for(i = 0; i<j; i++)
if(newp[i] == '?') if(newp[i] == '?')
newp[i] = '\x09'; newp[i] = '\x09';

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2017, 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
@ -73,10 +73,10 @@ static int hostmatch(char *hostname, char *pattern)
/* normalize pattern and hostname by stripping off trailing dots */ /* normalize pattern and hostname by stripping off trailing dots */
size_t len = strlen(hostname); size_t len = strlen(hostname);
if(hostname[len-1]=='.') if(hostname[len-1]=='.')
hostname[len-1]=0; hostname[len-1] = 0;
len = strlen(pattern); len = strlen(pattern);
if(pattern[len-1]=='.') if(pattern[len-1]=='.')
pattern[len-1]=0; pattern[len-1] = 0;
pattern_wildcard = strchr(pattern, '*'); pattern_wildcard = strchr(pattern, '*');
if(pattern_wildcard == NULL) if(pattern_wildcard == NULL)
@ -137,7 +137,7 @@ int Curl_cert_hostcheck(const char *match_pattern, const char *hostname)
hostp = strdup(hostname); hostp = strdup(hostname);
if(hostp) { if(hostp) {
if(hostmatch(hostp, matchp) == CURL_HOST_MATCH) if(hostmatch(hostp, matchp) == CURL_HOST_MATCH)
res= 1; res = 1;
free(hostp); free(hostp);
} }
free(matchp); free(matchp);

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2017, 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
@ -212,7 +212,7 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn,
if(port) { if(port) {
snprintf(sbuf, sizeof(sbuf), "%d", port); snprintf(sbuf, sizeof(sbuf), "%d", port);
sbufptr=sbuf; sbufptr = sbuf;
} }
error = Curl_getaddrinfo_ex(hostname, sbufptr, &hints, &res); error = Curl_getaddrinfo_ex(hostname, sbufptr, &hints, &res);

View File

@ -190,7 +190,7 @@ char *Curl_checkProxyheaders(const struct connectdata *conn,
for(head = (conn->bits.proxy && data->set.sep_headers) ? for(head = (conn->bits.proxy && data->set.sep_headers) ?
data->set.proxyheaders : data->set.headers; data->set.proxyheaders : data->set.headers;
head; head=head->next) { head; head = head->next) {
if(strncasecompare(head->data, thisheader, thislen)) if(strncasecompare(head->data, thisheader, thislen))
return head->data; return head->data;
} }
@ -592,7 +592,7 @@ output_auth_headers(struct connectdata *conn,
#endif #endif
#if defined(USE_NTLM) && defined(NTLM_WB_ENABLED) #if defined(USE_NTLM) && defined(NTLM_WB_ENABLED)
if(authstatus->picked == CURLAUTH_NTLM_WB) { if(authstatus->picked == CURLAUTH_NTLM_WB) {
auth="NTLM_WB"; auth = "NTLM_WB";
result = Curl_output_ntlm_wb(conn, proxy); result = Curl_output_ntlm_wb(conn, proxy);
if(result) if(result)
return result; return result;
@ -1004,7 +1004,7 @@ static size_t readmoredata(char *buffer,
http->sending++; /* move one step up */ http->sending++; /* move one step up */
http->backup.postsize=0; http->backup.postsize = 0;
} }
else else
http->postsize = 0; http->postsize = 0;
@ -1321,7 +1321,7 @@ Curl_compareheader(const char *headerline, /* line to check */
clen = strlen(content); /* length of the word to find */ clen = strlen(content); /* length of the word to find */
/* find the content string in the rest of the line */ /* find the content string in the rest of the line */
for(;len>=clen;len--, start++) { for(;len >= clen;len--, start++) {
if(strncasecompare(start, content, clen)) if(strncasecompare(start, content, clen))
return TRUE; /* match! */ return TRUE; /* match! */
} }
@ -1562,7 +1562,7 @@ CURLcode Curl_add_custom_headers(struct connectdata *conn,
char *ptr; char *ptr;
struct curl_slist *h[2]; struct curl_slist *h[2];
struct curl_slist *headers; struct curl_slist *headers;
int numlists=1; /* by default */ int numlists = 1; /* by default */
struct Curl_easy *data = conn->data; struct Curl_easy *data = conn->data;
int i; int i;
@ -1594,7 +1594,7 @@ CURLcode Curl_add_custom_headers(struct connectdata *conn,
} }
/* loop through one or two lists */ /* loop through one or two lists */
for(i=0; i < numlists; i++) { for(i = 0; i < numlists; i++) {
headers = h[i]; headers = h[i];
while(headers) { while(headers) {
@ -1859,7 +1859,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
here. */ here. */
if(Curl_checkheaders(conn, "User-Agent:")) { if(Curl_checkheaders(conn, "User-Agent:")) {
free(conn->allocptr.uagent); free(conn->allocptr.uagent);
conn->allocptr.uagent=NULL; conn->allocptr.uagent = NULL;
} }
/* setup the authentication headers */ /* setup the authentication headers */
@ -2184,7 +2184,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
} }
if(seekerr != CURL_SEEKFUNC_OK) { if(seekerr != CURL_SEEKFUNC_OK) {
curl_off_t passed=0; curl_off_t passed = 0;
if(seekerr != CURL_SEEKFUNC_CANTSEEK) { if(seekerr != CURL_SEEKFUNC_CANTSEEK) {
failf(data, "Could not seek stream"); failf(data, "Could not seek stream");
@ -2255,7 +2255,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
} }
else if(data->state.resume_from) { else if(data->state.resume_from) {
/* This is because "resume" was selected */ /* This is because "resume" was selected */
curl_off_t total_expected_size= curl_off_t total_expected_size =
data->state.resume_from + data->state.infilesize; data->state.resume_from + data->state.infilesize;
conn->allocptr.rangeline = conn->allocptr.rangeline =
aprintf("Content-Range: bytes %s%" CURL_FORMAT_CURL_OFF_T aprintf("Content-Range: bytes %s%" CURL_FORMAT_CURL_OFF_T
@ -2365,8 +2365,8 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
#if !defined(CURL_DISABLE_COOKIES) #if !defined(CURL_DISABLE_COOKIES)
if(data->cookies || addcookies) { if(data->cookies || addcookies) {
struct Cookie *co=NULL; /* no cookies from start */ struct Cookie *co = NULL; /* no cookies from start */
int count=0; int count = 0;
if(data->cookies) { if(data->cookies) {
Curl_share_lock(data, CURL_LOCK_DATA_COOKIE, CURL_LOCK_ACCESS_SINGLE); Curl_share_lock(data, CURL_LOCK_DATA_COOKIE, CURL_LOCK_ACCESS_SINGLE);
@ -2379,7 +2379,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
Curl_share_unlock(data, CURL_LOCK_DATA_COOKIE); Curl_share_unlock(data, CURL_LOCK_DATA_COOKIE);
} }
if(co) { if(co) {
struct Cookie *store=co; struct Cookie *store = co;
/* now loop through all cookies that matched */ /* now loop through all cookies that matched */
while(co) { while(co) {
if(co->value) { if(co->value) {
@ -2881,14 +2881,14 @@ static CURLcode header_append(struct Curl_easy *data,
return CURLE_OUT_OF_MEMORY; return CURLE_OUT_OF_MEMORY;
} }
newsize=CURLMAX((k->hbuflen+ length)*3/2, data->state.headersize*2); newsize = CURLMAX((k->hbuflen+ length)*3/2, data->state.headersize*2);
hbufp_index = k->hbufp - data->state.headerbuff; hbufp_index = k->hbufp - data->state.headerbuff;
newbuff = realloc(data->state.headerbuff, newsize); newbuff = realloc(data->state.headerbuff, newsize);
if(!newbuff) { if(!newbuff) {
failf(data, "Failed to alloc memory for big header!"); failf(data, "Failed to alloc memory for big header!");
return CURLE_OUT_OF_MEMORY; return CURLE_OUT_OF_MEMORY;
} }
data->state.headersize=newsize; data->state.headersize = newsize;
data->state.headerbuff = newbuff; data->state.headerbuff = newbuff;
k->hbufp = data->state.headerbuff + hbufp_index; k->hbufp = data->state.headerbuff + hbufp_index;
} }
@ -3349,7 +3349,7 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data,
separator = ' '; separator = ' ';
} }
if((nc==4) && (' ' == separator)) { if((nc == 4) && (' ' == separator)) {
conn->httpversion += 10 * httpversion_major; conn->httpversion += 10 * httpversion_major;
if(k->upgr101 == UPGR101_RECEIVED) { if(k->upgr101 == UPGR101_RECEIVED) {
@ -3362,7 +3362,7 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data,
/* this is the real world, not a Nirvana /* this is the real world, not a Nirvana
NCSA 1.5.x returns this crap when asked for HTTP/1.1 NCSA 1.5.x returns this crap when asked for HTTP/1.1
*/ */
nc=sscanf(HEADER1, " HTTP %3d", &k->httpcode); nc = sscanf(HEADER1, " HTTP %3d", &k->httpcode);
conn->httpversion = 10; conn->httpversion = 10;
/* If user has set option HTTP200ALIASES, /* If user has set option HTTP200ALIASES,
@ -3387,7 +3387,7 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data,
&rtspversion_major, &rtspversion_major,
&conn->rtspversion, &conn->rtspversion,
&k->httpcode); &k->httpcode);
if(nc==3) { if(nc == 3) {
conn->rtspversion += 10 * rtspversion_major; conn->rtspversion += 10 * rtspversion_major;
conn->httpversion = 11; /* For us, RTSP acts like HTTP 1.1 */ conn->httpversion = 11; /* For us, RTSP acts like HTTP 1.1 */
} }
@ -3419,7 +3419,7 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data,
((k->httpcode != 407) || !conn->bits.proxy_user_passwd) ) { ((k->httpcode != 407) || !conn->bits.proxy_user_passwd) ) {
if(data->state.resume_from && if(data->state.resume_from &&
(data->set.httpreq==HTTPREQ_GET) && (data->set.httpreq == HTTPREQ_GET) &&
(k->httpcode == 416)) { (k->httpcode == 416)) {
/* "Requested Range Not Satisfiable", just proceed and /* "Requested Range Not Satisfiable", just proceed and
pretend this is no error */ pretend this is no error */
@ -3475,8 +3475,8 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data,
* fields. */ * fields. */
if(data->set.timecondition) if(data->set.timecondition)
data->info.timecond = TRUE; data->info.timecond = TRUE;
k->size=0; k->size = 0;
k->maxdownload=0; k->maxdownload = 0;
k->ignorecl = TRUE; /* ignore Content-Length headers */ k->ignorecl = TRUE; /* ignore Content-Length headers */
break; break;
default: default:
@ -3724,7 +3724,7 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data,
#endif #endif
else if(checkprefix("Last-Modified:", k->p) && else if(checkprefix("Last-Modified:", k->p) &&
(data->set.timecondition || data->set.get_filetime) ) { (data->set.timecondition || data->set.get_filetime) ) {
time_t secs=time(NULL); time_t secs = time(NULL);
k->timeofdoc = curl_getdate(k->p+strlen("Last-Modified:"), k->timeofdoc = curl_getdate(k->p+strlen("Last-Modified:"),
&secs); &secs);
if(data->set.get_filetime) if(data->set.get_filetime)

View File

@ -384,7 +384,7 @@ char *curl_pushheader_byname(struct curl_pushheaders *h, const char *header)
struct HTTP *stream = h->data->req.protop; struct HTTP *stream = h->data->req.protop;
size_t len = strlen(header); size_t len = strlen(header);
size_t i; size_t i;
for(i=0; i<stream->push_headers_used; i++) { for(i = 0; i<stream->push_headers_used; i++) {
if(!strncmp(header, stream->push_headers[i], len)) { if(!strncmp(header, stream->push_headers[i], len)) {
/* sub-match, make sure that it is followed by a colon */ /* sub-match, make sure that it is followed by a colon */
if(stream->push_headers[i][len] != ':') if(stream->push_headers[i][len] != ':')
@ -464,7 +464,7 @@ static int push_promise(struct Curl_easy *data,
data->multi->push_userp); data->multi->push_userp);
/* free the headers again */ /* free the headers again */
for(i=0; i<stream->push_headers_used; i++) for(i = 0; i<stream->push_headers_used; i++)
free(stream->push_headers[i]); free(stream->push_headers[i]);
free(stream->push_headers); free(stream->push_headers);
stream->push_headers = NULL; stream->push_headers = NULL;

View File

@ -86,8 +86,8 @@ static bool Curl_isxdigit(char digit)
void Curl_httpchunk_init(struct connectdata *conn) void Curl_httpchunk_init(struct connectdata *conn)
{ {
struct Curl_chunker *chunk = &conn->chunk; struct Curl_chunker *chunk = &conn->chunk;
chunk->hexindex=0; /* start at 0 */ chunk->hexindex = 0; /* start at 0 */
chunk->dataleft=0; /* no data left yet! */ chunk->dataleft = 0; /* no data left yet! */
chunk->state = CHUNK_HEX; /* we get hex first! */ chunk->state = CHUNK_HEX; /* we get hex first! */
} }
@ -107,7 +107,7 @@ CHUNKcode Curl_httpchunk_read(struct connectdata *conn,
ssize_t datalen, ssize_t datalen,
ssize_t *wrotep) ssize_t *wrotep)
{ {
CURLcode result=CURLE_OK; CURLcode result = CURLE_OK;
struct Curl_easy *data = conn->data; struct Curl_easy *data = conn->data;
struct Curl_chunker *ch = &conn->chunk; struct Curl_chunker *ch = &conn->chunk;
struct SingleRequest *k = &data->req; struct SingleRequest *k = &data->req;
@ -147,7 +147,7 @@ CHUNKcode Curl_httpchunk_read(struct connectdata *conn,
return CHUNKE_ILLEGAL_HEX; return CHUNKE_ILLEGAL_HEX;
/* length and datap are unmodified */ /* length and datap are unmodified */
ch->hexbuffer[ch->hexindex]=0; ch->hexbuffer[ch->hexindex] = 0;
/* convert to host encoding before calling strtoul */ /* convert to host encoding before calling strtoul */
result = Curl_convert_from_network(conn->data, ch->hexbuffer, result = Curl_convert_from_network(conn->data, ch->hexbuffer,
@ -170,7 +170,7 @@ CHUNKcode Curl_httpchunk_read(struct connectdata *conn,
/* we're now expecting data to come, unless size was zero! */ /* we're now expecting data to come, unless size was zero! */
if(0 == ch->datasize) { if(0 == ch->datasize) {
ch->state = CHUNK_TRAILER; /* now check for trailers */ ch->state = CHUNK_TRAILER; /* now check for trailers */
conn->trlPos=0; conn->trlPos = 0;
} }
else else
ch->state = CHUNK_DATA; ch->state = CHUNK_DATA;
@ -257,9 +257,9 @@ CHUNKcode Curl_httpchunk_read(struct connectdata *conn,
if(conn->trlPos) { if(conn->trlPos) {
/* we allocate trailer with 3 bytes extra room to fit this */ /* we allocate trailer with 3 bytes extra room to fit this */
conn->trailer[conn->trlPos++]=0x0d; conn->trailer[conn->trlPos++] = 0x0d;
conn->trailer[conn->trlPos++]=0x0a; conn->trailer[conn->trlPos++] = 0x0a;
conn->trailer[conn->trlPos]=0; conn->trailer[conn->trlPos] = 0;
/* Convert to host encoding before calling Curl_client_write */ /* Convert to host encoding before calling Curl_client_write */
result = Curl_convert_from_network(conn->data, conn->trailer, result = Curl_convert_from_network(conn->data, conn->trailer,
@ -275,7 +275,7 @@ CHUNKcode Curl_httpchunk_read(struct connectdata *conn,
if(result) if(result)
return CHUNKE_WRITE_ERROR; return CHUNKE_WRITE_ERROR;
} }
conn->trlPos=0; conn->trlPos = 0;
ch->state = CHUNK_TRAILER_CR; ch->state = CHUNK_TRAILER_CR;
if(*datap == 0x0a) if(*datap == 0x0a)
/* already on the LF */ /* already on the LF */
@ -299,7 +299,7 @@ CHUNKcode Curl_httpchunk_read(struct connectdata *conn,
ptr = realloc(conn->trailer, conn->trlMax + 3); ptr = realloc(conn->trailer, conn->trlMax + 3);
} }
else { else {
conn->trlMax=128; conn->trlMax = 128;
ptr = malloc(conn->trlMax + 3); ptr = malloc(conn->trlMax + 3);
} }
if(!ptr) if(!ptr)

View File

@ -163,10 +163,10 @@ static CURLcode connect_init(struct connectdata *conn, bool reinit)
s = conn->connect_state; s = conn->connect_state;
} }
s->tunnel_state = TUNNEL_INIT; s->tunnel_state = TUNNEL_INIT;
s->keepon=TRUE; s->keepon = TRUE;
s->line_start = s->connect_buffer; s->line_start = s->connect_buffer;
s->ptr = s->line_start; s->ptr = s->line_start;
s->cl=0; s->cl = 0;
return CURLE_OK; return CURLE_OK;
} }
@ -182,8 +182,8 @@ static CURLcode CONNECT(struct connectdata *conn,
const char *hostname, const char *hostname,
int remote_port) int remote_port)
{ {
int subversion=0; int subversion = 0;
struct Curl_easy *data=conn->data; struct Curl_easy *data = conn->data;
struct SingleRequest *k = &data->req; struct SingleRequest *k = &data->req;
CURLcode result; CURLcode result;
curl_socket_t tunnelsocket = conn->sock[sockindex]; curl_socket_t tunnelsocket = conn->sock[sockindex];
@ -234,8 +234,8 @@ static CURLcode CONNECT(struct connectdata *conn,
if(!result) { if(!result) {
char *host = NULL; char *host = NULL;
const char *proxyconn=""; const char *proxyconn = "";
const char *useragent=""; const char *useragent = "";
const char *http = (conn->http_proxy.proxytype == CURLPROXY_HTTP_1_0) ? const char *http = (conn->http_proxy.proxytype == CURLPROXY_HTTP_1_0) ?
"1.0" : "1.1"; "1.0" : "1.1";
bool ipv6_ip = conn->bits.ipv6_ip; bool ipv6_ip = conn->bits.ipv6_ip;
@ -244,7 +244,7 @@ static CURLcode CONNECT(struct connectdata *conn,
/* the hostname may be different */ /* the hostname may be different */
if(hostname != conn->host.name) if(hostname != conn->host.name)
ipv6_ip = (strchr(hostname, ':') != NULL); ipv6_ip = (strchr(hostname, ':') != NULL);
hostheader= /* host:port with IPv6 support */ hostheader = /* host:port with IPv6 support */
aprintf("%s%s%s:%hu", ipv6_ip?"[":"", hostname, ipv6_ip?"]":"", aprintf("%s%s%s:%hu", ipv6_ip?"[":"", hostname, ipv6_ip?"]":"",
remote_port); remote_port);
if(!hostheader) { if(!hostheader) {

View File

@ -103,7 +103,7 @@ bool Curl_if_is_interface_name(const char *interf)
struct ifaddrs *iface, *head; struct ifaddrs *iface, *head;
if(getifaddrs(&head) >= 0) { if(getifaddrs(&head) >= 0) {
for(iface=head; iface != NULL; iface=iface->ifa_next) { for(iface = head; iface != NULL; iface = iface->ifa_next) {
if(strcasecompare(iface->ifa_name, interf)) { if(strcasecompare(iface->ifa_name, interf)) {
result = TRUE; result = TRUE;
break; break;
@ -131,7 +131,7 @@ if2ip_result_t Curl_if2ip(int af, unsigned int remote_scope,
#endif #endif
if(getifaddrs(&head) >= 0) { if(getifaddrs(&head) >= 0) {
for(iface = head; iface != NULL; iface=iface->ifa_next) { for(iface = head; iface != NULL; iface = iface->ifa_next) {
if(iface->ifa_addr != NULL) { if(iface->ifa_addr != NULL) {
if(iface->ifa_addr->sa_family == af) { if(iface->ifa_addr->sa_family == af) {
if(strcasecompare(iface->ifa_name, interf)) { if(strcasecompare(iface->ifa_name, interf)) {

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2017, 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
@ -267,7 +267,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
LDAPMessage *ldapmsg = NULL; LDAPMessage *ldapmsg = NULL;
LDAPMessage *entryIterator; LDAPMessage *entryIterator;
int num = 0; int num = 0;
struct Curl_easy *data=conn->data; struct Curl_easy *data = conn->data;
int ldap_proto = LDAP_VERSION3; int ldap_proto = LDAP_VERSION3;
int ldap_ssl = 0; int ldap_ssl = 0;
char *val_b64 = NULL; char *val_b64 = NULL;

View File

@ -225,9 +225,9 @@ char *curl_dostrdup(const char *str, int line, const char *source)
if(countcheck("strdup", line, source)) if(countcheck("strdup", line, source))
return NULL; return NULL;
len=strlen(str)+1; len = strlen(str)+1;
mem=curl_domalloc(len, 0, NULL); /* NULL prevents logging */ mem = curl_domalloc(len, 0, NULL); /* NULL prevents logging */
if(mem) if(mem)
memcpy(mem, str, len); memcpy(mem, str, len);
@ -269,7 +269,7 @@ wchar_t *curl_dowcsdup(const wchar_t *str, int line, const char *source)
void *curl_dorealloc(void *ptr, size_t wantedsize, void *curl_dorealloc(void *ptr, size_t wantedsize,
int line, const char *source) int line, const char *source)
{ {
struct memdebug *mem=NULL; struct memdebug *mem = NULL;
size_t size = sizeof(struct memdebug)+wantedsize; size_t size = sizeof(struct memdebug)+wantedsize;
@ -407,7 +407,7 @@ void curl_mark_sclose(curl_socket_t sockfd, int line, const char *source)
/* this is our own defined way to close sockets on *ALL* platforms */ /* this is our own defined way to close sockets on *ALL* platforms */
int curl_sclose(curl_socket_t sockfd, int line, const char *source) int curl_sclose(curl_socket_t sockfd, int line, const char *source)
{ {
int res=sclose(sockfd); int res = sclose(sockfd);
curl_mark_sclose(sockfd, line, source); curl_mark_sclose(sockfd, line, source);
return res; return res;
} }
@ -415,7 +415,7 @@ int curl_sclose(curl_socket_t sockfd, int line, const char *source)
FILE *curl_fopen(const char *file, const char *mode, FILE *curl_fopen(const char *file, const char *mode,
int line, const char *source) int line, const char *source)
{ {
FILE *res=fopen(file, mode); FILE *res = fopen(file, mode);
if(source) if(source)
curl_memlog("FILE %s:%d fopen(\"%s\",\"%s\") = %p\n", curl_memlog("FILE %s:%d fopen(\"%s\",\"%s\") = %p\n",
@ -428,7 +428,7 @@ FILE *curl_fopen(const char *file, const char *mode,
FILE *curl_fdopen(int filedes, const char *mode, FILE *curl_fdopen(int filedes, const char *mode,
int line, const char *source) int line, const char *source)
{ {
FILE *res=fdopen(filedes, mode); FILE *res = fdopen(filedes, mode);
if(source) if(source)
curl_memlog("FILE %s:%d fdopen(\"%d\",\"%s\") = %p\n", curl_memlog("FILE %s:%d fdopen(\"%d\",\"%s\") = %p\n",
@ -444,7 +444,7 @@ int curl_fclose(FILE *file, int line, const char *source)
DEBUGASSERT(file != NULL); DEBUGASSERT(file != NULL);
res=fclose(file); res = fclose(file);
if(source) if(source)
curl_memlog("FILE %s:%d fclose(%p)\n", curl_memlog("FILE %s:%d fclose(%p)\n",

View File

@ -247,8 +247,8 @@ static char *Curl_basename(char *path)
char *s1; char *s1;
char *s2; char *s2;
s1=strrchr(path, '/'); s1 = strrchr(path, '/');
s2=strrchr(path, '\\'); s2 = strrchr(path, '\\');
if(s1 && s2) { if(s1 && s2) {
path = (s1 > s2? s1 : s2)+1; path = (s1 > s2? s1 : s2)+1;

View File

@ -177,7 +177,7 @@ struct asprintf {
static long dprintf_DollarString(char *input, char **end) static long dprintf_DollarString(char *input, char **end)
{ {
int number=0; int number = 0;
while(ISDIGIT(*input)) { while(ISDIGIT(*input)) {
number *= 10; number *= 10;
number += *input-'0'; number += *input-'0';
@ -233,7 +233,7 @@ static int dprintf_Pass1(const char *format, va_stack_t *vto, char **endpos,
long width; long width;
long precision; long precision;
int flags; int flags;
long max_param=0; long max_param = 0;
long i; long i;
while(*fmt) { while(*fmt) {
@ -376,7 +376,7 @@ static int dprintf_Pass1(const char *format, va_stack_t *vto, char **endpos,
else else
width = param_num; width = param_num;
if(width > max_param) if(width > max_param)
max_param=width; max_param = width;
break; break;
default: default:
break; break;
@ -482,7 +482,7 @@ static int dprintf_Pass1(const char *format, va_stack_t *vto, char **endpos,
} }
/* Read the arg list parameters into our data list */ /* Read the arg list parameters into our data list */
for(i=0; i<max_param; i++) { for(i = 0; i<max_param; i++) {
/* Width/precision arguments must be read before the main argument /* Width/precision arguments must be read before the main argument
they are attached to */ they are attached to */
if(vto[i].flags & FLAGS_WIDTHPARAM) { if(vto[i].flags & FLAGS_WIDTHPARAM) {
@ -569,7 +569,7 @@ static int dprintf_formatf(
int done = 0; int done = 0;
long param; /* current parameter to read */ long param; /* current parameter to read */
long param_num=0; /* parameter counter */ long param_num = 0; /* parameter counter */
va_stack_t vto[MAX_PARAMETERS]; va_stack_t vto[MAX_PARAMETERS];
char *endpos[MAX_PARAMETERS]; char *endpos[MAX_PARAMETERS];
@ -639,7 +639,7 @@ static int dprintf_formatf(
/* If this is a positional parameter, the position must follow immediately /* If this is a positional parameter, the position must follow immediately
after the %, thus create a %<num>$ sequence */ after the %, thus create a %<num>$ sequence */
param=dprintf_DollarString(f, &f); param = dprintf_DollarString(f, &f);
if(!param) if(!param)
param = param_num; param = param_num;
@ -948,7 +948,7 @@ static int dprintf_formatf(
output characters */ output characters */
(sprintf)(work, formatbuf, p->data.dnum); (sprintf)(work, formatbuf, p->data.dnum);
DEBUGASSERT(strlen(work) <= sizeof(work)); DEBUGASSERT(strlen(work) <= sizeof(work));
for(fptr=work; *fptr; fptr++) for(fptr = work; *fptr; fptr++)
OUTCHAR(*fptr); OUTCHAR(*fptr);
} }
break; break;
@ -980,7 +980,7 @@ static int dprintf_formatf(
/* fputc() look-alike */ /* fputc() look-alike */
static int addbyter(int output, FILE *data) static int addbyter(int output, FILE *data)
{ {
struct nsprintf *infop=(struct nsprintf *)data; struct nsprintf *infop = (struct nsprintf *)data;
unsigned char outc = (unsigned char)output; unsigned char outc = (unsigned char)output;
if(infop->length < infop->max) { if(infop->length < infop->max) {
@ -1028,7 +1028,7 @@ int curl_msnprintf(char *buffer, size_t maxlength, const char *format, ...)
/* fputc() look-alike */ /* fputc() look-alike */
static int alloc_addbyter(int output, FILE *data) static int alloc_addbyter(int output, FILE *data)
{ {
struct asprintf *infop=(struct asprintf *)data; struct asprintf *infop = (struct asprintf *)data;
unsigned char outc = (unsigned char)output; unsigned char outc = (unsigned char)output;
if(!infop->buffer) { if(!infop->buffer) {
@ -1038,7 +1038,7 @@ static int alloc_addbyter(int output, FILE *data)
return -1; /* fail */ return -1; /* fail */
} }
infop->alloc = 32; infop->alloc = 32;
infop->len =0; infop->len = 0;
} }
else if(infop->len+1 >= infop->alloc) { else if(infop->len+1 >= infop->alloc) {
char *newptr = NULL; char *newptr = NULL;
@ -1129,7 +1129,7 @@ int curl_msprintf(char *buffer, const char *format, ...)
va_start(ap_save, format); va_start(ap_save, format);
retcode = dprintf_formatf(&buffer, storebuffer, format, ap_save); retcode = dprintf_formatf(&buffer, storebuffer, format, ap_save);
va_end(ap_save); va_end(ap_save);
*buffer=0; /* we terminate this with a zero byte */ *buffer = 0; /* we terminate this with a zero byte */
return retcode; return retcode;
} }
@ -1158,7 +1158,7 @@ int curl_mvsprintf(char *buffer, const char *format, va_list ap_save)
{ {
int retcode; int retcode;
retcode = dprintf_formatf(&buffer, storebuffer, format, ap_save); retcode = dprintf_formatf(&buffer, storebuffer, format, ap_save);
*buffer=0; /* we terminate this with a zero byte */ *buffer = 0; /* we terminate this with a zero byte */
return retcode; return retcode;
} }

View File

@ -592,7 +592,7 @@ static CURLcode multi_done(struct connectdata **connp,
/* if the transfer was completed in a paused state there can be buffered /* if the transfer was completed in a paused state there can be buffered
data left to free */ data left to free */
for(i=0; i < data->state.tempcount; i++) { for(i = 0; i < data->state.tempcount; i++) {
free(data->state.tempwrite[i].buf); free(data->state.tempwrite[i].buf);
} }
data->state.tempcount = 0; data->state.tempcount = 0;
@ -802,8 +802,8 @@ static int waitconnect_getsock(struct connectdata *conn,
int numsocks) int numsocks)
{ {
int i; int i;
int s=0; int s = 0;
int rc=0; int rc = 0;
if(!numsocks) if(!numsocks)
return GETSOCK_BLANK; return GETSOCK_BLANK;
@ -813,7 +813,7 @@ static int waitconnect_getsock(struct connectdata *conn,
return Curl_ssl_getsock(conn, sock, numsocks); return Curl_ssl_getsock(conn, sock, numsocks);
#endif #endif
for(i=0; i<2; i++) { for(i = 0; i<2; i++) {
if(conn->tempsock[i] != CURL_SOCKET_BAD) { if(conn->tempsock[i] != CURL_SOCKET_BAD) {
sock[s] = conn->tempsock[i]; sock[s] = conn->tempsock[i];
rc |= GETSOCK_WRITESOCK(s++); rc |= GETSOCK_WRITESOCK(s++);
@ -924,7 +924,7 @@ CURLMcode curl_multi_fdset(struct Curl_multi *multi,
Some easy handles may not have connected to the remote host yet, Some easy handles may not have connected to the remote host yet,
and then we must make sure that is done. */ and then we must make sure that is done. */
struct Curl_easy *data; struct Curl_easy *data;
int this_max_fd=-1; int this_max_fd = -1;
curl_socket_t sockbunch[MAX_SOCKSPEREASYHANDLE]; curl_socket_t sockbunch[MAX_SOCKSPEREASYHANDLE];
int bitmap; int bitmap;
int i; int i;
@ -933,11 +933,11 @@ CURLMcode curl_multi_fdset(struct Curl_multi *multi,
if(!GOOD_MULTI_HANDLE(multi)) if(!GOOD_MULTI_HANDLE(multi))
return CURLM_BAD_HANDLE; return CURLM_BAD_HANDLE;
data=multi->easyp; data = multi->easyp;
while(data) { while(data) {
bitmap = multi_getsock(data, sockbunch, MAX_SOCKSPEREASYHANDLE); bitmap = multi_getsock(data, sockbunch, MAX_SOCKSPEREASYHANDLE);
for(i=0; i< MAX_SOCKSPEREASYHANDLE; i++) { for(i = 0; i< MAX_SOCKSPEREASYHANDLE; i++) {
curl_socket_t s = CURL_SOCKET_BAD; curl_socket_t s = CURL_SOCKET_BAD;
if((bitmap & GETSOCK_READSOCK(i)) && VALID_SOCK((sockbunch[i]))) { if((bitmap & GETSOCK_READSOCK(i)) && VALID_SOCK((sockbunch[i]))) {
@ -994,11 +994,11 @@ CURLMcode curl_multi_wait(struct Curl_multi *multi,
timeout_ms = (int)timeout_internal; timeout_ms = (int)timeout_internal;
/* Count up how many fds we have from the multi handle */ /* Count up how many fds we have from the multi handle */
data=multi->easyp; data = multi->easyp;
while(data) { while(data) {
bitmap = multi_getsock(data, sockbunch, MAX_SOCKSPEREASYHANDLE); bitmap = multi_getsock(data, sockbunch, MAX_SOCKSPEREASYHANDLE);
for(i=0; i< MAX_SOCKSPEREASYHANDLE; i++) { for(i = 0; i< MAX_SOCKSPEREASYHANDLE; i++) {
curl_socket_t s = CURL_SOCKET_BAD; curl_socket_t s = CURL_SOCKET_BAD;
if(bitmap & GETSOCK_READSOCK(i)) { if(bitmap & GETSOCK_READSOCK(i)) {
@ -1041,11 +1041,11 @@ CURLMcode curl_multi_wait(struct Curl_multi *multi,
if(curlfds) { if(curlfds) {
/* Add the curl handles to our pollfds first */ /* Add the curl handles to our pollfds first */
data=multi->easyp; data = multi->easyp;
while(data) { while(data) {
bitmap = multi_getsock(data, sockbunch, MAX_SOCKSPEREASYHANDLE); bitmap = multi_getsock(data, sockbunch, MAX_SOCKSPEREASYHANDLE);
for(i=0; i< MAX_SOCKSPEREASYHANDLE; i++) { for(i = 0; i< MAX_SOCKSPEREASYHANDLE; i++) {
curl_socket_t s = CURL_SOCKET_BAD; curl_socket_t s = CURL_SOCKET_BAD;
if(bitmap & GETSOCK_READSOCK(i)) { if(bitmap & GETSOCK_READSOCK(i)) {
@ -1229,7 +1229,7 @@ static CURLcode multi_reconnect_request(struct connectdata **connp)
*/ */
static void do_complete(struct connectdata *conn) static void do_complete(struct connectdata *conn)
{ {
conn->data->req.chunk=FALSE; conn->data->req.chunk = FALSE;
conn->data->req.maxfd = (conn->sockfd>conn->writesockfd? conn->data->req.maxfd = (conn->sockfd>conn->writesockfd?
conn->sockfd:conn->writesockfd)+1; conn->sockfd:conn->writesockfd)+1;
Curl_pgrsTime(conn->data, TIMER_PRETRANSFER); Curl_pgrsTime(conn->data, TIMER_PRETRANSFER);
@ -1237,7 +1237,7 @@ static void do_complete(struct connectdata *conn)
static CURLcode multi_do(struct connectdata **connp, bool *done) static CURLcode multi_do(struct connectdata **connp, bool *done)
{ {
CURLcode result=CURLE_OK; CURLcode result = CURLE_OK;
struct connectdata *conn = *connp; struct connectdata *conn = *connp;
struct Curl_easy *data = conn->data; struct Curl_easy *data = conn->data;
@ -1286,7 +1286,7 @@ static CURLcode multi_do(struct connectdata **connp, bool *done)
static CURLcode multi_do_more(struct connectdata *conn, int *complete) static CURLcode multi_do_more(struct connectdata *conn, int *complete)
{ {
CURLcode result=CURLE_OK; CURLcode result = CURLE_OK;
*complete = 0; *complete = 0;
@ -1415,7 +1415,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
switch(data->mstate) { switch(data->mstate) {
case CURLM_STATE_INIT: case CURLM_STATE_INIT:
/* init this transfer. */ /* init this transfer. */
result=Curl_pretransfer(data); result = Curl_pretransfer(data);
if(!result) { if(!result) {
/* after init, go CONNECT */ /* after init, go CONNECT */
@ -1697,7 +1697,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
* back to the CONNECT phase so we can try again. * back to the CONNECT phase so we can try again.
*/ */
char *newurl = NULL; char *newurl = NULL;
followtype follow=FOLLOW_NONE; followtype follow = FOLLOW_NONE;
CURLcode drc; CURLcode drc;
bool retry = FALSE; bool retry = FALSE;
@ -1783,7 +1783,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
if(control) { if(control) {
/* if positive, advance to DO_DONE /* if positive, advance to DO_DONE
if negative, go back to DOING */ if negative, go back to DOING */
multistate(data, control==1? multistate(data, control == 1?
CURLM_STATE_DO_DONE: CURLM_STATE_DO_DONE:
CURLM_STATE_DOING); CURLM_STATE_DOING);
rc = CURLM_CALL_MULTI_PERFORM; rc = CURLM_CALL_MULTI_PERFORM;
@ -1938,7 +1938,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
multi_done(&data->easy_conn, result, TRUE); multi_done(&data->easy_conn, result, TRUE);
} }
else if(done) { else if(done) {
followtype follow=FOLLOW_NONE; followtype follow = FOLLOW_NONE;
/* call this even if the readwrite function returned error */ /* call this even if the readwrite function returned error */
Curl_posttransfer(data); Curl_posttransfer(data);
@ -2144,14 +2144,14 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
CURLMcode curl_multi_perform(struct Curl_multi *multi, int *running_handles) CURLMcode curl_multi_perform(struct Curl_multi *multi, int *running_handles)
{ {
struct Curl_easy *data; struct Curl_easy *data;
CURLMcode returncode=CURLM_OK; CURLMcode returncode = CURLM_OK;
struct Curl_tree *t; struct Curl_tree *t;
struct curltime now = Curl_tvnow(); struct curltime now = Curl_tvnow();
if(!GOOD_MULTI_HANDLE(multi)) if(!GOOD_MULTI_HANDLE(multi))
return CURLM_BAD_HANDLE; return CURLM_BAD_HANDLE;
data=multi->easyp; data = multi->easyp;
while(data) { while(data) {
CURLMcode result; CURLMcode result;
SIGPIPE_VARIABLE(pipe_st); SIGPIPE_VARIABLE(pipe_st);
@ -2246,7 +2246,7 @@ CURLMcode curl_multi_cleanup(struct Curl_multi *multi)
/* remove all easy handles */ /* remove all easy handles */
data = multi->easyp; data = multi->easyp;
while(data) { while(data) {
nextdata=data->next; nextdata = data->next;
if(data->dns.hostcachetype == HCACHE_MULTI) { if(data->dns.hostcachetype == HCACHE_MULTI) {
/* clear out the usage of the shared DNS cache */ /* clear out the usage of the shared DNS cache */
Curl_hostcache_clean(data, data->dns.hostcache); Curl_hostcache_clean(data, data->dns.hostcache);
@ -2326,7 +2326,7 @@ static void singlesocket(struct Curl_multi *multi,
int num; int num;
unsigned int curraction; unsigned int curraction;
for(i=0; i< MAX_SOCKSPEREASYHANDLE; i++) for(i = 0; i< MAX_SOCKSPEREASYHANDLE; i++)
socks[i] = CURL_SOCKET_BAD; socks[i] = CURL_SOCKET_BAD;
/* Fill in the 'current' struct with the state as it is now: what sockets to /* Fill in the 'current' struct with the state as it is now: what sockets to
@ -2338,7 +2338,7 @@ static void singlesocket(struct Curl_multi *multi,
longer supervised ones and add new ones */ longer supervised ones and add new ones */
/* walk over the sockets we got right now */ /* walk over the sockets we got right now */
for(i=0; (i< MAX_SOCKSPEREASYHANDLE) && for(i = 0; (i< MAX_SOCKSPEREASYHANDLE) &&
(curraction & (GETSOCK_READSOCK(i) | GETSOCK_WRITESOCK(i))); (curraction & (GETSOCK_READSOCK(i) | GETSOCK_WRITESOCK(i)));
i++) { i++) {
int action = CURL_POLL_NONE; int action = CURL_POLL_NONE;
@ -2382,10 +2382,10 @@ static void singlesocket(struct Curl_multi *multi,
/* when we've walked over all the sockets we should have right now, we must /* when we've walked over all the sockets we should have right now, we must
make sure to detect sockets that are removed */ make sure to detect sockets that are removed */
for(i=0; i< data->numsocks; i++) { for(i = 0; i< data->numsocks; i++) {
int j; int j;
s = data->sockets[i]; s = data->sockets[i];
for(j=0; j<num; j++) { for(j = 0; j<num; j++) {
if(s == socks[j]) { if(s == socks[j]) {
/* this is still supervised */ /* this is still supervised */
s = CURL_SOCKET_BAD; s = CURL_SOCKET_BAD;
@ -2558,7 +2558,7 @@ static CURLMcode multi_socket(struct Curl_multi *multi,
/* walk through each easy handle and do the socket state change magic /* walk through each easy handle and do the socket state change magic
and callbacks */ and callbacks */
if(result != CURLM_BAD_HANDLE) { if(result != CURLM_BAD_HANDLE) {
data=multi->easyp; data = multi->easyp;
while(data) { while(data) {
singlesocket(multi, data); singlesocket(multi, data);
data = data->next; data = data->next;
@ -2795,7 +2795,7 @@ static CURLMcode multi_timeout(struct Curl_multi *multi,
* processors while the diff is still present but less than one * processors while the diff is still present but less than one
* millisecond! instead we return 1 until the time is ripe. * millisecond! instead we return 1 until the time is ripe.
*/ */
*timeout_ms=1; *timeout_ms = 1;
} }
else else
/* 0 means immediately */ /* 0 means immediately */
@ -2831,7 +2831,7 @@ static int update_timer(struct Curl_multi *multi)
return -1; return -1;
} }
if(timeout_ms < 0) { if(timeout_ms < 0) {
static const struct curltime none={0, 0}; static const struct curltime none = {0, 0};
if(Curl_splaycomparekeys(none, multi->timer_lastcall)) { if(Curl_splaycomparekeys(none, multi->timer_lastcall)) {
multi->timer_lastcall = none; multi->timer_lastcall = none;
/* there's no timeout now but there was one previously, tell the app to /* there's no timeout now but there was one previously, tell the app to
@ -3115,13 +3115,13 @@ void Curl_multi_dump(struct Curl_multi *multi)
int i; int i;
fprintf(stderr, "* Multi status: %d handles, %d alive\n", fprintf(stderr, "* Multi status: %d handles, %d alive\n",
multi->num_easy, multi->num_alive); multi->num_easy, multi->num_alive);
for(data=multi->easyp; data; data = data->next) { for(data = multi->easyp; data; data = data->next) {
if(data->mstate < CURLM_STATE_COMPLETED) { if(data->mstate < CURLM_STATE_COMPLETED) {
/* only display handles that are not completed */ /* only display handles that are not completed */
fprintf(stderr, "handle %p, state %s, %d sockets\n", fprintf(stderr, "handle %p, state %s, %d sockets\n",
(void *)data, (void *)data,
statename[data->mstate], data->numsocks); statename[data->mstate], data->numsocks);
for(i=0; i < data->numsocks; i++) { for(i = 0; i < data->numsocks; i++) {
curl_socket_t s = data->sockets[i]; curl_socket_t s = data->sockets[i];
struct Curl_sh_entry *entry = sh_getentry(&multi->sockhash, s); struct Curl_sh_entry *entry = sh_getentry(&multi->sockhash, s);

View File

@ -56,14 +56,15 @@ int Curl_parsenetrc(const char *host,
char *netrcfile) char *netrcfile)
{ {
FILE *file; FILE *file;
int retcode=1; int retcode = 1;
int specific_login = (*loginp && **loginp != 0); int specific_login = (*loginp && **loginp != 0);
bool netrc_alloc = FALSE; bool netrc_alloc = FALSE;
enum host_lookup_state state=NOTHING; enum host_lookup_state state = NOTHING;
char state_login=0; /* Found a login keyword */ char state_login = 0; /* Found a login keyword */
char state_password=0; /* Found a password keyword */ char state_password = 0; /* Found a password keyword */
int state_our_login=FALSE; /* With specific_login, found *our* login name */ int state_our_login = FALSE; /* With specific_login, found *our* login
name */
#define NETRC DOT_CHAR "netrc" #define NETRC DOT_CHAR "netrc"
@ -88,7 +89,7 @@ int Curl_parsenetrc(const char *host,
} }
else { else {
struct passwd *pw; struct passwd *pw;
pw= getpwuid(geteuid()); pw = getpwuid(geteuid());
if(pw) { if(pw) {
home = pw->pw_dir; home = pw->pw_dir;
} }
@ -113,19 +114,19 @@ int Curl_parsenetrc(const char *host,
if(file) { if(file) {
char *tok; char *tok;
char *tok_buf; char *tok_buf;
bool done=FALSE; bool done = FALSE;
char netrcbuffer[256]; char netrcbuffer[256];
int netrcbuffsize = (int)sizeof(netrcbuffer); int netrcbuffsize = (int)sizeof(netrcbuffer);
while(!done && fgets(netrcbuffer, netrcbuffsize, file)) { while(!done && fgets(netrcbuffer, netrcbuffsize, file)) {
tok=strtok_r(netrcbuffer, " \t\n", &tok_buf); tok = strtok_r(netrcbuffer, " \t\n", &tok_buf);
if(tok && *tok == '#') if(tok && *tok == '#')
/* treat an initial hash as a comment line */ /* treat an initial hash as a comment line */
continue; continue;
while(!done && tok) { while(!done && tok) {
if((*loginp && **loginp) && (*passwordp && **passwordp)) { if((*loginp && **loginp) && (*passwordp && **passwordp)) {
done=TRUE; done = TRUE;
break; break;
} }
@ -136,22 +137,22 @@ int Curl_parsenetrc(const char *host,
delimiter that starts the stuff entered for this machine, delimiter that starts the stuff entered for this machine,
after this we need to search for 'login' and after this we need to search for 'login' and
'password'. */ 'password'. */
state=HOSTFOUND; state = HOSTFOUND;
} }
else if(strcasecompare("default", tok)) { else if(strcasecompare("default", tok)) {
state=HOSTVALID; state = HOSTVALID;
retcode=0; /* we did find our host */ retcode = 0; /* we did find our host */
} }
break; break;
case HOSTFOUND: case HOSTFOUND:
if(strcasecompare(host, tok)) { if(strcasecompare(host, tok)) {
/* and yes, this is our host! */ /* and yes, this is our host! */
state=HOSTVALID; state = HOSTVALID;
retcode=0; /* we did find our host */ retcode = 0; /* we did find our host */
} }
else else
/* not our host */ /* not our host */
state=NOTHING; state = NOTHING;
break; break;
case HOSTVALID: case HOSTVALID:
/* we are now parsing sub-keywords concerning "our" host */ /* we are now parsing sub-keywords concerning "our" host */
@ -167,7 +168,7 @@ int Curl_parsenetrc(const char *host,
goto out; goto out;
} }
} }
state_login=0; state_login = 0;
} }
else if(state_password) { else if(state_password) {
if(state_our_login || !specific_login) { if(state_our_login || !specific_login) {
@ -178,12 +179,12 @@ int Curl_parsenetrc(const char *host,
goto out; goto out;
} }
} }
state_password=0; state_password = 0;
} }
else if(strcasecompare("login", tok)) else if(strcasecompare("login", tok))
state_login=1; state_login = 1;
else if(strcasecompare("password", tok)) else if(strcasecompare("password", tok))
state_password=1; state_password = 1;
else if(strcasecompare("machine", tok)) { else if(strcasecompare("machine", tok)) {
/* ok, there's machine here go => */ /* ok, there's machine here go => */
state = HOSTFOUND; state = HOSTFOUND;

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 2010, Howard Chu, <hyc@openldap.org> * Copyright (C) 2010, 2017, Howard Chu, <hyc@openldap.org>
* Copyright (C) 2011 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 2011 - 2016, 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
@ -152,7 +152,7 @@ static CURLcode ldap_setup_connection(struct connectdata *conn)
{ {
ldapconninfo *li; ldapconninfo *li;
LDAPURLDesc *lud; LDAPURLDesc *lud;
struct Curl_easy *data=conn->data; struct Curl_easy *data = conn->data;
int rc, proto; int rc, proto;
CURLcode status; CURLcode status;
@ -354,7 +354,7 @@ static CURLcode ldap_do(struct connectdata *conn, bool *done)
int rc = 0; int rc = 0;
LDAPURLDesc *ludp = NULL; LDAPURLDesc *ludp = NULL;
int msgid; int msgid;
struct Curl_easy *data=conn->data; struct Curl_easy *data = conn->data;
connkeep(conn, "OpenLDAP do"); connkeep(conn, "OpenLDAP do");
@ -519,7 +519,7 @@ static ssize_t ldap_recv(struct connectdata *conn, int sockindex, char *buf,
else else
binary = 0; binary = 0;
for(i=0; bvals[i].bv_val != NULL; i++) { for(i = 0; bvals[i].bv_val != NULL; i++) {
int binval = 0; int binval = 0;
writeerr = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\t", 1); writeerr = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\t", 1);
if(writeerr) { if(writeerr) {
@ -549,7 +549,7 @@ static ssize_t ldap_recv(struct connectdata *conn, int sockindex, char *buf,
else { else {
/* check for unprintable characters */ /* check for unprintable characters */
unsigned int j; unsigned int j;
for(j=0; j<bvals[i].bv_len; j++) for(j = 0; j<bvals[i].bv_len; j++)
if(!ISPRINT(bvals[i].bv_val[j])) { if(!ISPRINT(bvals[i].bv_val[j])) {
binval = 1; binval = 1;
break; break;

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2017, 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
@ -205,14 +205,14 @@ static int checkday(const char *check, size_t len)
{ {
int i; int i;
const char * const *what; const char * const *what;
bool found= FALSE; bool found = FALSE;
if(len > 3) if(len > 3)
what = &weekday[0]; what = &weekday[0];
else else
what = &Curl_wkday[0]; what = &Curl_wkday[0];
for(i=0; i<7; i++) { for(i = 0; i<7; i++) {
if(strcasecompare(check, what[0])) { if(strcasecompare(check, what[0])) {
found=TRUE; found = TRUE;
break; break;
} }
what++; what++;
@ -224,12 +224,12 @@ static int checkmonth(const char *check)
{ {
int i; int i;
const char * const *what; const char * const *what;
bool found= FALSE; bool found = FALSE;
what = &Curl_month[0]; what = &Curl_month[0];
for(i=0; i<12; i++) { for(i = 0; i<12; i++) {
if(strcasecompare(check, what[0])) { if(strcasecompare(check, what[0])) {
found=TRUE; found = TRUE;
break; break;
} }
what++; what++;
@ -244,12 +244,12 @@ static int checktz(const char *check)
{ {
unsigned int i; unsigned int i;
const struct tzinfo *what; const struct tzinfo *what;
bool found= FALSE; bool found = FALSE;
what = tz; what = tz;
for(i=0; i< sizeof(tz)/sizeof(tz[0]); i++) { for(i = 0; i< sizeof(tz)/sizeof(tz[0]); i++) {
if(strcasecompare(check, what->name)) { if(strcasecompare(check, what->name)) {
found=TRUE; found = TRUE;
break; break;
} }
what++; what++;
@ -331,21 +331,21 @@ static time_t my_timegm(struct my_tm *tm)
static int parsedate(const char *date, time_t *output) static int parsedate(const char *date, time_t *output)
{ {
time_t t = 0; time_t t = 0;
int wdaynum=-1; /* day of the week number, 0-6 (mon-sun) */ int wdaynum = -1; /* day of the week number, 0-6 (mon-sun) */
int monnum=-1; /* month of the year number, 0-11 */ int monnum = -1; /* month of the year number, 0-11 */
int mdaynum=-1; /* day of month, 1 - 31 */ int mdaynum = -1; /* day of month, 1 - 31 */
int hournum=-1; int hournum = -1;
int minnum=-1; int minnum = -1;
int secnum=-1; int secnum = -1;
int yearnum=-1; int yearnum = -1;
int tzoff=-1; int tzoff = -1;
struct my_tm tm; struct my_tm tm;
enum assume dignext = DATE_MDAY; enum assume dignext = DATE_MDAY;
const char *indate = date; /* save the original pointer */ const char *indate = date; /* save the original pointer */
int part = 0; /* max 6 parts */ int part = 0; /* max 6 parts */
while(*date && (part < 6)) { while(*date && (part < 6)) {
bool found=FALSE; bool found = FALSE;
skip(&date); skip(&date);
@ -386,7 +386,7 @@ static int parsedate(const char *date, time_t *output)
/* a digit */ /* a digit */
int val; int val;
char *end; char *end;
int len=0; int len = 0;
if((secnum == -1) && if((secnum == -1) &&
(3 == sscanf(date, "%02d:%02d:%02d%n", (3 == sscanf(date, "%02d:%02d:%02d%n",
&hournum, &minnum, &secnum, &len))) { &hournum, &minnum, &secnum, &len))) {

View File

@ -47,10 +47,10 @@
time_t Curl_pp_state_timeout(struct pingpong *pp) time_t Curl_pp_state_timeout(struct pingpong *pp)
{ {
struct connectdata *conn = pp->conn; struct connectdata *conn = pp->conn;
struct Curl_easy *data=conn->data; struct Curl_easy *data = conn->data;
time_t timeout_ms; /* in milliseconds */ time_t timeout_ms; /* in milliseconds */
time_t timeout2_ms; /* in milliseconds */ time_t timeout2_ms; /* in milliseconds */
long response_time= (data->set.server_response_timeout)? long response_time = (data->set.server_response_timeout)?
data->set.server_response_timeout: pp->response_time; data->set.server_response_timeout: pp->response_time;
/* if CURLOPT_SERVER_RESPONSE_TIMEOUT is set, use that to determine /* if CURLOPT_SERVER_RESPONSE_TIMEOUT is set, use that to determine
@ -85,10 +85,10 @@ CURLcode Curl_pp_statemach(struct pingpong *pp, bool block)
int rc; int rc;
time_t interval_ms; time_t interval_ms;
time_t timeout_ms = Curl_pp_state_timeout(pp); time_t timeout_ms = Curl_pp_state_timeout(pp);
struct Curl_easy *data=conn->data; struct Curl_easy *data = conn->data;
CURLcode result = CURLE_OK; CURLcode result = CURLE_OK;
if(timeout_ms <=0) { if(timeout_ms <= 0) {
failf(data, "server response timeout"); failf(data, "server response timeout");
return CURLE_OPERATION_TIMEDOUT; /* already too little time */ return CURLE_OPERATION_TIMEDOUT; /* already too little time */
} }
@ -270,7 +270,7 @@ CURLcode Curl_pp_readresp(curl_socket_t sockfd,
size_t *size) /* size of the response */ size_t *size) /* size of the response */
{ {
ssize_t perline; /* count bytes per line */ ssize_t perline; /* count bytes per line */
bool keepon=TRUE; bool keepon = TRUE;
ssize_t gotbytes; ssize_t gotbytes;
char *ptr; char *ptr;
struct connectdata *conn = pp->conn; struct connectdata *conn = pp->conn;
@ -281,7 +281,7 @@ CURLcode Curl_pp_readresp(curl_socket_t sockfd,
*code = 0; /* 0 for errors or not done */ *code = 0; /* 0 for errors or not done */
*size = 0; *size = 0;
ptr=buf + pp->nread_resp; ptr = buf + pp->nread_resp;
/* number of bytes in the current line, so far */ /* number of bytes in the current line, so far */
perline = (ssize_t)(ptr-pp->linestart_resp); perline = (ssize_t)(ptr-pp->linestart_resp);
@ -351,7 +351,7 @@ CURLcode Curl_pp_readresp(curl_socket_t sockfd,
pp->nread_resp += gotbytes; pp->nread_resp += gotbytes;
for(i = 0; i < gotbytes; ptr++, i++) { for(i = 0; i < gotbytes; ptr++, i++) {
perline++; perline++;
if(*ptr=='\n') { if(*ptr == '\n') {
/* a newline is CRLF in pp-talk, so the CR is ignored as /* a newline is CRLF in pp-talk, so the CR is ignored as
the line isn't really terminated until the LF comes */ the line isn't really terminated until the LF comes */
@ -378,8 +378,8 @@ CURLcode Curl_pp_readresp(curl_socket_t sockfd,
start of the buffer and zero terminate, for old times sake */ start of the buffer and zero terminate, for old times sake */
size_t n = ptr - pp->linestart_resp; size_t n = ptr - pp->linestart_resp;
memmove(buf, pp->linestart_resp, n); memmove(buf, pp->linestart_resp, n);
buf[n]=0; /* zero terminate */ buf[n] = 0; /* zero terminate */
keepon=FALSE; keepon = FALSE;
pp->linestart_resp = ptr+1; /* advance pointer */ pp->linestart_resp = ptr+1; /* advance pointer */
i++; /* skip this before getting out */ i++; /* skip this before getting out */
@ -387,7 +387,7 @@ CURLcode Curl_pp_readresp(curl_socket_t sockfd,
pp->nread_resp = 0; /* restart */ pp->nread_resp = 0; /* restart */
break; break;
} }
perline=0; /* line starts over here */ perline = 0; /* line starts over here */
pp->linestart_resp = ptr+1; pp->linestart_resp = ptr+1;
} }
} }
@ -490,7 +490,7 @@ CURLcode Curl_pp_flushsend(struct pingpong *pp)
} }
else { else {
free(pp->sendthis); free(pp->sendthis);
pp->sendthis=NULL; pp->sendthis = NULL;
pp->sendleft = pp->sendsize = 0; pp->sendleft = pp->sendsize = 0;
pp->response = Curl_tvnow(); pp->response = Curl_tvnow();
} }

View File

@ -134,7 +134,7 @@ int Curl_pgrsDone(struct connectdata *conn)
{ {
int rc; int rc;
struct Curl_easy *data = conn->data; struct Curl_easy *data = conn->data;
data->progress.lastshow=0; data->progress.lastshow = 0;
rc = Curl_pgrsUpdate(conn); /* the final (forced) update */ rc = Curl_pgrsUpdate(conn); /* the final (forced) update */
if(rc) if(rc)
return rc; return rc;
@ -352,9 +352,9 @@ int Curl_pgrsUpdate(struct connectdata *conn)
struct curltime now; struct curltime now;
int result; int result;
char max5[6][10]; char max5[6][10];
curl_off_t dlpercen=0; curl_off_t dlpercen = 0;
curl_off_t ulpercen=0; curl_off_t ulpercen = 0;
curl_off_t total_percen=0; curl_off_t total_percen = 0;
curl_off_t total_transfer; curl_off_t total_transfer;
curl_off_t total_expected_transfer; curl_off_t total_expected_transfer;
curl_off_t timespent; curl_off_t timespent;
@ -365,10 +365,10 @@ int Curl_pgrsUpdate(struct connectdata *conn)
char time_left[10]; char time_left[10];
char time_total[10]; char time_total[10];
char time_spent[10]; char time_spent[10];
curl_off_t ulestimate=0; curl_off_t ulestimate = 0;
curl_off_t dlestimate=0; curl_off_t dlestimate = 0;
curl_off_t total_estimate; curl_off_t total_estimate;
bool shownow=FALSE; bool shownow = FALSE;
now = Curl_tvnow(); /* what time is it */ now = Curl_tvnow(); /* what time is it */
@ -408,7 +408,7 @@ int Curl_pgrsUpdate(struct connectdata *conn)
array. With N_ENTRIES filled in, we have about N_ENTRIES-1 seconds of array. With N_ENTRIES filled in, we have about N_ENTRIES-1 seconds of
transfer. Imagine, after one second we have filled in two entries, transfer. Imagine, after one second we have filled in two entries,
after two seconds we've filled in three entries etc. */ after two seconds we've filled in three entries etc. */
countindex = ((data->progress.speeder_c>=CURR_TIME)? countindex = ((data->progress.speeder_c >= CURR_TIME)?
CURR_TIME:data->progress.speeder_c) - 1; CURR_TIME:data->progress.speeder_c) - 1;
/* first of all, we don't do this if there's no counted seconds yet */ /* first of all, we don't do this if there's no counted seconds yet */
@ -418,14 +418,14 @@ int Curl_pgrsUpdate(struct connectdata *conn)
/* Get the index position to compare with the 'nowindex' position. /* Get the index position to compare with the 'nowindex' position.
Get the oldest entry possible. While we have less than CURR_TIME Get the oldest entry possible. While we have less than CURR_TIME
entries, the first entry will remain the oldest. */ entries, the first entry will remain the oldest. */
checkindex = (data->progress.speeder_c>=CURR_TIME)? checkindex = (data->progress.speeder_c >= CURR_TIME)?
data->progress.speeder_c%CURR_TIME:0; data->progress.speeder_c%CURR_TIME:0;
/* Figure out the exact time for the time span */ /* Figure out the exact time for the time span */
span_ms = Curl_tvdiff(now, span_ms = Curl_tvdiff(now,
data->progress.speeder_time[checkindex]); data->progress.speeder_time[checkindex]);
if(0 == span_ms) if(0 == span_ms)
span_ms=1; /* at least one millisecond MUST have passed */ span_ms = 1; /* at least one millisecond MUST have passed */
/* Calculate the average speed the last 'span_ms' milliseconds */ /* Calculate the average speed the last 'span_ms' milliseconds */
{ {
@ -455,22 +455,22 @@ int Curl_pgrsUpdate(struct connectdata *conn)
if(data->set.fxferinfo) { if(data->set.fxferinfo) {
/* There's a callback set, call that */ /* There's a callback set, call that */
result= data->set.fxferinfo(data->set.progress_client, result = data->set.fxferinfo(data->set.progress_client,
data->progress.size_dl, data->progress.size_dl,
data->progress.downloaded, data->progress.downloaded,
data->progress.size_ul, data->progress.size_ul,
data->progress.uploaded); data->progress.uploaded);
if(result) if(result)
failf(data, "Callback aborted"); failf(data, "Callback aborted");
return result; return result;
} }
if(data->set.fprogress) { if(data->set.fprogress) {
/* The older deprecated callback is set, call that */ /* The older deprecated callback is set, call that */
result= data->set.fprogress(data->set.progress_client, result = data->set.fprogress(data->set.progress_client,
(double)data->progress.size_dl, (double)data->progress.size_dl,
(double)data->progress.downloaded, (double)data->progress.downloaded,
(double)data->progress.size_ul, (double)data->progress.size_ul,
(double)data->progress.uploaded); (double)data->progress.uploaded);
if(result) if(result)
failf(data, "Callback aborted"); failf(data, "Callback aborted");
return result; return result;

View File

@ -250,7 +250,7 @@ static CURLcode rtsp_done(struct connectdata *conn,
static CURLcode rtsp_do(struct connectdata *conn, bool *done) static CURLcode rtsp_do(struct connectdata *conn, bool *done)
{ {
struct Curl_easy *data = conn->data; struct Curl_easy *data = conn->data;
CURLcode result=CURLE_OK; CURLcode result = CURLE_OK;
Curl_RtspReq rtspreq = data->set.rtspreq; Curl_RtspReq rtspreq = data->set.rtspreq;
struct RTSP *rtsp = data->req.protop; struct RTSP *rtsp = data->req.protop;
struct HTTP *http; struct HTTP *http;

View File

@ -7,7 +7,7 @@
* rewrite to work around the paragraph 2 in the BSD licenses as explained * rewrite to work around the paragraph 2 in the BSD licenses as explained
* below. * below.
* *
* Copyright (c) 1998, 1999 Kungliga Tekniska Högskolan * Copyright (c) 1998, 1999, 2017 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden). * (Royal Institute of Technology, Stockholm, Sweden).
* *
* Copyright (C) 2001 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 2001 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
@ -115,7 +115,7 @@ static char level_to_char(int level)
static int ftp_send_command(struct connectdata *conn, const char *message, ...) static int ftp_send_command(struct connectdata *conn, const char *message, ...)
{ {
int ftp_code; int ftp_code;
ssize_t nread=0; ssize_t nread = 0;
va_list args; va_list args;
char print_buffer[50]; char print_buffer[50];

View File

@ -279,7 +279,7 @@ CURLcode Curl_sendf(curl_socket_t sockfd, struct connectdata *conn,
if(!s) if(!s)
return CURLE_OUT_OF_MEMORY; /* failure */ return CURLE_OUT_OF_MEMORY; /* failure */
bytes_written=0; bytes_written = 0;
write_len = strlen(s); write_len = strlen(s);
sptr = s; sptr = s;
@ -387,7 +387,7 @@ ssize_t Curl_send_plain(struct connectdata *conn, int num,
#endif #endif
) { ) {
/* this is just a case of EWOULDBLOCK */ /* this is just a case of EWOULDBLOCK */
bytes_written=0; bytes_written = 0;
*code = CURLE_AGAIN; *code = CURLE_AGAIN;
} }
else { else {
@ -480,7 +480,7 @@ static CURLcode pausewrite(struct Curl_easy *data,
bool newtype = TRUE; bool newtype = TRUE;
if(s->tempcount) { if(s->tempcount) {
for(i=0; i< s->tempcount; i++) { for(i = 0; i< s->tempcount; i++) {
if(s->tempwrite[i].type == type) { if(s->tempwrite[i].type == type) {
/* data for this type exists */ /* data for this type exists */
newtype = FALSE; newtype = FALSE;
@ -704,7 +704,7 @@ CURLcode Curl_read(struct connectdata *conn, /* connection data */
us use the correct ssl handle. */ us use the correct ssl handle. */
int num = (sockfd == conn->sock[SECONDARYSOCKET]); int num = (sockfd == conn->sock[SECONDARYSOCKET]);
*n=0; /* reset amount to zero */ *n = 0; /* reset amount to zero */
/* If session can pipeline, check connection buffer */ /* If session can pipeline, check connection buffer */
if(pipelining) { if(pipelining) {
@ -823,8 +823,8 @@ int Curl_debug(struct Curl_easy *data, curl_infotype type,
int rc; int rc;
if(data->set.printhost && conn && conn->host.dispname) { if(data->set.printhost && conn && conn->host.dispname) {
char buffer[160]; char buffer[160];
const char *t=NULL; const char *t = NULL;
const char *w="Data"; const char *w = "Data";
switch(type) { switch(type) {
case CURLINFO_HEADER_IN: case CURLINFO_HEADER_IN:
w = "Header"; w = "Header";

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2017, 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
@ -154,7 +154,7 @@ CURLcode Curl_SOCKS4(const char *proxy_user,
/* DNS resolve only for SOCKS4, not SOCKS4a */ /* DNS resolve only for SOCKS4, not SOCKS4a */
if(!protocol4a) { if(!protocol4a) {
struct Curl_dns_entry *dns; struct Curl_dns_entry *dns;
Curl_addrinfo *hp=NULL; Curl_addrinfo *hp = NULL;
int rc; int rc;
rc = Curl_resolv(conn, hostname, remote_port, &dns); rc = Curl_resolv(conn, hostname, remote_port, &dns);
@ -171,7 +171,7 @@ CURLcode Curl_SOCKS4(const char *proxy_user,
* returns a Curl_addrinfo pointer that may not always look the same. * returns a Curl_addrinfo pointer that may not always look the same.
*/ */
if(dns) if(dns)
hp=dns->addr; hp = dns->addr;
if(hp) { if(hp) {
char buf[64]; char buf[64];
Curl_printable_address(hp, buf, sizeof(buf)); Curl_printable_address(hp, buf, sizeof(buf));
@ -483,7 +483,7 @@ CURLcode Curl_SOCKS5(const char *proxy_user,
(void)curlx_nonblock(sock, FALSE); (void)curlx_nonblock(sock, FALSE);
result=Curl_blockread_all(conn, sock, (char *)socksreq, 2, &actualread); result = Curl_blockread_all(conn, sock, (char *)socksreq, 2, &actualread);
if(result || (actualread != 2)) { if(result || (actualread != 2)) {
failf(data, "Unable to receive initial SOCKS5 response."); failf(data, "Unable to receive initial SOCKS5 response.");
return CURLE_COULDNT_CONNECT; return CURLE_COULDNT_CONNECT;
@ -542,7 +542,7 @@ CURLcode Curl_SOCKS5(const char *proxy_user,
return CURLE_COULDNT_CONNECT; return CURLE_COULDNT_CONNECT;
} }
result=Curl_blockread_all(conn, sock, (char *)socksreq, 2, &actualread); result = Curl_blockread_all(conn, sock, (char *)socksreq, 2, &actualread);
if(result || (actualread != 2)) { if(result || (actualread != 2)) {
failf(data, "Unable to receive SOCKS5 sub-negotiation response."); failf(data, "Unable to receive SOCKS5 sub-negotiation response.");
return CURLE_COULDNT_CONNECT; return CURLE_COULDNT_CONNECT;
@ -615,7 +615,7 @@ CURLcode Curl_SOCKS5(const char *proxy_user,
* returns a Curl_addrinfo pointer that may not always look the same. * returns a Curl_addrinfo pointer that may not always look the same.
*/ */
if(dns) if(dns)
hp=dns->addr; hp = dns->addr;
if(hp) { if(hp) {
int i; int i;
char buf[64]; char buf[64];

View File

@ -5,8 +5,8 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 2009, 2011, Markus Moeller, <markus_moeller@compuserve.com> * Copyright (C) 2009, Markus Moeller, <markus_moeller@compuserve.com>
* Copyright (C) 2012 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 2012 - 2017, 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
@ -119,7 +119,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
gss_name_t server = GSS_C_NO_NAME; gss_name_t server = GSS_C_NO_NAME;
gss_name_t gss_client_name = GSS_C_NO_NAME; gss_name_t gss_client_name = GSS_C_NO_NAME;
unsigned short us_length; unsigned short us_length;
char *user=NULL; char *user = NULL;
unsigned char socksreq[4]; /* room for GSS-API exchange header only */ unsigned char socksreq[4]; /* room for GSS-API exchange header only */
const char *serviceptr = data->set.str[STRING_PROXY_SERVICE_NAME] ? const char *serviceptr = data->set.str[STRING_PROXY_SERVICE_NAME] ?
data->set.str[STRING_PROXY_SERVICE_NAME] : "rcmd"; data->set.str[STRING_PROXY_SERVICE_NAME] : "rcmd";
@ -236,7 +236,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
* +----+------+-----+----------------+ * +----+------+-----+----------------+
*/ */
result=Curl_blockread_all(conn, sock, (char *)socksreq, 4, &actualread); result = Curl_blockread_all(conn, sock, (char *)socksreq, 4, &actualread);
if(result || (actualread != 4)) { if(result || (actualread != 4)) {
failf(data, "Failed to receive GSS-API authentication response."); failf(data, "Failed to receive GSS-API authentication response.");
gss_release_name(&gss_status, &server); gss_release_name(&gss_status, &server);
@ -264,8 +264,8 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
memcpy(&us_length, socksreq+2, sizeof(short)); memcpy(&us_length, socksreq+2, sizeof(short));
us_length = ntohs(us_length); us_length = ntohs(us_length);
gss_recv_token.length=us_length; gss_recv_token.length = us_length;
gss_recv_token.value=malloc(us_length); gss_recv_token.value = malloc(us_length);
if(!gss_recv_token.value) { if(!gss_recv_token.value) {
failf(data, failf(data,
"Could not allocate memory for GSS-API authentication " "Could not allocate memory for GSS-API authentication "
@ -275,8 +275,8 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
return CURLE_OUT_OF_MEMORY; return CURLE_OUT_OF_MEMORY;
} }
result=Curl_blockread_all(conn, sock, (char *)gss_recv_token.value, result = Curl_blockread_all(conn, sock, (char *)gss_recv_token.value,
gss_recv_token.length, &actualread); gss_recv_token.length, &actualread);
if(result || (actualread != us_length)) { if(result || (actualread != us_length)) {
failf(data, "Failed to receive GSS-API authentication token."); failf(data, "Failed to receive GSS-API authentication token.");
@ -312,7 +312,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
failf(data, "Failed to determine user name."); failf(data, "Failed to determine user name.");
return CURLE_COULDNT_CONNECT; return CURLE_COULDNT_CONNECT;
} }
user=malloc(gss_send_token.length+1); user = malloc(gss_send_token.length+1);
if(!user) { if(!user) {
gss_delete_sec_context(&gss_status, &gss_context, NULL); gss_delete_sec_context(&gss_status, &gss_context, NULL);
gss_release_name(&gss_status, &gss_client_name); gss_release_name(&gss_status, &gss_client_name);
@ -326,7 +326,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
gss_release_buffer(&gss_status, &gss_send_token); gss_release_buffer(&gss_status, &gss_send_token);
infof(data, "SOCKS5 server authencticated user %s with GSS-API.\n",user); infof(data, "SOCKS5 server authencticated user %s with GSS-API.\n",user);
free(user); free(user);
user=NULL; user = NULL;
/* Do encryption */ /* Do encryption */
socksreq[0] = 1; /* GSS-API subnegotiation version */ socksreq[0] = 1; /* GSS-API subnegotiation version */
@ -341,7 +341,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
gss_enc = 1; gss_enc = 1;
infof(data, "SOCKS5 server supports GSS-API %s data protection.\n", infof(data, "SOCKS5 server supports GSS-API %s data protection.\n",
(gss_enc==0)?"no":((gss_enc==1)?"integrity":"confidentiality")); (gss_enc == 0)?"no":((gss_enc==1)?"integrity":"confidentiality"));
/* force for the moment to no data protection */ /* force for the moment to no data protection */
gss_enc = 0; gss_enc = 0;
/* /*
@ -433,7 +433,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
gss_release_buffer(&gss_status, &gss_w_token); gss_release_buffer(&gss_status, &gss_w_token);
} }
result=Curl_blockread_all(conn, sock, (char *)socksreq, 4, &actualread); result = Curl_blockread_all(conn, sock, (char *)socksreq, 4, &actualread);
if(result || (actualread != 4)) { if(result || (actualread != 4)) {
failf(data, "Failed to receive GSS-API encryption response."); failf(data, "Failed to receive GSS-API encryption response.");
gss_delete_sec_context(&gss_status, &gss_context, NULL); gss_delete_sec_context(&gss_status, &gss_context, NULL);
@ -458,14 +458,14 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
memcpy(&us_length, socksreq+2, sizeof(short)); memcpy(&us_length, socksreq+2, sizeof(short));
us_length = ntohs(us_length); us_length = ntohs(us_length);
gss_recv_token.length= us_length; gss_recv_token.length = us_length;
gss_recv_token.value=malloc(gss_recv_token.length); gss_recv_token.value = malloc(gss_recv_token.length);
if(!gss_recv_token.value) { if(!gss_recv_token.value) {
gss_delete_sec_context(&gss_status, &gss_context, NULL); gss_delete_sec_context(&gss_status, &gss_context, NULL);
return CURLE_OUT_OF_MEMORY; return CURLE_OUT_OF_MEMORY;
} }
result=Curl_blockread_all(conn, sock, (char *)gss_recv_token.value, result = Curl_blockread_all(conn, sock, (char *)gss_recv_token.value,
gss_recv_token.length, &actualread); gss_recv_token.length, &actualread);
if(result || (actualread != us_length)) { if(result || (actualread != us_length)) {
failf(data, "Failed to receive GSS-API encryptrion type."); failf(data, "Failed to receive GSS-API encryptrion type.");
@ -513,8 +513,8 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
} }
infof(data, "SOCKS5 access with%s protection granted.\n", infof(data, "SOCKS5 access with%s protection granted.\n",
(socksreq[0]==0)?"out GSS-API data": (socksreq[0] == 0)?"out GSS-API data":
((socksreq[0]==1)?" GSS-API integrity":" GSS-API confidentiality")); ((socksreq[0] == 1)?" GSS-API integrity":" GSS-API confidentiality"));
conn->socks5_gssapi_enctype = socksreq[0]; conn->socks5_gssapi_enctype = socksreq[0];
if(socksreq[0] == 0) if(socksreq[0] == 0)

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 2012 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 2012 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 2009, 2011, Markus Moeller, <markus_moeller@compuserve.com> * Copyright (C) 2009, 2011, Markus Moeller, <markus_moeller@compuserve.com>
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
@ -341,7 +341,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
gss_enc = 1; gss_enc = 1;
infof(data, "SOCKS5 server supports GSS-API %s data protection.\n", infof(data, "SOCKS5 server supports GSS-API %s data protection.\n",
(gss_enc==0)?"no":((gss_enc==1)?"integrity":"confidentiality") ); (gss_enc == 0)?"no":((gss_enc == 1)?"integrity":"confidentiality") );
/* force to no data protection, avoid encryption/decryption for now */ /* force to no data protection, avoid encryption/decryption for now */
gss_enc = 0; gss_enc = 0;
/* /*
@ -588,8 +588,8 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
} }
infof(data, "SOCKS5 access with%s protection granted.\n", infof(data, "SOCKS5 access with%s protection granted.\n",
(socksreq[0]==0)?"out GSS-API data": (socksreq[0] == 0)?"out GSS-API data":
((socksreq[0]==1)?" GSS-API integrity":" GSS-API confidentiality")); ((socksreq[0] == 1)?" GSS-API integrity":" GSS-API confidentiality"));
/* For later use if encryption is required /* For later use if encryption is required
conn->socks5_gssapi_enctype = socksreq[0]; conn->socks5_gssapi_enctype = socksreq[0];

View File

@ -110,7 +110,7 @@ struct Curl_tree *Curl_splayinsert(struct curltime i,
if(t != NULL) { if(t != NULL) {
t = Curl_splay(i, t); t = Curl_splay(i, t);
if(compare(i, t->key)==0) { if(compare(i, t->key) == 0) {
/* There already exists a node in the tree with the very same key. Build /* There already exists a node in the tree with the very same key. Build
a doubly-linked circular list of nodes. We add the new 'node' struct a doubly-linked circular list of nodes. We add the new 'node' struct
to the end of this list. */ to the end of this list. */

View File

@ -1813,7 +1813,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
zero even though libssh2_sftp_open() failed previously! We need zero even though libssh2_sftp_open() failed previously! We need
to work around that! */ to work around that! */
sshc->actualcode = CURLE_SSH; sshc->actualcode = CURLE_SSH;
err=-1; err = -1;
} }
failf(data, "Upload failed: %s (%d/%d)", failf(data, "Upload failed: %s (%d/%d)",
err>= LIBSSH2_FX_OK?sftp_libssh2_strerror(err):"ssh error", err>= LIBSSH2_FX_OK?sftp_libssh2_strerror(err):"ssh error",
@ -1831,7 +1831,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
} }
if(seekerr != CURL_SEEKFUNC_OK) { if(seekerr != CURL_SEEKFUNC_OK) {
curl_off_t passed=0; curl_off_t passed = 0;
if(seekerr != CURL_SEEKFUNC_CANTSEEK) { if(seekerr != CURL_SEEKFUNC_CANTSEEK) {
failf(data, "Could not seek stream"); failf(data, "Could not seek stream");
@ -2239,7 +2239,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
from_t = curlx_strtoofft(conn->data->state.range, &ptr, 0, &from); from_t = curlx_strtoofft(conn->data->state.range, &ptr, 0, &from);
if(from_t == CURL_OFFT_FLOW) if(from_t == CURL_OFFT_FLOW)
return CURLE_RANGE_ERROR; return CURLE_RANGE_ERROR;
while(*ptr && (ISSPACE(*ptr) || (*ptr=='-'))) while(*ptr && (ISSPACE(*ptr) || (*ptr == '-')))
ptr++; ptr++;
to_t = curlx_strtoofft(ptr, &ptr2, 0, &to); to_t = curlx_strtoofft(ptr, &ptr2, 0, &to);
if(to_t == CURL_OFFT_FLOW) if(to_t == CURL_OFFT_FLOW)
@ -3045,8 +3045,8 @@ static CURLcode ssh_do(struct connectdata *conn, bool *done)
data->req.size = -1; /* make sure this is unknown at this point */ data->req.size = -1; /* make sure this is unknown at this point */
sshc->actualcode = CURLE_OK; /* reset error code */ sshc->actualcode = CURLE_OK; /* reset error code */
sshc->secondCreateDirs =0; /* reset the create dir attempt state sshc->secondCreateDirs = 0; /* reset the create dir attempt state
variable */ variable */
Curl_pgrsSetUploadCounter(data, 0); Curl_pgrsSetUploadCounter(data, 0);
Curl_pgrsSetDownloadCounter(data, 0); Curl_pgrsSetDownloadCounter(data, 0);

View File

@ -296,7 +296,7 @@ static void negotiate(struct connectdata *conn)
struct TELNET *tn = (struct TELNET *) conn->data->req.protop; struct TELNET *tn = (struct TELNET *) conn->data->req.protop;
for(i = 0;i < CURL_NTELOPTS;i++) { for(i = 0;i < CURL_NTELOPTS;i++) {
if(i==CURL_TELOPT_ECHO) if(i == CURL_TELOPT_ECHO)
continue; continue;
if(tn->us_preferred[i] == CURL_YES) if(tn->us_preferred[i] == CURL_YES)
@ -843,7 +843,7 @@ static CURLcode check_telnet_options(struct connectdata *conn)
tn->us_preferred[CURL_TELOPT_NEW_ENVIRON] = CURL_YES; tn->us_preferred[CURL_TELOPT_NEW_ENVIRON] = CURL_YES;
} }
for(head = data->set.telnet_options; head; head=head->next) { for(head = data->set.telnet_options; head; head = head->next) {
if(sscanf(head->data, "%127[^= ]%*[ =]%255s", if(sscanf(head->data, "%127[^= ]%*[ =]%255s",
option_keyword, option_arg) == 2) { option_keyword, option_arg) == 2) {
@ -890,8 +890,8 @@ static CURLcode check_telnet_options(struct connectdata *conn)
/* To take care or not of the 8th bit in data exchange */ /* To take care or not of the 8th bit in data exchange */
if(strcasecompare(option_keyword, "BINARY")) { if(strcasecompare(option_keyword, "BINARY")) {
binary_option=atoi(option_arg); binary_option = atoi(option_arg);
if(binary_option!=1) { if(binary_option != 1) {
tn->us_preferred[CURL_TELOPT_BINARY] = CURL_NO; tn->us_preferred[CURL_TELOPT_BINARY] = CURL_NO;
tn->him_preferred[CURL_TELOPT_BINARY] = CURL_NO; tn->him_preferred[CURL_TELOPT_BINARY] = CURL_NO;
} }
@ -1019,8 +1019,8 @@ static void sendsuboption(struct connectdata *conn, int option)
CURL_SB_ACCUM(tn, CURL_TELOPT_NAWS); CURL_SB_ACCUM(tn, CURL_TELOPT_NAWS);
/* We must deal either with litte or big endian processors */ /* We must deal either with litte or big endian processors */
/* Window size must be sent according to the 'network order' */ /* Window size must be sent according to the 'network order' */
x=htons(tn->subopt_wsx); x = htons(tn->subopt_wsx);
y=htons(tn->subopt_wsy); y = htons(tn->subopt_wsy);
uc1 = (unsigned char *)&x; uc1 = (unsigned char *)&x;
uc2 = (unsigned char *)&y; uc2 = (unsigned char *)&y;
CURL_SB_ACCUM(tn, uc1[0]); CURL_SB_ACCUM(tn, uc1[0]);
@ -1064,7 +1064,7 @@ CURLcode telrcv(struct connectdata *conn,
unsigned char c; unsigned char c;
CURLcode result; CURLcode result;
int in = 0; int in = 0;
int startwrite=-1; int startwrite = -1;
struct Curl_easy *data = conn->data; struct Curl_easy *data = conn->data;
struct TELNET *tn = (struct TELNET *)data->req.protop; struct TELNET *tn = (struct TELNET *)data->req.protop;

View File

@ -76,12 +76,12 @@
#define TFTP_OPTION_INTERVAL "timeout" #define TFTP_OPTION_INTERVAL "timeout"
typedef enum { typedef enum {
TFTP_MODE_NETASCII=0, TFTP_MODE_NETASCII = 0,
TFTP_MODE_OCTET TFTP_MODE_OCTET
} tftp_mode_t; } tftp_mode_t;
typedef enum { typedef enum {
TFTP_STATE_START=0, TFTP_STATE_START = 0,
TFTP_STATE_RX, TFTP_STATE_RX,
TFTP_STATE_TX, TFTP_STATE_TX,
TFTP_STATE_FIN TFTP_STATE_FIN
@ -100,7 +100,7 @@ typedef enum {
} tftp_event_t; } tftp_event_t;
typedef enum { typedef enum {
TFTP_ERR_UNDEF=0, TFTP_ERR_UNDEF = 0,
TFTP_ERR_NOTFOUND, TFTP_ERR_NOTFOUND,
TFTP_ERR_PERM, TFTP_ERR_PERM,
TFTP_ERR_DISKFULL, TFTP_ERR_DISKFULL,
@ -232,7 +232,7 @@ static CURLcode tftp_set_timeouts(tftp_state_data_t *state)
/* Compute the re-start interval to suit the timeout */ /* Compute the re-start interval to suit the timeout */
state->retry_time = (int)timeout/state->retry_max; state->retry_time = (int)timeout/state->retry_max;
if(state->retry_time<1) if(state->retry_time<1)
state->retry_time=1; state->retry_time = 1;
} }
else { else {
@ -251,15 +251,15 @@ static CURLcode tftp_set_timeouts(tftp_state_data_t *state)
} }
/* But bound the total number */ /* But bound the total number */
if(state->retry_max<3) if(state->retry_max<3)
state->retry_max=3; state->retry_max = 3;
if(state->retry_max>50) if(state->retry_max>50)
state->retry_max=50; state->retry_max = 50;
/* Compute the re-ACK interval to suit the timeout */ /* Compute the re-ACK interval to suit the timeout */
state->retry_time = (int)(timeout/state->retry_max); state->retry_time = (int)(timeout/state->retry_max);
if(state->retry_time<1) if(state->retry_time<1)
state->retry_time=1; state->retry_time = 1;
infof(state->conn->data, infof(state->conn->data,
"set timeouts for state %d; Total %ld, retry %d maxtry %d\n", "set timeouts for state %d; Total %ld, retry %d maxtry %d\n",
@ -1113,7 +1113,7 @@ static CURLcode tftp_receive_packet(struct connectdata *conn)
0, 0,
(struct sockaddr *)&fromaddr, (struct sockaddr *)&fromaddr,
&fromlen); &fromlen);
if(state->remote_addrlen==0) { if(state->remote_addrlen == 0) {
memcpy(&state->remote_addr, &fromaddr, fromlen); memcpy(&state->remote_addr, &fromaddr, fromlen);
state->remote_addrlen = fromlen; state->remote_addrlen = fromlen;
} }

View File

@ -96,7 +96,7 @@ char *Curl_checkheaders(const struct connectdata *conn,
size_t thislen = strlen(thisheader); size_t thislen = strlen(thisheader);
struct Curl_easy *data = conn->data; struct Curl_easy *data = conn->data;
for(head = data->set.headers;head; head=head->next) { for(head = data->set.headers; head; head = head->next) {
if(strncasecompare(head->data, thisheader, thislen)) if(strncasecompare(head->data, thisheader, thislen))
return head->data; return head->data;
} }
@ -599,7 +599,7 @@ static CURLcode readwrite_data(struct Curl_easy *data,
infof(data, "Ignoring the response-body\n"); infof(data, "Ignoring the response-body\n");
} }
if(data->state.resume_from && !k->content_range && if(data->state.resume_from && !k->content_range &&
(data->set.httpreq==HTTPREQ_GET) && (data->set.httpreq == HTTPREQ_GET) &&
!k->ignorebody) { !k->ignorebody) {
if(k->size == data->state.resume_from) { if(k->size == data->state.resume_from) {
@ -954,7 +954,7 @@ static CURLcode readwrite_upload(struct Curl_easy *data,
/* this is a paused transfer */ /* this is a paused transfer */
break; break;
} }
if(nread<=0) { if(nread <= 0) {
result = done_sending(conn, k); result = done_sending(conn, k);
if(result) if(result)
return result; return result;
@ -1094,7 +1094,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
{ {
struct SingleRequest *k = &data->req; struct SingleRequest *k = &data->req;
CURLcode result; CURLcode result;
int didwhat=0; int didwhat = 0;
curl_socket_t fd_read; curl_socket_t fd_read;
curl_socket_t fd_write; curl_socket_t fd_write;
@ -1342,7 +1342,7 @@ CURLcode Curl_pretransfer(struct Curl_easy *data)
if(result) if(result)
return result; return result;
data->set.followlocation=0; /* reset the location-follow counter */ data->set.followlocation = 0; /* reset the location-follow counter */
data->state.this_is_a_follow = FALSE; /* reset this */ data->state.this_is_a_follow = FALSE; /* reset this */
data->state.errorbuf = FALSE; /* no error has occurred */ data->state.errorbuf = FALSE; /* no error has occurred */
data->state.httpversion = 0; /* don't assume any particular server version */ data->state.httpversion = 0; /* don't assume any particular server version */
@ -1466,14 +1466,14 @@ static const char *find_host_sep(const char *url)
static size_t strlen_url(const char *url, bool relative) static size_t strlen_url(const char *url, bool relative)
{ {
const unsigned char *ptr; const unsigned char *ptr;
size_t newlen=0; size_t newlen = 0;
bool left=TRUE; /* left side of the ? */ bool left = TRUE; /* left side of the ? */
const unsigned char *host_sep = (const unsigned char *) url; const unsigned char *host_sep = (const unsigned char *) url;
if(!relative) if(!relative)
host_sep = (const unsigned char *) find_host_sep(url); host_sep = (const unsigned char *) find_host_sep(url);
for(ptr=(unsigned char *)url; *ptr; ptr++) { for(ptr = (unsigned char *)url; *ptr; ptr++) {
if(ptr < host_sep) { if(ptr < host_sep) {
++newlen; ++newlen;
@ -1482,7 +1482,7 @@ static size_t strlen_url(const char *url, bool relative)
switch(*ptr) { switch(*ptr) {
case '?': case '?':
left=FALSE; left = FALSE;
/* fall through */ /* fall through */
default: default:
if(*ptr >= 0x80) if(*ptr >= 0x80)
@ -1491,7 +1491,7 @@ static size_t strlen_url(const char *url, bool relative)
break; break;
case ' ': case ' ':
if(left) if(left)
newlen+=3; newlen += 3;
else else
newlen++; newlen++;
break; break;
@ -1508,7 +1508,7 @@ static size_t strlen_url(const char *url, bool relative)
static void strcpy_url(char *output, const char *url, bool relative) static void strcpy_url(char *output, const char *url, bool relative)
{ {
/* we must add this with whitespace-replacing */ /* we must add this with whitespace-replacing */
bool left=TRUE; bool left = TRUE;
const unsigned char *iptr; const unsigned char *iptr;
char *optr = output; char *optr = output;
const unsigned char *host_sep = (const unsigned char *) url; const unsigned char *host_sep = (const unsigned char *) url;
@ -1527,7 +1527,7 @@ static void strcpy_url(char *output, const char *url, bool relative)
switch(*iptr) { switch(*iptr) {
case '?': case '?':
left=FALSE; left = FALSE;
/* fall through */ /* fall through */
default: default:
if(*iptr >= 0x80) { if(*iptr >= 0x80) {
@ -1548,7 +1548,7 @@ static void strcpy_url(char *output, const char *url, bool relative)
break; break;
} }
} }
*optr=0; /* zero terminate output buffer */ *optr = 0; /* zero terminate output buffer */
} }
@ -1587,26 +1587,26 @@ static char *concat_url(const char *base, const char *relurl)
/* we must make our own copy of the URL to play with, as it may /* we must make our own copy of the URL to play with, as it may
point to read-only data */ point to read-only data */
char *url_clone=strdup(base); char *url_clone = strdup(base);
if(!url_clone) if(!url_clone)
return NULL; /* skip out of this NOW */ return NULL; /* skip out of this NOW */
/* protsep points to the start of the host name */ /* protsep points to the start of the host name */
protsep=strstr(url_clone, "//"); protsep = strstr(url_clone, "//");
if(!protsep) if(!protsep)
protsep=url_clone; protsep = url_clone;
else else
protsep+=2; /* pass the slashes */ protsep += 2; /* pass the slashes */
if('/' != relurl[0]) { if('/' != relurl[0]) {
int level=0; int level = 0;
/* First we need to find out if there's a ?-letter in the URL, /* First we need to find out if there's a ?-letter in the URL,
and cut it and the right-side of that off */ and cut it and the right-side of that off */
pathsep = strchr(protsep, '?'); pathsep = strchr(protsep, '?');
if(pathsep) if(pathsep)
*pathsep=0; *pathsep = 0;
/* we have a relative path to append to the last slash if there's one /* we have a relative path to append to the last slash if there's one
available, or if the new URL is just a query string (starts with a available, or if the new URL is just a query string (starts with a
@ -1615,7 +1615,7 @@ static char *concat_url(const char *base, const char *relurl)
if(useurl[0] != '?') { if(useurl[0] != '?') {
pathsep = strrchr(protsep, '/'); pathsep = strrchr(protsep, '/');
if(pathsep) if(pathsep)
*pathsep=0; *pathsep = 0;
} }
/* Check if there's any slash after the host name, and if so, remember /* Check if there's any slash after the host name, and if so, remember
@ -1630,13 +1630,13 @@ static char *concat_url(const char *base, const char *relurl)
and act accordingly */ and act accordingly */
if((useurl[0] == '.') && (useurl[1] == '/')) if((useurl[0] == '.') && (useurl[1] == '/'))
useurl+=2; /* just skip the "./" */ useurl += 2; /* just skip the "./" */
while((useurl[0] == '.') && while((useurl[0] == '.') &&
(useurl[1] == '.') && (useurl[1] == '.') &&
(useurl[2] == '/')) { (useurl[2] == '/')) {
level++; level++;
useurl+=3; /* pass the "../" */ useurl += 3; /* pass the "../" */
} }
if(protsep) { if(protsep) {
@ -1644,9 +1644,9 @@ static char *concat_url(const char *base, const char *relurl)
/* cut off one more level from the right of the original URL */ /* cut off one more level from the right of the original URL */
pathsep = strrchr(protsep, '/'); pathsep = strrchr(protsep, '/');
if(pathsep) if(pathsep)
*pathsep=0; *pathsep = 0;
else { else {
*protsep=0; *protsep = 0;
break; break;
} }
} }
@ -1658,7 +1658,7 @@ static char *concat_url(const char *base, const char *relurl)
if((relurl[0] == '/') && (relurl[1] == '/')) { if((relurl[0] == '/') && (relurl[1] == '/')) {
/* the new URL starts with //, just keep the protocol part from the /* the new URL starts with //, just keep the protocol part from the
original one */ original one */
*protsep=0; *protsep = 0;
useurl = &relurl[2]; /* we keep the slashes from the original, so we useurl = &relurl[2]; /* we keep the slashes from the original, so we
skip the new ones */ skip the new ones */
host_changed = TRUE; host_changed = TRUE;
@ -1674,7 +1674,7 @@ static char *concat_url(const char *base, const char *relurl)
char *sep = strchr(protsep, '?'); char *sep = strchr(protsep, '?');
if(sep && (sep < pathsep)) if(sep && (sep < pathsep))
pathsep = sep; pathsep = sep;
*pathsep=0; *pathsep = 0;
} }
else { else {
/* There was no slash. Now, since we might be operating on a badly /* There was no slash. Now, since we might be operating on a badly
@ -1683,7 +1683,7 @@ static char *concat_url(const char *base, const char *relurl)
?-letter as well! */ ?-letter as well! */
pathsep = strchr(protsep, '?'); pathsep = strchr(protsep, '?');
if(pathsep) if(pathsep)
*pathsep=0; *pathsep = 0;
} }
} }
} }

View File

@ -285,7 +285,7 @@ void Curl_freeset(struct Curl_easy *data)
{ {
/* Free all dynamic strings stored in the data->set substructure. */ /* Free all dynamic strings stored in the data->set substructure. */
enum dupstring i; enum dupstring i;
for(i=(enum dupstring)0; i < STRING_LAST; i++) { for(i = (enum dupstring)0; i < STRING_LAST; i++) {
Curl_safefree(data->set.str[i]); Curl_safefree(data->set.str[i]);
} }
@ -372,7 +372,7 @@ CURLcode Curl_dupset(struct Curl_easy *dst, struct Curl_easy *src)
memset(dst->set.str, 0, STRING_LAST * sizeof(char *)); memset(dst->set.str, 0, STRING_LAST * sizeof(char *));
/* duplicate all strings */ /* duplicate all strings */
for(i=(enum dupstring)0; i< STRING_LASTZEROTERMINATED; i++) { for(i = (enum dupstring)0; i< STRING_LASTZEROTERMINATED; i++) {
result = setstropt(&dst->set.str[i], src->set.str[i]); result = setstropt(&dst->set.str[i], src->set.str[i]);
if(result) if(result)
return result; return result;
@ -681,7 +681,7 @@ CURLcode Curl_open(struct Curl_easy **curl)
else { else {
result = Curl_init_userdefined(&data->set); result = Curl_init_userdefined(&data->set);
data->state.headersize=HEADERSIZE; data->state.headersize = HEADERSIZE;
Curl_convert_init(data); Curl_convert_init(data);
@ -1677,28 +1677,28 @@ CURLcode Curl_setopt(struct Curl_easy *data, CURLoption option,
* The low speed limit that if transfers are below this for * The low speed limit that if transfers are below this for
* CURLOPT_LOW_SPEED_TIME, the transfer is aborted. * CURLOPT_LOW_SPEED_TIME, the transfer is aborted.
*/ */
data->set.low_speed_limit=va_arg(param, long); data->set.low_speed_limit = va_arg(param, long);
break; break;
case CURLOPT_MAX_SEND_SPEED_LARGE: case CURLOPT_MAX_SEND_SPEED_LARGE:
/* /*
* When transfer uploads are faster then CURLOPT_MAX_SEND_SPEED_LARGE * When transfer uploads are faster then CURLOPT_MAX_SEND_SPEED_LARGE
* bytes per second the transfer is throttled.. * bytes per second the transfer is throttled..
*/ */
data->set.max_send_speed=va_arg(param, curl_off_t); data->set.max_send_speed = va_arg(param, curl_off_t);
break; break;
case CURLOPT_MAX_RECV_SPEED_LARGE: case CURLOPT_MAX_RECV_SPEED_LARGE:
/* /*
* When receiving data faster than CURLOPT_MAX_RECV_SPEED_LARGE bytes per * When receiving data faster than CURLOPT_MAX_RECV_SPEED_LARGE bytes per
* second the transfer is throttled.. * second the transfer is throttled..
*/ */
data->set.max_recv_speed=va_arg(param, curl_off_t); data->set.max_recv_speed = va_arg(param, curl_off_t);
break; break;
case CURLOPT_LOW_SPEED_TIME: case CURLOPT_LOW_SPEED_TIME:
/* /*
* The low speed time that if transfers are below the set * The low speed time that if transfers are below the set
* CURLOPT_LOW_SPEED_LIMIT during this time, the transfer is aborted. * CURLOPT_LOW_SPEED_LIMIT during this time, the transfer is aborted.
*/ */
data->set.low_speed_time=va_arg(param, long); data->set.low_speed_time = va_arg(param, long);
break; break;
case CURLOPT_URL: case CURLOPT_URL:
/* /*
@ -2935,7 +2935,7 @@ CURLcode Curl_setopt(struct Curl_easy *data, CURLoption option,
return CURLE_NOT_BUILT_IN; return CURLE_NOT_BUILT_IN;
#else #else
arg = va_arg(param, long); arg = va_arg(param, long);
if((arg>=1) && (arg <= 256)) if((arg >= 1) && (arg <= 256))
data->set.stream_weight = (int)arg; data->set.stream_weight = (int)arg;
break; break;
#endif #endif
@ -3301,7 +3301,7 @@ Curl_oldest_idle_connection(struct Curl_easy *data)
struct curl_hash_iterator iter; struct curl_hash_iterator iter;
struct curl_llist_element *curr; struct curl_llist_element *curr;
struct curl_hash_element *he; struct curl_hash_element *he;
time_t highscore=-1; time_t highscore =- 1;
time_t score; time_t score;
struct curltime now; struct curltime now;
struct connectdata *conn_candidate = NULL; struct connectdata *conn_candidate = NULL;
@ -3364,7 +3364,7 @@ find_oldest_idle_connection_in_bundle(struct Curl_easy *data,
struct connectbundle *bundle) struct connectbundle *bundle)
{ {
struct curl_llist_element *curr; struct curl_llist_element *curr;
time_t highscore=-1; time_t highscore = -1;
time_t score; time_t score;
struct curltime now; struct curltime now;
struct connectdata *conn_candidate = NULL; struct connectdata *conn_candidate = NULL;
@ -3995,7 +3995,7 @@ int Curl_doing_getsock(struct connectdata *conn,
CURLcode Curl_protocol_connecting(struct connectdata *conn, CURLcode Curl_protocol_connecting(struct connectdata *conn,
bool *done) bool *done)
{ {
CURLcode result=CURLE_OK; CURLcode result = CURLE_OK;
if(conn && conn->handler->connecting) { if(conn && conn->handler->connecting) {
*done = FALSE; *done = FALSE;
@ -4014,7 +4014,7 @@ CURLcode Curl_protocol_connecting(struct connectdata *conn,
CURLcode Curl_protocol_doing(struct connectdata *conn, bool *done) CURLcode Curl_protocol_doing(struct connectdata *conn, bool *done)
{ {
CURLcode result=CURLE_OK; CURLcode result = CURLE_OK;
if(conn && conn->handler->doing) { if(conn && conn->handler->doing) {
*done = FALSE; *done = FALSE;
@ -4034,7 +4034,7 @@ CURLcode Curl_protocol_doing(struct connectdata *conn, bool *done)
CURLcode Curl_protocol_connect(struct connectdata *conn, CURLcode Curl_protocol_connect(struct connectdata *conn,
bool *protocol_done) bool *protocol_done)
{ {
CURLcode result=CURLE_OK; CURLcode result = CURLE_OK;
*protocol_done = FALSE; *protocol_done = FALSE;
@ -4121,7 +4121,7 @@ static void fix_hostname(struct connectdata *conn, struct hostname *host)
if(len && (host->name[len-1] == '.')) if(len && (host->name[len-1] == '.'))
/* strip off a single trailing dot if present, primarily for SNI but /* strip off a single trailing dot if present, primarily for SNI but
there's no use for it */ there's no use for it */
host->name[len-1]=0; host->name[len-1] = 0;
/* Check name for non-ASCII and convert hostname to ACE form if we can */ /* Check name for non-ASCII and convert hostname to ACE form if we can */
if(!is_ASCII_name(host->name)) { if(!is_ASCII_name(host->name)) {
@ -4537,7 +4537,7 @@ static CURLcode parseurlandfillconn(struct Curl_easy *data,
else { else {
/* clear path */ /* clear path */
char slashbuf[4]; char slashbuf[4];
path[0]=0; path[0] = 0;
rc = sscanf(data->change.url, rc = sscanf(data->change.url,
"%15[^\n/:]:%3[/]%[^\n/?#]%[^\n]", "%15[^\n/:]:%3[/]%[^\n/?#]%[^\n]",
@ -4648,7 +4648,7 @@ static CURLcode parseurlandfillconn(struct Curl_easy *data,
path[0]='/'; /* prepend the missing slash */ path[0]='/'; /* prepend the missing slash */
rebuild_url = TRUE; rebuild_url = TRUE;
*query=0; /* now cut off the hostname at the ? */ *query = 0; /* now cut off the hostname at the ? */
} }
else if(!path[0]) { else if(!path[0]) {
/* if there's no path set, use a single slash */ /* if there's no path set, use a single slash */
@ -5040,7 +5040,7 @@ static char *detect_proxy(struct connectdata *conn)
strcpy(envp, "_proxy"); strcpy(envp, "_proxy");
/* read the protocol proxy: */ /* read the protocol proxy: */
prox=curl_getenv(proxy_env); prox = curl_getenv(proxy_env);
/* /*
* We don't try the uppercase version of HTTP_PROXY because of * We don't try the uppercase version of HTTP_PROXY because of
@ -5057,7 +5057,7 @@ static char *detect_proxy(struct connectdata *conn)
if(!prox && !strcasecompare("http_proxy", proxy_env)) { if(!prox && !strcasecompare("http_proxy", proxy_env)) {
/* There was no lowercase variable, try the uppercase version: */ /* There was no lowercase variable, try the uppercase version: */
Curl_strntoupper(proxy_env, proxy_env, sizeof(proxy_env)); Curl_strntoupper(proxy_env, proxy_env, sizeof(proxy_env));
prox=curl_getenv(proxy_env); prox = curl_getenv(proxy_env);
} }
if(prox) if(prox)
@ -5065,7 +5065,7 @@ static char *detect_proxy(struct connectdata *conn)
else { else {
proxy = curl_getenv("all_proxy"); /* default proxy to use */ proxy = curl_getenv("all_proxy"); /* default proxy to use */
if(!proxy) if(!proxy)
proxy=curl_getenv("ALL_PROXY"); proxy = curl_getenv("ALL_PROXY");
} }
return proxy; return proxy;
@ -5813,7 +5813,7 @@ static CURLcode parse_remote_port(struct Curl_easy *data,
char *rest; char *rest;
long port; long port;
port=strtol(portptr+1, &rest, 10); /* Port number must be decimal */ port = strtol(portptr+1, &rest, 10); /* Port number must be decimal */
if((port < 0) || (port > 0xffff)) { if((port < 0) || (port > 0xffff)) {
/* Single unix standard says port numbers are 16 bits long */ /* Single unix standard says port numbers are 16 bits long */
@ -6169,7 +6169,7 @@ static CURLcode resolve_server(struct Curl_easy *data,
struct connectdata *conn, struct connectdata *conn,
bool *async) bool *async)
{ {
CURLcode result=CURLE_OK; CURLcode result = CURLE_OK;
time_t timeout_ms = Curl_timeleft(data, NULL, TRUE); time_t timeout_ms = Curl_timeleft(data, NULL, TRUE);
/************************************************************* /*************************************************************
@ -6332,7 +6332,7 @@ static void reuse_conn(struct connectdata *old_conn,
free_fixed_hostname(&conn->conn_to_host); free_fixed_hostname(&conn->conn_to_host);
Curl_safefree(conn->host.rawalloc); Curl_safefree(conn->host.rawalloc);
Curl_safefree(conn->conn_to_host.rawalloc); Curl_safefree(conn->conn_to_host.rawalloc);
conn->host=old_conn->host; conn->host = old_conn->host;
conn->bits.conn_to_host = old_conn->bits.conn_to_host; conn->bits.conn_to_host = old_conn->bits.conn_to_host;
conn->conn_to_host = old_conn->conn_to_host; conn->conn_to_host = old_conn->conn_to_host;
conn->bits.conn_to_port = old_conn->bits.conn_to_port; conn->bits.conn_to_port = old_conn->bits.conn_to_port;
@ -6435,9 +6435,9 @@ static CURLcode create_conn(struct Curl_easy *data,
* other parts of the code will rely on this fact * other parts of the code will rely on this fact
***********************************************************/ ***********************************************************/
#define LEAST_PATH_ALLOC 256 #define LEAST_PATH_ALLOC 256
urllen=strlen(data->change.url); urllen = strlen(data->change.url);
if(urllen < LEAST_PATH_ALLOC) if(urllen < LEAST_PATH_ALLOC)
urllen=LEAST_PATH_ALLOC; urllen = LEAST_PATH_ALLOC;
/* /*
* We malloc() the buffers below urllen+2 to make room for 2 possibilities: * We malloc() the buffers below urllen+2 to make room for 2 possibilities:
@ -7088,7 +7088,7 @@ CURLcode Curl_init_do(struct Curl_easy *data, struct connectdata *conn)
k->buf = data->state.buffer; k->buf = data->state.buffer;
k->hbufp = data->state.headerbuff; k->hbufp = data->state.headerbuff;
k->ignorebody=FALSE; k->ignorebody = FALSE;
Curl_speedinit(data); Curl_speedinit(data);

View File

@ -204,7 +204,7 @@ static CURLcode connect_prep(struct connectdata *conn, int sockindex)
/* Load client certificate */ /* Load client certificate */
if(SSL_SET_OPTION(cert)) { if(SSL_SET_OPTION(cert)) {
i=0; i = 0;
/* Instead of trying to analyze cert type here, let axTLS try them all. */ /* Instead of trying to analyze cert type here, let axTLS try them all. */
while(cert_types[i] != 0) { while(cert_types[i] != 0) {
ssl_fcn_return = ssl_obj_load(ssl_ctx, cert_types[i], ssl_fcn_return = ssl_obj_load(ssl_ctx, cert_types[i],
@ -228,7 +228,7 @@ static CURLcode connect_prep(struct connectdata *conn, int sockindex)
If a pkcs12 file successfully loaded a cert, then there's nothing to do If a pkcs12 file successfully loaded a cert, then there's nothing to do
because the key has already been loaded. */ because the key has already been loaded. */
if(SSL_SET_OPTION(key) && cert_types[i] != SSL_OBJ_PKCS12) { if(SSL_SET_OPTION(key) && cert_types[i] != SSL_OBJ_PKCS12) {
i=0; i = 0;
/* Instead of trying to analyze key type here, let axTLS try them all. */ /* Instead of trying to analyze key type here, let axTLS try them all. */
while(key_types[i] != 0) { while(key_types[i] != 0) {
ssl_fcn_return = ssl_obj_load(ssl_ctx, key_types[i], ssl_fcn_return = ssl_obj_load(ssl_ctx, key_types[i],
@ -444,7 +444,7 @@ static CURLcode Curl_axtls_connect_nonblocking(struct connectdata *conn,
/* Loop to perform more work in between sleeps. This is work around the /* Loop to perform more work in between sleeps. This is work around the
fact that axtls does not expose any knowledge about when work needs fact that axtls does not expose any knowledge about when work needs
to be performed. This can save ~25% of time on SSL handshakes. */ to be performed. This can save ~25% of time on SSL handshakes. */
for(i=0; i<5; i++) { for(i = 0; i<5; i++) {
ssl_fcn_return = ssl_read(BACKEND->ssl, NULL); ssl_fcn_return = ssl_read(BACKEND->ssl, NULL);
if(ssl_fcn_return < 0) { if(ssl_fcn_return < 0) {
Curl_axtls_close(conn, sockindex); Curl_axtls_close(conn, sockindex);

View File

@ -828,7 +828,7 @@ cyassl_connect_common(struct connectdata *conn,
return CURLE_OK; return CURLE_OK;
} }
if(ssl_connect_1==connssl->connecting_state) { if(ssl_connect_1 == connssl->connecting_state) {
/* Find out how much more time we're allowed */ /* Find out how much more time we're allowed */
timeout_ms = Curl_timeleft(data, NULL, TRUE); timeout_ms = Curl_timeleft(data, NULL, TRUE);
@ -860,9 +860,9 @@ cyassl_connect_common(struct connectdata *conn,
if(connssl->connecting_state == ssl_connect_2_reading if(connssl->connecting_state == ssl_connect_2_reading
|| connssl->connecting_state == ssl_connect_2_writing) { || connssl->connecting_state == ssl_connect_2_writing) {
curl_socket_t writefd = ssl_connect_2_writing== curl_socket_t writefd = ssl_connect_2_writing ==
connssl->connecting_state?sockfd:CURL_SOCKET_BAD; connssl->connecting_state?sockfd:CURL_SOCKET_BAD;
curl_socket_t readfd = ssl_connect_2_reading== curl_socket_t readfd = ssl_connect_2_reading ==
connssl->connecting_state?sockfd:CURL_SOCKET_BAD; connssl->connecting_state?sockfd:CURL_SOCKET_BAD;
what = Curl_socket_check(readfd, CURL_SOCKET_BAD, writefd, what = Curl_socket_check(readfd, CURL_SOCKET_BAD, writefd,

View File

@ -1045,7 +1045,7 @@ static OSStatus CopyIdentityWithLabel(char *label,
keys_list_count = CFArrayGetCount(keys_list); keys_list_count = CFArrayGetCount(keys_list);
*out_cert_and_key = NULL; *out_cert_and_key = NULL;
status = 1; status = 1;
for(i=0; i<keys_list_count; i++) { for(i = 0; i<keys_list_count; i++) {
OSStatus err = noErr; OSStatus err = noErr;
SecCertificateRef cert = NULL; SecCertificateRef cert = NULL;
SecIdentityRef identity = SecIdentityRef identity =
@ -2499,7 +2499,7 @@ darwinssl_connect_common(struct connectdata *conn,
return CURLE_OK; return CURLE_OK;
} }
if(ssl_connect_1==connssl->connecting_state) { if(ssl_connect_1 == connssl->connecting_state) {
/* Find out how much more time we're allowed */ /* Find out how much more time we're allowed */
timeout_ms = Curl_timeleft(data, NULL, TRUE); timeout_ms = Curl_timeleft(data, NULL, TRUE);

View File

@ -306,9 +306,9 @@ static CURLcode handshake(struct connectdata *conn,
if(connssl->connecting_state == ssl_connect_2_reading if(connssl->connecting_state == ssl_connect_2_reading
|| connssl->connecting_state == ssl_connect_2_writing) { || connssl->connecting_state == ssl_connect_2_writing) {
curl_socket_t writefd = ssl_connect_2_writing== curl_socket_t writefd = ssl_connect_2_writing ==
connssl->connecting_state?sockfd:CURL_SOCKET_BAD; connssl->connecting_state?sockfd:CURL_SOCKET_BAD;
curl_socket_t readfd = ssl_connect_2_reading== curl_socket_t readfd = ssl_connect_2_reading ==
connssl->connecting_state?sockfd:CURL_SOCKET_BAD; connssl->connecting_state?sockfd:CURL_SOCKET_BAD;
what = Curl_socket_check(readfd, CURL_SOCKET_BAD, writefd, what = Curl_socket_check(readfd, CURL_SOCKET_BAD, writefd,
@ -1208,7 +1208,7 @@ gtls_connect_step3(struct connectdata *conn,
SSL_SET_OPTION(issuercert)?SSL_SET_OPTION(issuercert):"none"); SSL_SET_OPTION(issuercert)?SSL_SET_OPTION(issuercert):"none");
} }
size=sizeof(certbuf); size = sizeof(certbuf);
rc = gnutls_x509_crt_get_dn_by_oid(x509_cert, GNUTLS_OID_X520_COMMON_NAME, rc = gnutls_x509_crt_get_dn_by_oid(x509_cert, GNUTLS_OID_X520_COMMON_NAME,
0, /* the first and only one */ 0, /* the first and only one */
FALSE, FALSE,
@ -1248,7 +1248,7 @@ gtls_connect_step3(struct connectdata *conn,
#endif #endif
if(addrlen) { if(addrlen) {
for(i=0; ; i++) { for(i = 0; ; i++) {
certaddrlen = sizeof(certaddr); certaddrlen = sizeof(certaddr);
ret = gnutls_x509_crt_get_subject_alt_name(x509_cert, i, certaddr, ret = gnutls_x509_crt_get_subject_alt_name(x509_cert, i, certaddr,
&certaddrlen, NULL); &certaddrlen, NULL);
@ -1481,7 +1481,7 @@ gtls_connect_common(struct connectdata *conn,
struct ssl_connect_data *connssl = &conn->ssl[sockindex]; struct ssl_connect_data *connssl = &conn->ssl[sockindex];
/* Initiate the connection, if not already done */ /* Initiate the connection, if not already done */
if(ssl_connect_1==connssl->connecting_state) { if(ssl_connect_1 == connssl->connecting_state) {
rc = gtls_connect_step1(conn, sockindex); rc = gtls_connect_step1(conn, sockindex);
if(rc) if(rc)
return rc; return rc;
@ -1493,13 +1493,13 @@ gtls_connect_common(struct connectdata *conn,
return rc; return rc;
/* Finish connecting once the handshake is done */ /* Finish connecting once the handshake is done */
if(ssl_connect_1==connssl->connecting_state) { if(ssl_connect_1 == connssl->connecting_state) {
rc = gtls_connect_step3(conn, sockindex); rc = gtls_connect_step3(conn, sockindex);
if(rc) if(rc)
return rc; return rc;
} }
*done = ssl_connect_1==connssl->connecting_state; *done = ssl_connect_1 == connssl->connecting_state;
return CURLE_OK; return CURLE_OK;
} }

View File

@ -253,7 +253,7 @@ mbed_connect_step1(struct connectdata *conn,
const long int port = SSL_IS_PROXY() ? conn->port : conn->remote_port; const long int port = SSL_IS_PROXY() ? conn->port : conn->remote_port;
int ret = -1; int ret = -1;
char errorbuf[128]; char errorbuf[128];
errorbuf[0]=0; errorbuf[0] = 0;
/* mbedTLS only supports SSLv3 and TLSv1 */ /* mbedTLS only supports SSLv3 and TLSv1 */
if(SSL_CONN_CONFIG(version) == CURL_SSLVERSION_SSLv2) { if(SSL_CONN_CONFIG(version) == CURL_SSLVERSION_SSLv2) {
@ -829,7 +829,7 @@ static CURLcode Curl_mbedtls_random(struct Curl_easy *data,
mbedtls_ctr_drbg_context ctr_drbg; mbedtls_ctr_drbg_context ctr_drbg;
mbedtls_entropy_init(&ctr_entropy); mbedtls_entropy_init(&ctr_entropy);
mbedtls_ctr_drbg_init(&ctr_drbg); mbedtls_ctr_drbg_init(&ctr_drbg);
errorbuf[0]=0; errorbuf[0] = 0;
ret = mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func, ret = mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func,
&ctr_entropy, NULL, 0); &ctr_entropy, NULL, 0);
@ -887,7 +887,7 @@ mbed_connect_common(struct connectdata *conn,
return CURLE_OK; return CURLE_OK;
} }
if(ssl_connect_1==connssl->connecting_state) { if(ssl_connect_1 == connssl->connecting_state) {
/* Find out how much more time we're allowed */ /* Find out how much more time we're allowed */
timeout_ms = Curl_timeleft(data, NULL, TRUE); timeout_ms = Curl_timeleft(data, NULL, TRUE);
@ -918,9 +918,9 @@ mbed_connect_common(struct connectdata *conn,
if(connssl->connecting_state == ssl_connect_2_reading if(connssl->connecting_state == ssl_connect_2_reading
|| connssl->connecting_state == ssl_connect_2_writing) { || connssl->connecting_state == ssl_connect_2_writing) {
curl_socket_t writefd = ssl_connect_2_writing== curl_socket_t writefd = ssl_connect_2_writing ==
connssl->connecting_state?sockfd:CURL_SOCKET_BAD; connssl->connecting_state?sockfd:CURL_SOCKET_BAD;
curl_socket_t readfd = ssl_connect_2_reading== curl_socket_t readfd = ssl_connect_2_reading ==
connssl->connecting_state?sockfd:CURL_SOCKET_BAD; connssl->connecting_state?sockfd:CURL_SOCKET_BAD;
what = Curl_socket_check(readfd, CURL_SOCKET_BAD, writefd, what = Curl_socket_check(readfd, CURL_SOCKET_BAD, writefd,
@ -960,13 +960,13 @@ mbed_connect_common(struct connectdata *conn,
} /* repeat step2 until all transactions are done. */ } /* repeat step2 until all transactions are done. */
if(ssl_connect_3==connssl->connecting_state) { if(ssl_connect_3 == connssl->connecting_state) {
retcode = mbed_connect_step3(conn, sockindex); retcode = mbed_connect_step3(conn, sockindex);
if(retcode) if(retcode)
return retcode; return retcode;
} }
if(ssl_connect_done==connssl->connecting_state) { if(ssl_connect_done == connssl->connecting_state) {
connssl->state = ssl_connection_complete; connssl->state = ssl_connection_complete;
conn->recv[sockindex] = mbed_recv; conn->recv[sockindex] = mbed_recv;
conn->send[sockindex] = mbed_send; conn->send[sockindex] = mbed_send;

View File

@ -281,7 +281,7 @@ static SECStatus set_ciphers(struct Curl_easy *data, PRFileDesc * model,
found = PR_FALSE; found = PR_FALSE;
for(i=0; i<NUM_OF_CIPHERS; i++) { for(i = 0; i<NUM_OF_CIPHERS; i++) {
if(strcasecompare(cipher, cipherlist[i].name)) { if(strcasecompare(cipher, cipherlist[i].name)) {
cipher_state[i] = PR_TRUE; cipher_state[i] = PR_TRUE;
found = PR_TRUE; found = PR_TRUE;
@ -300,7 +300,7 @@ static SECStatus set_ciphers(struct Curl_easy *data, PRFileDesc * model,
} }
/* Finally actually enable the selected ciphers */ /* Finally actually enable the selected ciphers */
for(i=0; i<NUM_OF_CIPHERS; i++) { for(i = 0; i<NUM_OF_CIPHERS; i++) {
if(!cipher_state[i]) if(!cipher_state[i])
continue; continue;
@ -321,7 +321,7 @@ static bool any_cipher_enabled(void)
{ {
unsigned int i; unsigned int i;
for(i=0; i<NUM_OF_CIPHERS; i++) { for(i = 0; i<NUM_OF_CIPHERS; i++) {
PRInt32 policy = 0; PRInt32 policy = 0;
SSL_CipherPolicyGet(cipherlist[i].num, &policy); SSL_CipherPolicyGet(cipherlist[i].num, &policy);
if(policy) if(policy)
@ -1002,7 +1002,7 @@ static SECStatus check_issuer_cert(PRFileDesc *sock,
char *issuer_nickname) char *issuer_nickname)
{ {
CERTCertificate *cert, *cert_issuer, *issuer; CERTCertificate *cert, *cert_issuer, *issuer;
SECStatus res=SECSuccess; SECStatus res = SECSuccess;
void *proto_win = NULL; void *proto_win = NULL;
cert = SSL_PeerCertificate(sock); cert = SSL_PeerCertificate(sock);
@ -1014,7 +1014,7 @@ static SECStatus check_issuer_cert(PRFileDesc *sock,
if((!cert_issuer) || (!issuer)) if((!cert_issuer) || (!issuer))
res = SECFailure; res = SECFailure;
else if(SECITEM_CompareItem(&cert_issuer->derCert, else if(SECITEM_CompareItem(&cert_issuer->derCert,
&issuer->derCert)!=SECEqual) &issuer->derCert) != SECEqual)
res = SECFailure; res = SECFailure;
CERT_DestroyCertificate(cert); CERT_DestroyCertificate(cert);

View File

@ -459,7 +459,7 @@ static CURLcode Curl_ossl_seed(struct Curl_easy *data)
} while(!rand_enough()); } while(!rand_enough());
/* generates a default path for the random seed file */ /* generates a default path for the random seed file */
fname[0]=0; /* blank it first */ fname[0] = 0; /* blank it first */
RAND_file_name(fname, sizeof(fname)); RAND_file_name(fname, sizeof(fname));
if(fname[0]) { if(fname[0]) {
/* we got a file name to try */ /* we got a file name to try */
@ -755,7 +755,7 @@ int cert_stuff(struct connectdata *conn,
break; break;
if(!key_file) if(!key_file)
/* cert & key can only be in PEM case in the same file */ /* cert & key can only be in PEM case in the same file */
key_file=cert_file; key_file = cert_file;
/* FALLTHROUGH */ /* FALLTHROUGH */
case SSL_FILETYPE_ASN1: case SSL_FILETYPE_ASN1:
if(SSL_CTX_use_PrivateKey_file(ctx, key_file, file_type) != 1) { if(SSL_CTX_use_PrivateKey_file(ctx, key_file, file_type) != 1) {
@ -818,13 +818,13 @@ int cert_stuff(struct connectdata *conn,
return 0; return 0;
} }
ssl=SSL_new(ctx); ssl = SSL_new(ctx);
if(!ssl) { if(!ssl) {
failf(data, "unable to create an SSL structure"); failf(data, "unable to create an SSL structure");
return 0; return 0;
} }
x509=SSL_get_certificate(ssl); x509 = SSL_get_certificate(ssl);
/* This version was provided by Evan Jordan and is supposed to not /* This version was provided by Evan Jordan and is supposed to not
leak memory as the previous version: */ leak memory as the previous version: */
@ -872,7 +872,7 @@ static int x509_name_oneline(X509_NAME *a, char *buf, size_t size)
size--; /* don't overwrite the buffer end */ size--; /* don't overwrite the buffer end */
memcpy(buf, biomem->data, size); memcpy(buf, biomem->data, size);
buf[size]=0; buf[size] = 0;
BIO_free(bio_out); BIO_free(bio_out);
@ -1357,7 +1357,7 @@ static CURLcode verifyhost(struct connectdata *conn, X509 *server_cert)
numalts = sk_GENERAL_NAME_num(altnames); numalts = sk_GENERAL_NAME_num(altnames);
/* loop through all alternatives - until a dnsmatch */ /* loop through all alternatives - until a dnsmatch */
for(i=0; (i < numalts) && !dnsmatched; i++) { for(i = 0; (i < numalts) && !dnsmatched; i++) {
/* get a handle to alternative name number i */ /* get a handle to alternative name number i */
const GENERAL_NAME *check = sk_GENERAL_NAME_value(altnames, i); const GENERAL_NAME *check = sk_GENERAL_NAME_value(altnames, i);
@ -1426,7 +1426,7 @@ static CURLcode verifyhost(struct connectdata *conn, X509 *server_cert)
else { else {
/* we have to look to the last occurrence of a commonName in the /* we have to look to the last occurrence of a commonName in the
distinguished one to get the most significant one. */ distinguished one to get the most significant one. */
int j, i=-1; int j, i = -1;
/* The following is done because of a bug in 0.9.6b */ /* The following is done because of a bug in 0.9.6b */
@ -1435,14 +1435,14 @@ static CURLcode verifyhost(struct connectdata *conn, X509 *server_cert)
X509_NAME *name = X509_get_subject_name(server_cert); X509_NAME *name = X509_get_subject_name(server_cert);
if(name) if(name)
while((j = X509_NAME_get_index_by_NID(name, NID_commonName, i))>=0) while((j = X509_NAME_get_index_by_NID(name, NID_commonName, i)) >= 0)
i=j; i = j;
/* we have the name entry and we will now convert this to a string /* we have the name entry and we will now convert this to a string
that we can use for comparison. Doing this we support BMPstring, that we can use for comparison. Doing this we support BMPstring,
UTF8 etc. */ UTF8 etc. */
if(i>=0) { if(i >= 0) {
ASN1_STRING *tmp = ASN1_STRING *tmp =
X509_NAME_ENTRY_get_data(X509_NAME_get_entry(name, i)); X509_NAME_ENTRY_get_data(X509_NAME_get_entry(name, i));
@ -2351,7 +2351,7 @@ static CURLcode ossl_connect_step1(struct connectdata *conn, int sockindex)
if(ssl_crlfile) { if(ssl_crlfile) {
/* tell SSL where to find CRL file that is used to check certificate /* tell SSL where to find CRL file that is used to check certificate
* revocation */ * revocation */
lookup=X509_STORE_add_lookup(SSL_CTX_get_cert_store(BACKEND->ctx), lookup = X509_STORE_add_lookup(SSL_CTX_get_cert_store(BACKEND->ctx),
X509_LOOKUP_file()); X509_LOOKUP_file());
if(!lookup || if(!lookup ||
(!X509_load_crl_file(lookup, ssl_crlfile, X509_FILETYPE_PEM)) ) { (!X509_load_crl_file(lookup, ssl_crlfile, X509_FILETYPE_PEM)) ) {
@ -2631,7 +2631,7 @@ static int asn1_object_dump(ASN1_OBJECT *a, char *buf, size_t len)
do { \ do { \
long info_len = BIO_get_mem_data(mem, &ptr); \ long info_len = BIO_get_mem_data(mem, &ptr); \
Curl_ssl_push_certinfo_len(data, _num, _label, ptr, info_len); \ Curl_ssl_push_certinfo_len(data, _num, _label, ptr, info_len); \
if(1!=BIO_reset(mem)) \ if(1 != BIO_reset(mem)) \
break; \ break; \
} WHILE_FALSE } WHILE_FALSE
@ -2679,12 +2679,12 @@ static int X509V3_ext(struct Curl_easy *data,
/* no extensions, bail out */ /* no extensions, bail out */
return 1; return 1;
for(i=0; i < (int)sk_X509_EXTENSION_num(exts); i++) { for(i = 0; i < (int)sk_X509_EXTENSION_num(exts); i++) {
ASN1_OBJECT *obj; ASN1_OBJECT *obj;
X509_EXTENSION *ext = sk_X509_EXTENSION_value(exts, i); X509_EXTENSION *ext = sk_X509_EXTENSION_value(exts, i);
BUF_MEM *biomem; BUF_MEM *biomem;
char buf[512]; char buf[512];
char *ptr=buf; char *ptr = buf;
char namebuf[128]; char namebuf[128];
BIO *bio_out = BIO_new(BIO_s_mem()); BIO *bio_out = BIO_new(BIO_s_mem());
@ -2701,16 +2701,16 @@ static int X509V3_ext(struct Curl_easy *data,
BIO_get_mem_ptr(bio_out, &biomem); BIO_get_mem_ptr(bio_out, &biomem);
for(j = 0; j < (size_t)biomem->length; j++) { for(j = 0; j < (size_t)biomem->length; j++) {
const char *sep=""; const char *sep = "";
if(biomem->data[j] == '\n') { if(biomem->data[j] == '\n') {
sep=", "; sep = ", ";
j++; /* skip the newline */ j++; /* skip the newline */
}; };
while((j<(size_t)biomem->length) && (biomem->data[j] == ' ')) while((j<(size_t)biomem->length) && (biomem->data[j] == ' '))
j++; j++;
if(j<(size_t)biomem->length) if(j<(size_t)biomem->length)
ptr+=snprintf(ptr, sizeof(buf)-(ptr-buf), "%s%c", sep, ptr += snprintf(ptr, sizeof(buf)-(ptr-buf), "%s%c", sep,
biomem->data[j]); biomem->data[j]);
} }
Curl_ssl_push_certinfo(data, certnum, namebuf, buf); Curl_ssl_push_certinfo(data, certnum, namebuf, buf);
@ -2749,7 +2749,7 @@ static CURLcode get_cert_chain(struct connectdata *conn,
for(i = 0; i < numcerts; i++) { for(i = 0; i < numcerts; i++) {
ASN1_INTEGER *num; ASN1_INTEGER *num;
X509 *x = sk_X509_value(sk, i); X509 *x = sk_X509_value(sk, i);
EVP_PKEY *pubkey=NULL; EVP_PKEY *pubkey = NULL;
int j; int j;
char *ptr; char *ptr;
const ASN1_BIT_STRING *psig = NULL; const ASN1_BIT_STRING *psig = NULL;
@ -3281,9 +3281,9 @@ static CURLcode ossl_connect_common(struct connectdata *conn,
if(connssl->connecting_state == ssl_connect_2_reading || if(connssl->connecting_state == ssl_connect_2_reading ||
connssl->connecting_state == ssl_connect_2_writing) { connssl->connecting_state == ssl_connect_2_writing) {
curl_socket_t writefd = ssl_connect_2_writing== curl_socket_t writefd = ssl_connect_2_writing ==
connssl->connecting_state?sockfd:CURL_SOCKET_BAD; connssl->connecting_state?sockfd:CURL_SOCKET_BAD;
curl_socket_t readfd = ssl_connect_2_reading== curl_socket_t readfd = ssl_connect_2_reading ==
connssl->connecting_state?sockfd:CURL_SOCKET_BAD; connssl->connecting_state?sockfd:CURL_SOCKET_BAD;
what = Curl_socket_check(readfd, CURL_SOCKET_BAD, writefd, what = Curl_socket_check(readfd, CURL_SOCKET_BAD, writefd,
@ -3502,9 +3502,9 @@ static size_t Curl_ossl_version(char *buffer, size_t size)
unsigned long ssleay_value; unsigned long ssleay_value;
sub[2]='\0'; sub[2]='\0';
sub[1]='\0'; sub[1]='\0';
ssleay_value=OpenSSL_version_num(); ssleay_value = OpenSSL_version_num();
if(ssleay_value < 0x906000) { if(ssleay_value < 0x906000) {
ssleay_value=SSLEAY_VERSION_NUMBER; ssleay_value = SSLEAY_VERSION_NUMBER;
sub[0]='\0'; sub[0]='\0';
} }
else { else {

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 2012 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 2012 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 2010 - 2011, Hoi-Ho Chan, <hoiho.chan@gmail.com> * Copyright (C) 2010 - 2011, Hoi-Ho Chan, <hoiho.chan@gmail.com>
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
@ -227,7 +227,7 @@ polarssl_connect_step1(struct connectdata *conn,
const long int port = SSL_IS_PROXY() ? conn->port : conn->remote_port; const long int port = SSL_IS_PROXY() ? conn->port : conn->remote_port;
int ret = -1; int ret = -1;
char errorbuf[128]; char errorbuf[128];
errorbuf[0]=0; errorbuf[0] = 0;
/* PolarSSL only supports SSLv3 and TLSv1 */ /* PolarSSL only supports SSLv3 and TLSv1 */
if(SSL_CONN_CONFIG(version) == CURL_SSLVERSION_SSLv2) { if(SSL_CONN_CONFIG(version) == CURL_SSLVERSION_SSLv2) {
@ -777,9 +777,9 @@ polarssl_connect_common(struct connectdata *conn,
if(connssl->connecting_state == ssl_connect_2_reading || if(connssl->connecting_state == ssl_connect_2_reading ||
connssl->connecting_state == ssl_connect_2_writing) { connssl->connecting_state == ssl_connect_2_writing) {
curl_socket_t writefd = ssl_connect_2_writing== curl_socket_t writefd = ssl_connect_2_writing ==
connssl->connecting_state?sockfd:CURL_SOCKET_BAD; connssl->connecting_state?sockfd:CURL_SOCKET_BAD;
curl_socket_t readfd = ssl_connect_2_reading== curl_socket_t readfd = ssl_connect_2_reading ==
connssl->connecting_state?sockfd:CURL_SOCKET_BAD; connssl->connecting_state?sockfd:CURL_SOCKET_BAD;
what = Curl_socket_check(readfd, CURL_SOCKET_BAD, writefd, what = Curl_socket_check(readfd, CURL_SOCKET_BAD, writefd,

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 2013-2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 2013-2017, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 2010, 2011, Hoi-Ho Chan, <hoiho.chan@gmail.com> * Copyright (C) 2010, 2011, Hoi-Ho Chan, <hoiho.chan@gmail.com>
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
@ -114,7 +114,7 @@ int Curl_polarsslthreadlock_lock_function(int n)
} }
#elif defined(HAVE_PROCESS_H) #elif defined(HAVE_PROCESS_H)
if(n < NUMT) { if(n < NUMT) {
ret = (WaitForSingleObject(mutex_buf[n], INFINITE)==WAIT_FAILED?1:0); ret = (WaitForSingleObject(mutex_buf[n], INFINITE) == WAIT_FAILED?1:0);
if(ret) { if(ret) {
DEBUGF(fprintf(stderr, DEBUGF(fprintf(stderr,
"Error: polarsslthreadlock_lock_function failed\n")); "Error: polarsslthreadlock_lock_function failed\n"));

View File

@ -147,7 +147,7 @@ int Curl_ssl_backend(void)
#ifdef USE_SSL #ifdef USE_SSL
/* "global" init done? */ /* "global" init done? */
static bool init_ssl=FALSE; static bool init_ssl = FALSE;
/** /**
* Global SSL init * Global SSL init
@ -383,7 +383,7 @@ void Curl_ssl_kill_session(struct curl_ssl_session *session)
void Curl_ssl_delsessionid(struct connectdata *conn, void *ssl_sessionid) void Curl_ssl_delsessionid(struct connectdata *conn, void *ssl_sessionid)
{ {
size_t i; size_t i;
struct Curl_easy *data=conn->data; struct Curl_easy *data = conn->data;
for(i = 0; i < data->set.general_ssl.max_ssl_sessions; i++) { for(i = 0; i < data->set.general_ssl.max_ssl_sessions; i++) {
struct curl_ssl_session *check = &data->state.session[i]; struct curl_ssl_session *check = &data->state.session[i];
@ -407,9 +407,9 @@ CURLcode Curl_ssl_addsessionid(struct connectdata *conn,
int sockindex) int sockindex)
{ {
size_t i; size_t i;
struct Curl_easy *data=conn->data; /* the mother of all structs */ struct Curl_easy *data = conn->data; /* the mother of all structs */
struct curl_ssl_session *store = &data->state.session[0]; struct curl_ssl_session *store = &data->state.session[0];
long oldest_age=data->state.session[0].age; /* zero if unused */ long oldest_age = data->state.session[0].age; /* zero if unused */
char *clone_host; char *clone_host;
char *clone_conn_to_host; char *clone_conn_to_host;
int conn_to_port; int conn_to_port;
@ -643,7 +643,7 @@ void Curl_ssl_free_certinfo(struct Curl_easy *data)
if(ci->num_of_certs) { if(ci->num_of_certs) {
/* free all individual lists used */ /* free all individual lists used */
for(i=0; i<ci->num_of_certs; i++) { for(i = 0; i<ci->num_of_certs; i++) {
curl_slist_free_all(ci->certinfo[i]); curl_slist_free_all(ci->certinfo[i]);
ci->certinfo[i] = NULL; ci->certinfo[i] = NULL;
} }

View File

@ -141,11 +141,11 @@ CURLcode easysrc_perform(void)
const char *c; const char *c;
CHKRET(easysrc_add(&easysrc_code, "")); CHKRET(easysrc_add(&easysrc_code, ""));
/* Preamble comment */ /* Preamble comment */
for(i=0; ((c = srchard[i]) != NULL); i++) for(i = 0; ((c = srchard[i]) != NULL); i++)
CHKRET(easysrc_add(&easysrc_code, c)); CHKRET(easysrc_add(&easysrc_code, c));
/* Each unconverted option */ /* Each unconverted option */
if(easysrc_toohard) { if(easysrc_toohard) {
for(ptr=easysrc_toohard->first; ptr; ptr = ptr->next) for(ptr = easysrc_toohard->first; ptr; ptr = ptr->next)
CHKRET(easysrc_add(&easysrc_code, ptr->data)); CHKRET(easysrc_add(&easysrc_code, ptr->data));
} }
CHKRET(easysrc_add(&easysrc_code, "")); CHKRET(easysrc_add(&easysrc_code, ""));
@ -189,12 +189,12 @@ void dumpeasysrc(struct GlobalConfig *config)
int i; int i;
const char *c; const char *c;
for(i=0; ((c = srchead[i]) != NULL); i++) for(i = 0; ((c = srchead[i]) != NULL); i++)
fprintf(out, "%s\n", c); fprintf(out, "%s\n", c);
/* Declare variables used for complex setopt values */ /* Declare variables used for complex setopt values */
if(easysrc_decl) { if(easysrc_decl) {
for(ptr=easysrc_decl->first; ptr; ptr = ptr->next) for(ptr = easysrc_decl->first; ptr; ptr = ptr->next)
fprintf(out, " %s\n", ptr->data); fprintf(out, " %s\n", ptr->data);
} }
@ -202,13 +202,13 @@ void dumpeasysrc(struct GlobalConfig *config)
if(easysrc_data) { if(easysrc_data) {
fprintf(out, "\n"); fprintf(out, "\n");
for(ptr=easysrc_data->first; ptr; ptr = ptr->next) for(ptr = easysrc_data->first; ptr; ptr = ptr->next)
fprintf(out, " %s\n", ptr->data); fprintf(out, " %s\n", ptr->data);
} }
fprintf(out, "\n"); fprintf(out, "\n");
if(easysrc_code) { if(easysrc_code) {
for(ptr=easysrc_code->first; ptr; ptr = ptr->next) { for(ptr = easysrc_code->first; ptr; ptr = ptr->next) {
if(ptr->data[0]) { if(ptr->data[0]) {
fprintf(out, " %s\n", ptr->data); fprintf(out, " %s\n", ptr->data);
} }
@ -219,11 +219,11 @@ void dumpeasysrc(struct GlobalConfig *config)
} }
if(easysrc_clean) { if(easysrc_clean) {
for(ptr=easysrc_clean->first; ptr; ptr = ptr->next) for(ptr = easysrc_clean->first; ptr; ptr = ptr->next)
fprintf(out, " %s\n", ptr->data); fprintf(out, " %s\n", ptr->data);
} }
for(i=0; ((c = srcend[i]) != NULL); i++) for(i = 0; ((c = srcend[i]) != NULL); i++)
fprintf(out, "%s\n", c); fprintf(out, "%s\n", c);
if(fopened) if(fopened)

View File

@ -77,7 +77,7 @@ static char *get_param_word(char **str, char **end_pos)
while(ptr < *end_pos); while(ptr < *end_pos);
*end_pos = ptr2; *end_pos = ptr2;
} }
while(*ptr && NULL==strchr(end_chars, *ptr)) while(*ptr && NULL == strchr(end_chars, *ptr))
++ptr; ++ptr;
*str = ptr; *str = ptr;
return word_begin+1; return word_begin+1;
@ -88,7 +88,7 @@ static char *get_param_word(char **str, char **end_pos)
ptr = word_begin; ptr = word_begin;
} }
while(*ptr && NULL==strchr(end_chars, *ptr)) while(*ptr && NULL == strchr(end_chars, *ptr))
++ptr; ++ptr;
*str = *end_pos = ptr; *str = *end_pos = ptr;
return word_begin; return word_begin;

View File

@ -492,7 +492,7 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */
if(!longopt) { if(!longopt) {
letter = (char)*parse; letter = (char)*parse;
subletter='\0'; subletter = '\0';
} }
else { else {
letter = parse[0]; letter = parse[0];
@ -1190,7 +1190,7 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */
config->resume_from_current = TRUE; config->resume_from_current = TRUE;
config->resume_from = 0; config->resume_from = 0;
} }
config->use_resume=TRUE; config->use_resume = TRUE;
break; break;
case 'd': case 'd':
/* postfield data */ /* postfield data */
@ -1608,7 +1608,7 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */
nextarg, nextarg,
&config->mimepost, &config->mimepost,
&config->mimecurrent, &config->mimecurrent,
(subletter=='s')?TRUE:FALSE)) /* 's' means literal string */ (subletter == 's')?TRUE:FALSE)) /* 's' is literal string */
return PARAM_BAD_USE; return PARAM_BAD_USE;
if(SetHTTPrequest(config, HTTPREQ_MIMEPOST, &config->httpreq)) if(SetHTTPrequest(config, HTTPREQ_MIMEPOST, &config->httpreq))
return PARAM_BAD_USE; return PARAM_BAD_USE;
@ -2053,7 +2053,7 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */
break; break;
} }
now = time(NULL); now = time(NULL);
config->condtime=curl_getdate(nextarg, &now); config->condtime = curl_getdate(nextarg, &now);
if(-1 == (int)config->condtime) { if(-1 == (int)config->condtime) {
/* now let's see if it is a file name to get the time from instead! */ /* now let's see if it is a file name to get the time from instead! */
struct_stat statbuf; struct_stat statbuf;

View File

@ -525,7 +525,7 @@ static CURLcode operate_do(struct GlobalConfig *global,
urlnum = 1; /* without globbing, this is a single URL */ urlnum = 1; /* without globbing, this is a single URL */
/* if multiple files extracted to stdout, insert separators! */ /* if multiple files extracted to stdout, insert separators! */
separator= ((!outfiles || !strcmp(outfiles, "-")) && urlnum > 1); separator = ((!outfiles || !strcmp(outfiles, "-")) && urlnum > 1);
/* Here's looping around each globbed URL */ /* Here's looping around each globbed URL */
for(li = 0 ; li < urlnum; li++) { for(li = 0 ; li < urlnum; li++) {
@ -822,7 +822,7 @@ static CURLcode operate_do(struct GlobalConfig *global,
if(strchr(pc, '?')) if(strchr(pc, '?'))
/* Ouch, there's already a question mark in the URL string, we /* Ouch, there's already a question mark in the URL string, we
then append the data with an ampersand separator instead! */ then append the data with an ampersand separator instead! */
sep='&'; sep = '&';
} }
/* /*
* Then append ? followed by the get fields to the url. * Then append ? followed by the get fields to the url.

View File

@ -334,7 +334,7 @@ long proto2num(struct OperationConfig *config, long *val, const char *str)
} }
} }
for(pp=protos; pp->name; pp++) { for(pp = protos; pp->name; pp++) {
if(curl_strequal(token, pp->name)) { if(curl_strequal(token, pp->name)) {
switch(action) { switch(action) {
case deny: case deny:

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2017, 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
@ -131,7 +131,7 @@ int parseconfig(const char *filename, struct GlobalConfig *global)
while(NULL != (aline = my_get_line(file))) { while(NULL != (aline = my_get_line(file))) {
lineno++; lineno++;
line = aline; line = aline;
alloced_param=FALSE; alloced_param = FALSE;
/* line with # in the first non-blank column is a comment! */ /* line with # in the first non-blank column is a comment! */
while(*line && ISSPACE(*line)) while(*line && ISSPACE(*line))

View File

@ -229,24 +229,24 @@ static char *c_escape(const char *str, size_t len)
return NULL; return NULL;
e = escaped; e = escaped;
for(s=str; (c=*s) != '\0'; s++) { for(s = str; (c = *s) != '\0'; s++) {
if(c=='\n') { if(c == '\n') {
strcpy(e, "\\n"); strcpy(e, "\\n");
e += 2; e += 2;
} }
else if(c=='\r') { else if(c == '\r') {
strcpy(e, "\\r"); strcpy(e, "\\r");
e += 2; e += 2;
} }
else if(c=='\t') { else if(c == '\t') {
strcpy(e, "\\t"); strcpy(e, "\\t");
e += 2; e += 2;
} }
else if(c=='\\') { else if(c == '\\') {
strcpy(e, "\\\\"); strcpy(e, "\\\\");
e += 2; e += 2;
} }
else if(c=='"') { else if(c == '"') {
strcpy(e, "\\\""); strcpy(e, "\\\"");
e += 2; e += 2;
} }
@ -276,7 +276,7 @@ CURLcode tool_setopt_enum(CURL *curl, struct GlobalConfig *config,
if(config->libcurl && !skip && !ret) { if(config->libcurl && !skip && !ret) {
/* we only use this for real if --libcurl was used */ /* we only use this for real if --libcurl was used */
const NameValue *nv = NULL; const NameValue *nv = NULL;
for(nv=nvlist; nv->name; nv++) { for(nv = nvlist; nv->name; nv++) {
if(nv->value == lval) break; /* found it */ if(nv->value == lval) break; /* found it */
} }
if(! nv->name) { if(! nv->name) {
@ -313,7 +313,7 @@ CURLcode tool_setopt_flags(CURL *curl, struct GlobalConfig *config,
const NameValue *nv = NULL; const NameValue *nv = NULL;
snprintf(preamble, sizeof(preamble), snprintf(preamble, sizeof(preamble),
"curl_easy_setopt(hnd, %s, ", name); "curl_easy_setopt(hnd, %s, ", name);
for(nv=nvlist; nv->name; nv++) { for(nv = nvlist; nv->name; nv++) {
if((nv->value & ~ rest) == 0) { if((nv->value & ~ rest) == 0) {
/* all value flags contained in rest */ /* all value flags contained in rest */
rest &= ~ nv->value; /* remove bits handled here */ rest &= ~ nv->value; /* remove bits handled here */
@ -356,7 +356,7 @@ CURLcode tool_setopt_bitmask(CURL *curl, struct GlobalConfig *config,
const NameValueUnsigned *nv = NULL; const NameValueUnsigned *nv = NULL;
snprintf(preamble, sizeof(preamble), snprintf(preamble, sizeof(preamble),
"curl_easy_setopt(hnd, %s, ", name); "curl_easy_setopt(hnd, %s, ", name);
for(nv=nvlist; nv->name; nv++) { for(nv = nvlist; nv->name; nv++) {
if((nv->value & ~ rest) == 0) { if((nv->value & ~ rest) == 0) {
/* all value flags contained in rest */ /* all value flags contained in rest */
rest &= ~ nv->value; /* remove bits handled here */ rest &= ~ nv->value; /* remove bits handled here */
@ -632,7 +632,7 @@ CURLcode tool_setopt(CURL *curl, bool str, struct GlobalConfig *config,
long lval = va_arg(arg, long); long lval = va_arg(arg, long);
long defval = 0L; long defval = 0L;
const NameValue *nv = NULL; const NameValue *nv = NULL;
for(nv=setopt_nv_CURLNONZERODEFAULTS; nv->name; nv++) { for(nv = setopt_nv_CURLNONZERODEFAULTS; nv->name; nv++) {
if(!strcmp(name, nv->name)) { if(!strcmp(name, nv->name)) {
defval = nv->value; defval = nv->value;
break; /* found it */ break; /* found it */

View File

@ -259,7 +259,7 @@ static CURLcode glob_range(URLGlob *glob, char **patternp,
errno = 0; errno = 0;
min_n = strtoul(pattern, &endp, 10); min_n = strtoul(pattern, &endp, 10);
if(errno || (endp == pattern)) if(errno || (endp == pattern))
endp=NULL; endp = NULL;
else { else {
if(*endp != '-') if(*endp != '-')
endp = NULL; endp = NULL;
@ -287,7 +287,7 @@ static CURLcode glob_range(URLGlob *glob, char **patternp,
else else
step_n = 1; step_n = 1;
if(endp && (*endp == ']')) { if(endp && (*endp == ']')) {
pattern= endp+1; pattern = endp+1;
} }
else else
endp = NULL; endp = NULL;
@ -444,7 +444,7 @@ CURLcode glob_url(URLGlob **glob, char *url, unsigned long *urlnum,
glob_buffer = malloc(strlen(url) + 1); glob_buffer = malloc(strlen(url) + 1);
if(!glob_buffer) if(!glob_buffer)
return CURLE_OUT_OF_MEMORY; return CURLE_OUT_OF_MEMORY;
glob_buffer[0]=0; glob_buffer[0] = 0;
glob_expand = calloc(1, sizeof(URLGlob)); glob_expand = calloc(1, sizeof(URLGlob));
if(!glob_expand) { if(!glob_expand) {
@ -623,12 +623,12 @@ CURLcode glob_match_url(char **result, char *filename, URLGlob *glob)
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);
URLPattern *pat =NULL; URLPattern *pat = NULL;
if(num < glob->size) { if(num < glob->size) {
num--; /* make it zero based */ num--; /* make it zero based */
/* find the correct glob entry */ /* find the correct glob entry */
for(i=0; i<glob->size; i++) { for(i = 0; i<glob->size; i++) {
if(glob->pattern[i].globindex == (int)num) { if(glob->pattern[i].globindex == (int)num) {
pat = &glob->pattern[i]; pat = &glob->pattern[i];
break; break;

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2017, 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
@ -72,8 +72,8 @@ void wait_ms(int ms)
select_wrapper(0, NULL, NULL, NULL, &t); select_wrapper(0, NULL, NULL, NULL, &t);
} }
char *libtest_arg2=NULL; char *libtest_arg2 = NULL;
char *libtest_arg3=NULL; char *libtest_arg3 = NULL;
int test_argc; int test_argc;
char **test_argv; char **test_argv;
@ -123,7 +123,7 @@ char *hexdump(const unsigned char *buffer, size_t len)
size_t i; size_t i;
if(len > 200) if(len > 200)
return NULL; return NULL;
for(i=0; i<len; i++, p += 3) for(i = 0; i<len; i++, p += 3)
snprintf(p, 4, "%02x ", buffer[i]); snprintf(p, 4, "%02x ", buffer[i]);
return dump; return dump;
} }
@ -162,10 +162,10 @@ int main(int argc, char **argv)
test_argv = argv; test_argv = argv;
if(argc>2) if(argc>2)
libtest_arg2=argv[2]; libtest_arg2 = argv[2];
if(argc>3) if(argc>3)
libtest_arg3=argv[3]; libtest_arg3 = argv[3];
URL = argv[1]; /* provide this to the rest */ URL = argv[1]; /* provide this to the rest */

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 2013, Linus Nielsen Feltzing <linus@haxx.se> * Copyright (C) 2013, 2017, Linus Nielsen Feltzing <linus@haxx.se>
* *
* 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
@ -45,7 +45,7 @@ int test(char *URL)
(void)URL; (void)URL;
/* Create fake DNS entries for serverX.example.com for all handles */ /* Create fake DNS entries for serverX.example.com for all handles */
for(i=0; i < NUM_HANDLES; i++) { for(i = 0; i < NUM_HANDLES; i++) {
snprintf(dnsentry, sizeof(dnsentry), "server%d.example.com:%s:%s", snprintf(dnsentry, sizeof(dnsentry), "server%d.example.com:%s:%s",
i + 1, port, address); i + 1, port, address);
printf("%s\n", dnsentry); printf("%s\n", dnsentry);
@ -66,7 +66,7 @@ int test(char *URL)
multi_setopt(m, CURLMOPT_MAXCONNECTS, 3L); multi_setopt(m, CURLMOPT_MAXCONNECTS, 3L);
/* get NUM_HANDLES easy handles */ /* get NUM_HANDLES easy handles */
for(i=0; i < NUM_HANDLES; i++) { for(i = 0; i < NUM_HANDLES; i++) {
/* get an easy handle */ /* get an easy handle */
easy_init(curl[i]); easy_init(curl[i]);
/* specify target */ /* specify target */
@ -85,7 +85,7 @@ int test(char *URL)
fprintf(stderr, "Start at URL 0\n"); fprintf(stderr, "Start at URL 0\n");
for(i=0; i < NUM_HANDLES; i++) { for(i = 0; i < NUM_HANDLES; i++) {
/* add handle to multi */ /* add handle to multi */
multi_add_handle(m, curl[i]); multi_add_handle(m, curl[i]);
@ -123,7 +123,7 @@ test_cleanup:
/* proper cleanup sequence - type PB */ /* proper cleanup sequence - type PB */
for(i=0; i < NUM_HANDLES; i++) { for(i = 0; i < NUM_HANDLES; i++) {
curl_multi_remove_handle(m, curl[i]); curl_multi_remove_handle(m, curl[i]);
curl_easy_cleanup(curl[i]); curl_easy_cleanup(curl[i]);
} }

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 2013, Linus Nielsen Feltzing <linus@haxx.se> * Copyright (C) 2013, 2017, Linus Nielsen Feltzing <linus@haxx.se>
* *
* 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
@ -43,7 +43,7 @@ int test(char *URL)
(void)URL; (void)URL;
/* Create fake DNS entries for serverX.example.com for all handles */ /* Create fake DNS entries for serverX.example.com for all handles */
for(i=0; i < NUM_URLS; i++) { for(i = 0; i < NUM_URLS; i++) {
snprintf(dnsentry, sizeof(dnsentry), "server%d.example.com:%s:%s", i + 1, snprintf(dnsentry, sizeof(dnsentry), "server%d.example.com:%s:%s", i + 1,
port, address); port, address);
printf("%s\n", dnsentry); printf("%s\n", dnsentry);
@ -72,7 +72,7 @@ int test(char *URL)
easy_setopt(curl, CURLOPT_MAXCONNECTS, 3L); easy_setopt(curl, CURLOPT_MAXCONNECTS, 3L);
/* get NUM_HANDLES easy handles */ /* get NUM_HANDLES easy handles */
for(i=0; i < NUM_URLS; i++) { for(i = 0; i < NUM_URLS; i++) {
/* specify target */ /* specify target */
snprintf(target_url, sizeof(target_url), snprintf(target_url, sizeof(target_url),
"http://server%d.example.com:%s/path/1510%04i", "http://server%d.example.com:%s/path/1510%04i",

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 2013 - 2016, Linus Nielsen Feltzing <linus@haxx.se> * Copyright (C) 2013 - 2017, Linus Nielsen Feltzing <linus@haxx.se>
* *
* 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
@ -55,7 +55,7 @@ int test(char *URL)
slist = curl_slist_append(slist, dnsentry); slist = curl_slist_append(slist, dnsentry);
/* get NUM_HANDLES easy handles */ /* get NUM_HANDLES easy handles */
for(i=0; i < NUM_HANDLES; i++) { for(i = 0; i < NUM_HANDLES; i++) {
/* get an easy handle */ /* get an easy handle */
easy_init(curl[i]); easy_init(curl[i]);
/* specify target */ /* specify target */
@ -76,7 +76,7 @@ int test(char *URL)
easy_setopt(curl[0], CURLOPT_RESOLVE, slist); easy_setopt(curl[0], CURLOPT_RESOLVE, slist);
/* run NUM_HANDLES transfers */ /* run NUM_HANDLES transfers */
for(i=0; (i < NUM_HANDLES) && !res; i++) for(i = 0; (i < NUM_HANDLES) && !res; i++)
res = curl_easy_perform(curl[i]); res = curl_easy_perform(curl[i]);
test_cleanup: test_cleanup:

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2015, 2017, 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
@ -48,7 +48,7 @@ static int progressKiller(void *arg,
int test(char *URL) int test(char *URL)
{ {
CURL *curl; CURL *curl;
int res=0; int res = 0;
global_init(CURL_GLOBAL_ALL); global_init(CURL_GLOBAL_ALL);

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2017, 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,7 +54,7 @@ static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *userp)
int test(char *URL) int test(char *URL)
{ {
CURL *curl; CURL *curl;
CURLcode res=CURLE_OK; CURLcode res = CURLE_OK;
struct WriteThis pooh; struct WriteThis pooh;

View File

@ -37,13 +37,14 @@ int test(char *URL)
curl_easy_strerror(-INT_MAX); curl_easy_strerror(-INT_MAX);
curl_multi_strerror(-INT_MAX); curl_multi_strerror(-INT_MAX);
curl_share_strerror(-INT_MAX); curl_share_strerror(-INT_MAX);
for(easyret=CURLE_OK; easyret <= CURL_LAST; easyret++) { for(easyret = CURLE_OK; easyret <= CURL_LAST; easyret++) {
printf("e%d: %s\n", (int)easyret, curl_easy_strerror(easyret)); printf("e%d: %s\n", (int)easyret, curl_easy_strerror(easyret));
} }
for(multiret=CURLM_CALL_MULTI_PERFORM; multiret <= CURLM_LAST; multiret++) { for(multiret = CURLM_CALL_MULTI_PERFORM; multiret <= CURLM_LAST;
multiret++) {
printf("m%d: %s\n", (int)multiret, curl_multi_strerror(multiret)); printf("m%d: %s\n", (int)multiret, curl_multi_strerror(multiret));
} }
for(shareret=CURLSHE_OK; shareret <= CURLSHE_LAST; shareret++) { for(shareret = CURLSHE_OK; shareret <= CURLSHE_LAST; shareret++) {
printf("s%d: %s\n", (int)shareret, curl_share_strerror(shareret)); printf("s%d: %s\n", (int)shareret, curl_share_strerror(shareret));
} }

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2017, 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
@ -61,7 +61,7 @@ int test(char *URL)
{ {
CURLcode res; CURLcode res;
CURL *curl; CURL *curl;
char *ipstr=NULL; char *ipstr = NULL;
if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n"); fprintf(stderr, "curl_global_init() failed\n");

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2017, 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
@ -43,7 +43,7 @@ int test(char *URL)
struct_stat file_info; struct_stat file_info;
struct curl_slist *hl; struct curl_slist *hl;
struct curl_slist *headerlist=NULL; struct curl_slist *headerlist = NULL;
const char *buf_1 = "RNFR 505"; const char *buf_1 = "RNFR 505";
const char *buf_2 = "RNTO 505-forreal"; const char *buf_2 = "RNTO 505-forreal";

View File

@ -131,7 +131,7 @@ static void *fire(void *ptr)
struct curl_slist *headers; struct curl_slist *headers;
struct Tdata *tdata = (struct Tdata*)ptr; struct Tdata *tdata = (struct Tdata*)ptr;
CURL *curl; CURL *curl;
int i=0; int i = 0;
curl = curl_easy_init(); curl = curl_easy_init();
if(!curl) { if(!curl) {
@ -261,7 +261,7 @@ int test(char *URL)
res = 0; res = 0;
/* start treads */ /* start treads */
for(i=1; i<=THREADS; i++) { for(i = 1; i <= THREADS; i++) {
/* set thread data */ /* set thread data */
tdata.url = suburl(URL, i); /* must be curl_free()d */ tdata.url = suburl(URL, i); /* must be curl_free()d */
@ -349,7 +349,7 @@ int test(char *URL)
/* try to free share, expect to fail because share is in use*/ /* try to free share, expect to fail because share is in use*/
printf("try SHARE_CLEANUP...\n"); printf("try SHARE_CLEANUP...\n");
scode = curl_share_cleanup(share); scode = curl_share_cleanup(share);
if(scode==CURLSHE_OK) { if(scode == CURLSHE_OK) {
fprintf(stderr, "curl_share_cleanup succeed but error expected\n"); fprintf(stderr, "curl_share_cleanup succeed but error expected\n");
share = NULL; share = NULL;
} }
@ -368,7 +368,7 @@ test_cleanup:
/* free share */ /* free share */
printf("SHARE_CLEANUP\n"); printf("SHARE_CLEANUP\n");
scode = curl_share_cleanup(share); scode = curl_share_cleanup(share);
if(scode!=CURLSHE_OK) if(scode != CURLSHE_OK)
fprintf(stderr, "curl_share_cleanup failed, code errno %d\n", fprintf(stderr, "curl_share_cleanup failed, code errno %d\n",
(int)scode); (int)scode);

Some files were not shown because too many files have changed in this diff Show More