mirror of
https://github.com/moparisthebest/curl
synced 2024-12-21 23:58:49 -05:00
Clear up int/long/size_t/ssize_t usage a bit
This commit is contained in:
parent
33eaf2e18b
commit
d571064b65
@ -115,8 +115,8 @@ free_cookiemess(struct Cookie *co)
|
||||
|
||||
static bool tailmatch(const char *little, const char *bigone)
|
||||
{
|
||||
unsigned int littlelen = strlen(little);
|
||||
unsigned int biglen = strlen(bigone);
|
||||
size_t littlelen = strlen(little);
|
||||
size_t biglen = strlen(bigone);
|
||||
|
||||
if(littlelen > biglen)
|
||||
return FALSE;
|
||||
@ -192,7 +192,7 @@ Curl_cookie_add(struct SessionHandle *data,
|
||||
char *whatptr;
|
||||
|
||||
/* Strip off trailing whitespace from the 'what' */
|
||||
int len=strlen(what);
|
||||
size_t len=strlen(what);
|
||||
while(len && isspace((int)what[len-1])) {
|
||||
what[len-1]=0;
|
||||
len--;
|
||||
@ -360,7 +360,7 @@ Curl_cookie_add(struct SessionHandle *data,
|
||||
/* no path was given in the header line, set the default now */
|
||||
char *endslash = strrchr(path, '/');
|
||||
if(endslash) {
|
||||
int pathlen = endslash-path+1; /* include the ending slash */
|
||||
size_t pathlen = endslash-path+1; /* include the ending slash */
|
||||
co->path=malloc(pathlen+1); /* one extra for the zero byte */
|
||||
if(co->path) {
|
||||
memcpy(co->path, path, pathlen);
|
||||
|
@ -556,15 +556,16 @@ static const char * ContentTypeForFilename (const char *filename,
|
||||
* Returns 0 on success and 1 if the malloc failed.
|
||||
*
|
||||
***************************************************************************/
|
||||
static int AllocAndCopy (char **buffer, int buffer_length)
|
||||
static int AllocAndCopy(char **buffer, size_t buffer_length)
|
||||
{
|
||||
const char *src = *buffer;
|
||||
int length, add = 0;
|
||||
size_t length;
|
||||
bool add = FALSE;
|
||||
if (buffer_length)
|
||||
length = buffer_length;
|
||||
else {
|
||||
length = strlen(*buffer);
|
||||
add = 1;
|
||||
add = TRUE;
|
||||
}
|
||||
*buffer = (char*)malloc(length+add);
|
||||
if (!*buffer)
|
||||
@ -1003,7 +1004,7 @@ CURLFORMcode curl_formadd(struct curl_httppost **httppost,
|
||||
|
||||
static int AddFormData(struct FormData **formp,
|
||||
const void *line,
|
||||
long length)
|
||||
size_t length)
|
||||
{
|
||||
struct FormData *newform = (struct FormData *)
|
||||
malloc(sizeof(struct FormData));
|
||||
@ -1047,7 +1048,7 @@ char *Curl_FormBoundary(void)
|
||||
char *retstring;
|
||||
static int randomizer=0; /* this is just so that two boundaries within
|
||||
the same form won't be identical */
|
||||
int i;
|
||||
size_t i;
|
||||
|
||||
static char table16[]="abcdef0123456789";
|
||||
|
||||
@ -1114,7 +1115,7 @@ void curl_formfree(struct curl_httppost *form)
|
||||
|
||||
CURLcode Curl_getFormData(struct FormData **finalform,
|
||||
struct curl_httppost *post,
|
||||
int *sizep)
|
||||
size_t *sizep)
|
||||
{
|
||||
struct FormData *form = NULL;
|
||||
struct FormData *firstform;
|
||||
@ -1232,7 +1233,7 @@ CURLcode Curl_getFormData(struct FormData **finalform,
|
||||
/* we should include the contents from the specified file */
|
||||
FILE *fileread;
|
||||
char buffer[1024];
|
||||
int nread;
|
||||
size_t nread;
|
||||
|
||||
fileread = strequal("-", file->contents)?stdin:
|
||||
/* binary read for win32 crap */
|
||||
@ -1306,14 +1307,14 @@ int Curl_FormInit(struct Form *form, struct FormData *formdata )
|
||||
}
|
||||
|
||||
/* fread() emulation */
|
||||
int Curl_FormReader(char *buffer,
|
||||
size_t Curl_FormReader(char *buffer,
|
||||
size_t size,
|
||||
size_t nitems,
|
||||
FILE *mydata)
|
||||
{
|
||||
struct Form *form;
|
||||
int wantedsize;
|
||||
int gotsize = 0;
|
||||
size_t wantedsize;
|
||||
size_t gotsize = 0;
|
||||
|
||||
form=(struct Form *)mydata;
|
||||
|
||||
@ -1352,21 +1353,21 @@ int Curl_FormReader(char *buffer,
|
||||
}
|
||||
|
||||
/* possible (old) fread() emulation that copies at most one line */
|
||||
int Curl_FormReadOneLine(char *buffer,
|
||||
size_t Curl_FormReadOneLine(char *buffer,
|
||||
size_t size,
|
||||
size_t nitems,
|
||||
FILE *mydata)
|
||||
{
|
||||
struct Form *form;
|
||||
int wantedsize;
|
||||
int gotsize;
|
||||
size_t wantedsize;
|
||||
size_t gotsize;
|
||||
|
||||
form=(struct Form *)mydata;
|
||||
|
||||
wantedsize = size * nitems;
|
||||
|
||||
if(!form->data)
|
||||
return -1; /* nothing, error, empty */
|
||||
return 0; /* nothing, error, empty */
|
||||
|
||||
do {
|
||||
|
||||
@ -1443,7 +1444,7 @@ int main()
|
||||
int value6length = strlen(value5);
|
||||
int errors = 0;
|
||||
int size;
|
||||
int nread;
|
||||
size_t nread;
|
||||
char buffer[4096];
|
||||
struct curl_httppost *httppost=NULL;
|
||||
struct curl_httppost *last_post=NULL;
|
||||
|
@ -27,28 +27,25 @@
|
||||
struct FormData {
|
||||
struct FormData *next;
|
||||
char *line;
|
||||
long length;
|
||||
size_t length;
|
||||
};
|
||||
|
||||
struct Form {
|
||||
struct FormData *data; /* current form line to send */
|
||||
int sent; /* number of bytes of the current line that has already
|
||||
unsigned int sent; /* number of bytes of the current line that has already
|
||||
been sent in a previous invoke */
|
||||
};
|
||||
|
||||
/* used by FormAdd for temporary storage */
|
||||
typedef struct FormInfo {
|
||||
char *name;
|
||||
long namelength;
|
||||
size_t namelength;
|
||||
char *value;
|
||||
long contentslength;
|
||||
size_t contentslength;
|
||||
char *contenttype;
|
||||
long flags;
|
||||
|
||||
/* CMC: Added support for buffer uploads */
|
||||
char *buffer; /* pointer to existing buffer used for file upload */
|
||||
long bufferlength;
|
||||
|
||||
size_t bufferlength;
|
||||
char *showfilename; /* The file name to show. If not set, the actual
|
||||
file name will be used */
|
||||
struct curl_slist* contentheader;
|
||||
@ -60,16 +57,16 @@ int Curl_FormInit(struct Form *form, struct FormData *formdata );
|
||||
CURLcode
|
||||
Curl_getFormData(struct FormData **,
|
||||
struct curl_httppost *post,
|
||||
int *size);
|
||||
size_t *size);
|
||||
|
||||
/* fread() emulation */
|
||||
int Curl_FormReader(char *buffer,
|
||||
size_t Curl_FormReader(char *buffer,
|
||||
size_t size,
|
||||
size_t nitems,
|
||||
FILE *mydata);
|
||||
|
||||
/* possible (old) fread() emulation that copies at most one line */
|
||||
int Curl_FormReadOneLine(char *buffer,
|
||||
size_t Curl_FormReadOneLine(char *buffer,
|
||||
size_t size,
|
||||
size_t nitems,
|
||||
FILE *mydata);
|
||||
|
@ -134,8 +134,8 @@ static CURLcode AllowServerConnect(struct connectdata *conn)
|
||||
struct SessionHandle *data = conn->data;
|
||||
int sock = conn->sock[SECONDARYSOCKET];
|
||||
struct timeval now = Curl_tvnow();
|
||||
int timespent = Curl_tvdiff(Curl_tvnow(), now)/1000;
|
||||
int timeout = data->set.connecttimeout?data->set.connecttimeout:
|
||||
long timespent = Curl_tvdiff(Curl_tvnow(), now)/1000;
|
||||
long timeout = data->set.connecttimeout?data->set.connecttimeout:
|
||||
(data->set.timeout?data->set.timeout: 0);
|
||||
|
||||
FD_ZERO(&rdset);
|
||||
@ -1347,7 +1347,7 @@ CURLcode ftp_use_port(struct connectdata *conn)
|
||||
rc = Curl_wait_for_resolv(conn, &h);
|
||||
}
|
||||
else {
|
||||
int len = strlen(data->set.ftpport);
|
||||
size_t len = strlen(data->set.ftpport);
|
||||
if(len>1) {
|
||||
rc = Curl_resolv(conn, data->set.ftpport, 0, &h);
|
||||
if(rc == 1)
|
||||
|
26
lib/http.c
26
lib/http.c
@ -440,14 +440,14 @@ CURLcode Curl_http_auth(struct connectdata *conn,
|
||||
|
||||
|
||||
/* fread() emulation to provide POST and/or request data */
|
||||
static int readmoredata(char *buffer,
|
||||
static size_t readmoredata(char *buffer,
|
||||
size_t size,
|
||||
size_t nitems,
|
||||
void *userp)
|
||||
{
|
||||
struct connectdata *conn = (struct connectdata *)userp;
|
||||
struct HTTP *http = conn->proto.http;
|
||||
int fullsize = size * nitems;
|
||||
size_t fullsize = size * nitems;
|
||||
|
||||
if(0 == http->postsize)
|
||||
/* nothing to return */
|
||||
@ -528,9 +528,9 @@ CURLcode add_buffer_send(send_buffer *in,
|
||||
ssize_t amount;
|
||||
CURLcode res;
|
||||
char *ptr;
|
||||
int size;
|
||||
size_t size;
|
||||
struct HTTP *http = conn->proto.http;
|
||||
int sendsize;
|
||||
size_t sendsize;
|
||||
int sockfd = conn->sock[FIRSTSOCKET];
|
||||
|
||||
/* The looping below is required since we use non-blocking sockets, but due
|
||||
@ -570,7 +570,7 @@ CURLcode add_buffer_send(send_buffer *in,
|
||||
|
||||
*bytes_written += amount;
|
||||
|
||||
if(amount != size) {
|
||||
if((size_t)amount != size) {
|
||||
/* The whole request could not be sent in one system call. We must queue
|
||||
it up and send it later when we get the chance. We must not loop here
|
||||
and wait until it might work again. */
|
||||
@ -639,7 +639,7 @@ static
|
||||
CURLcode add_buffer(send_buffer *in, const void *inptr, size_t size)
|
||||
{
|
||||
char *new_rb;
|
||||
int new_size;
|
||||
size_t new_size;
|
||||
|
||||
if(!in->buffer ||
|
||||
((in->size_used + size) > (in->size_max - 1))) {
|
||||
@ -744,7 +744,7 @@ CURLcode Curl_ConnectHTTPProxyTunnel(struct connectdata *conn,
|
||||
bool keepon=TRUE;
|
||||
ssize_t gotbytes;
|
||||
char *ptr;
|
||||
int timeout = 3600; /* default timeout in seconds */
|
||||
long timeout = 3600; /* default timeout in seconds */
|
||||
struct timeval interval;
|
||||
fd_set rkeepfd;
|
||||
fd_set readfd;
|
||||
@ -1164,7 +1164,7 @@ CURLcode Curl_http(struct connectdata *conn)
|
||||
ptr++;
|
||||
|
||||
if(ptr != start) {
|
||||
int len=ptr-start;
|
||||
size_t len=ptr-start;
|
||||
conn->allocptr.cookiehost = malloc(len+1);
|
||||
if(!conn->allocptr.cookiehost)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
@ -1260,8 +1260,8 @@ CURLcode Curl_http(struct connectdata *conn)
|
||||
input. If we knew it was a proper file we could've just
|
||||
fseek()ed but we only have a stream here */
|
||||
do {
|
||||
curl_off_t readthisamountnow = (conn->resume_from - passed);
|
||||
curl_off_t actuallyread;
|
||||
size_t readthisamountnow = (conn->resume_from - passed);
|
||||
size_t actuallyread;
|
||||
|
||||
if(readthisamountnow > BUFSIZE)
|
||||
readthisamountnow = BUFSIZE;
|
||||
@ -1509,12 +1509,12 @@ CURLcode Curl_http(struct connectdata *conn)
|
||||
work, but we support it anyway.
|
||||
*/
|
||||
char contentType[256];
|
||||
int linelength=0;
|
||||
linelength = Curl_FormReadOneLine (contentType,
|
||||
size_t linelength=0;
|
||||
linelength = Curl_FormReadOneLine(contentType,
|
||||
sizeof(contentType),
|
||||
1,
|
||||
(FILE *)&http->form);
|
||||
if(linelength == -1) {
|
||||
if(!linelength) {
|
||||
failf(data, "Could not get Content-Type header line!");
|
||||
return CURLE_HTTP_POST_ERROR;
|
||||
}
|
||||
|
@ -152,7 +152,7 @@ void Curl_failf(struct SessionHandle *data, const char *fmt, ...)
|
||||
data->state.errorbuf = TRUE; /* wrote error string */
|
||||
|
||||
if(data->set.verbose) {
|
||||
int len = strlen(data->set.errorbuffer);
|
||||
size_t len = strlen(data->set.errorbuffer);
|
||||
bool doneit=FALSE;
|
||||
if(len < CURL_ERROR_SIZE - 1) {
|
||||
doneit = TRUE;
|
||||
@ -174,7 +174,7 @@ CURLcode Curl_sendf(int sockfd, struct connectdata *conn,
|
||||
{
|
||||
struct SessionHandle *data = conn->data;
|
||||
ssize_t bytes_written;
|
||||
ssize_t write_len;
|
||||
size_t write_len;
|
||||
CURLcode res;
|
||||
char *s;
|
||||
char *sptr;
|
||||
@ -199,7 +199,7 @@ CURLcode Curl_sendf(int sockfd, struct connectdata *conn,
|
||||
if(data->set.verbose)
|
||||
Curl_debug(data, CURLINFO_DATA_OUT, sptr, bytes_written);
|
||||
|
||||
if(bytes_written != write_len) {
|
||||
if((size_t)bytes_written != write_len) {
|
||||
/* if not all was written at once, we must advance the pointer, decrease
|
||||
the size left and try again! */
|
||||
write_len -= bytes_written;
|
||||
@ -284,7 +284,7 @@ CURLcode Curl_write(struct connectdata *conn,
|
||||
else
|
||||
#endif /* HAVE_KRB4 */
|
||||
{
|
||||
bytes_written = swrite(sockfd, mem, len);
|
||||
bytes_written = (ssize_t)swrite(sockfd, mem, len);
|
||||
}
|
||||
if(-1 == bytes_written) {
|
||||
int err = Curl_ourerrno();
|
||||
|
@ -205,7 +205,7 @@ struct negotiatedata {
|
||||
***************************************************************************/
|
||||
struct HTTP {
|
||||
struct FormData *sendit;
|
||||
int postsize;
|
||||
size_t postsize;
|
||||
char *postdata;
|
||||
|
||||
const char *p_pragma; /* Pragma: string */
|
||||
|
Loading…
Reference in New Issue
Block a user