Yet another curl_off_t printf format attempt, we now exclude the %-letter from
FORMAT_OFF_T to allow additional options to get specified, like with '"%5" FORMAT_OFF_T'.
This commit is contained in:
@@ -191,7 +191,7 @@ CURLcode Curl_file(struct connectdata *conn)
|
|||||||
date. */
|
date. */
|
||||||
if(data->set.no_body && data->set.include_header && fstated) {
|
if(data->set.no_body && data->set.include_header && fstated) {
|
||||||
CURLcode result;
|
CURLcode result;
|
||||||
sprintf(buf, "Content-Length: " FORMAT_OFF_T "\r\n", expected_size);
|
sprintf(buf, "Content-Length: %" FORMAT_OFF_T "\r\n", expected_size);
|
||||||
result = Curl_client_write(data, CLIENTWRITE_BOTH, buf, 0);
|
result = Curl_client_write(data, CLIENTWRITE_BOTH, buf, 0);
|
||||||
if(result)
|
if(result)
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
35
lib/ftp.c
35
lib/ftp.c
@@ -732,7 +732,8 @@ CURLcode Curl_ftp_done(struct connectdata *conn)
|
|||||||
if((-1 != data->set.infilesize) &&
|
if((-1 != data->set.infilesize) &&
|
||||||
(data->set.infilesize != *ftp->bytecountp) &&
|
(data->set.infilesize != *ftp->bytecountp) &&
|
||||||
!data->set.crlf) {
|
!data->set.crlf) {
|
||||||
failf(data, "Uploaded unaligned file size (" FORMAT_OFF_T " out of " FORMAT_OFF_T " bytes)",
|
failf(data, "Uploaded unaligned file size (%" FORMAT_OFF_T
|
||||||
|
" out of %" FORMAT_OFF_T " bytes)",
|
||||||
*ftp->bytecountp, data->set.infilesize);
|
*ftp->bytecountp, data->set.infilesize);
|
||||||
conn->bits.close = TRUE; /* close this connection since we don't
|
conn->bits.close = TRUE; /* close this connection since we don't
|
||||||
know what state this error leaves us in */
|
know what state this error leaves us in */
|
||||||
@@ -742,7 +743,7 @@ CURLcode Curl_ftp_done(struct connectdata *conn)
|
|||||||
else {
|
else {
|
||||||
if((-1 != conn->size) && (conn->size != *ftp->bytecountp) &&
|
if((-1 != conn->size) && (conn->size != *ftp->bytecountp) &&
|
||||||
(conn->maxdownload != *ftp->bytecountp)) {
|
(conn->maxdownload != *ftp->bytecountp)) {
|
||||||
failf(data, "Received only partial file: " FORMAT_OFF_T " bytes",
|
failf(data, "Received only partial file: %" FORMAT_OFF_T " bytes",
|
||||||
*ftp->bytecountp);
|
*ftp->bytecountp);
|
||||||
conn->bits.close = TRUE; /* close this connection since we don't
|
conn->bits.close = TRUE; /* close this connection since we don't
|
||||||
know what state this error leaves us in */
|
know what state this error leaves us in */
|
||||||
@@ -1751,8 +1752,8 @@ CURLcode Curl_ftp_nextconnect(struct connectdata *conn)
|
|||||||
|
|
||||||
passed += actuallyread;
|
passed += actuallyread;
|
||||||
if(actuallyread != readthisamountnow) {
|
if(actuallyread != readthisamountnow) {
|
||||||
failf(data, "Could only read " FORMAT_OFF_T " bytes from the input",
|
failf(data, "Could only read %" FORMAT_OFF_T
|
||||||
passed);
|
" bytes from the input", passed);
|
||||||
return CURLE_FTP_COULDNT_USE_REST;
|
return CURLE_FTP_COULDNT_USE_REST;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1849,24 +1850,25 @@ CURLcode Curl_ftp_nextconnect(struct connectdata *conn)
|
|||||||
if((-1 == to) && (from>=0)) {
|
if((-1 == to) && (from>=0)) {
|
||||||
/* X - */
|
/* X - */
|
||||||
conn->resume_from = from;
|
conn->resume_from = from;
|
||||||
infof(data, "FTP RANGE " FORMAT_OFF_T " to end of file\n", from);
|
infof(data, "FTP RANGE %" FORMAT_OFF_T " to end of file\n", from);
|
||||||
}
|
}
|
||||||
else if(from < 0) {
|
else if(from < 0) {
|
||||||
/* -Y */
|
/* -Y */
|
||||||
totalsize = -from;
|
totalsize = -from;
|
||||||
conn->maxdownload = -from;
|
conn->maxdownload = -from;
|
||||||
conn->resume_from = from;
|
conn->resume_from = from;
|
||||||
infof(data, "FTP RANGE the last " FORMAT_OFF_T " bytes\n", totalsize);
|
infof(data, "FTP RANGE the last %" FORMAT_OFF_T " bytes\n", totalsize);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* X-Y */
|
/* X-Y */
|
||||||
totalsize = to-from;
|
totalsize = to-from;
|
||||||
conn->maxdownload = totalsize+1; /* include the last mentioned byte */
|
conn->maxdownload = totalsize+1; /* include the last mentioned byte */
|
||||||
conn->resume_from = from;
|
conn->resume_from = from;
|
||||||
infof(data, "FTP RANGE from " FORMAT_OFF_T " getting " FORMAT_OFF_T " bytes\n", from,
|
infof(data, "FTP RANGE from %" FORMAT_OFF_T
|
||||||
conn->maxdownload);
|
" getting %" FORMAT_OFF_T " bytes\n", from, conn->maxdownload);
|
||||||
}
|
}
|
||||||
infof(data, "range-download from " FORMAT_OFF_T " to " FORMAT_OFF_T ", totally " FORMAT_OFF_T " bytes\n",
|
infof(data, "range-download from %" FORMAT_OFF_T
|
||||||
|
" to %" FORMAT_OFF_T ", totally %" FORMAT_OFF_T " bytes\n",
|
||||||
from, to, conn->maxdownload);
|
from, to, conn->maxdownload);
|
||||||
ftp->dont_check = TRUE; /* dont check for successful transfer */
|
ftp->dont_check = TRUE; /* dont check for successful transfer */
|
||||||
}
|
}
|
||||||
@@ -1941,7 +1943,8 @@ CURLcode Curl_ftp_nextconnect(struct connectdata *conn)
|
|||||||
if(conn->resume_from< 0) {
|
if(conn->resume_from< 0) {
|
||||||
/* We're supposed to download the last abs(from) bytes */
|
/* We're supposed to download the last abs(from) bytes */
|
||||||
if(foundsize < -conn->resume_from) {
|
if(foundsize < -conn->resume_from) {
|
||||||
failf(data, "Offset (" FORMAT_OFF_T ") was beyond file size (" FORMAT_OFF_T ")",
|
failf(data, "Offset (%" FORMAT_OFF_T
|
||||||
|
") was beyond file size (%" FORMAT_OFF_T ")",
|
||||||
conn->resume_from, foundsize);
|
conn->resume_from, foundsize);
|
||||||
return CURLE_FTP_BAD_DOWNLOAD_RESUME;
|
return CURLE_FTP_BAD_DOWNLOAD_RESUME;
|
||||||
}
|
}
|
||||||
@@ -1952,7 +1955,8 @@ CURLcode Curl_ftp_nextconnect(struct connectdata *conn)
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(foundsize < conn->resume_from) {
|
if(foundsize < conn->resume_from) {
|
||||||
failf(data, "Offset (" FORMAT_OFF_T ") was beyond file size (" FORMAT_OFF_T ")",
|
failf(data, "Offset (%" FORMAT_OFF_T
|
||||||
|
") was beyond file size (%" FORMAT_OFF_T ")",
|
||||||
conn->resume_from, foundsize);
|
conn->resume_from, foundsize);
|
||||||
return CURLE_FTP_BAD_DOWNLOAD_RESUME;
|
return CURLE_FTP_BAD_DOWNLOAD_RESUME;
|
||||||
}
|
}
|
||||||
@@ -1973,10 +1977,11 @@ CURLcode Curl_ftp_nextconnect(struct connectdata *conn)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Set resume file transfer offset */
|
/* Set resume file transfer offset */
|
||||||
infof(data, "Instructs server to resume from offset " FORMAT_OFF_T "\n",
|
infof(data, "Instructs server to resume from offset %" FORMAT_OFF_T
|
||||||
|
"\n",
|
||||||
conn->resume_from);
|
conn->resume_from);
|
||||||
|
|
||||||
FTPSENDF(conn, "REST " FORMAT_OFF_T "", conn->resume_from);
|
FTPSENDF(conn, "REST %" FORMAT_OFF_T, conn->resume_from);
|
||||||
|
|
||||||
result = Curl_GetFTPResponse(&nread, conn, &ftpcode);
|
result = Curl_GetFTPResponse(&nread, conn, &ftpcode);
|
||||||
if(result)
|
if(result)
|
||||||
@@ -2082,7 +2087,7 @@ CURLcode Curl_ftp_nextconnect(struct connectdata *conn)
|
|||||||
if(size > conn->maxdownload && conn->maxdownload > 0)
|
if(size > conn->maxdownload && conn->maxdownload > 0)
|
||||||
size = conn->size = conn->maxdownload;
|
size = conn->size = conn->maxdownload;
|
||||||
|
|
||||||
infof(data, "Getting file with size: " FORMAT_OFF_T "\n", size);
|
infof(data, "Getting file with size: %" FORMAT_OFF_T "\n", size);
|
||||||
|
|
||||||
/* FTP download: */
|
/* FTP download: */
|
||||||
result=Curl_Transfer(conn, SECONDARYSOCKET, size, FALSE,
|
result=Curl_Transfer(conn, SECONDARYSOCKET, size, FALSE,
|
||||||
@@ -2214,7 +2219,7 @@ CURLcode ftp_perform(struct connectdata *conn,
|
|||||||
result = ftp_getsize(conn, ftp->file, &filesize);
|
result = ftp_getsize(conn, ftp->file, &filesize);
|
||||||
|
|
||||||
if(CURLE_OK == result) {
|
if(CURLE_OK == result) {
|
||||||
sprintf(buf, "Content-Length: " FORMAT_OFF_T "\r\n", filesize);
|
sprintf(buf, "Content-Length: %" FORMAT_OFF_T "\r\n", filesize);
|
||||||
result = Curl_client_write(data, CLIENTWRITE_BOTH, buf, 0);
|
result = Curl_client_write(data, CLIENTWRITE_BOTH, buf, 0);
|
||||||
if(result)
|
if(result)
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
10
lib/http.c
10
lib/http.c
@@ -1272,7 +1272,7 @@ CURLcode Curl_http(struct connectdata *conn)
|
|||||||
|
|
||||||
passed += actuallyread;
|
passed += actuallyread;
|
||||||
if(actuallyread != readthisamountnow) {
|
if(actuallyread != readthisamountnow) {
|
||||||
failf(data, "Could only read " FORMAT_OFF_T
|
failf(data, "Could only read %" FORMAT_OFF_T
|
||||||
" bytes from the input",
|
" bytes from the input",
|
||||||
passed);
|
passed);
|
||||||
return CURLE_READ_ERROR;
|
return CURLE_READ_ERROR;
|
||||||
@@ -1312,8 +1312,8 @@ CURLcode Curl_http(struct connectdata *conn)
|
|||||||
curl_off_t total_expected_size=
|
curl_off_t total_expected_size=
|
||||||
conn->resume_from + data->set.infilesize;
|
conn->resume_from + data->set.infilesize;
|
||||||
conn->allocptr.rangeline =
|
conn->allocptr.rangeline =
|
||||||
aprintf("Content-Range: bytes %s" FORMAT_OFF_T "/"
|
aprintf("Content-Range: bytes %s%" FORMAT_OFF_T
|
||||||
FORMAT_OFF_T "\r\n",
|
"/%" FORMAT_OFF_T "\r\n",
|
||||||
conn->range, total_expected_size-1,
|
conn->range, total_expected_size-1,
|
||||||
total_expected_size);
|
total_expected_size);
|
||||||
}
|
}
|
||||||
@@ -1321,7 +1321,7 @@ CURLcode Curl_http(struct connectdata *conn)
|
|||||||
/* Range was selected and then we just pass the incoming range and
|
/* Range was selected and then we just pass the incoming range and
|
||||||
append total size */
|
append total size */
|
||||||
conn->allocptr.rangeline =
|
conn->allocptr.rangeline =
|
||||||
aprintf("Content-Range: bytes %s/" FORMAT_OFF_T "\r\n",
|
aprintf("Content-Range: bytes %s/%" FORMAT_OFF_T "\r\n",
|
||||||
conn->range, data->set.infilesize);
|
conn->range, data->set.infilesize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1551,7 +1551,7 @@ CURLcode Curl_http(struct connectdata *conn)
|
|||||||
if((data->set.infilesize>0) && !conn->bits.upload_chunky)
|
if((data->set.infilesize>0) && !conn->bits.upload_chunky)
|
||||||
/* only add Content-Length if not uploading chunked */
|
/* only add Content-Length if not uploading chunked */
|
||||||
add_bufferf(req_buffer,
|
add_bufferf(req_buffer,
|
||||||
"Content-Length: " FORMAT_OFF_T "\r\n", /* size */
|
"Content-Length: %" FORMAT_OFF_T "\r\n", /* size */
|
||||||
data->set.infilesize );
|
data->set.infilesize );
|
||||||
|
|
||||||
add_bufferf(req_buffer, "\r\n");
|
add_bufferf(req_buffer, "\r\n");
|
||||||
|
|||||||
@@ -60,11 +60,11 @@ static char *max5data(double bytes, char *max5)
|
|||||||
#define ONE_GIGABYTE (1024*1024*1024)
|
#define ONE_GIGABYTE (1024*1024*1024)
|
||||||
|
|
||||||
if(bytes < 100000) {
|
if(bytes < 100000) {
|
||||||
sprintf(max5, "%5Od", (curl_off_t)bytes);
|
sprintf(max5, "%5" FORMAT_OFF_T, (curl_off_t)bytes);
|
||||||
return max5;
|
return max5;
|
||||||
}
|
}
|
||||||
if(bytes < (10000*ONE_KILOBYTE)) {
|
if(bytes < (10000*ONE_KILOBYTE)) {
|
||||||
sprintf(max5, "%4Odk", (curl_off_t)bytes/ONE_KILOBYTE);
|
sprintf(max5, "%4" FORMAT_OFF_T "k", (curl_off_t)bytes/ONE_KILOBYTE);
|
||||||
return max5;
|
return max5;
|
||||||
}
|
}
|
||||||
if(bytes < (100*ONE_MEGABYTE)) {
|
if(bytes < (100*ONE_MEGABYTE)) {
|
||||||
@@ -74,13 +74,13 @@ static char *max5data(double bytes, char *max5)
|
|||||||
}
|
}
|
||||||
#if SIZEOF_CURL_OFF_T > 4
|
#if SIZEOF_CURL_OFF_T > 4
|
||||||
if((curl_off_t)bytes < ((curl_off_t)10000*ONE_MEGABYTE)) {
|
if((curl_off_t)bytes < ((curl_off_t)10000*ONE_MEGABYTE)) {
|
||||||
sprintf(max5, "%4OdM", (curl_off_t)bytes/ONE_MEGABYTE);
|
sprintf(max5, "%4" FORMAT_OFF_T "M", (curl_off_t)bytes/ONE_MEGABYTE);
|
||||||
return max5;
|
return max5;
|
||||||
}
|
}
|
||||||
/* 10000 MB - 8589934587 GB !! */
|
/* 10000 MB - 8589934587 GB !! */
|
||||||
sprintf(max5, "%4.1fG", bytes/ONE_GIGABYTE);
|
sprintf(max5, "%4.1fG", bytes/ONE_GIGABYTE);
|
||||||
#else
|
#else
|
||||||
sprintf(max5, "%4OdM", (curl_off_t)bytes/ONE_MEGABYTE);
|
sprintf(max5, "%4" FORMAT_OFF_T "M", (curl_off_t)bytes/ONE_MEGABYTE);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return max5;
|
return max5;
|
||||||
@@ -240,7 +240,7 @@ int Curl_pgrsUpdate(struct connectdata *conn)
|
|||||||
if (!data->progress.callback) {
|
if (!data->progress.callback) {
|
||||||
if(conn->resume_from)
|
if(conn->resume_from)
|
||||||
fprintf(data->set.err,
|
fprintf(data->set.err,
|
||||||
"** Resuming transfer from byte position " FORMAT_OFF_T
|
"** Resuming transfer from byte position %" FORMAT_OFF_T
|
||||||
"\n",
|
"\n",
|
||||||
conn->resume_from);
|
conn->resume_from);
|
||||||
fprintf(data->set.err,
|
fprintf(data->set.err,
|
||||||
|
|||||||
@@ -82,12 +82,11 @@ typedef unsigned char bool;
|
|||||||
|
|
||||||
/* We set up our internal prefered (CURL_)FORMAT_OFF_T here */
|
/* We set up our internal prefered (CURL_)FORMAT_OFF_T here */
|
||||||
#if defined(SIZEOF_CURL_OFF_T) && (SIZEOF_CURL_OFF_T > 4)
|
#if defined(SIZEOF_CURL_OFF_T) && (SIZEOF_CURL_OFF_T > 4)
|
||||||
#define FORMAT_OFF_T "%lld"
|
#define FORMAT_OFF_T "lld"
|
||||||
#else
|
#else
|
||||||
#define FORMAT_OFF_T "%ld"
|
#define FORMAT_OFF_T "ld"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef NEED_REENTRANT
|
#ifdef NEED_REENTRANT
|
||||||
/* Solaris machines needs _REENTRANT set for a few function prototypes and
|
/* Solaris machines needs _REENTRANT set for a few function prototypes and
|
||||||
things to appear in the #include files. We need to #define it before all
|
things to appear in the #include files. We need to #define it before all
|
||||||
|
|||||||
@@ -1240,8 +1240,8 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
|||||||
|
|
||||||
if (data->set.timeout &&
|
if (data->set.timeout &&
|
||||||
((Curl_tvdiff(k->now, k->start)/1000) >= data->set.timeout)) {
|
((Curl_tvdiff(k->now, k->start)/1000) >= data->set.timeout)) {
|
||||||
failf (data, "Operation timed out with " FORMAT_OFF_T " out of "
|
failf (data, "Operation timed out with %" FORMAT_OFF_T
|
||||||
FORMAT_OFF_T " bytes received",
|
" out of %" FORMAT_OFF_T " bytes received",
|
||||||
k->bytecount, conn->size);
|
k->bytecount, conn->size);
|
||||||
return CURLE_OPERATION_TIMEOUTED;
|
return CURLE_OPERATION_TIMEOUTED;
|
||||||
}
|
}
|
||||||
@@ -1255,7 +1255,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
|||||||
if(!(data->set.no_body) && (conn->size != -1) &&
|
if(!(data->set.no_body) && (conn->size != -1) &&
|
||||||
(k->bytecount != conn->size) &&
|
(k->bytecount != conn->size) &&
|
||||||
!conn->newurl) {
|
!conn->newurl) {
|
||||||
failf(data, "transfer closed with " FORMAT_OFF_T
|
failf(data, "transfer closed with %" FORMAT_OFF_T
|
||||||
" bytes remaining to read",
|
" bytes remaining to read",
|
||||||
conn->size - k->bytecount);
|
conn->size - k->bytecount);
|
||||||
return CURLE_PARTIAL_FILE;
|
return CURLE_PARTIAL_FILE;
|
||||||
|
|||||||
@@ -2411,7 +2411,7 @@ static CURLcode CreateConnection(struct SessionHandle *data,
|
|||||||
if(conn->resume_from) {
|
if(conn->resume_from) {
|
||||||
if(!conn->bits.use_range) {
|
if(!conn->bits.use_range) {
|
||||||
/* if it already was in use, we just skip this */
|
/* if it already was in use, we just skip this */
|
||||||
snprintf(resumerange, sizeof(resumerange), FORMAT_OFF_T "-",
|
snprintf(resumerange, sizeof(resumerange), "%" FORMAT_OFF_T "-",
|
||||||
conn->resume_from);
|
conn->resume_from);
|
||||||
conn->range=strdup(resumerange); /* tell ourselves to fetch this range */
|
conn->range=strdup(resumerange); /* tell ourselves to fetch this range */
|
||||||
conn->bits.rangestringalloc = TRUE; /* mark as allocated */
|
conn->bits.rangestringalloc = TRUE; /* mark as allocated */
|
||||||
@@ -2941,7 +2941,7 @@ static CURLcode CreateConnection(struct SessionHandle *data,
|
|||||||
*/
|
*/
|
||||||
conn->resume_from = data->set.set_resume_from;
|
conn->resume_from = data->set.set_resume_from;
|
||||||
if (conn->resume_from) {
|
if (conn->resume_from) {
|
||||||
snprintf(resumerange, sizeof(resumerange), FORMAT_OFF_T "-",
|
snprintf(resumerange, sizeof(resumerange), "%" FORMAT_OFF_T "-",
|
||||||
conn->resume_from);
|
conn->resume_from);
|
||||||
if (conn->bits.rangestringalloc == TRUE)
|
if (conn->bits.rangestringalloc == TRUE)
|
||||||
free(conn->range);
|
free(conn->range);
|
||||||
|
|||||||
Reference in New Issue
Block a user