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;
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--;
/* 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);
* 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)
static int AddFormData(struct FormData **formp,
const void *line,
- long length)
+ size_t length)
{
struct FormData *newform = (struct FormData *)
malloc(sizeof(struct FormData));
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";
CURLcode Curl_getFormData(struct FormData **finalform,
struct curl_httppost *post,
- int *sizep)
+ size_t *sizep)
{
struct FormData *form = NULL;
struct FormData *firstform;
/* 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 */
}
/* fread() emulation */
-int Curl_FormReader(char *buffer,
- size_t size,
- size_t nitems,
- FILE *mydata)
+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;
}
/* possible (old) fread() emulation that copies at most one line */
-int Curl_FormReadOneLine(char *buffer,
- size_t size,
- size_t nitems,
- FILE *mydata)
+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 {
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;
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
- been sent in a previous invoke */
+ 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;
CURLcode
Curl_getFormData(struct FormData **,
struct curl_httppost *post,
- int *size);
+ size_t *size);
/* fread() emulation */
-int Curl_FormReader(char *buffer,
- size_t size,
- size_t nitems,
- FILE *mydata);
+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 size,
- size_t nitems,
- FILE *mydata);
+size_t Curl_FormReadOneLine(char *buffer,
+ size_t size,
+ size_t nitems,
+ FILE *mydata);
char *Curl_FormBoundary(void);
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);
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)
/* fread() emulation to provide POST and/or request data */
-static int readmoredata(char *buffer,
- size_t size,
- size_t nitems,
- void *userp)
+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 */
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
*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. */
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))) {
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;
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;
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;
work, but we support it anyway.
*/
char contentType[256];
- int linelength=0;
- linelength = Curl_FormReadOneLine (contentType,
- sizeof(contentType),
- 1,
- (FILE *)&http->form);
- if(linelength == -1) {
+ size_t linelength=0;
+ linelength = Curl_FormReadOneLine(contentType,
+ sizeof(contentType),
+ 1,
+ (FILE *)&http->form);
+ if(!linelength) {
failf(data, "Could not get Content-Type header line!");
return CURLE_HTTP_POST_ERROR;
}
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;
{
struct SessionHandle *data = conn->data;
ssize_t bytes_written;
- ssize_t write_len;
+ size_t write_len;
CURLcode res;
char *s;
char *sptr;
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;
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();
***************************************************************************/
struct HTTP {
struct FormData *sendit;
- int postsize;
+ size_t postsize;
char *postdata;
const char *p_pragma; /* Pragma: string */