mirror of
https://github.com/moparisthebest/curl
synced 2024-12-21 23:58:49 -05:00
mprintf: Replaced internal usage of FORMAT_OFF_T and FORMAT_OFF_TU
Following commit 0aafd77fa4
, replaced the internal usage of
FORMAT_OFF_T and FORMAT_OFF_TU with the external versions that we
expect API programmers to use.
This negates the need for separate definitions which were subtly
different under different platforms/compilers.
This commit is contained in:
parent
6e4d4a9b51
commit
60bd22620a
@ -815,7 +815,7 @@ Curl_cookie_add(struct SessionHandle *data,
|
||||
if(c->running)
|
||||
/* Only show this when NOT reading the cookies from a file */
|
||||
infof(data, "%s cookie %s=\"%s\" for domain %s, path %s, "
|
||||
"expire %" FORMAT_OFF_T "\n",
|
||||
"expire %" CURL_FORMAT_CURL_OFF_T "\n",
|
||||
replace_old?"Replaced":"Added", co->name, co->value,
|
||||
co->domain, co->path, co->expires);
|
||||
|
||||
@ -1172,7 +1172,7 @@ static char *get_netscape_format(const struct Cookie *co)
|
||||
"%s\t" /* tailmatch */
|
||||
"%s\t" /* path */
|
||||
"%s\t" /* secure */
|
||||
"%" FORMAT_OFF_T "\t" /* expires */
|
||||
"%" CURL_FORMAT_CURL_OFF_T "\t" /* expires */
|
||||
"%s\t" /* name */
|
||||
"%s", /* value */
|
||||
co->httponly?"#HttpOnly_":"",
|
||||
|
@ -139,29 +139,6 @@
|
||||
Error Compilation_aborted_SIZEOF_CURL_OFF_T_shall_not_be_defined
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Set up internal curl_off_t formatting string directives for
|
||||
* exclusive use with libcurl's internal *printf functions.
|
||||
*/
|
||||
|
||||
#ifdef FORMAT_OFF_T
|
||||
# error "FORMAT_OFF_T shall not be defined before this point!"
|
||||
Error Compilation_aborted_FORMAT_OFF_T_already_defined
|
||||
#endif
|
||||
|
||||
#ifdef FORMAT_OFF_TU
|
||||
# error "FORMAT_OFF_TU shall not be defined before this point!"
|
||||
Error Compilation_aborted_FORMAT_OFF_TU_already_defined
|
||||
#endif
|
||||
|
||||
#if (CURL_SIZEOF_CURL_OFF_T > CURL_SIZEOF_LONG)
|
||||
# define FORMAT_OFF_T "lld"
|
||||
# define FORMAT_OFF_TU "llu"
|
||||
#else
|
||||
# define FORMAT_OFF_T "ld"
|
||||
# define FORMAT_OFF_TU "lu"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Disable other protocols when http is the only one desired.
|
||||
*/
|
||||
|
15
lib/file.c
15
lib/file.c
@ -152,14 +152,14 @@ static CURLcode file_range(struct connectdata *conn)
|
||||
if((-1 == to) && (from>=0)) {
|
||||
/* X - */
|
||||
data->state.resume_from = from;
|
||||
DEBUGF(infof(data, "RANGE %" FORMAT_OFF_T " to end of file\n",
|
||||
DEBUGF(infof(data, "RANGE %" CURL_FORMAT_CURL_OFF_T " to end of file\n",
|
||||
from));
|
||||
}
|
||||
else if(from < 0) {
|
||||
/* -Y */
|
||||
data->req.maxdownload = -from;
|
||||
data->state.resume_from = from;
|
||||
DEBUGF(infof(data, "RANGE the last %" FORMAT_OFF_T " bytes\n",
|
||||
DEBUGF(infof(data, "RANGE the last %" CURL_FORMAT_CURL_OFF_T " bytes\n",
|
||||
-from));
|
||||
}
|
||||
else {
|
||||
@ -167,12 +167,13 @@ static CURLcode file_range(struct connectdata *conn)
|
||||
totalsize = to-from;
|
||||
data->req.maxdownload = totalsize+1; /* include last byte */
|
||||
data->state.resume_from = from;
|
||||
DEBUGF(infof(data, "RANGE from %" FORMAT_OFF_T
|
||||
" getting %" FORMAT_OFF_T " bytes\n",
|
||||
DEBUGF(infof(data, "RANGE from %" CURL_FORMAT_CURL_OFF_T
|
||||
" getting %" CURL_FORMAT_CURL_OFF_T " bytes\n",
|
||||
from, data->req.maxdownload));
|
||||
}
|
||||
DEBUGF(infof(data, "range-download from %" FORMAT_OFF_T
|
||||
" to %" FORMAT_OFF_T ", totally %" FORMAT_OFF_T " bytes\n",
|
||||
DEBUGF(infof(data, "range-download from %" CURL_FORMAT_CURL_OFF_T
|
||||
" to %" CURL_FORMAT_CURL_OFF_T ", totally %"
|
||||
CURL_FORMAT_CURL_OFF_T " bytes\n",
|
||||
from, to, data->req.maxdownload));
|
||||
}
|
||||
else
|
||||
@ -465,7 +466,7 @@ static CURLcode file_do(struct connectdata *conn, bool *done)
|
||||
if(data->set.opt_no_body && data->set.include_header && fstated) {
|
||||
CURLcode result;
|
||||
snprintf(buf, sizeof(data->state.buffer),
|
||||
"Content-Length: %" FORMAT_OFF_T "\r\n", expected_size);
|
||||
"Content-Length: %" CURL_FORMAT_CURL_OFF_T "\r\n", expected_size);
|
||||
result = Curl_client_write(conn, CLIENTWRITE_BOTH, buf, 0);
|
||||
if(result)
|
||||
return result;
|
||||
|
49
lib/ftp.c
49
lib/ftp.c
@ -2263,8 +2263,8 @@ static CURLcode ftp_state_retr(struct connectdata *conn,
|
||||
if(data->state.resume_from< 0) {
|
||||
/* We're supposed to download the last abs(from) bytes */
|
||||
if(filesize < -data->state.resume_from) {
|
||||
failf(data, "Offset (%" FORMAT_OFF_T
|
||||
") was beyond file size (%" FORMAT_OFF_T ")",
|
||||
failf(data, "Offset (%" CURL_FORMAT_CURL_OFF_T
|
||||
") was beyond file size (%" CURL_FORMAT_CURL_OFF_T ")",
|
||||
data->state.resume_from, filesize);
|
||||
return CURLE_BAD_DOWNLOAD_RESUME;
|
||||
}
|
||||
@ -2275,8 +2275,8 @@ static CURLcode ftp_state_retr(struct connectdata *conn,
|
||||
}
|
||||
else {
|
||||
if(filesize < data->state.resume_from) {
|
||||
failf(data, "Offset (%" FORMAT_OFF_T
|
||||
") was beyond file size (%" FORMAT_OFF_T ")",
|
||||
failf(data, "Offset (%" CURL_FORMAT_CURL_OFF_T
|
||||
") was beyond file size (%" CURL_FORMAT_CURL_OFF_T ")",
|
||||
data->state.resume_from, filesize);
|
||||
return CURLE_BAD_DOWNLOAD_RESUME;
|
||||
}
|
||||
@ -2298,13 +2298,13 @@ static CURLcode ftp_state_retr(struct connectdata *conn,
|
||||
}
|
||||
|
||||
/* Set resume file transfer offset */
|
||||
infof(data, "Instructs server to resume from offset %" FORMAT_OFF_T
|
||||
"\n", data->state.resume_from);
|
||||
infof(data, "Instructs server to resume from offset %"
|
||||
CURL_FORMAT_CURL_OFF_T "\n", data->state.resume_from);
|
||||
|
||||
PPSENDF(&ftpc->pp, "REST %" FORMAT_OFF_T, data->state.resume_from);
|
||||
PPSENDF(&ftpc->pp, "REST %" CURL_FORMAT_CURL_OFF_T,
|
||||
data->state.resume_from);
|
||||
|
||||
state(conn, FTP_RETR_REST);
|
||||
|
||||
}
|
||||
else {
|
||||
/* no resume */
|
||||
@ -2331,7 +2331,7 @@ static CURLcode ftp_state_size_resp(struct connectdata *conn,
|
||||
#ifdef CURL_FTP_HTTPSTYLE_HEAD
|
||||
if(-1 != filesize) {
|
||||
snprintf(buf, sizeof(data->state.buffer),
|
||||
"Content-Length: %" FORMAT_OFF_T "\r\n", filesize);
|
||||
"Content-Length: %" CURL_FORMAT_CURL_OFF_T "\r\n", filesize);
|
||||
result = Curl_client_write(conn, CLIENTWRITE_BOTH, buf, 0);
|
||||
if(result)
|
||||
return result;
|
||||
@ -2508,10 +2508,12 @@ static CURLcode ftp_state_get_resp(struct connectdata *conn,
|
||||
else if((instate != FTP_LIST) && (data->set.prefer_ascii))
|
||||
size = -1; /* kludge for servers that understate ASCII mode file size */
|
||||
|
||||
infof(data, "Maxdownload = %" FORMAT_OFF_T "\n", data->req.maxdownload);
|
||||
infof(data, "Maxdownload = %" CURL_FORMAT_CURL_OFF_T "\n",
|
||||
data->req.maxdownload);
|
||||
|
||||
if(instate != FTP_LIST)
|
||||
infof(data, "Getting file with size: %" FORMAT_OFF_T "\n", size);
|
||||
infof(data, "Getting file with size: %" CURL_FORMAT_CURL_OFF_T "\n",
|
||||
size);
|
||||
|
||||
/* FTP download: */
|
||||
conn->proto.ftpc.state_saved = instate;
|
||||
@ -3367,8 +3369,8 @@ static CURLcode ftp_done(struct connectdata *conn, CURLcode status,
|
||||
(data->set.infilesize != *ftp->bytecountp) &&
|
||||
!data->set.crlf &&
|
||||
(ftp->transfer == FTPTRANSFER_BODY)) {
|
||||
failf(data, "Uploaded unaligned file size (%" FORMAT_OFF_T
|
||||
" out of %" FORMAT_OFF_T " bytes)",
|
||||
failf(data, "Uploaded unaligned file size (%" CURL_FORMAT_CURL_OFF_T
|
||||
" out of %" CURL_FORMAT_CURL_OFF_T " bytes)",
|
||||
*ftp->bytecountp, data->set.infilesize);
|
||||
result = CURLE_PARTIAL_FILE;
|
||||
}
|
||||
@ -3385,8 +3387,8 @@ static CURLcode ftp_done(struct connectdata *conn, CURLcode status,
|
||||
*ftp->bytecountp) &&
|
||||
#endif /* CURL_DO_LINEEND_CONV */
|
||||
(data->req.maxdownload != *ftp->bytecountp)) {
|
||||
failf(data, "Received only partial file: %" FORMAT_OFF_T " bytes",
|
||||
*ftp->bytecountp);
|
||||
failf(data, "Received only partial file: %" CURL_FORMAT_CURL_OFF_T
|
||||
" bytes", *ftp->bytecountp);
|
||||
result = CURLE_PARTIAL_FILE;
|
||||
}
|
||||
else if(!ftpc->dont_check &&
|
||||
@ -3551,26 +3553,27 @@ static CURLcode ftp_range(struct connectdata *conn)
|
||||
if((-1 == to) && (from>=0)) {
|
||||
/* X - */
|
||||
data->state.resume_from = from;
|
||||
DEBUGF(infof(conn->data, "FTP RANGE %" FORMAT_OFF_T " to end of file\n",
|
||||
from));
|
||||
DEBUGF(infof(conn->data, "FTP RANGE %" CURL_FORMAT_CURL_OFF_T
|
||||
" to end of file\n", from));
|
||||
}
|
||||
else if(from < 0) {
|
||||
/* -Y */
|
||||
data->req.maxdownload = -from;
|
||||
data->state.resume_from = from;
|
||||
DEBUGF(infof(conn->data, "FTP RANGE the last %" FORMAT_OFF_T " bytes\n",
|
||||
-from));
|
||||
DEBUGF(infof(conn->data, "FTP RANGE the last %" CURL_FORMAT_CURL_OFF_T
|
||||
" bytes\n", -from));
|
||||
}
|
||||
else {
|
||||
/* X-Y */
|
||||
data->req.maxdownload = (to-from)+1; /* include last byte */
|
||||
data->state.resume_from = from;
|
||||
DEBUGF(infof(conn->data, "FTP RANGE from %" FORMAT_OFF_T
|
||||
" getting %" FORMAT_OFF_T " bytes\n",
|
||||
DEBUGF(infof(conn->data, "FTP RANGE from %" CURL_FORMAT_CURL_OFF_T
|
||||
" getting %" CURL_FORMAT_CURL_OFF_T " bytes\n",
|
||||
from, data->req.maxdownload));
|
||||
}
|
||||
DEBUGF(infof(conn->data, "range-download from %" FORMAT_OFF_T
|
||||
" to %" FORMAT_OFF_T ", totally %" FORMAT_OFF_T " bytes\n",
|
||||
DEBUGF(infof(conn->data, "range-download from %" CURL_FORMAT_CURL_OFF_T
|
||||
" to %" CURL_FORMAT_CURL_OFF_T ", totally %"
|
||||
CURL_FORMAT_CURL_OFF_T " bytes\n",
|
||||
from, to, data->req.maxdownload));
|
||||
ftpc->dont_check = TRUE; /* dont check for successful transfer */
|
||||
}
|
||||
|
38
lib/http.c
38
lib/http.c
@ -414,8 +414,9 @@ static CURLcode http_perhapsrewind(struct connectdata *conn)
|
||||
/* this is already marked to get closed */
|
||||
return CURLE_OK;
|
||||
|
||||
infof(data, "NTLM send, close instead of sending %" FORMAT_OFF_T
|
||||
" bytes\n", (curl_off_t)(expectsend - bytessent));
|
||||
infof(data, "NTLM send, close instead of sending %"
|
||||
CURL_FORMAT_CURL_OFF_T " bytes\n",
|
||||
(curl_off_t)(expectsend - bytessent));
|
||||
}
|
||||
|
||||
/* This is not NTLM or many bytes left to send: close
|
||||
@ -2018,9 +2019,8 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
|
||||
if((actuallyread == 0) || (actuallyread > readthisamountnow)) {
|
||||
/* this checks for greater-than only to make sure that the
|
||||
CURL_READFUNC_ABORT return code still aborts */
|
||||
failf(data, "Could only read %" FORMAT_OFF_T
|
||||
" bytes from the input",
|
||||
passed);
|
||||
failf(data, "Could only read %" CURL_FORMAT_CURL_OFF_T
|
||||
" bytes from the input", passed);
|
||||
return CURLE_READ_ERROR;
|
||||
}
|
||||
} while(passed < data->state.resume_from);
|
||||
@ -2065,8 +2065,8 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
|
||||
remote part so we tell the server (and act accordingly) that we
|
||||
upload the whole file (again) */
|
||||
conn->allocptr.rangeline =
|
||||
aprintf("Content-Range: bytes 0-%" FORMAT_OFF_T
|
||||
"/%" FORMAT_OFF_T "\r\n",
|
||||
aprintf("Content-Range: bytes 0-%" CURL_FORMAT_CURL_OFF_T
|
||||
"/%" CURL_FORMAT_CURL_OFF_T "\r\n",
|
||||
data->set.infilesize - 1, data->set.infilesize);
|
||||
|
||||
}
|
||||
@ -2075,8 +2075,8 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
|
||||
curl_off_t total_expected_size=
|
||||
data->state.resume_from + data->set.infilesize;
|
||||
conn->allocptr.rangeline =
|
||||
aprintf("Content-Range: bytes %s%" FORMAT_OFF_T
|
||||
"/%" FORMAT_OFF_T "\r\n",
|
||||
aprintf("Content-Range: bytes %s%" CURL_FORMAT_CURL_OFF_T
|
||||
"/%" CURL_FORMAT_CURL_OFF_T "\r\n",
|
||||
data->state.range, total_expected_size-1,
|
||||
total_expected_size);
|
||||
}
|
||||
@ -2084,7 +2084,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
|
||||
/* Range was selected and then we just pass the incoming range and
|
||||
append total size */
|
||||
conn->allocptr.rangeline =
|
||||
aprintf("Content-Range: bytes %s/%" FORMAT_OFF_T "\r\n",
|
||||
aprintf("Content-Range: bytes %s/%" CURL_FORMAT_CURL_OFF_T "\r\n",
|
||||
data->state.range, data->set.infilesize);
|
||||
}
|
||||
if(!conn->allocptr.rangeline)
|
||||
@ -2294,8 +2294,8 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
|
||||
!Curl_checkheaders(data, "Content-Length:")) {
|
||||
/* only add Content-Length if not uploading chunked */
|
||||
result = Curl_add_bufferf(req_buffer,
|
||||
"Content-Length: %" FORMAT_OFF_T "\r\n",
|
||||
http->postsize);
|
||||
"Content-Length: %" CURL_FORMAT_CURL_OFF_T
|
||||
"\r\n", http->postsize);
|
||||
if(result)
|
||||
return result;
|
||||
}
|
||||
@ -2366,8 +2366,8 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
|
||||
!Curl_checkheaders(data, "Content-Length:")) {
|
||||
/* only add Content-Length if not uploading chunked */
|
||||
result = Curl_add_bufferf(req_buffer,
|
||||
"Content-Length: %" FORMAT_OFF_T "\r\n",
|
||||
postsize );
|
||||
"Content-Length: %" CURL_FORMAT_CURL_OFF_T
|
||||
"\r\n", postsize);
|
||||
if(result)
|
||||
return result;
|
||||
}
|
||||
@ -2417,8 +2417,8 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
|
||||
/* we allow replacing this header if not during auth negotiation,
|
||||
although it isn't very wise to actually set your own */
|
||||
result = Curl_add_bufferf(req_buffer,
|
||||
"Content-Length: %" FORMAT_OFF_T"\r\n",
|
||||
postsize);
|
||||
"Content-Length: %" CURL_FORMAT_CURL_OFF_T
|
||||
"\r\n", postsize);
|
||||
if(result)
|
||||
return result;
|
||||
}
|
||||
@ -2582,8 +2582,8 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
|
||||
if(http->writebytecount >= postsize) {
|
||||
/* already sent the entire request body, mark the "upload" as
|
||||
complete */
|
||||
infof(data, "upload completely sent off: %" FORMAT_OFF_T " out of "
|
||||
"%" FORMAT_OFF_T " bytes\n",
|
||||
infof(data, "upload completely sent off: %" CURL_FORMAT_CURL_OFF_T
|
||||
" out of %" CURL_FORMAT_CURL_OFF_T " bytes\n",
|
||||
http->writebytecount, postsize);
|
||||
data->req.upload_done = TRUE;
|
||||
data->req.keepon &= ~KEEP_SEND; /* we're done writing */
|
||||
@ -3233,7 +3233,7 @@ CURLcode Curl_http_readwrite_headers(struct SessionHandle *data,
|
||||
happens for example when older Apache servers send large
|
||||
files */
|
||||
conn->bits.close = TRUE;
|
||||
infof(data, "Negative content-length: %" FORMAT_OFF_T
|
||||
infof(data, "Negative content-length: %" CURL_FORMAT_CURL_OFF_T
|
||||
", closing after transfer\n", contentlength);
|
||||
}
|
||||
}
|
||||
|
@ -380,9 +380,9 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn,
|
||||
keepon = 2;
|
||||
|
||||
if(cl) {
|
||||
|
||||
infof(data, "Ignore %" FORMAT_OFF_T
|
||||
infof(data, "Ignore %" CURL_FORMAT_CURL_OFF_T
|
||||
" bytes of response-body\n", cl);
|
||||
|
||||
/* remove the remaining chunk of what we already
|
||||
read */
|
||||
cl -= (gotbytes - i);
|
||||
|
@ -775,7 +775,7 @@ static CURLcode imap_perform_append(struct connectdata *conn)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
|
||||
/* Send the APPEND command */
|
||||
result = imap_sendf(conn, "APPEND %s (\\Seen) {%" FORMAT_OFF_T "}",
|
||||
result = imap_sendf(conn, "APPEND %s (\\Seen) {%" CURL_FORMAT_CURL_OFF_T "}",
|
||||
mailbox, conn->data->set.infilesize);
|
||||
|
||||
Curl_safefree(mailbox);
|
||||
@ -1494,7 +1494,7 @@ static CURLcode imap_state_fetch_resp(struct connectdata *conn, int imapcode,
|
||||
}
|
||||
|
||||
if(parsed) {
|
||||
infof(data, "Found %" FORMAT_OFF_TU " bytes to download\n", size);
|
||||
infof(data, "Found %" CURL_FORMAT_CURL_OFF_TU " bytes to download\n", size);
|
||||
Curl_pgrsSetDownloadSize(data, size);
|
||||
|
||||
if(pp->cache) {
|
||||
@ -1513,7 +1513,8 @@ static CURLcode imap_state_fetch_resp(struct connectdata *conn, int imapcode,
|
||||
|
||||
data->req.bytecount += chunk;
|
||||
|
||||
infof(data, "Written %" FORMAT_OFF_TU " bytes, %" FORMAT_OFF_TU
|
||||
infof(data, "Written %" CURL_FORMAT_CURL_OFF_TU
|
||||
" bytes, %" CURL_FORMAT_CURL_OFF_TU
|
||||
" bytes are left for transfer\n", (curl_off_t)chunk,
|
||||
size - chunk);
|
||||
|
||||
|
@ -986,7 +986,8 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
|
||||
else {
|
||||
k = &data->req;
|
||||
failf(data, "Operation timed out after %ld milliseconds with %"
|
||||
FORMAT_OFF_T " out of %" FORMAT_OFF_T " bytes received",
|
||||
CURL_FORMAT_CURL_OFF_T " out of %"
|
||||
CURL_FORMAT_CURL_OFF_T " bytes received",
|
||||
Curl_tvdiff(now, data->progress.t_startsingle), k->bytecount,
|
||||
k->size);
|
||||
}
|
||||
|
@ -85,8 +85,8 @@ bool Curl_pipeline_penalized(struct SessionHandle *data,
|
||||
(curl_off_t)conn->chunk.datasize > chunk_penalty_size)
|
||||
penalized = TRUE;
|
||||
|
||||
infof(data, "Conn: %ld (%p) Receive pipe weight: (%" FORMAT_OFF_T
|
||||
"/%zu), penalized: %s\n",
|
||||
infof(data, "Conn: %ld (%p) Receive pipe weight: (%"
|
||||
CURL_FORMAT_CURL_OFF_T "/%zu), penalized: %s\n",
|
||||
conn->connection_id, (void *)conn, recv_size,
|
||||
conn->chunk.datasize, penalized?"TRUE":"FALSE");
|
||||
return penalized;
|
||||
|
@ -42,8 +42,8 @@ static void time2str(char *r, curl_off_t seconds)
|
||||
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));
|
||||
snprintf(r, 9, "%2" FORMAT_OFF_T ":%02" FORMAT_OFF_T ":%02" FORMAT_OFF_T,
|
||||
h, m, s);
|
||||
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
|
||||
@ -51,9 +51,10 @@ static void time2str(char *r, curl_off_t seconds)
|
||||
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" FORMAT_OFF_T "d %02" FORMAT_OFF_T "h", d, h);
|
||||
snprintf(r, 9, "%3" CURL_FORMAT_CURL_OFF_T
|
||||
"d %02" CURL_FORMAT_CURL_OFF_T "h", d, h);
|
||||
else
|
||||
snprintf(r, 9, "%7" FORMAT_OFF_T "d", d);
|
||||
snprintf(r, 9, "%7" CURL_FORMAT_CURL_OFF_T "d", d);
|
||||
}
|
||||
}
|
||||
|
||||
@ -69,40 +70,40 @@ static char *max5data(curl_off_t bytes, char *max5)
|
||||
#define ONE_PETABYTE (CURL_OFF_T_C(1024) * ONE_TERABYTE)
|
||||
|
||||
if(bytes < CURL_OFF_T_C(100000))
|
||||
snprintf(max5, 6, "%5" FORMAT_OFF_T, bytes);
|
||||
snprintf(max5, 6, "%5" CURL_FORMAT_CURL_OFF_T, bytes);
|
||||
|
||||
else if(bytes < CURL_OFF_T_C(10000) * ONE_KILOBYTE)
|
||||
snprintf(max5, 6, "%4" FORMAT_OFF_T "k", bytes/ONE_KILOBYTE);
|
||||
snprintf(max5, 6, "%4" CURL_FORMAT_CURL_OFF_T "k", bytes/ONE_KILOBYTE);
|
||||
|
||||
else if(bytes < CURL_OFF_T_C(100) * ONE_MEGABYTE)
|
||||
/* 'XX.XM' is good as long as we're less than 100 megs */
|
||||
snprintf(max5, 6, "%2" FORMAT_OFF_T ".%0" FORMAT_OFF_T "M",
|
||||
bytes/ONE_MEGABYTE,
|
||||
snprintf(max5, 6, "%2" CURL_FORMAT_CURL_OFF_T ".%0"
|
||||
CURL_FORMAT_CURL_OFF_T "M", bytes/ONE_MEGABYTE,
|
||||
(bytes%ONE_MEGABYTE) / (ONE_MEGABYTE/CURL_OFF_T_C(10)) );
|
||||
|
||||
#if (CURL_SIZEOF_CURL_OFF_T > 4)
|
||||
|
||||
else if(bytes < CURL_OFF_T_C(10000) * ONE_MEGABYTE)
|
||||
/* 'XXXXM' is good until we're at 10000MB or above */
|
||||
snprintf(max5, 6, "%4" FORMAT_OFF_T "M", bytes/ONE_MEGABYTE);
|
||||
snprintf(max5, 6, "%4" CURL_FORMAT_CURL_OFF_T "M", bytes/ONE_MEGABYTE);
|
||||
|
||||
else if(bytes < CURL_OFF_T_C(100) * ONE_GIGABYTE)
|
||||
/* 10000 MB - 100 GB, we show it as XX.XG */
|
||||
snprintf(max5, 6, "%2" FORMAT_OFF_T ".%0" FORMAT_OFF_T "G",
|
||||
bytes/ONE_GIGABYTE,
|
||||
snprintf(max5, 6, "%2" CURL_FORMAT_CURL_OFF_T ".%0"
|
||||
CURL_FORMAT_CURL_OFF_T "G", bytes/ONE_GIGABYTE,
|
||||
(bytes%ONE_GIGABYTE) / (ONE_GIGABYTE/CURL_OFF_T_C(10)) );
|
||||
|
||||
else if(bytes < CURL_OFF_T_C(10000) * ONE_GIGABYTE)
|
||||
/* up to 10000GB, display without decimal: XXXXG */
|
||||
snprintf(max5, 6, "%4" FORMAT_OFF_T "G", bytes/ONE_GIGABYTE);
|
||||
snprintf(max5, 6, "%4" CURL_FORMAT_CURL_OFF_T "G", bytes/ONE_GIGABYTE);
|
||||
|
||||
else if(bytes < CURL_OFF_T_C(10000) * ONE_TERABYTE)
|
||||
/* up to 10000TB, display without decimal: XXXXT */
|
||||
snprintf(max5, 6, "%4" FORMAT_OFF_T "T", bytes/ONE_TERABYTE);
|
||||
snprintf(max5, 6, "%4" CURL_FORMAT_CURL_OFF_T "T", bytes/ONE_TERABYTE);
|
||||
|
||||
else
|
||||
/* up to 10000PB, display without decimal: XXXXP */
|
||||
snprintf(max5, 6, "%4" FORMAT_OFF_T "P", bytes/ONE_PETABYTE);
|
||||
snprintf(max5, 6, "%4" CURL_FORMAT_CURL_OFF_T "P", bytes/ONE_PETABYTE);
|
||||
|
||||
/* 16384 petabytes (16 exabytes) is the maximum a 64 bit unsigned number
|
||||
can hold, but our data type is signed so 8192PB will be the maximum. */
|
||||
@ -110,7 +111,7 @@ static char *max5data(curl_off_t bytes, char *max5)
|
||||
#else
|
||||
|
||||
else
|
||||
snprintf(max5, 6, "%4" FORMAT_OFF_T "M", bytes/ONE_MEGABYTE);
|
||||
snprintf(max5, 6, "%4" CURL_FORMAT_CURL_OFF_T "M", bytes/ONE_MEGABYTE);
|
||||
|
||||
#endif
|
||||
|
||||
@ -392,8 +393,8 @@ int Curl_pgrsUpdate(struct connectdata *conn)
|
||||
if(!(data->progress.flags & PGRS_HEADERS_OUT)) {
|
||||
if(data->state.resume_from) {
|
||||
fprintf(data->set.err,
|
||||
"** Resuming transfer from byte position %" FORMAT_OFF_T "\n",
|
||||
data->state.resume_from);
|
||||
"** Resuming transfer from byte position %"
|
||||
CURL_FORMAT_CURL_OFF_T "\n", data->state.resume_from);
|
||||
}
|
||||
fprintf(data->set.err,
|
||||
" %% Total %% Received %% Xferd Average Speed "
|
||||
@ -457,9 +458,9 @@ int Curl_pgrsUpdate(struct connectdata *conn)
|
||||
|
||||
fprintf(data->set.err,
|
||||
"\r"
|
||||
"%3" FORMAT_OFF_T " %s "
|
||||
"%3" FORMAT_OFF_T " %s "
|
||||
"%3" FORMAT_OFF_T " %s %s %s %s %s %s %s",
|
||||
"%3" CURL_FORMAT_CURL_OFF_T " %s "
|
||||
"%3" CURL_FORMAT_CURL_OFF_T " %s "
|
||||
"%3" CURL_FORMAT_CURL_OFF_T " %s %s %s %s %s %s %s",
|
||||
total_percen, /* 3 letters */ /* total % */
|
||||
max5data(total_expected_transfer, max5[2]), /* total size */
|
||||
dlpercen, /* 3 letters */ /* rcvd % */
|
||||
|
@ -509,7 +509,7 @@ static CURLcode rtsp_do(struct connectdata *conn, bool *done)
|
||||
* actually set a custom Content-Length in the headers */
|
||||
if(!Curl_checkheaders(data, "Content-Length:")) {
|
||||
result = Curl_add_bufferf(req_buffer,
|
||||
"Content-Length: %" FORMAT_OFF_T"\r\n",
|
||||
"Content-Length: %" CURL_FORMAT_CURL_OFF_T"\r\n",
|
||||
(data->set.upload ? putsize : postsize));
|
||||
if(result)
|
||||
return result;
|
||||
|
@ -582,7 +582,7 @@ static CURLcode smtp_perform_mail(struct connectdata *conn)
|
||||
|
||||
/* Calculate the optional SIZE parameter */
|
||||
if(conn->proto.smtpc.size_supported && conn->data->set.infilesize > 0) {
|
||||
size = aprintf("%" FORMAT_OFF_T, data->set.infilesize);
|
||||
size = aprintf("%" CURL_FORMAT_CURL_OFF_T, data->set.infilesize);
|
||||
|
||||
if(!size) {
|
||||
Curl_safefree(from);
|
||||
|
15
lib/ssh.c
15
lib/ssh.c
@ -1602,7 +1602,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
|
||||
else {
|
||||
curl_off_t size = attrs.filesize;
|
||||
if(size < 0) {
|
||||
failf(data, "Bad file size (%" FORMAT_OFF_T ")", size);
|
||||
failf(data, "Bad file size (%" CURL_FORMAT_CURL_OFF_T ")", size);
|
||||
return CURLE_BAD_DOWNLOAD_RESUME;
|
||||
}
|
||||
data->state.resume_from = attrs.filesize;
|
||||
@ -2070,7 +2070,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
|
||||
curl_off_t size = attrs.filesize;
|
||||
|
||||
if(size < 0) {
|
||||
failf(data, "Bad file size (%" FORMAT_OFF_T ")", size);
|
||||
failf(data, "Bad file size (%" CURL_FORMAT_CURL_OFF_T ")", size);
|
||||
return CURLE_BAD_DOWNLOAD_RESUME;
|
||||
}
|
||||
if(conn->data->state.use_range) {
|
||||
@ -2092,8 +2092,8 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
|
||||
}
|
||||
if(from >= size) {
|
||||
failf(data, "Offset (%"
|
||||
FORMAT_OFF_T ") was beyond file size (%" FORMAT_OFF_T ")",
|
||||
from, attrs.filesize);
|
||||
CURL_FORMAT_CURL_OFF_T ") was beyond file size (%"
|
||||
CURL_FORMAT_CURL_OFF_T ")", from, attrs.filesize);
|
||||
return CURLE_BAD_DOWNLOAD_RESUME;
|
||||
}
|
||||
if(from > to) {
|
||||
@ -2117,7 +2117,8 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
|
||||
/* We're supposed to download the last abs(from) bytes */
|
||||
if((curl_off_t)attrs.filesize < -data->state.resume_from) {
|
||||
failf(data, "Offset (%"
|
||||
FORMAT_OFF_T ") was beyond file size (%" FORMAT_OFF_T ")",
|
||||
CURL_FORMAT_CURL_OFF_T ") was beyond file size (%"
|
||||
CURL_FORMAT_CURL_OFF_T ")",
|
||||
data->state.resume_from, attrs.filesize);
|
||||
return CURLE_BAD_DOWNLOAD_RESUME;
|
||||
}
|
||||
@ -2126,8 +2127,8 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
|
||||
}
|
||||
else {
|
||||
if((curl_off_t)attrs.filesize < data->state.resume_from) {
|
||||
failf(data, "Offset (%" FORMAT_OFF_T
|
||||
") was beyond file size (%" FORMAT_OFF_T ")",
|
||||
failf(data, "Offset (%" CURL_FORMAT_CURL_OFF_T
|
||||
") was beyond file size (%" CURL_FORMAT_CURL_OFF_T ")",
|
||||
data->state.resume_from, attrs.filesize);
|
||||
return CURLE_BAD_DOWNLOAD_RESUME;
|
||||
}
|
||||
|
@ -499,7 +499,8 @@ static CURLcode tftp_send_first(tftp_state_data_t *state, tftp_event_t event)
|
||||
|
||||
/* add tsize option */
|
||||
if(data->set.upload && (data->set.infilesize != -1))
|
||||
snprintf( buf, sizeof(buf), "%" FORMAT_OFF_T, data->set.infilesize );
|
||||
snprintf(buf, sizeof(buf), "%" CURL_FORMAT_CURL_OFF_T,
|
||||
data->set.infilesize);
|
||||
else
|
||||
strcpy(buf, "0"); /* the destination is large enough */
|
||||
|
||||
|
@ -646,9 +646,9 @@ static CURLcode readwrite_data(struct SessionHandle *data,
|
||||
always will fit in a size_t */
|
||||
infof(data,
|
||||
"Rewinding stream by : %zu"
|
||||
" bytes on url %s (size = %" FORMAT_OFF_T
|
||||
", maxdownload = %" FORMAT_OFF_T
|
||||
", bytecount = %" FORMAT_OFF_T ", nread = %zd)\n",
|
||||
" bytes on url %s (size = %" CURL_FORMAT_CURL_OFF_T
|
||||
", maxdownload = %" CURL_FORMAT_CURL_OFF_T
|
||||
", bytecount = %" CURL_FORMAT_CURL_OFF_T ", nread = %zd)\n",
|
||||
excess, data->state.path,
|
||||
k->size, k->maxdownload, k->bytecount, nread);
|
||||
read_rewind(conn, excess);
|
||||
@ -657,9 +657,9 @@ static CURLcode readwrite_data(struct SessionHandle *data,
|
||||
infof(data,
|
||||
"Excess found in a non pipelined read:"
|
||||
" excess = %zu"
|
||||
", size = %" FORMAT_OFF_T
|
||||
", maxdownload = %" FORMAT_OFF_T
|
||||
", bytecount = %" FORMAT_OFF_T "\n",
|
||||
", size = %" CURL_FORMAT_CURL_OFF_T
|
||||
", maxdownload = %" CURL_FORMAT_CURL_OFF_T
|
||||
", bytecount = %" CURL_FORMAT_CURL_OFF_T "\n",
|
||||
excess, k->size, k->maxdownload, k->bytecount);
|
||||
}
|
||||
}
|
||||
@ -1095,13 +1095,14 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
||||
if(0 > Curl_timeleft(data, &k->now, FALSE)) {
|
||||
if(k->size != -1) {
|
||||
failf(data, "Operation timed out after %ld milliseconds with %"
|
||||
FORMAT_OFF_T " out of %" FORMAT_OFF_T " bytes received",
|
||||
CURL_FORMAT_CURL_OFF_T " out of %"
|
||||
CURL_FORMAT_CURL_OFF_T " bytes received",
|
||||
Curl_tvdiff(k->now, data->progress.t_startsingle), k->bytecount,
|
||||
k->size);
|
||||
}
|
||||
else {
|
||||
failf(data, "Operation timed out after %ld milliseconds with %"
|
||||
FORMAT_OFF_T " bytes received",
|
||||
CURL_FORMAT_CURL_OFF_T " bytes received",
|
||||
Curl_tvdiff(k->now, data->progress.t_startsingle), k->bytecount);
|
||||
}
|
||||
return CURLE_OPERATION_TIMEDOUT;
|
||||
@ -1123,7 +1124,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
||||
(k->bytecount != (k->size + data->state.crlf_conversions)) &&
|
||||
#endif /* CURL_DO_LINEEND_CONV */
|
||||
!data->req.newurl) {
|
||||
failf(data, "transfer closed with %" FORMAT_OFF_T
|
||||
failf(data, "transfer closed with %" CURL_FORMAT_CURL_OFF_T
|
||||
" bytes remaining to read",
|
||||
k->size - k->bytecount);
|
||||
return CURLE_PARTIAL_FILE;
|
||||
|
@ -3991,7 +3991,7 @@ static CURLcode setup_range(struct SessionHandle *data)
|
||||
free(s->range);
|
||||
|
||||
if(s->resume_from)
|
||||
s->range = aprintf("%" FORMAT_OFF_TU "-", s->resume_from);
|
||||
s->range = aprintf("%" CURL_FORMAT_CURL_OFF_TU "-", s->resume_from);
|
||||
else
|
||||
s->range = strdup(data->set.str[STRING_SET_RANGE]);
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
@ -1354,7 +1354,7 @@ static int test_curl_off_t_formatting(void)
|
||||
co_test[i].result[j] = 'X';
|
||||
co_test[i].result[BUFSZ-1] = '\0';
|
||||
|
||||
(void)curl_msprintf(co_test[i].result, "%" FORMAT_OFF_T, co_test[i].num);
|
||||
(void)curl_msprintf(co_test[i].result, "%" CURL_FORMAT_CURL_OFF_T, co_test[i].num);
|
||||
|
||||
if(memcmp(co_test[i].result,
|
||||
co_test[i].expected,
|
||||
|
Loading…
Reference in New Issue
Block a user