mirror of
https://github.com/moparisthebest/curl
synced 2025-02-28 09:21:50 -05:00
cppcheck: fix warnings
- Get rid of variable that was generating false positive warning (unitialized) - Fix issues in tests - Reduce scope of several variables all over etc Closes #2631
This commit is contained in:
parent
38203f1585
commit
c45360d463
@ -49,13 +49,12 @@ static size_t decodeQuantum(unsigned char *dest, const char *src)
|
||||
unsigned long i, x = 0;
|
||||
|
||||
for(i = 0, s = src; i < 4; i++, s++) {
|
||||
unsigned long v = 0;
|
||||
|
||||
if(*s == '=') {
|
||||
x = (x << 6);
|
||||
padding++;
|
||||
}
|
||||
else {
|
||||
unsigned long v = 0;
|
||||
p = base64;
|
||||
|
||||
while(*p && (*p != *s)) {
|
||||
|
@ -1237,8 +1237,6 @@ static int conn_is_conn(struct connectdata *conn, void *param)
|
||||
curl_socket_t Curl_getconnectinfo(struct Curl_easy *data,
|
||||
struct connectdata **connp)
|
||||
{
|
||||
curl_socket_t sockfd;
|
||||
|
||||
DEBUGASSERT(data);
|
||||
|
||||
/* this works for an easy handle:
|
||||
@ -1264,12 +1262,10 @@ curl_socket_t Curl_getconnectinfo(struct Curl_easy *data,
|
||||
if(connp)
|
||||
/* only store this if the caller cares for it */
|
||||
*connp = c;
|
||||
sockfd = c->sock[FIRSTSOCKET];
|
||||
return c->sock[FIRSTSOCKET];
|
||||
}
|
||||
else
|
||||
return CURL_SOCKET_BAD;
|
||||
|
||||
return sockfd;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -163,7 +163,6 @@ static CURLcode inflate_stream(struct connectdata *conn,
|
||||
z_stream *z = &zp->z; /* zlib state structure */
|
||||
uInt nread = z->avail_in;
|
||||
Bytef *orig_in = z->next_in;
|
||||
int status; /* zlib status */
|
||||
bool done = FALSE;
|
||||
CURLcode result = CURLE_OK; /* Curl_client_write status */
|
||||
char *decomp; /* Put the decompressed data here. */
|
||||
@ -184,6 +183,7 @@ static CURLcode inflate_stream(struct connectdata *conn,
|
||||
/* because the buffer size is fixed, iteratively decompress and transfer to
|
||||
the client via downstream_write function. */
|
||||
while(!done) {
|
||||
int status; /* zlib status */
|
||||
done = TRUE;
|
||||
|
||||
/* (re)set buffer for decompressed output for every iteration */
|
||||
@ -761,7 +761,6 @@ char *Curl_all_content_encodings(void)
|
||||
const content_encoding * const *cep;
|
||||
const content_encoding *ce;
|
||||
char *ace;
|
||||
char *p;
|
||||
|
||||
for(cep = encodings; *cep; cep++) {
|
||||
ce = *cep;
|
||||
@ -774,7 +773,7 @@ char *Curl_all_content_encodings(void)
|
||||
|
||||
ace = malloc(len);
|
||||
if(ace) {
|
||||
p = ace;
|
||||
char *p = ace;
|
||||
for(cep = encodings; *cep; cep++) {
|
||||
ce = *cep;
|
||||
if(!strcasecompare(ce->name, CONTENT_ENCODING_DEFAULT)) {
|
||||
@ -921,10 +920,9 @@ void Curl_unencode_cleanup(struct connectdata *conn)
|
||||
static const content_encoding *find_encoding(const char *name, size_t len)
|
||||
{
|
||||
const content_encoding * const *cep;
|
||||
const content_encoding *ce;
|
||||
|
||||
for(cep = encodings; *cep; cep++) {
|
||||
ce = *cep;
|
||||
const content_encoding *ce = *cep;
|
||||
if((strncasecompare(name, ce->name, len) && !ce->name[len]) ||
|
||||
(ce->alias && strncasecompare(name, ce->alias, len) && !ce->alias[len]))
|
||||
return ce;
|
||||
|
@ -376,13 +376,13 @@ static void strstore(char **str, const char *newstr)
|
||||
*/
|
||||
static void remove_expired(struct CookieInfo *cookies)
|
||||
{
|
||||
struct Cookie *co, *nx, *pv;
|
||||
struct Cookie *co, *nx;
|
||||
curl_off_t now = (curl_off_t)time(NULL);
|
||||
unsigned int i;
|
||||
|
||||
for(i = 0; i < COOKIE_HASH_SIZE; i++) {
|
||||
struct Cookie *pv = NULL;
|
||||
co = cookies->cookies[i];
|
||||
pv = NULL;
|
||||
while(co) {
|
||||
nx = co->next;
|
||||
if(co->expires && co->expires < now) {
|
||||
@ -1385,9 +1385,8 @@ void Curl_cookie_clearsess(struct CookieInfo *cookies)
|
||||
****************************************************************************/
|
||||
void Curl_cookie_cleanup(struct CookieInfo *c)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
if(c) {
|
||||
unsigned int i;
|
||||
free(c->filename);
|
||||
for(i = 0; i < COOKIE_HASH_SIZE; i++)
|
||||
Curl_cookie_freelist(c->cookies[i]);
|
||||
|
@ -146,7 +146,6 @@ CURLcode Curl_sasl_parse_url_auth_option(struct SASL *sasl,
|
||||
const char *value, size_t len)
|
||||
{
|
||||
CURLcode result = CURLE_OK;
|
||||
unsigned int mechbit;
|
||||
size_t mechlen;
|
||||
|
||||
if(!len)
|
||||
@ -160,7 +159,7 @@ CURLcode Curl_sasl_parse_url_auth_option(struct SASL *sasl,
|
||||
if(!strncmp(value, "*", len))
|
||||
sasl->prefmech = SASL_AUTH_DEFAULT;
|
||||
else {
|
||||
mechbit = Curl_sasl_decode_mech(value, len, &mechlen);
|
||||
unsigned int mechbit = Curl_sasl_decode_mech(value, len, &mechlen);
|
||||
if(mechbit && mechlen == len)
|
||||
sasl->prefmech |= mechbit;
|
||||
else
|
||||
|
@ -95,10 +95,7 @@ static char *unescape_word(struct Curl_easy *data, const char *inputbuff)
|
||||
{
|
||||
char *newp = NULL;
|
||||
char *dictp;
|
||||
char *ptr;
|
||||
size_t len;
|
||||
char ch;
|
||||
int olen = 0;
|
||||
|
||||
CURLcode result = Curl_urldecode(data, inputbuff, 0, &newp, &len, FALSE);
|
||||
if(!newp || result)
|
||||
@ -106,6 +103,9 @@ static char *unescape_word(struct Curl_easy *data, const char *inputbuff)
|
||||
|
||||
dictp = malloc(((size_t)len)*2 + 1); /* add one for terminating zero */
|
||||
if(dictp) {
|
||||
char *ptr;
|
||||
char ch;
|
||||
int olen = 0;
|
||||
/* According to RFC2229 section 2.2, these letters need to be escaped with
|
||||
\[letter] */
|
||||
for(ptr = newp;
|
||||
|
@ -82,7 +82,6 @@ char *curl_easy_escape(struct Curl_easy *data, const char *string,
|
||||
size_t alloc;
|
||||
char *ns;
|
||||
char *testing_ptr = NULL;
|
||||
unsigned char in; /* we need to treat the characters unsigned */
|
||||
size_t newlen;
|
||||
size_t strindex = 0;
|
||||
size_t length;
|
||||
@ -100,7 +99,7 @@ char *curl_easy_escape(struct Curl_easy *data, const char *string,
|
||||
|
||||
length = alloc-1;
|
||||
while(length--) {
|
||||
in = *string;
|
||||
unsigned char in = *string; /* we need to treat the characters unsigned */
|
||||
|
||||
if(Curl_isunreserved(in))
|
||||
/* just copy this */
|
||||
@ -150,7 +149,6 @@ CURLcode Curl_urldecode(struct Curl_easy *data,
|
||||
{
|
||||
size_t alloc = (length?length:strlen(string)) + 1;
|
||||
char *ns = malloc(alloc);
|
||||
unsigned char in;
|
||||
size_t strindex = 0;
|
||||
unsigned long hex;
|
||||
CURLcode result;
|
||||
@ -159,7 +157,7 @@ CURLcode Curl_urldecode(struct Curl_easy *data,
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
|
||||
while(--alloc > 0) {
|
||||
in = *string;
|
||||
unsigned char in = *string;
|
||||
if(('%' == in) && (alloc > 2) &&
|
||||
ISXDIGIT(string[1]) && ISXDIGIT(string[2])) {
|
||||
/* this is two hexadecimal digits following a '%' */
|
||||
|
@ -256,8 +256,6 @@ static CURLcode file_upload(struct connectdata *conn)
|
||||
CURLcode result = CURLE_OK;
|
||||
struct Curl_easy *data = conn->data;
|
||||
char *buf = data->state.buffer;
|
||||
size_t nread;
|
||||
size_t nwrite;
|
||||
curl_off_t bytecount = 0;
|
||||
struct_stat file_stat;
|
||||
const char *buf2;
|
||||
@ -306,6 +304,8 @@ static CURLcode file_upload(struct connectdata *conn)
|
||||
}
|
||||
|
||||
while(!result) {
|
||||
size_t nread;
|
||||
size_t nwrite;
|
||||
int readcount;
|
||||
result = Curl_fillreadbuffer(conn, (int)data->set.buffer_size, &readcount);
|
||||
if(result)
|
||||
@ -378,7 +378,6 @@ static CURLcode file_do(struct connectdata *conn, bool *done)
|
||||
curl_off_t expected_size = 0;
|
||||
bool size_known;
|
||||
bool fstated = FALSE;
|
||||
ssize_t nread;
|
||||
struct Curl_easy *data = conn->data;
|
||||
char *buf = data->state.buffer;
|
||||
curl_off_t bytecount = 0;
|
||||
@ -502,6 +501,7 @@ static CURLcode file_do(struct connectdata *conn, bool *done)
|
||||
Curl_pgrsTime(data, TIMER_STARTTRANSFER);
|
||||
|
||||
while(!result) {
|
||||
ssize_t nread;
|
||||
/* Don't fill a whole buffer if we want less than all data */
|
||||
size_t bytestoread;
|
||||
|
||||
|
@ -812,7 +812,6 @@ CURLcode Curl_getformdata(struct Curl_easy *data,
|
||||
{
|
||||
CURLcode result = CURLE_OK;
|
||||
curl_mime *form = NULL;
|
||||
curl_mime *multipart;
|
||||
curl_mimepart *part;
|
||||
struct curl_httppost *file;
|
||||
|
||||
@ -831,7 +830,7 @@ CURLcode Curl_getformdata(struct Curl_easy *data,
|
||||
/* Process each top part. */
|
||||
for(; !result && post; post = post->next) {
|
||||
/* If we have more than a file here, create a mime subpart and fill it. */
|
||||
multipart = form;
|
||||
curl_mime *multipart = form;
|
||||
if(post->more) {
|
||||
part = curl_mime_addpart(form);
|
||||
if(!part)
|
||||
|
13
lib/ftp.c
13
lib/ftp.c
@ -239,8 +239,8 @@ static void close_secondarysocket(struct connectdata *conn)
|
||||
|
||||
static void freedirs(struct ftp_conn *ftpc)
|
||||
{
|
||||
int i;
|
||||
if(ftpc->dirs) {
|
||||
int i;
|
||||
for(i = 0; i < ftpc->dirdepth; i++) {
|
||||
free(ftpc->dirs[i]);
|
||||
ftpc->dirs[i] = NULL;
|
||||
@ -637,8 +637,6 @@ CURLcode Curl_GetFTPResponse(ssize_t *nreadp, /* return number of bytes read */
|
||||
* line in a response or continue reading. */
|
||||
|
||||
curl_socket_t sockfd = conn->sock[FIRSTSOCKET];
|
||||
time_t timeout; /* timeout in milliseconds */
|
||||
time_t interval_ms;
|
||||
struct Curl_easy *data = conn->data;
|
||||
CURLcode result = CURLE_OK;
|
||||
struct ftp_conn *ftpc = &conn->proto.ftpc;
|
||||
@ -657,7 +655,8 @@ CURLcode Curl_GetFTPResponse(ssize_t *nreadp, /* return number of bytes read */
|
||||
|
||||
while(!*ftpcode && !result) {
|
||||
/* check and reset timeout value every lap */
|
||||
timeout = Curl_pp_state_timeout(pp);
|
||||
time_t timeout = Curl_pp_state_timeout(pp); /* timeout in milliseconds */
|
||||
time_t interval_ms;
|
||||
|
||||
if(timeout <= 0) {
|
||||
failf(data, "FTP response timeout");
|
||||
@ -1589,7 +1588,6 @@ static CURLcode ftp_state_ul_setup(struct connectdata *conn,
|
||||
struct FTP *ftp = conn->data->req.protop;
|
||||
struct Curl_easy *data = conn->data;
|
||||
struct ftp_conn *ftpc = &conn->proto.ftpc;
|
||||
int seekerr = CURL_SEEKFUNC_OK;
|
||||
|
||||
if((data->state.resume_from && !sizechecked) ||
|
||||
((data->state.resume_from > 0) && sizechecked)) {
|
||||
@ -1605,6 +1603,7 @@ static CURLcode ftp_state_ul_setup(struct connectdata *conn,
|
||||
/* 3. pass file-size number of bytes in the source file */
|
||||
/* 4. lower the infilesize counter */
|
||||
/* => transfer as usual */
|
||||
int seekerr = CURL_SEEKFUNC_OK;
|
||||
|
||||
if(data->state.resume_from < 0) {
|
||||
/* Got no given size to start from, figure it out */
|
||||
@ -2782,7 +2781,6 @@ static CURLcode ftp_statemach_act(struct connectdata *conn)
|
||||
char *ptr = &data->state.buffer[4]; /* start on the first letter */
|
||||
const size_t buf_size = data->set.buffer_size;
|
||||
char *dir;
|
||||
char *store;
|
||||
bool entry_extracted = FALSE;
|
||||
|
||||
dir = malloc(nread + 1);
|
||||
@ -2805,6 +2803,7 @@ static CURLcode ftp_statemach_act(struct connectdata *conn)
|
||||
|
||||
if('\"' == *ptr) {
|
||||
/* it started good */
|
||||
char *store;
|
||||
ptr++;
|
||||
for(store = dir; *ptr;) {
|
||||
if('\"' == *ptr) {
|
||||
@ -4384,7 +4383,6 @@ static CURLcode ftp_setup_connection(struct connectdata *conn)
|
||||
{
|
||||
struct Curl_easy *data = conn->data;
|
||||
char *type;
|
||||
char command;
|
||||
struct FTP *ftp;
|
||||
|
||||
conn->data->req.protop = ftp = malloc(sizeof(struct FTP));
|
||||
@ -4402,6 +4400,7 @@ static CURLcode ftp_setup_connection(struct connectdata *conn)
|
||||
type = strstr(conn->host.rawalloc, ";type=");
|
||||
|
||||
if(type) {
|
||||
char command;
|
||||
*type = 0; /* it was in the middle of the hostname */
|
||||
command = Curl_raw_toupper(type[6]);
|
||||
conn->bits.type_set = TRUE;
|
||||
|
11
lib/hash.c
11
lib/hash.c
@ -60,8 +60,6 @@ Curl_hash_init(struct curl_hash *h,
|
||||
comp_function comparator,
|
||||
curl_hash_dtor dtor)
|
||||
{
|
||||
int i;
|
||||
|
||||
if(!slots || !hfunc || !comparator ||!dtor) {
|
||||
return 1; /* failure */
|
||||
}
|
||||
@ -74,6 +72,7 @@ Curl_hash_init(struct curl_hash *h,
|
||||
|
||||
h->table = malloc(slots * sizeof(struct curl_llist));
|
||||
if(h->table) {
|
||||
int i;
|
||||
for(i = 0; i < slots; ++i)
|
||||
Curl_llist_init(&h->table[i], (curl_llist_dtor) hash_element_dtor);
|
||||
return 0; /* fine */
|
||||
@ -140,11 +139,10 @@ Curl_hash_add(struct curl_hash *h, void *key, size_t key_len, void *p)
|
||||
int Curl_hash_delete(struct curl_hash *h, void *key, size_t key_len)
|
||||
{
|
||||
struct curl_llist_element *le;
|
||||
struct curl_hash_element *he;
|
||||
struct curl_llist *l = FETCH_LIST(h, key, key_len);
|
||||
|
||||
for(le = l->head; le; le = le->next) {
|
||||
he = le->ptr;
|
||||
struct curl_hash_element *he = le->ptr;
|
||||
if(h->comp_func(he->key, he->key_len, key, key_len)) {
|
||||
Curl_llist_remove(l, le, (void *) h);
|
||||
--h->size;
|
||||
@ -162,13 +160,12 @@ void *
|
||||
Curl_hash_pick(struct curl_hash *h, void *key, size_t key_len)
|
||||
{
|
||||
struct curl_llist_element *le;
|
||||
struct curl_hash_element *he;
|
||||
struct curl_llist *l;
|
||||
|
||||
if(h) {
|
||||
l = FETCH_LIST(h, key, key_len);
|
||||
for(le = l->head; le; le = le->next) {
|
||||
he = le->ptr;
|
||||
struct curl_hash_element *he = le->ptr;
|
||||
if(h->comp_func(he->key, he->key_len, key, key_len)) {
|
||||
return he->ptr;
|
||||
}
|
||||
@ -291,7 +288,6 @@ void Curl_hash_start_iterate(struct curl_hash *hash,
|
||||
struct curl_hash_element *
|
||||
Curl_hash_next_element(struct curl_hash_iterator *iter)
|
||||
{
|
||||
int i;
|
||||
struct curl_hash *h = iter->hash;
|
||||
|
||||
/* Get the next element in the current list, if any */
|
||||
@ -300,6 +296,7 @@ Curl_hash_next_element(struct curl_hash_iterator *iter)
|
||||
|
||||
/* If we have reached the end of the list, find the next one */
|
||||
if(!iter->current_element) {
|
||||
int i;
|
||||
for(i = iter->slot_index; i < h->slots; i++) {
|
||||
if(h->table[i].head) {
|
||||
iter->current_element = h->table[i].head;
|
||||
|
10
lib/http.c
10
lib/http.c
@ -1276,7 +1276,6 @@ CURLcode Curl_add_bufferf(Curl_send_buffer *in, const char *fmt, ...)
|
||||
CURLcode Curl_add_buffer(Curl_send_buffer *in, const void *inptr, size_t size)
|
||||
{
|
||||
char *new_rb;
|
||||
size_t new_size;
|
||||
|
||||
if(~size < in->size_used) {
|
||||
/* If resulting used size of send buffer would wrap size_t, cleanup
|
||||
@ -1289,10 +1288,10 @@ CURLcode Curl_add_buffer(Curl_send_buffer *in, const void *inptr, size_t size)
|
||||
|
||||
if(!in->buffer ||
|
||||
((in->size_used + size) > (in->size_max - 1))) {
|
||||
|
||||
/* If current buffer size isn't enough to hold the result, use a
|
||||
buffer size that doubles the required size. If this new size
|
||||
would wrap size_t, then just use the largest possible one */
|
||||
size_t new_size;
|
||||
|
||||
if((size > (size_t)-1 / 2) || (in->size_used > (size_t)-1 / 2) ||
|
||||
(~(size * 2) < (in->size_used * 2)))
|
||||
@ -1627,7 +1626,6 @@ static CURLcode expect100(struct Curl_easy *data,
|
||||
Curl_send_buffer *req_buffer)
|
||||
{
|
||||
CURLcode result = CURLE_OK;
|
||||
const char *ptr;
|
||||
data->state.expect100header = FALSE; /* default to false unless it is set
|
||||
to TRUE below */
|
||||
if(use_http_1_1plus(data, conn) &&
|
||||
@ -1635,7 +1633,7 @@ static CURLcode expect100(struct Curl_easy *data,
|
||||
/* if not doing HTTP 1.0 or version 2, or disabled explicitly, we add an
|
||||
Expect: 100-continue to the headers which actually speeds up post
|
||||
operations (as there is one packet coming back from the web server) */
|
||||
ptr = Curl_checkheaders(conn, "Expect");
|
||||
const char *ptr = Curl_checkheaders(conn, "Expect");
|
||||
if(ptr) {
|
||||
data->state.expect100header =
|
||||
Curl_compareheader(ptr, "Expect:", "100-continue");
|
||||
@ -1872,7 +1870,6 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
|
||||
const char *httpstring;
|
||||
Curl_send_buffer *req_buffer;
|
||||
curl_off_t postsize = 0; /* curl_off_t to handle large file sizes */
|
||||
int seekerr = CURL_SEEKFUNC_CANTSEEK;
|
||||
|
||||
/* Always consider the DO phase done after this function call, even if there
|
||||
may be parts of the request that is not yet sent, since we can deal with
|
||||
@ -2141,7 +2138,6 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
|
||||
else {
|
||||
/* If the host begins with '[', we start searching for the port after
|
||||
the bracket has been closed */
|
||||
int startsearch = 0;
|
||||
if(*cookiehost == '[') {
|
||||
char *closingbracket;
|
||||
/* since the 'cookiehost' is an allocated memory area that will be
|
||||
@ -2152,6 +2148,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
|
||||
*closingbracket = 0;
|
||||
}
|
||||
else {
|
||||
int startsearch = 0;
|
||||
char *colon = strchr(cookiehost + startsearch, ':');
|
||||
if(colon)
|
||||
*colon = 0; /* The host must not include an embedded port number */
|
||||
@ -2297,6 +2294,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
|
||||
|
||||
/* Now, let's read off the proper amount of bytes from the
|
||||
input. */
|
||||
int seekerr = CURL_SEEKFUNC_CANTSEEK;
|
||||
if(conn->seek_func) {
|
||||
Curl_set_in_callback(data, true);
|
||||
seekerr = conn->seek_func(conn->seek_client, data->state.resume_from,
|
||||
|
@ -188,7 +188,6 @@ static CURLcode CONNECT(struct connectdata *conn,
|
||||
struct SingleRequest *k = &data->req;
|
||||
CURLcode result;
|
||||
curl_socket_t tunnelsocket = conn->sock[sockindex];
|
||||
timediff_t check;
|
||||
struct http_connect_state *s = conn->connect_state;
|
||||
|
||||
#define SELECT_OK 0
|
||||
@ -201,6 +200,7 @@ static CURLcode CONNECT(struct connectdata *conn,
|
||||
conn->bits.proxy_connect_closed = FALSE;
|
||||
|
||||
do {
|
||||
timediff_t check;
|
||||
if(TUNNEL_INIT == s->tunnel_state) {
|
||||
/* BEGIN CONNECT PHASE */
|
||||
char *host_port;
|
||||
|
@ -609,7 +609,6 @@ static CURLcode imap_perform_list(struct connectdata *conn)
|
||||
CURLcode result = CURLE_OK;
|
||||
struct Curl_easy *data = conn->data;
|
||||
struct IMAP *imap = data->req.protop;
|
||||
char *mailbox;
|
||||
|
||||
if(imap->custom)
|
||||
/* Send the custom request */
|
||||
@ -617,7 +616,8 @@ static CURLcode imap_perform_list(struct connectdata *conn)
|
||||
imap->custom_params ? imap->custom_params : "");
|
||||
else {
|
||||
/* Make sure the mailbox is in the correct atom format if necessary */
|
||||
mailbox = imap->mailbox ? imap_atom(imap->mailbox, true) : strdup("");
|
||||
char *mailbox = imap->mailbox ? imap_atom(imap->mailbox, true)
|
||||
: strdup("");
|
||||
if(!mailbox)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
|
||||
@ -854,7 +854,6 @@ static CURLcode imap_state_capability_resp(struct connectdata *conn,
|
||||
struct Curl_easy *data = conn->data;
|
||||
struct imap_conn *imapc = &conn->proto.imapc;
|
||||
const char *line = data->state.buffer;
|
||||
size_t wordlen;
|
||||
|
||||
(void)instate; /* no use for this yet */
|
||||
|
||||
@ -864,6 +863,7 @@ static CURLcode imap_state_capability_resp(struct connectdata *conn,
|
||||
|
||||
/* Loop through the data line */
|
||||
for(;;) {
|
||||
size_t wordlen;
|
||||
while(*line &&
|
||||
(*line == ' ' || *line == '\t' ||
|
||||
*line == '\r' || *line == '\n')) {
|
||||
@ -1046,12 +1046,12 @@ static CURLcode imap_state_select_resp(struct connectdata *conn, int imapcode,
|
||||
struct IMAP *imap = conn->data->req.protop;
|
||||
struct imap_conn *imapc = &conn->proto.imapc;
|
||||
const char *line = data->state.buffer;
|
||||
char tmp[20];
|
||||
|
||||
(void)instate; /* no use for this yet */
|
||||
|
||||
if(imapcode == '*') {
|
||||
/* See if this is an UIDVALIDITY response */
|
||||
char tmp[20];
|
||||
if(sscanf(line + 2, "OK [UIDVALIDITY %19[0123456789]]", tmp) == 1) {
|
||||
Curl_safefree(imapc->mailbox_uidvalidity);
|
||||
imapc->mailbox_uidvalidity = strdup(tmp);
|
||||
|
32
lib/mime.c
32
lib/mime.c
@ -505,9 +505,6 @@ static size_t encoder_qp_read(char *buffer, size_t size, bool ateof,
|
||||
mime_encoder_state *st = &part->encstate;
|
||||
char *ptr = buffer;
|
||||
size_t cursize = 0;
|
||||
int i;
|
||||
size_t len;
|
||||
size_t consumed;
|
||||
int softlinebreak;
|
||||
char buf[4];
|
||||
|
||||
@ -516,9 +513,9 @@ static size_t encoder_qp_read(char *buffer, size_t size, bool ateof,
|
||||
character constants that can be interpreted as non-ascii on some
|
||||
platforms. Preserve ASCII encoding on output too. */
|
||||
while(st->bufbeg < st->bufend) {
|
||||
len = 1;
|
||||
consumed = 1;
|
||||
i = st->buf[st->bufbeg];
|
||||
size_t len = 1;
|
||||
size_t consumed = 1;
|
||||
int i = st->buf[st->bufbeg];
|
||||
buf[0] = (char) i;
|
||||
buf[1] = aschex[(i >> 4) & 0xF];
|
||||
buf[2] = aschex[i & 0xF];
|
||||
@ -813,8 +810,6 @@ static size_t readback_part(curl_mimepart *part,
|
||||
char *buffer, size_t bufsize)
|
||||
{
|
||||
size_t cursize = 0;
|
||||
size_t sz;
|
||||
struct curl_slist *hdr;
|
||||
#ifdef CURL_DOES_CONVERSIONS
|
||||
char *convbuf = buffer;
|
||||
#endif
|
||||
@ -822,8 +817,8 @@ static size_t readback_part(curl_mimepart *part,
|
||||
/* Readback from part. */
|
||||
|
||||
while(bufsize) {
|
||||
sz = 0;
|
||||
hdr = (struct curl_slist *) part->state.ptr;
|
||||
size_t sz = 0;
|
||||
struct curl_slist *hdr = (struct curl_slist *) part->state.ptr;
|
||||
switch(part->state.state) {
|
||||
case MIMESTATE_BEGIN:
|
||||
mimesetstate(&part->state, part->flags & MIME_BODY_ONLY? MIMESTATE_BODY:
|
||||
@ -918,8 +913,6 @@ static size_t mime_subparts_read(char *buffer, size_t size, size_t nitems,
|
||||
{
|
||||
curl_mime *mime = (curl_mime *) instream;
|
||||
size_t cursize = 0;
|
||||
size_t sz;
|
||||
curl_mimepart *part;
|
||||
#ifdef CURL_DOES_CONVERSIONS
|
||||
char *convbuf = buffer;
|
||||
#endif
|
||||
@ -927,8 +920,8 @@ static size_t mime_subparts_read(char *buffer, size_t size, size_t nitems,
|
||||
(void) size; /* Always 1. */
|
||||
|
||||
while(nitems) {
|
||||
sz = 0;
|
||||
part = mime->state.ptr;
|
||||
size_t sz = 0;
|
||||
curl_mimepart *part = mime->state.ptr;
|
||||
switch(mime->state.state) {
|
||||
case MIMESTATE_BEGIN:
|
||||
case MIMESTATE_BODY:
|
||||
@ -1044,7 +1037,6 @@ static int mime_subparts_seek(void *instream, curl_off_t offset, int whence)
|
||||
curl_mime *mime = (curl_mime *) instream;
|
||||
curl_mimepart *part;
|
||||
int result = CURL_SEEKFUNC_OK;
|
||||
int res;
|
||||
|
||||
if(whence != SEEK_SET || offset)
|
||||
return CURL_SEEKFUNC_CANTSEEK; /* Only support full rewind. */
|
||||
@ -1053,7 +1045,7 @@ static int mime_subparts_seek(void *instream, curl_off_t offset, int whence)
|
||||
return CURL_SEEKFUNC_OK; /* Already rewound. */
|
||||
|
||||
for(part = mime->firstpart; part; part = part->nextpart) {
|
||||
res = mime_part_rewind(part);
|
||||
int res = mime_part_rewind(part);
|
||||
if(res != CURL_SEEKFUNC_OK)
|
||||
result = res;
|
||||
}
|
||||
@ -1349,7 +1341,6 @@ CURLcode curl_mime_data(curl_mimepart *part,
|
||||
CURLcode curl_mime_filedata(curl_mimepart *part, const char *filename)
|
||||
{
|
||||
CURLcode result = CURLE_OK;
|
||||
char *base;
|
||||
|
||||
if(!part)
|
||||
return CURLE_BAD_FUNCTION_ARGUMENT;
|
||||
@ -1357,6 +1348,7 @@ CURLcode curl_mime_filedata(curl_mimepart *part, const char *filename)
|
||||
cleanup_part_content(part);
|
||||
|
||||
if(filename) {
|
||||
char *base;
|
||||
struct_stat sbuf;
|
||||
|
||||
if(stat(filename, &sbuf) || access(filename, R_OK))
|
||||
@ -1564,7 +1556,6 @@ static size_t slist_size(struct curl_slist *s,
|
||||
static curl_off_t multipart_size(curl_mime *mime)
|
||||
{
|
||||
curl_off_t size;
|
||||
curl_off_t sz;
|
||||
size_t boundarysize;
|
||||
curl_mimepart *part;
|
||||
|
||||
@ -1575,7 +1566,7 @@ static curl_off_t multipart_size(curl_mime *mime)
|
||||
size = boundarysize; /* Final boundary - CRLF after headers. */
|
||||
|
||||
for(part = mime->firstpart; part; part = part->nextpart) {
|
||||
sz = Curl_mime_size(part);
|
||||
curl_off_t sz = Curl_mime_size(part);
|
||||
|
||||
if(sz < 0)
|
||||
size = sz;
|
||||
@ -1643,8 +1634,6 @@ static CURLcode add_content_type(struct curl_slist **slp,
|
||||
|
||||
const char *Curl_mime_contenttype(const char *filename)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
/*
|
||||
* If no content type was specified, we scan through a few well-known
|
||||
* extensions and pick the first we match!
|
||||
@ -1669,6 +1658,7 @@ const char *Curl_mime_contenttype(const char *filename)
|
||||
if(filename) {
|
||||
size_t len1 = strlen(filename);
|
||||
const char *nameend = filename + len1;
|
||||
unsigned int i;
|
||||
|
||||
for(i = 0; i < sizeof(ctts) / sizeof(ctts[0]); i++) {
|
||||
size_t len2 = strlen(ctts[i].extension);
|
||||
|
@ -917,7 +917,6 @@ CURLMcode curl_multi_fdset(struct Curl_multi *multi,
|
||||
struct Curl_easy *data;
|
||||
int this_max_fd = -1;
|
||||
curl_socket_t sockbunch[MAX_SOCKSPEREASYHANDLE];
|
||||
int bitmap;
|
||||
int i;
|
||||
(void)exc_fd_set; /* not used */
|
||||
|
||||
@ -929,7 +928,7 @@ CURLMcode curl_multi_fdset(struct Curl_multi *multi,
|
||||
|
||||
data = multi->easyp;
|
||||
while(data) {
|
||||
bitmap = multi_getsock(data, sockbunch, MAX_SOCKSPEREASYHANDLE);
|
||||
int bitmap = multi_getsock(data, sockbunch, MAX_SOCKSPEREASYHANDLE);
|
||||
|
||||
for(i = 0; i< MAX_SOCKSPEREASYHANDLE; i++) {
|
||||
curl_socket_t s = CURL_SOCKET_BAD;
|
||||
@ -2943,7 +2942,6 @@ void Curl_expire(struct Curl_easy *data, time_t milli, expire_id id)
|
||||
{
|
||||
struct Curl_multi *multi = data->multi;
|
||||
struct curltime *nowp = &data->state.expiretime;
|
||||
int rc;
|
||||
struct curltime set;
|
||||
|
||||
/* this is only interesting while there is still an associated multi struct
|
||||
@ -2974,6 +2972,7 @@ void Curl_expire(struct Curl_easy *data, time_t milli, expire_id id)
|
||||
Compare if the new time is earlier, and only remove-old/add-new if it
|
||||
is. */
|
||||
timediff_t diff = Curl_timediff(set, *nowp);
|
||||
int rc;
|
||||
|
||||
if(diff > 0) {
|
||||
/* The current splay tree entry is sooner than this new expiry time.
|
||||
@ -3019,7 +3018,6 @@ void Curl_expire_clear(struct Curl_easy *data)
|
||||
{
|
||||
struct Curl_multi *multi = data->multi;
|
||||
struct curltime *nowp = &data->state.expiretime;
|
||||
int rc;
|
||||
|
||||
/* this is only interesting while there is still an associated multi struct
|
||||
remaining! */
|
||||
@ -3030,6 +3028,7 @@ void Curl_expire_clear(struct Curl_easy *data)
|
||||
/* Since this is an cleared time, we must remove the previous entry from
|
||||
the splay tree */
|
||||
struct curl_llist *list = &data->state.timeoutlist;
|
||||
int rc;
|
||||
|
||||
rc = Curl_splayremovebyaddr(multi->timetree,
|
||||
&data->state.timenode,
|
||||
|
@ -49,7 +49,6 @@ time_t Curl_pp_state_timeout(struct pingpong *pp)
|
||||
struct connectdata *conn = pp->conn;
|
||||
struct Curl_easy *data = conn->data;
|
||||
time_t timeout_ms; /* in milliseconds */
|
||||
time_t timeout2_ms; /* in milliseconds */
|
||||
long response_time = (data->set.server_response_timeout)?
|
||||
data->set.server_response_timeout: pp->response_time;
|
||||
|
||||
@ -65,7 +64,7 @@ time_t Curl_pp_state_timeout(struct pingpong *pp)
|
||||
|
||||
if(data->set.timeout) {
|
||||
/* if timeout is requested, find out how much remaining time we have */
|
||||
timeout2_ms = data->set.timeout - /* timeout time */
|
||||
time_t timeout2_ms = data->set.timeout - /* timeout time */
|
||||
Curl_timediff(Curl_now(), conn->now); /* spent time */
|
||||
|
||||
/* pick the lowest number */
|
||||
|
@ -613,7 +613,6 @@ static CURLcode pop3_state_servergreet_resp(struct connectdata *conn,
|
||||
struct pop3_conn *pop3c = &conn->proto.pop3c;
|
||||
const char *line = data->state.buffer;
|
||||
size_t len = strlen(line);
|
||||
size_t i;
|
||||
|
||||
(void)instate; /* no use for this yet */
|
||||
|
||||
@ -625,6 +624,7 @@ static CURLcode pop3_state_servergreet_resp(struct connectdata *conn,
|
||||
/* Does the server support APOP authentication? */
|
||||
if(len >= 4 && line[len - 2] == '>') {
|
||||
/* Look for the APOP timestamp */
|
||||
size_t i;
|
||||
for(i = 3; i < len - 2; ++i) {
|
||||
if(line[i] == '<') {
|
||||
/* Calculate the length of the timestamp */
|
||||
@ -664,7 +664,6 @@ static CURLcode pop3_state_capa_resp(struct connectdata *conn, int pop3code,
|
||||
struct pop3_conn *pop3c = &conn->proto.pop3c;
|
||||
const char *line = data->state.buffer;
|
||||
size_t len = strlen(line);
|
||||
size_t wordlen;
|
||||
|
||||
(void)instate; /* no use for this yet */
|
||||
|
||||
@ -689,6 +688,7 @@ static CURLcode pop3_state_capa_resp(struct connectdata *conn, int pop3code,
|
||||
/* Loop through the data line */
|
||||
for(;;) {
|
||||
size_t llen;
|
||||
size_t wordlen;
|
||||
unsigned int mechbit;
|
||||
|
||||
while(len &&
|
||||
|
@ -35,22 +35,22 @@
|
||||
byte) */
|
||||
static void time2str(char *r, curl_off_t seconds)
|
||||
{
|
||||
curl_off_t d, h, m, s;
|
||||
curl_off_t h;
|
||||
if(seconds <= 0) {
|
||||
strcpy(r, "--:--:--");
|
||||
return;
|
||||
}
|
||||
h = seconds / CURL_OFF_T_C(3600);
|
||||
if(h <= CURL_OFF_T_C(99)) {
|
||||
m = (seconds - (h*CURL_OFF_T_C(3600))) / CURL_OFF_T_C(60);
|
||||
s = (seconds - (h*CURL_OFF_T_C(3600))) - (m*CURL_OFF_T_C(60));
|
||||
curl_off_t m = (seconds - (h*CURL_OFF_T_C(3600))) / CURL_OFF_T_C(60);
|
||||
curl_off_t s = (seconds - (h*CURL_OFF_T_C(3600))) - (m*CURL_OFF_T_C(60));
|
||||
snprintf(r, 9, "%2" CURL_FORMAT_CURL_OFF_T ":%02" CURL_FORMAT_CURL_OFF_T
|
||||
":%02" CURL_FORMAT_CURL_OFF_T, h, m, s);
|
||||
}
|
||||
else {
|
||||
/* this equals to more than 99 hours, switch to a more suitable output
|
||||
format to fit within the limits. */
|
||||
d = seconds / CURL_OFF_T_C(86400);
|
||||
curl_off_t d = seconds / CURL_OFF_T_C(86400);
|
||||
h = (seconds - (d*CURL_OFF_T_C(86400))) / CURL_OFF_T_C(3600);
|
||||
if(d <= CURL_OFF_T_C(999))
|
||||
snprintf(r, 9, "%3" CURL_FORMAT_CURL_OFF_T
|
||||
@ -369,25 +369,10 @@ void Curl_pgrsSetUploadSize(struct Curl_easy *data, curl_off_t size)
|
||||
int Curl_pgrsUpdate(struct connectdata *conn)
|
||||
{
|
||||
struct curltime now;
|
||||
int result;
|
||||
char max5[6][10];
|
||||
curl_off_t dlpercen = 0;
|
||||
curl_off_t ulpercen = 0;
|
||||
curl_off_t total_percen = 0;
|
||||
curl_off_t total_transfer;
|
||||
curl_off_t total_expected_transfer;
|
||||
curl_off_t timespent;
|
||||
curl_off_t timespent_ms; /* milliseconds */
|
||||
struct Curl_easy *data = conn->data;
|
||||
int nowindex = data->progress.speeder_c% CURR_TIME;
|
||||
int checkindex;
|
||||
int countindex; /* amount of seconds stored in the speeder array */
|
||||
char time_left[10];
|
||||
char time_total[10];
|
||||
char time_spent[10];
|
||||
curl_off_t ulestimate = 0;
|
||||
curl_off_t dlestimate = 0;
|
||||
curl_off_t total_estimate;
|
||||
bool shownow = FALSE;
|
||||
curl_off_t dl = data->progress.downloaded;
|
||||
curl_off_t ul = data->progress.uploaded;
|
||||
@ -413,6 +398,7 @@ int Curl_pgrsUpdate(struct connectdata *conn)
|
||||
|
||||
/* Calculations done at most once a second, unless end is reached */
|
||||
if(data->progress.lastshow != now.tv_sec) {
|
||||
int countindex; /* amount of seconds stored in the speeder array */
|
||||
shownow = TRUE;
|
||||
|
||||
data->progress.lastshow = now.tv_sec;
|
||||
@ -438,6 +424,7 @@ int Curl_pgrsUpdate(struct connectdata *conn)
|
||||
|
||||
/* first of all, we don't do this if there's no counted seconds yet */
|
||||
if(countindex) {
|
||||
int checkindex;
|
||||
timediff_t span_ms;
|
||||
|
||||
/* Get the index position to compare with the 'nowindex' position.
|
||||
@ -477,8 +464,21 @@ int Curl_pgrsUpdate(struct connectdata *conn)
|
||||
|
||||
if(!(data->progress.flags & PGRS_HIDE)) {
|
||||
/* progress meter has not been shut off */
|
||||
char max5[6][10];
|
||||
curl_off_t dlpercen = 0;
|
||||
curl_off_t ulpercen = 0;
|
||||
curl_off_t total_percen = 0;
|
||||
curl_off_t total_transfer;
|
||||
curl_off_t total_expected_transfer;
|
||||
char time_left[10];
|
||||
char time_total[10];
|
||||
char time_spent[10];
|
||||
curl_off_t ulestimate = 0;
|
||||
curl_off_t dlestimate = 0;
|
||||
curl_off_t total_estimate;
|
||||
|
||||
if(data->set.fxferinfo) {
|
||||
int result;
|
||||
/* There's a callback set, call that */
|
||||
Curl_set_in_callback(data, true);
|
||||
result = data->set.fxferinfo(data->set.progress_client,
|
||||
@ -492,6 +492,7 @@ int Curl_pgrsUpdate(struct connectdata *conn)
|
||||
return result;
|
||||
}
|
||||
if(data->set.fprogress) {
|
||||
int result;
|
||||
/* The older deprecated callback is set, call that */
|
||||
Curl_set_in_callback(data, true);
|
||||
result = data->set.fprogress(data->set.progress_client,
|
||||
|
@ -218,8 +218,6 @@ static CURLcode rtsp_done(struct connectdata *conn,
|
||||
struct Curl_easy *data = conn->data;
|
||||
struct RTSP *rtsp = data->req.protop;
|
||||
CURLcode httpStatus;
|
||||
long CSeq_sent;
|
||||
long CSeq_recv;
|
||||
|
||||
/* Bypass HTTP empty-reply checks on receive */
|
||||
if(data->set.rtspreq == RTSPREQ_RECEIVE)
|
||||
@ -229,8 +227,8 @@ static CURLcode rtsp_done(struct connectdata *conn,
|
||||
|
||||
if(rtsp) {
|
||||
/* Check the sequence numbers */
|
||||
CSeq_sent = rtsp->CSeq_sent;
|
||||
CSeq_recv = rtsp->CSeq_recv;
|
||||
long CSeq_sent = rtsp->CSeq_sent;
|
||||
long CSeq_recv = rtsp->CSeq_recv;
|
||||
if((data->set.rtspreq != RTSPREQ_RECEIVE) && (CSeq_sent != CSeq_recv)) {
|
||||
failf(data,
|
||||
"The CSeq of this request %ld did not match the response %ld",
|
||||
|
@ -80,7 +80,6 @@ int Curl_wait_ms(int timeout_ms)
|
||||
#endif
|
||||
struct curltime initial_tv;
|
||||
int pending_ms;
|
||||
int error;
|
||||
#endif
|
||||
int r = 0;
|
||||
|
||||
@ -98,6 +97,7 @@ int Curl_wait_ms(int timeout_ms)
|
||||
pending_ms = timeout_ms;
|
||||
initial_tv = Curl_now();
|
||||
do {
|
||||
int error;
|
||||
#if defined(HAVE_POLL_FINE)
|
||||
r = poll(NULL, 0, pending_ms);
|
||||
#else
|
||||
@ -160,7 +160,6 @@ int Curl_socket_check(curl_socket_t readfd0, /* two sockets to read from */
|
||||
#endif
|
||||
struct curltime initial_tv = {0, 0};
|
||||
int pending_ms = 0;
|
||||
int error;
|
||||
int r;
|
||||
int ret;
|
||||
|
||||
@ -210,6 +209,7 @@ int Curl_socket_check(curl_socket_t readfd0, /* two sockets to read from */
|
||||
}
|
||||
|
||||
do {
|
||||
int error;
|
||||
if(timeout_ms < 0)
|
||||
pending_ms = -1;
|
||||
else if(!timeout_ms)
|
||||
@ -291,6 +291,7 @@ int Curl_socket_check(curl_socket_t readfd0, /* two sockets to read from */
|
||||
ptimeout = (timeout_ms < 0) ? NULL : &pending_tv;
|
||||
|
||||
do {
|
||||
int error;
|
||||
if(timeout_ms > 0) {
|
||||
pending_tv.tv_sec = pending_ms / 1000;
|
||||
pending_tv.tv_usec = (pending_ms % 1000) * 1000;
|
||||
@ -402,7 +403,6 @@ int Curl_poll(struct pollfd ufds[], unsigned int nfds, int timeout_ms)
|
||||
bool fds_none = TRUE;
|
||||
unsigned int i;
|
||||
int pending_ms = 0;
|
||||
int error;
|
||||
int r;
|
||||
|
||||
if(ufds) {
|
||||
@ -431,6 +431,7 @@ int Curl_poll(struct pollfd ufds[], unsigned int nfds, int timeout_ms)
|
||||
#ifdef HAVE_POLL_FINE
|
||||
|
||||
do {
|
||||
int error;
|
||||
if(timeout_ms < 0)
|
||||
pending_ms = -1;
|
||||
else if(!timeout_ms)
|
||||
@ -502,6 +503,7 @@ int Curl_poll(struct pollfd ufds[], unsigned int nfds, int timeout_ms)
|
||||
ptimeout = (timeout_ms < 0) ? NULL : &pending_tv;
|
||||
|
||||
do {
|
||||
int error;
|
||||
if(timeout_ms > 0) {
|
||||
pending_tv.tv_sec = pending_ms / 1000;
|
||||
pending_tv.tv_usec = (pending_ms % 1000) * 1000;
|
||||
|
@ -841,7 +841,6 @@ int Curl_debug(struct Curl_easy *data, curl_infotype type,
|
||||
{
|
||||
int rc;
|
||||
if(data->set.printhost && conn && conn->host.dispname) {
|
||||
char buffer[160];
|
||||
const char *t = NULL;
|
||||
const char *w = "Data";
|
||||
switch(type) {
|
||||
@ -862,6 +861,7 @@ int Curl_debug(struct Curl_easy *data, curl_infotype type,
|
||||
}
|
||||
|
||||
if(t) {
|
||||
char buffer[160];
|
||||
snprintf(buffer, sizeof(buffer), "[%s %s %s]", w, t,
|
||||
conn->host.dispname);
|
||||
rc = showit(data, CURLINFO_TEXT, buffer, strlen(buffer));
|
||||
|
@ -84,8 +84,8 @@ CURLcode Curl_write_plain(struct connectdata *conn,
|
||||
ssize_t *written);
|
||||
|
||||
/* the function used to output verbose information */
|
||||
int Curl_debug(struct Curl_easy *handle, curl_infotype type,
|
||||
char *data, size_t size,
|
||||
int Curl_debug(struct Curl_easy *data, curl_infotype type,
|
||||
char *ptr, size_t size,
|
||||
struct connectdata *conn);
|
||||
|
||||
|
||||
|
12
lib/sha256.c
12
lib/sha256.c
@ -130,8 +130,7 @@ static const unsigned long K[64] = {
|
||||
static int sha256_compress(struct sha256_state *md,
|
||||
unsigned char *buf)
|
||||
{
|
||||
unsigned long S[8], W[64], t0, t1;
|
||||
unsigned long t;
|
||||
unsigned long S[8], W[64];
|
||||
int i;
|
||||
/* copy state into S */
|
||||
for(i = 0; i < 8; i++) {
|
||||
@ -146,12 +145,13 @@ static int sha256_compress(struct sha256_state *md,
|
||||
W[i - 16];
|
||||
}
|
||||
/* Compress */
|
||||
#define RND(a,b,c,d,e,f,g,h,i) \
|
||||
t0 = h + Sigma1(e) + Ch(e, f, g) + K[i] + W[i]; \
|
||||
t1 = Sigma0(a) + Maj(a, b, c); \
|
||||
d += t0; \
|
||||
#define RND(a,b,c,d,e,f,g,h,i) \
|
||||
unsigned long t0 = h + Sigma1(e) + Ch(e, f, g) + K[i] + W[i]; \
|
||||
unsigned long t1 = Sigma0(a) + Maj(a, b, c); \
|
||||
d += t0; \
|
||||
h = t0 + t1;
|
||||
for(i = 0; i < 64; ++i) {
|
||||
unsigned long t;
|
||||
RND(S[0], S[1], S[2], S[3], S[4], S[5], S[6], S[7], i);
|
||||
t = S[7]; S[7] = S[6]; S[6] = S[5]; S[5] = S[4];
|
||||
S[4] = S[3]; S[3] = S[2]; S[2] = S[1]; S[1] = S[0]; S[0] = t;
|
||||
|
@ -704,7 +704,6 @@ static CURLcode smtp_state_ehlo_resp(struct connectdata *conn, int smtpcode,
|
||||
struct smtp_conn *smtpc = &conn->proto.smtpc;
|
||||
const char *line = data->state.buffer;
|
||||
size_t len = strlen(line);
|
||||
size_t wordlen;
|
||||
|
||||
(void)instate; /* no use for this yet */
|
||||
|
||||
@ -739,6 +738,7 @@ static CURLcode smtp_state_ehlo_resp(struct connectdata *conn, int smtpcode,
|
||||
/* Loop through the data line */
|
||||
for(;;) {
|
||||
size_t llen;
|
||||
size_t wordlen;
|
||||
unsigned int mechbit;
|
||||
|
||||
while(len &&
|
||||
|
@ -57,10 +57,9 @@ int Curl_blockread_all(struct connectdata *conn, /* connection data */
|
||||
ssize_t nread;
|
||||
ssize_t allread = 0;
|
||||
int result;
|
||||
timediff_t timeleft;
|
||||
*n = 0;
|
||||
for(;;) {
|
||||
timeleft = Curl_timeleft(conn->data, NULL, TRUE);
|
||||
timediff_t timeleft = Curl_timeleft(conn->data, NULL, TRUE);
|
||||
if(timeleft < 0) {
|
||||
/* we already got the timeout */
|
||||
result = CURLE_OPERATION_TIMEDOUT;
|
||||
@ -116,7 +115,6 @@ CURLcode Curl_SOCKS4(const char *proxy_user,
|
||||
#define SOCKS4REQLEN 262
|
||||
unsigned char socksreq[SOCKS4REQLEN]; /* room for SOCKS4 request incl. user
|
||||
id */
|
||||
int result;
|
||||
CURLcode code;
|
||||
curl_socket_t sock = conn->sock[sockindex];
|
||||
struct Curl_easy *data = conn->data;
|
||||
@ -220,6 +218,7 @@ CURLcode Curl_SOCKS4(const char *proxy_user,
|
||||
* Make connection
|
||||
*/
|
||||
{
|
||||
int result;
|
||||
ssize_t actualread;
|
||||
ssize_t written;
|
||||
ssize_t hostnamelen = 0;
|
||||
@ -617,11 +616,11 @@ CURLcode Curl_SOCKS5(const char *proxy_user,
|
||||
if(dns)
|
||||
hp = dns->addr;
|
||||
if(hp) {
|
||||
int i;
|
||||
char buf[64];
|
||||
Curl_printable_address(hp, buf, sizeof(buf));
|
||||
|
||||
if(hp->ai_family == AF_INET) {
|
||||
int i;
|
||||
struct sockaddr_in *saddr_in;
|
||||
socksreq[len++] = 1; /* ATYP: IPv4 = 1 */
|
||||
|
||||
@ -634,6 +633,7 @@ CURLcode Curl_SOCKS5(const char *proxy_user,
|
||||
}
|
||||
#ifdef ENABLE_IPV6
|
||||
else if(hp->ai_family == AF_INET6) {
|
||||
int i;
|
||||
struct sockaddr_in6 *saddr_in6;
|
||||
socksreq[len++] = 4; /* ATYP: IPv6 = 4 */
|
||||
|
||||
|
@ -41,7 +41,6 @@ struct Curl_tree *Curl_splay(struct curltime i,
|
||||
struct Curl_tree *t)
|
||||
{
|
||||
struct Curl_tree N, *l, *r, *y;
|
||||
long comp;
|
||||
|
||||
if(t == NULL)
|
||||
return t;
|
||||
@ -49,7 +48,7 @@ struct Curl_tree *Curl_splay(struct curltime i,
|
||||
l = r = &N;
|
||||
|
||||
for(;;) {
|
||||
comp = compare(i, t->key);
|
||||
long comp = compare(i, t->key);
|
||||
if(comp < 0) {
|
||||
if(t->smaller == NULL)
|
||||
break;
|
||||
|
32
lib/telnet.c
32
lib/telnet.c
@ -109,8 +109,10 @@ static void printoption(struct Curl_easy *data,
|
||||
|
||||
static void negotiate(struct connectdata *);
|
||||
static void send_negotiation(struct connectdata *, int cmd, int option);
|
||||
static void set_local_option(struct connectdata *, int cmd, int option);
|
||||
static void set_remote_option(struct connectdata *, int cmd, int option);
|
||||
static void set_local_option(struct connectdata *conn,
|
||||
int option, int newstate);
|
||||
static void set_remote_option(struct connectdata *conn,
|
||||
int option, int newstate);
|
||||
|
||||
static void printsub(struct Curl_easy *data,
|
||||
int direction, unsigned char *pointer,
|
||||
@ -311,9 +313,6 @@ static void negotiate(struct connectdata *conn)
|
||||
static void printoption(struct Curl_easy *data,
|
||||
const char *direction, int cmd, int option)
|
||||
{
|
||||
const char *fmt;
|
||||
const char *opt;
|
||||
|
||||
if(data->set.verbose) {
|
||||
if(cmd == CURL_IAC) {
|
||||
if(CURL_TELCMD_OK(option))
|
||||
@ -322,9 +321,12 @@ static void printoption(struct Curl_easy *data,
|
||||
infof(data, "%s IAC %d\n", direction, option);
|
||||
}
|
||||
else {
|
||||
fmt = (cmd == CURL_WILL) ? "WILL" : (cmd == CURL_WONT) ? "WONT" :
|
||||
(cmd == CURL_DO) ? "DO" : (cmd == CURL_DONT) ? "DONT" : 0;
|
||||
const char *fmt = (cmd == CURL_WILL) ? "WILL" :
|
||||
(cmd == CURL_WONT) ? "WONT" :
|
||||
(cmd == CURL_DO) ? "DO" :
|
||||
(cmd == CURL_DONT) ? "DONT" : 0;
|
||||
if(fmt) {
|
||||
const char *opt;
|
||||
if(CURL_TELOPT_OK(option))
|
||||
opt = CURL_TELOPT(option);
|
||||
else if(option == CURL_TELOPT_EXOPL)
|
||||
@ -348,7 +350,6 @@ static void send_negotiation(struct connectdata *conn, int cmd, int option)
|
||||
{
|
||||
unsigned char buf[3];
|
||||
ssize_t bytes_written;
|
||||
int err;
|
||||
struct Curl_easy *data = conn->data;
|
||||
|
||||
buf[0] = CURL_IAC;
|
||||
@ -357,7 +358,7 @@ static void send_negotiation(struct connectdata *conn, int cmd, int option)
|
||||
|
||||
bytes_written = swrite(conn->sock[FIRSTSOCKET], buf, 3);
|
||||
if(bytes_written < 0) {
|
||||
err = SOCKERRNO;
|
||||
int err = SOCKERRNO;
|
||||
failf(data,"Sending data failed (%d)",err);
|
||||
}
|
||||
|
||||
@ -710,9 +711,8 @@ static void printsub(struct Curl_easy *data,
|
||||
unsigned char *pointer, /* where suboption data is */
|
||||
size_t length) /* length of suboption data */
|
||||
{
|
||||
unsigned int i = 0;
|
||||
|
||||
if(data->set.verbose) {
|
||||
unsigned int i = 0;
|
||||
if(direction) {
|
||||
infof(data, "%s IAC SB ", (direction == '<')? "RCVD":"SENT");
|
||||
if(length >= 3) {
|
||||
@ -928,7 +928,6 @@ static void suboption(struct connectdata *conn)
|
||||
unsigned char temp[2048];
|
||||
ssize_t bytes_written;
|
||||
size_t len;
|
||||
size_t tmplen;
|
||||
int err;
|
||||
char varname[128] = "";
|
||||
char varval[128] = "";
|
||||
@ -968,7 +967,7 @@ static void suboption(struct connectdata *conn)
|
||||
len = 4;
|
||||
|
||||
for(v = tn->telnet_vars; v; v = v->next) {
|
||||
tmplen = (strlen(v->data) + 1);
|
||||
size_t tmplen = (strlen(v->data) + 1);
|
||||
/* Add the variable only if it fits */
|
||||
if(len + tmplen < (int)sizeof(temp)-6) {
|
||||
if(sscanf(v->data, "%127[^,],%127s", varname, varval)) {
|
||||
@ -1223,7 +1222,7 @@ CURLcode telrcv(struct connectdata *conn,
|
||||
static CURLcode send_telnet_data(struct connectdata *conn,
|
||||
char *buffer, ssize_t nread)
|
||||
{
|
||||
ssize_t escapes, i, j, outlen;
|
||||
ssize_t escapes, i, outlen;
|
||||
unsigned char *outbuf = NULL;
|
||||
CURLcode result = CURLE_OK;
|
||||
ssize_t bytes_written, total_written;
|
||||
@ -1238,6 +1237,7 @@ static CURLcode send_telnet_data(struct connectdata *conn,
|
||||
if(outlen == nread)
|
||||
outbuf = (unsigned char *)buffer;
|
||||
else {
|
||||
ssize_t j;
|
||||
outbuf = malloc(nread + escapes + 1);
|
||||
if(!outbuf)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
@ -1315,7 +1315,6 @@ static CURLcode telnet_do(struct connectdata *conn, bool *done)
|
||||
HANDLE objs[2];
|
||||
DWORD obj_count;
|
||||
DWORD wait_timeout;
|
||||
DWORD waitret;
|
||||
DWORD readfile_read;
|
||||
int err;
|
||||
#else
|
||||
@ -1438,7 +1437,8 @@ static CURLcode telnet_do(struct connectdata *conn, bool *done)
|
||||
/* Keep on listening and act on events */
|
||||
while(keepon) {
|
||||
const DWORD buf_size = (DWORD)data->set.buffer_size;
|
||||
waitret = WaitForMultipleObjects(obj_count, objs, FALSE, wait_timeout);
|
||||
DWORD waitret = WaitForMultipleObjects(obj_count, objs,
|
||||
FALSE, wait_timeout);
|
||||
switch(waitret) {
|
||||
case WAIT_TIMEOUT:
|
||||
{
|
||||
|
16
lib/tftp.c
16
lib/tftp.c
@ -451,7 +451,6 @@ static CURLcode tftp_send_first(tftp_state_data_t *state, tftp_event_t event)
|
||||
ssize_t senddata;
|
||||
const char *mode = "octet";
|
||||
char *filename;
|
||||
char buf[64];
|
||||
struct Curl_easy *data = state->conn->data;
|
||||
CURLcode result = CURLE_OK;
|
||||
|
||||
@ -504,6 +503,7 @@ static CURLcode tftp_send_first(tftp_state_data_t *state, tftp_event_t event)
|
||||
|
||||
/* optional addition of TFTP options */
|
||||
if(!data->set.tftp_no_options) {
|
||||
char buf[64];
|
||||
/* add tsize option */
|
||||
if(data->set.upload && (data->state.infilesize != -1))
|
||||
snprintf(buf, sizeof(buf), "%" CURL_FORMAT_CURL_OFF_T,
|
||||
@ -710,7 +710,6 @@ static CURLcode tftp_tx(tftp_state_data_t *state, tftp_event_t event)
|
||||
{
|
||||
struct Curl_easy *data = state->conn->data;
|
||||
ssize_t sbytes;
|
||||
int rblock;
|
||||
CURLcode result = CURLE_OK;
|
||||
struct SingleRequest *k = &data->req;
|
||||
int cb; /* Bytes currently read */
|
||||
@ -721,7 +720,7 @@ static CURLcode tftp_tx(tftp_state_data_t *state, tftp_event_t event)
|
||||
case TFTP_EVENT_OACK:
|
||||
if(event == TFTP_EVENT_ACK) {
|
||||
/* Ack the packet */
|
||||
rblock = getrpacketblock(&state->rpacket);
|
||||
int rblock = getrpacketblock(&state->rpacket);
|
||||
|
||||
if(rblock != state->block &&
|
||||
/* There's a bug in tftpd-hpa that causes it to send us an ack for
|
||||
@ -969,7 +968,7 @@ static CURLcode tftp_disconnect(struct connectdata *conn, bool dead_connection)
|
||||
static CURLcode tftp_connect(struct connectdata *conn, bool *done)
|
||||
{
|
||||
tftp_state_data_t *state;
|
||||
int blksize, rc;
|
||||
int blksize;
|
||||
|
||||
blksize = TFTP_BLKSIZE_DEFAULT;
|
||||
|
||||
@ -1028,8 +1027,8 @@ static CURLcode tftp_connect(struct connectdata *conn, bool *done)
|
||||
* assume uses the same IP version and thus hopefully this works for both
|
||||
* IPv4 and IPv6...
|
||||
*/
|
||||
rc = bind(state->sockfd, (struct sockaddr *)&state->local_addr,
|
||||
conn->ip_addr->ai_addrlen);
|
||||
int rc = bind(state->sockfd, (struct sockaddr *)&state->local_addr,
|
||||
conn->ip_addr->ai_addrlen);
|
||||
if(rc) {
|
||||
failf(conn->data, "bind() failed; %s",
|
||||
Curl_strerror(conn, SOCKERRNO));
|
||||
@ -1224,7 +1223,6 @@ static long tftp_state_timeout(struct connectdata *conn, tftp_event_t *event)
|
||||
**********************************************************/
|
||||
static CURLcode tftp_multi_statemach(struct connectdata *conn, bool *done)
|
||||
{
|
||||
int rc;
|
||||
tftp_event_t event;
|
||||
CURLcode result = CURLE_OK;
|
||||
struct Curl_easy *data = conn->data;
|
||||
@ -1248,7 +1246,7 @@ static CURLcode tftp_multi_statemach(struct connectdata *conn, bool *done)
|
||||
}
|
||||
else {
|
||||
/* no timeouts to handle, check our socket */
|
||||
rc = SOCKET_READABLE(state->sockfd, 0);
|
||||
int rc = SOCKET_READABLE(state->sockfd, 0);
|
||||
|
||||
if(rc == -1) {
|
||||
/* bail out */
|
||||
@ -1371,7 +1369,6 @@ static CURLcode tftp_setup_connection(struct connectdata * conn)
|
||||
{
|
||||
struct Curl_easy *data = conn->data;
|
||||
char *type;
|
||||
char command;
|
||||
|
||||
conn->socktype = SOCK_DGRAM; /* UDP datagram based */
|
||||
|
||||
@ -1383,6 +1380,7 @@ static CURLcode tftp_setup_connection(struct connectdata * conn)
|
||||
type = strstr(conn->host.rawalloc, ";mode=");
|
||||
|
||||
if(type) {
|
||||
char command;
|
||||
*type = 0; /* it was in the middle of the hostname */
|
||||
command = Curl_raw_toupper(type[6]);
|
||||
|
||||
|
@ -444,7 +444,6 @@ static CURLcode readwrite_data(struct Curl_easy *data,
|
||||
CURLcode result = CURLE_OK;
|
||||
ssize_t nread; /* number of bytes read */
|
||||
size_t excess = 0; /* excess bytes read */
|
||||
bool is_empty_data = FALSE;
|
||||
bool readmore = FALSE; /* used by RTP to signal for more data */
|
||||
int maxloops = 100;
|
||||
|
||||
@ -454,6 +453,7 @@ static CURLcode readwrite_data(struct Curl_easy *data,
|
||||
/* This is where we loop until we have read everything there is to
|
||||
read or we get a CURLE_AGAIN */
|
||||
do {
|
||||
bool is_empty_data = FALSE;
|
||||
size_t buffersize = data->set.buffer_size;
|
||||
size_t bytestoread = buffersize;
|
||||
|
||||
|
15
lib/url.c
15
lib/url.c
@ -2003,7 +2003,6 @@ static CURLcode parseurlandfillconn(struct Curl_easy *data,
|
||||
char *fragment;
|
||||
char *path = data->state.path;
|
||||
char *query;
|
||||
int i;
|
||||
int rc;
|
||||
const char *protop = "";
|
||||
CURLcode result;
|
||||
@ -2055,6 +2054,7 @@ static CURLcode parseurlandfillconn(struct Curl_easy *data,
|
||||
; /* do nothing */
|
||||
}
|
||||
else { /* check for a scheme */
|
||||
int i;
|
||||
for(i = 0; i < 16 && data->change.url[i]; ++i) {
|
||||
if(data->change.url[i] == '/')
|
||||
break;
|
||||
@ -2543,14 +2543,13 @@ static bool check_noproxy(const char *name, const char *no_proxy)
|
||||
* not be proxied, or an asterisk to override
|
||||
* all proxy variables)
|
||||
*/
|
||||
size_t tok_start;
|
||||
size_t tok_end;
|
||||
const char *separator = ", ";
|
||||
size_t no_proxy_len;
|
||||
size_t namelen;
|
||||
char *endptr;
|
||||
|
||||
if(no_proxy && no_proxy[0]) {
|
||||
size_t tok_start;
|
||||
size_t tok_end;
|
||||
const char *separator = ", ";
|
||||
size_t no_proxy_len;
|
||||
size_t namelen;
|
||||
char *endptr;
|
||||
if(strcasecompare("*", no_proxy)) {
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -158,7 +158,7 @@ static void auth_digest_sha256_to_ascii(unsigned char *source, /* 32 bytes */
|
||||
/* Perform quoted-string escaping as described in RFC2616 and its errata */
|
||||
static char *auth_digest_string_quoted(const char *source)
|
||||
{
|
||||
char *dest, *d;
|
||||
char *dest;
|
||||
const char *s = source;
|
||||
size_t n = 1; /* null terminator */
|
||||
|
||||
@ -173,8 +173,8 @@ static char *auth_digest_string_quoted(const char *source)
|
||||
|
||||
dest = malloc(n);
|
||||
if(dest) {
|
||||
char *d = dest;
|
||||
s = source;
|
||||
d = dest;
|
||||
while(*s) {
|
||||
if(*s == '"' || *s == '\\') {
|
||||
*d++ = '\\';
|
||||
@ -696,7 +696,6 @@ static CURLcode _Curl_auth_create_digest_http_message(
|
||||
unsigned char ha1[65]; /* 64 digits and 1 zero byte */
|
||||
unsigned char ha2[65]; /* 64 digits and 1 zero byte */
|
||||
char userh[65];
|
||||
char cnoncebuf[33];
|
||||
char *cnonce = NULL;
|
||||
size_t cnonce_sz = 0;
|
||||
char *userp_quoted;
|
||||
@ -707,6 +706,7 @@ static CURLcode _Curl_auth_create_digest_http_message(
|
||||
digest->nc = 1;
|
||||
|
||||
if(!digest->cnonce) {
|
||||
char cnoncebuf[33];
|
||||
result = Curl_rand_hex(data, (unsigned char *)cnoncebuf,
|
||||
sizeof(cnoncebuf));
|
||||
if(result)
|
||||
|
@ -50,15 +50,15 @@ int tool_debug_cb(CURL *handle, curl_infotype type,
|
||||
FILE *output = config->errors;
|
||||
const char *text;
|
||||
struct timeval tv;
|
||||
struct tm *now;
|
||||
char timebuf[20];
|
||||
time_t secs;
|
||||
static time_t epoch_offset;
|
||||
static int known_offset;
|
||||
|
||||
(void)handle; /* not used */
|
||||
|
||||
if(config->tracetime) {
|
||||
struct tm *now;
|
||||
static time_t epoch_offset;
|
||||
static int known_offset;
|
||||
tv = tvnow();
|
||||
if(!known_offset) {
|
||||
epoch_offset = time(NULL) - tv.tv_sec;
|
||||
@ -101,14 +101,14 @@ int tool_debug_cb(CURL *handle, curl_infotype type,
|
||||
static const char * const s_infotype[] = {
|
||||
"*", "<", ">", "{", "}", "{", "}"
|
||||
};
|
||||
size_t i;
|
||||
size_t st = 0;
|
||||
static bool newl = FALSE;
|
||||
static bool traced_data = FALSE;
|
||||
|
||||
switch(type) {
|
||||
case CURLINFO_HEADER_OUT:
|
||||
if(size > 0) {
|
||||
size_t st = 0;
|
||||
size_t i;
|
||||
for(i = 0; i < size - 1; i++) {
|
||||
if(data[i] == '\n') { /* LF */
|
||||
if(!newl) {
|
||||
|
@ -113,12 +113,6 @@ int tool_progress_cb(void *clientp,
|
||||
/* The original progress-bar source code was written for curl by Lars Aas,
|
||||
and this new edition inherits some of his concepts. */
|
||||
|
||||
char line[MAX_BARLENGTH + 1];
|
||||
char format[40];
|
||||
double frac;
|
||||
double percent;
|
||||
int barwidth;
|
||||
int num;
|
||||
struct timeval now = tvnow();
|
||||
struct ProgressData *bar = (struct ProgressData *)clientp;
|
||||
curl_off_t total;
|
||||
@ -154,6 +148,12 @@ int tool_progress_cb(void *clientp,
|
||||
bar->calls++;
|
||||
|
||||
if((total > 0) && (point != bar->prev)) {
|
||||
char line[MAX_BARLENGTH + 1];
|
||||
char format[40];
|
||||
double frac;
|
||||
double percent;
|
||||
int barwidth;
|
||||
int num;
|
||||
if(point > total)
|
||||
/* we have got more than the expected total! */
|
||||
total = point;
|
||||
|
@ -123,13 +123,12 @@ static int read_field_headers(struct OperationConfig *config,
|
||||
{
|
||||
size_t hdrlen = 0;
|
||||
size_t pos = 0;
|
||||
int c;
|
||||
bool incomment = FALSE;
|
||||
int lineno = 1;
|
||||
char hdrbuf[999]; /* Max. header length + 1. */
|
||||
|
||||
for(;;) {
|
||||
c = getc(fp);
|
||||
int c = getc(fp);
|
||||
if(c == EOF || (!pos && !ISSPACE(c))) {
|
||||
/* Strip and flush the current header. */
|
||||
while(hdrlen && ISSPACE(hdrbuf[hdrlen - 1]))
|
||||
@ -563,7 +562,6 @@ int formparse(struct OperationConfig *config,
|
||||
struct curl_slist *headers = NULL;
|
||||
curl_mimepart *part = NULL;
|
||||
CURLcode res;
|
||||
int sep = '\0';
|
||||
|
||||
/* Allocate the main mime structure if needed. */
|
||||
if(!*mimepost) {
|
||||
@ -585,6 +583,7 @@ int formparse(struct OperationConfig *config,
|
||||
/* Scan for the end of the name. */
|
||||
contp = strchr(contents, '=');
|
||||
if(contp) {
|
||||
int sep = '\0';
|
||||
if(contp > contents)
|
||||
name = contents;
|
||||
*contp++ = '\0';
|
||||
|
@ -506,8 +506,7 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */
|
||||
|
||||
*usedarg = FALSE; /* default is that we don't use the arg */
|
||||
|
||||
if(('-' != flag[0]) ||
|
||||
(('-' == flag[0]) && ('-' == flag[1]))) {
|
||||
if(('-' != flag[0]) || ('-' == flag[1])) {
|
||||
/* this should be a long name */
|
||||
const char *word = ('-' == flag[0]) ? flag + 2 : flag;
|
||||
size_t fnam = strlen(word);
|
||||
@ -2155,7 +2154,6 @@ ParameterError parse_args(struct GlobalConfig *config, int argc,
|
||||
orig_opt = argv[i];
|
||||
|
||||
if(stillflags && ('-' == argv[i][0])) {
|
||||
char *nextarg;
|
||||
bool passarg;
|
||||
char *flag = argv[i];
|
||||
|
||||
@ -2164,7 +2162,7 @@ ParameterError parse_args(struct GlobalConfig *config, int argc,
|
||||
following (URL) argument to start with -. */
|
||||
stillflags = FALSE;
|
||||
else {
|
||||
nextarg = (i < (argc - 1)) ? argv[i + 1] : NULL;
|
||||
char *nextarg = (i < (argc - 1)) ? argv[i + 1] : NULL;
|
||||
|
||||
result = getparameter(flag, nextarg, &passarg, config, operation);
|
||||
if(result == PARAM_NEXT_OPERATION) {
|
||||
|
@ -76,7 +76,6 @@ CURLcode get_libcurl_info(void)
|
||||
{ NULL, 0 }
|
||||
};
|
||||
|
||||
struct proto_name_pattern const *p;
|
||||
const char *const *proto;
|
||||
|
||||
/* Pointer to libcurl's run-time version information */
|
||||
@ -88,6 +87,7 @@ CURLcode get_libcurl_info(void)
|
||||
built_in_protos = 0;
|
||||
if(curlinfo->protocols) {
|
||||
for(proto = curlinfo->protocols; *proto; proto++) {
|
||||
struct proto_name_pattern const *p;
|
||||
for(p = possibly_built_in; p->proto_name; p++) {
|
||||
if(curl_strequal(*proto, p->proto_name)) {
|
||||
built_in_protos |= p->proto_pattern;
|
||||
|
@ -109,8 +109,8 @@ void warnf(struct GlobalConfig *config, const char *fmt, ...)
|
||||
|
||||
void helpf(FILE *errors, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
if(fmt) {
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
fputs("curl: ", errors); /* prefix it */
|
||||
vfprintf(errors, fmt, ap);
|
||||
|
@ -58,14 +58,14 @@ struct getout *new_getout(struct OperationConfig *config)
|
||||
|
||||
ParameterError file2string(char **bufp, FILE *file)
|
||||
{
|
||||
char buffer[256];
|
||||
char *ptr;
|
||||
char *string = NULL;
|
||||
size_t stringlen = 0;
|
||||
size_t buflen;
|
||||
|
||||
if(file) {
|
||||
char buffer[256];
|
||||
size_t stringlen = 0;
|
||||
while(fgets(buffer, sizeof(buffer), file)) {
|
||||
size_t buflen;
|
||||
ptr = strchr(buffer, '\r');
|
||||
if(ptr)
|
||||
*ptr = '\0';
|
||||
@ -91,11 +91,11 @@ ParameterError file2memory(char **bufp, size_t *size, FILE *file)
|
||||
{
|
||||
char *newbuf;
|
||||
char *buffer = NULL;
|
||||
size_t alloc = 512;
|
||||
size_t nused = 0;
|
||||
size_t nread;
|
||||
|
||||
if(file) {
|
||||
size_t nread;
|
||||
size_t alloc = 512;
|
||||
do {
|
||||
if(!buffer || (alloc == nused)) {
|
||||
/* size_t overflow detection for huge files */
|
||||
|
@ -46,11 +46,9 @@ static char *my_get_line(FILE *fp);
|
||||
/* return 0 on everything-is-fine, and non-zero otherwise */
|
||||
int parseconfig(const char *filename, struct GlobalConfig *global)
|
||||
{
|
||||
int res;
|
||||
FILE *file;
|
||||
char filebuffer[512];
|
||||
bool usedarg = FALSE;
|
||||
char *home;
|
||||
int rc = 0;
|
||||
struct OperationConfig *operation = global->first;
|
||||
|
||||
@ -58,8 +56,8 @@ int parseconfig(const char *filename, struct GlobalConfig *global)
|
||||
/* NULL or no file name attempts to load .curlrc from the homedir! */
|
||||
|
||||
#ifndef __AMIGA__
|
||||
char *home = homedir(); /* portable homedir finder */
|
||||
filename = CURLRC; /* sensible default */
|
||||
home = homedir(); /* portable homedir finder */
|
||||
if(home) {
|
||||
if(strlen(home) < (sizeof(filebuffer) - strlen(CURLRC))) {
|
||||
snprintf(filebuffer, sizeof(filebuffer),
|
||||
@ -125,13 +123,13 @@ int parseconfig(const char *filename, struct GlobalConfig *global)
|
||||
char *option;
|
||||
char *param;
|
||||
int lineno = 0;
|
||||
bool alloced_param;
|
||||
bool dashed_option;
|
||||
|
||||
while(NULL != (aline = my_get_line(file))) {
|
||||
int res;
|
||||
bool alloced_param = FALSE;
|
||||
lineno++;
|
||||
line = aline;
|
||||
alloced_param = FALSE;
|
||||
|
||||
/* line with # in the first non-blank column is a comment! */
|
||||
while(*line && ISSPACE(*line))
|
||||
|
@ -622,12 +622,12 @@ CURLcode glob_match_url(char **result, char *filename, URLGlob *glob)
|
||||
|
||||
while(*filename) {
|
||||
if(*filename == '#' && ISDIGIT(filename[1])) {
|
||||
unsigned long i;
|
||||
char *ptr = filename;
|
||||
unsigned long num = strtoul(&filename[1], &filename, 10);
|
||||
URLPattern *pat = NULL;
|
||||
|
||||
if(num < glob->size) {
|
||||
unsigned long i;
|
||||
num--; /* make it zero based */
|
||||
/* find the correct glob entry */
|
||||
for(i = 0; i<glob->size; i++) {
|
||||
|
@ -122,9 +122,9 @@ void ourWriteOut(CURL *curl, struct OutStruct *outs, const char *writeinfo)
|
||||
else {
|
||||
/* this is meant as a variable to output */
|
||||
char *end;
|
||||
char keepit;
|
||||
int i;
|
||||
if('{' == ptr[1]) {
|
||||
char keepit;
|
||||
int i;
|
||||
bool match = FALSE;
|
||||
end = strchr(ptr, '}');
|
||||
ptr += 2; /* pass the % and the { */
|
||||
|
@ -43,8 +43,7 @@ int test(char *URL)
|
||||
asize = (int)sizeof(a);
|
||||
ptr = curl_easy_escape(NULL, (char *)a, asize);
|
||||
printf("%s\n", ptr);
|
||||
if(ptr)
|
||||
curl_free(ptr);
|
||||
curl_free(ptr);
|
||||
|
||||
/* deprecated API */
|
||||
ptr = curl_escape((char *)a, asize);
|
||||
@ -58,8 +57,7 @@ int test(char *URL)
|
||||
printf("outlen == %d\n", outlen);
|
||||
printf("unescape == original? %s\n",
|
||||
memcmp(raw, a, outlen) ? "no" : "YES");
|
||||
if(raw)
|
||||
curl_free(raw);
|
||||
curl_free(raw);
|
||||
|
||||
/* deprecated API */
|
||||
raw = curl_unescape(ptr, (int)strlen(ptr));
|
||||
@ -71,10 +69,8 @@ int test(char *URL)
|
||||
printf("[old] outlen == %d\n", outlen);
|
||||
printf("[old] unescape == original? %s\n",
|
||||
memcmp(raw, a, outlen) ? "no" : "YES");
|
||||
if(raw)
|
||||
curl_free(raw);
|
||||
if(ptr)
|
||||
curl_free(ptr);
|
||||
curl_free(raw);
|
||||
curl_free(ptr);
|
||||
|
||||
/* weird input length */
|
||||
ptr = curl_easy_escape(NULL, (char *)a, -1);
|
||||
@ -86,8 +82,7 @@ int test(char *URL)
|
||||
printf("unescape -1 length: %s %d\n", ptr, outlen);
|
||||
|
||||
test_cleanup:
|
||||
if(ptr)
|
||||
curl_free(ptr);
|
||||
curl_free(ptr);
|
||||
curl_global_cleanup();
|
||||
|
||||
return (int)res;
|
||||
|
@ -43,7 +43,6 @@ static void my_unlock(CURL *handle, curl_lock_data data, void *useptr)
|
||||
/* test function */
|
||||
int test(char *URL)
|
||||
{
|
||||
CURL *curl;
|
||||
CURLcode res = CURLE_OK;
|
||||
CURLSH *share;
|
||||
int i;
|
||||
@ -65,7 +64,7 @@ int test(char *URL)
|
||||
still reuse connections since the pool is in the shared object! */
|
||||
|
||||
for(i = 0; i < 3; i++) {
|
||||
curl = curl_easy_init();
|
||||
CURL *curl = curl_easy_init();
|
||||
if(curl) {
|
||||
curl_easy_setopt(curl, CURLOPT_URL, URL);
|
||||
|
||||
|
@ -63,14 +63,14 @@ static int parse_url_file(const char *filename)
|
||||
return 0;
|
||||
|
||||
while(!feof(f)) {
|
||||
if(fscanf(f, "%d %s\n", &filetime, buf)) {
|
||||
if(fscanf(f, "%d %199s\n", &filetime, buf)) {
|
||||
urltime[num_handles] = filetime;
|
||||
urlstring[num_handles] = strdup(buf);
|
||||
num_handles++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if(fscanf(f, "blacklist_site %s\n", buf)) {
|
||||
if(fscanf(f, "blacklist_site %199s\n", buf)) {
|
||||
site_blacklist[blacklist_num_sites] = strdup(buf);
|
||||
blacklist_num_sites++;
|
||||
continue;
|
||||
@ -192,11 +192,11 @@ int test(char *URL)
|
||||
do {
|
||||
msg = curl_multi_info_read(m, &msgs_left);
|
||||
if(msg && msg->msg == CURLMSG_DONE) {
|
||||
int i, found = 0;
|
||||
int i;
|
||||
|
||||
/* Find out which handle this message is about */
|
||||
for(i = 0; i < num_handles; i++) {
|
||||
found = (msg->easy_handle == handles[i]);
|
||||
int found = (msg->easy_handle == handles[i]);
|
||||
if(found)
|
||||
break;
|
||||
}
|
||||
|
@ -131,7 +131,6 @@ static void *fire(void *ptr)
|
||||
struct curl_slist *headers;
|
||||
struct Tdata *tdata = (struct Tdata*)ptr;
|
||||
CURL *curl;
|
||||
int i = 0;
|
||||
|
||||
curl = curl_easy_init();
|
||||
if(!curl) {
|
||||
@ -149,6 +148,7 @@ static void *fire(void *ptr)
|
||||
printf("PERFORM\n");
|
||||
code = curl_easy_perform(curl);
|
||||
if(code) {
|
||||
int i = 0;
|
||||
fprintf(stderr, "perform url '%s' repeat %d failed, curlcode %d\n",
|
||||
tdata->url, i, (int)code);
|
||||
}
|
||||
|
@ -29,15 +29,13 @@
|
||||
int test(char *URL)
|
||||
{
|
||||
CURLcode code;
|
||||
CURL *curl;
|
||||
CURL *curl2;
|
||||
int rc = 99;
|
||||
|
||||
code = curl_global_init(CURL_GLOBAL_ALL);
|
||||
if(code == CURLE_OK) {
|
||||
|
||||
curl = curl_easy_init();
|
||||
CURL *curl = curl_easy_init();
|
||||
if(curl) {
|
||||
CURL *curl2;
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
curl_easy_setopt(curl, CURLOPT_HEADER, 1L);
|
||||
|
@ -71,7 +71,6 @@ int test(char *URL)
|
||||
"Host: ninja\r\n\r\n";
|
||||
#endif
|
||||
size_t iolen;
|
||||
char buf[1024];
|
||||
|
||||
res = curl_easy_send(curl, request, strlen(request), &iolen);
|
||||
|
||||
@ -79,6 +78,7 @@ int test(char *URL)
|
||||
/* we assume that sending always work */
|
||||
|
||||
do {
|
||||
char buf[1024];
|
||||
/* busy-read like crazy */
|
||||
res = curl_easy_recv(curl, buf, sizeof(buf), &iolen);
|
||||
|
||||
|
@ -39,7 +39,6 @@ struct WriteThis {
|
||||
static int progress_callback(void *clientp, double dltotal, double dlnow,
|
||||
double ultotal, double ulnow)
|
||||
{
|
||||
FILE *moo;
|
||||
static int prev_ultotal = -1;
|
||||
static int prev_ulnow = -1;
|
||||
(void)clientp; /* UNUSED */
|
||||
@ -53,7 +52,7 @@ static int progress_callback(void *clientp, double dltotal, double dlnow,
|
||||
if((prev_ultotal != (int)ultotal) ||
|
||||
(prev_ulnow != (int)ulnow)) {
|
||||
|
||||
moo = fopen(libtest_arg2, "ab");
|
||||
FILE *moo = fopen(libtest_arg2, "ab");
|
||||
if(moo) {
|
||||
fprintf(moo, "Progress callback called with UL %d out of %d\n",
|
||||
(int)ulnow, (int)ultotal);
|
||||
|
@ -99,7 +99,6 @@ static void *fire(void *ptr)
|
||||
CURLcode code;
|
||||
struct Tdata *tdata = (struct Tdata*)ptr;
|
||||
CURL *curl;
|
||||
int i = 0;
|
||||
|
||||
curl = curl_easy_init();
|
||||
if(!curl) {
|
||||
@ -116,6 +115,7 @@ static void *fire(void *ptr)
|
||||
printf("PERFORM\n");
|
||||
code = curl_easy_perform(curl);
|
||||
if(code != CURLE_OK) {
|
||||
int i = 0;
|
||||
fprintf(stderr, "perform url '%s' repeat %d failed, curlcode %d\n",
|
||||
tdata->url, i, (int)code);
|
||||
}
|
||||
|
@ -90,7 +90,6 @@ int libtest_debug_cb(CURL *handle, curl_infotype type,
|
||||
struct libtest_trace_cfg *trace_cfg = userp;
|
||||
const char *text;
|
||||
struct timeval tv;
|
||||
struct tm *now;
|
||||
char timebuf[20];
|
||||
char *timestr;
|
||||
time_t secs;
|
||||
@ -101,6 +100,7 @@ int libtest_debug_cb(CURL *handle, curl_infotype type,
|
||||
timestr = &timebuf[0];
|
||||
|
||||
if(trace_cfg->tracetime) {
|
||||
struct tm *now;
|
||||
tv = tutil_tvnow();
|
||||
if(!known_offset) {
|
||||
epoch_offset = time(NULL) - tv.tv_sec;
|
||||
|
@ -116,7 +116,6 @@ CURLcode Curl_convert_clone(struct Curl_easy *data,
|
||||
static int readline(char **buffer, size_t *bufsize, FILE *stream)
|
||||
{
|
||||
size_t offset = 0;
|
||||
size_t length;
|
||||
char *newptr;
|
||||
|
||||
if(!*buffer) {
|
||||
@ -127,6 +126,7 @@ static int readline(char **buffer, size_t *bufsize, FILE *stream)
|
||||
}
|
||||
|
||||
for(;;) {
|
||||
size_t length;
|
||||
int bytestoread = curlx_uztosi(*bufsize - offset);
|
||||
|
||||
if(!fgets(*buffer + offset, bytestoread, stream))
|
||||
|
@ -340,11 +340,8 @@ static int ProcessRequest(struct httprequest *req)
|
||||
static char request[REQUEST_KEYWORD_SIZE];
|
||||
static char doc[MAXDOCNAMELEN];
|
||||
static char prot_str[5];
|
||||
char logbuf[256];
|
||||
int prot_major, prot_minor;
|
||||
char *end;
|
||||
int error;
|
||||
end = strstr(line, END_OF_HEADERS);
|
||||
char *end = strstr(line, END_OF_HEADERS);
|
||||
|
||||
logmsg("ProcessRequest() called with testno %ld and line [%s]",
|
||||
req->testno, line);
|
||||
@ -360,6 +357,7 @@ static int ProcessRequest(struct httprequest *req)
|
||||
&prot_major,
|
||||
&prot_minor) == 5) {
|
||||
char *ptr;
|
||||
char logbuf[256];
|
||||
|
||||
if(!strcmp(prot_str, "HTTP")) {
|
||||
req->protocol = RPROT_HTTP;
|
||||
@ -426,7 +424,7 @@ static int ProcessRequest(struct httprequest *req)
|
||||
|
||||
stream = fopen(filename, "rb");
|
||||
if(!stream) {
|
||||
error = errno;
|
||||
int error = errno;
|
||||
logmsg("fopen() failed with error: %d %s", error, strerror(error));
|
||||
logmsg("Error opening file: %s", filename);
|
||||
logmsg("Couldn't open test file %ld", req->testno);
|
||||
@ -441,11 +439,10 @@ static int ProcessRequest(struct httprequest *req)
|
||||
int rtp_channel = 0;
|
||||
int rtp_size = 0;
|
||||
int rtp_partno = -1;
|
||||
int i = 0;
|
||||
char *rtp_scratch = NULL;
|
||||
|
||||
/* get the custom server control "commands" */
|
||||
error = getpart(&cmd, &cmdsize, "reply", "servercmd", stream);
|
||||
int error = getpart(&cmd, &cmdsize, "reply", "servercmd", stream);
|
||||
fclose(stream);
|
||||
if(error) {
|
||||
logmsg("getpart() failed with error: %d", error);
|
||||
@ -486,6 +483,7 @@ static int ProcessRequest(struct httprequest *req)
|
||||
&rtp_partno, &rtp_channel, &rtp_size)) {
|
||||
|
||||
if(rtp_partno == req->partno) {
|
||||
int i = 0;
|
||||
logmsg("RTP: part %d channel %d size %d",
|
||||
rtp_partno, rtp_channel, rtp_size);
|
||||
|
||||
@ -900,7 +898,6 @@ static int send_doc(curl_socket_t sock, struct httprequest *req)
|
||||
size_t count;
|
||||
const char *buffer;
|
||||
char *ptr = NULL;
|
||||
FILE *stream;
|
||||
char *cmd = NULL;
|
||||
size_t cmdsize = 0;
|
||||
FILE *dump;
|
||||
@ -912,8 +909,6 @@ static int send_doc(curl_socket_t sock, struct httprequest *req)
|
||||
|
||||
static char weare[256];
|
||||
|
||||
char partbuf[80]="data";
|
||||
|
||||
logmsg("Send response number %ld part %ld", req->testno, req->partno);
|
||||
|
||||
switch(req->rcmd) {
|
||||
@ -987,7 +982,8 @@ static int send_doc(curl_socket_t sock, struct httprequest *req)
|
||||
}
|
||||
else {
|
||||
char *filename = test2file(req->testno);
|
||||
|
||||
char partbuf[80]="data";
|
||||
FILE *stream;
|
||||
if(0 != req->partno)
|
||||
snprintf(partbuf, sizeof(partbuf), "data%ld", req->partno);
|
||||
|
||||
|
@ -358,11 +358,11 @@ static ssize_t write_wincon(int fd, const void *buf, size_t count)
|
||||
static ssize_t fullread(int filedes, void *buffer, size_t nbytes)
|
||||
{
|
||||
int error;
|
||||
ssize_t rc;
|
||||
ssize_t nread = 0;
|
||||
|
||||
do {
|
||||
rc = read(filedes, (unsigned char *)buffer + nread, nbytes - nread);
|
||||
ssize_t rc = read(filedes,
|
||||
(unsigned char *)buffer + nread, nbytes - nread);
|
||||
|
||||
if(got_exit_signal) {
|
||||
logmsg("signalled to die");
|
||||
@ -404,12 +404,11 @@ static ssize_t fullread(int filedes, void *buffer, size_t nbytes)
|
||||
static ssize_t fullwrite(int filedes, const void *buffer, size_t nbytes)
|
||||
{
|
||||
int error;
|
||||
ssize_t wc;
|
||||
ssize_t nwrite = 0;
|
||||
|
||||
do {
|
||||
wc = write(filedes, (const unsigned char *)buffer + nwrite,
|
||||
nbytes - nwrite);
|
||||
ssize_t wc = write(filedes, (const unsigned char *)buffer + nwrite,
|
||||
nbytes - nwrite);
|
||||
|
||||
if(got_exit_signal) {
|
||||
logmsg("signalled to die");
|
||||
@ -699,8 +698,6 @@ static int select_ws(int nfds, fd_set *readfds, fd_set *writefds,
|
||||
WSANETWORKEVENTS wsanetevents;
|
||||
struct select_ws_data *data;
|
||||
HANDLE handle, *handles;
|
||||
curl_socket_t sock;
|
||||
long networkevents;
|
||||
WSAEVENT wsaevent;
|
||||
int error, fds;
|
||||
HANDLE waitevent = NULL;
|
||||
@ -729,6 +726,7 @@ static int select_ws(int nfds, fd_set *readfds, fd_set *writefds,
|
||||
/* allocate internal array for the internal data */
|
||||
data = calloc(nfds, sizeof(struct select_ws_data));
|
||||
if(data == NULL) {
|
||||
CloseHandle(waitevent);
|
||||
errno = ENOMEM;
|
||||
return -1;
|
||||
}
|
||||
@ -736,6 +734,7 @@ static int select_ws(int nfds, fd_set *readfds, fd_set *writefds,
|
||||
/* allocate internal array for the internal event handles */
|
||||
handles = calloc(nfds, sizeof(HANDLE));
|
||||
if(handles == NULL) {
|
||||
CloseHandle(waitevent);
|
||||
free(data);
|
||||
errno = ENOMEM;
|
||||
return -1;
|
||||
@ -743,7 +742,7 @@ static int select_ws(int nfds, fd_set *readfds, fd_set *writefds,
|
||||
|
||||
/* loop over the handles in the input descriptor sets */
|
||||
for(fds = 0; fds < nfds; fds++) {
|
||||
networkevents = 0;
|
||||
long networkevents = 0;
|
||||
handles[nfd] = 0;
|
||||
|
||||
if(FD_ISSET(fds, readfds))
|
||||
@ -812,8 +811,8 @@ static int select_ws(int nfds, fd_set *readfds, fd_set *writefds,
|
||||
|
||||
/* loop over the internal handles returned in the descriptors */
|
||||
for(idx = 0; idx < nfd; idx++) {
|
||||
curl_socket_t sock = data[idx].fd;
|
||||
handle = handles[idx];
|
||||
sock = data[idx].fd;
|
||||
fds = curlx_sktosi(sock);
|
||||
|
||||
/* check if the current internal handle was triggered */
|
||||
@ -920,9 +919,6 @@ static bool juggle(curl_socket_t *sockfdp,
|
||||
curl_socket_t sockfd = CURL_SOCKET_BAD;
|
||||
int maxfd = -99;
|
||||
ssize_t rc;
|
||||
ssize_t nread_socket;
|
||||
ssize_t bytes_written;
|
||||
ssize_t buffer_len;
|
||||
int error = 0;
|
||||
|
||||
/* 'buffer' is this excessively large only to be able to support things like
|
||||
@ -1034,6 +1030,7 @@ static bool juggle(curl_socket_t *sockfdp,
|
||||
|
||||
|
||||
if(FD_ISSET(fileno(stdin), &fds_read)) {
|
||||
ssize_t buffer_len;
|
||||
/* read from stdin, commands/data to be dealt with and possibly passed on
|
||||
to the socket
|
||||
|
||||
@ -1105,7 +1102,7 @@ static bool juggle(curl_socket_t *sockfdp,
|
||||
}
|
||||
else {
|
||||
/* send away on the socket */
|
||||
bytes_written = swrite(sockfd, buffer, buffer_len);
|
||||
ssize_t bytes_written = swrite(sockfd, buffer, buffer_len);
|
||||
if(bytes_written != buffer_len) {
|
||||
logmsg("Not all data was sent. Bytes to send: %zd sent: %zd",
|
||||
buffer_len, bytes_written);
|
||||
@ -1133,13 +1130,11 @@ static bool juggle(curl_socket_t *sockfdp,
|
||||
|
||||
|
||||
if((sockfd != CURL_SOCKET_BAD) && (FD_ISSET(sockfd, &fds_read)) ) {
|
||||
|
||||
curl_socket_t newfd = CURL_SOCKET_BAD; /* newly accepted socket */
|
||||
|
||||
ssize_t nread_socket;
|
||||
if(*mode == PASSIVE_LISTEN) {
|
||||
/* there's no stream set up yet, this is an indication that there's a
|
||||
client connecting. */
|
||||
newfd = accept(sockfd, NULL, NULL);
|
||||
curl_socket_t newfd = accept(sockfd, NULL, NULL);
|
||||
if(CURL_SOCKET_BAD == newfd) {
|
||||
error = SOCKERRNO;
|
||||
logmsg("accept(%d, NULL, NULL) failed with error: (%d) %s",
|
||||
|
@ -555,7 +555,6 @@ static int ProcessRequest(struct httprequest *req)
|
||||
if(sscanf(req->reqbuf, "CONNECT %" MAXDOCNAMELEN_TXT "s HTTP/%d.%d",
|
||||
doc, &prot_major, &prot_minor) == 3) {
|
||||
char *portp = NULL;
|
||||
unsigned long part = 0;
|
||||
|
||||
snprintf(logbuf, sizeof(logbuf),
|
||||
"Received a CONNECT %s HTTP/%d.%d request",
|
||||
@ -569,6 +568,7 @@ static int ProcessRequest(struct httprequest *req)
|
||||
|
||||
if(doc[0] == '[') {
|
||||
char *p = &doc[1];
|
||||
unsigned long part = 0;
|
||||
/* scan through the hexgroups and store the value of the last group
|
||||
in the 'part' variable and use as test case number!! */
|
||||
while(*p && (ISXDIGIT(*p) || (*p == ':') || (*p == '.'))) {
|
||||
@ -954,7 +954,6 @@ static void init_httprequest(struct httprequest *req)
|
||||
is no data waiting, or < 0 if it should be closed */
|
||||
static int get_request(curl_socket_t sock, struct httprequest *req)
|
||||
{
|
||||
int error;
|
||||
int fail = 0;
|
||||
char *reqbuf = req->reqbuf;
|
||||
ssize_t got = 0;
|
||||
@ -1000,7 +999,7 @@ static int get_request(curl_socket_t sock, struct httprequest *req)
|
||||
fail = 1;
|
||||
}
|
||||
else if(got < 0) {
|
||||
error = SOCKERRNO;
|
||||
int error = SOCKERRNO;
|
||||
if(EAGAIN == error || EWOULDBLOCK == error) {
|
||||
/* nothing to read at the moment */
|
||||
return 0;
|
||||
|
@ -30,15 +30,15 @@
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int rc;
|
||||
char *part;
|
||||
size_t partlen, i;
|
||||
size_t partlen;
|
||||
|
||||
if(argc< 3) {
|
||||
printf("./testpart main sub\n");
|
||||
}
|
||||
else {
|
||||
rc = getpart(&part, &partlen, argv[1], argv[2], stdin);
|
||||
int rc = getpart(&part, &partlen, argv[1], argv[2], stdin);
|
||||
size_t i;
|
||||
if(rc)
|
||||
return rc;
|
||||
for(i = 0; i < partlen; i++)
|
||||
|
@ -955,8 +955,6 @@ static int do_tftp(struct testcase *test, struct tftphdr *tp, ssize_t size)
|
||||
int first = 1, ecode;
|
||||
struct formats *pf;
|
||||
char *filename, *mode = NULL;
|
||||
int error;
|
||||
FILE *server;
|
||||
#ifdef USE_WINSOCK
|
||||
DWORD recvtimeout, recvtimeoutbak;
|
||||
#endif
|
||||
@ -964,9 +962,9 @@ static int do_tftp(struct testcase *test, struct tftphdr *tp, ssize_t size)
|
||||
int toggle = 1;
|
||||
|
||||
/* Open request dump file. */
|
||||
server = fopen(REQUEST_DUMP, "ab");
|
||||
FILE *server = fopen(REQUEST_DUMP, "ab");
|
||||
if(!server) {
|
||||
error = errno;
|
||||
int error = errno;
|
||||
logmsg("fopen() failed with error: %d %s", error, strerror(error));
|
||||
logmsg("Error opening file: %s", REQUEST_DUMP);
|
||||
return -1;
|
||||
@ -1138,9 +1136,6 @@ static int validate_access(struct testcase *test,
|
||||
const char *filename, int mode)
|
||||
{
|
||||
char *ptr;
|
||||
long testno, partno;
|
||||
int error;
|
||||
char partbuf[80]="data";
|
||||
|
||||
logmsg("trying to get file: %s mode %x", filename, mode);
|
||||
|
||||
@ -1161,6 +1156,9 @@ static int validate_access(struct testcase *test,
|
||||
ptr = strrchr(filename, '/');
|
||||
|
||||
if(ptr) {
|
||||
char partbuf[80]="data";
|
||||
long partno;
|
||||
long testno;
|
||||
char *file;
|
||||
|
||||
ptr++; /* skip the slash */
|
||||
@ -1194,7 +1192,7 @@ static int validate_access(struct testcase *test,
|
||||
if(file) {
|
||||
FILE *stream = fopen(file, "rb");
|
||||
if(!stream) {
|
||||
error = errno;
|
||||
int error = errno;
|
||||
logmsg("fopen() failed with error: %d %s", error, strerror(error));
|
||||
logmsg("Error opening file: %s", file);
|
||||
logmsg("Couldn't open test file: %s", file);
|
||||
@ -1202,7 +1200,7 @@ static int validate_access(struct testcase *test,
|
||||
}
|
||||
else {
|
||||
size_t count;
|
||||
error = getpart(&test->buffer, &count, "reply", partbuf, stream);
|
||||
int error = getpart(&test->buffer, &count, "reply", partbuf, stream);
|
||||
fclose(stream);
|
||||
if(error) {
|
||||
logmsg("getpart() failed with error: %d", error);
|
||||
|
@ -101,7 +101,6 @@ void logmsg(const char *msg, ...)
|
||||
va_list ap;
|
||||
char buffer[2048 + 1];
|
||||
FILE *logfp;
|
||||
int error;
|
||||
struct timeval tv;
|
||||
time_t sec;
|
||||
struct tm *now;
|
||||
@ -135,7 +134,7 @@ void logmsg(const char *msg, ...)
|
||||
fclose(logfp);
|
||||
}
|
||||
else {
|
||||
error = errno;
|
||||
int error = errno;
|
||||
fprintf(stderr, "fopen() failed with error: %d %s\n",
|
||||
error, strerror(error));
|
||||
fprintf(stderr, "Error opening file: %s\n", serverlogfile);
|
||||
@ -217,7 +216,6 @@ int wait_ms(int timeout_ms)
|
||||
#endif
|
||||
struct timeval initial_tv;
|
||||
int pending_ms;
|
||||
int error;
|
||||
#endif
|
||||
int r = 0;
|
||||
|
||||
@ -235,6 +233,7 @@ int wait_ms(int timeout_ms)
|
||||
pending_ms = timeout_ms;
|
||||
initial_tv = tvnow();
|
||||
do {
|
||||
int error;
|
||||
#if defined(HAVE_POLL_FINE)
|
||||
r = poll(NULL, 0, pending_ms);
|
||||
#else
|
||||
|
@ -264,7 +264,7 @@ UNITTEST_START
|
||||
fail_unless(llist_destination.tail != NULL,
|
||||
"llist_destination tail set to null after moving an element");
|
||||
|
||||
fail_unless(llist_destination.tail == llist_destination.tail,
|
||||
fail_unless(llist_destination.tail == llist_destination.head,
|
||||
"llist_destination tail doesn't equal llist_destination head");
|
||||
}
|
||||
UNITTEST_STOP
|
||||
|
@ -75,7 +75,6 @@ struct timetest {
|
||||
UNITTEST_START
|
||||
{
|
||||
struct curltime now;
|
||||
time_t timeout;
|
||||
unsigned int i;
|
||||
|
||||
const struct timetest run[] = {
|
||||
@ -139,6 +138,7 @@ UNITTEST_START
|
||||
data->progress.t_startop.tv_usec = 0;
|
||||
|
||||
for(i = 0; i < sizeof(run)/sizeof(run[0]); i++) {
|
||||
time_t timeout;
|
||||
NOW(run[i].now_s, run[i].now_us);
|
||||
TIMEOUTS(run[i].timeout_ms, run[i].connecttimeout_ms);
|
||||
timeout = Curl_timeleft(data, &now, run[i].connecting);
|
||||
|
@ -272,7 +272,7 @@ enum system {
|
||||
UNITTEST_START
|
||||
{
|
||||
int testnum = sizeof(tests) / sizeof(struct testcase);
|
||||
int i, rc;
|
||||
int i;
|
||||
enum system machine;
|
||||
|
||||
#ifdef HAVE_FNMATCH
|
||||
@ -290,7 +290,7 @@ UNITTEST_START
|
||||
|
||||
for(i = 0; i < testnum; i++) {
|
||||
int result = tests[i].result;
|
||||
rc = Curl_fnmatch(NULL, tests[i].pattern, tests[i].string);
|
||||
int rc = Curl_fnmatch(NULL, tests[i].pattern, tests[i].string);
|
||||
if(result & (LINUX_DIFFER|MAC_DIFFER)) {
|
||||
if((result & LINUX_DIFFER) && (machine == SYSTEM_LINUX))
|
||||
result >>= LINUX_SHIFT;
|
||||
|
Loading…
x
Reference in New Issue
Block a user