1
0
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:
Steve Holme 2013-12-31 11:10:25 +00:00
parent 6e4d4a9b51
commit 60bd22620a
17 changed files with 111 additions and 124 deletions

View File

@ -815,7 +815,7 @@ Curl_cookie_add(struct SessionHandle *data,
if(c->running) if(c->running)
/* Only show this when NOT reading the cookies from a file */ /* Only show this when NOT reading the cookies from a file */
infof(data, "%s cookie %s=\"%s\" for domain %s, path %s, " 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, replace_old?"Replaced":"Added", co->name, co->value,
co->domain, co->path, co->expires); co->domain, co->path, co->expires);
@ -1172,7 +1172,7 @@ static char *get_netscape_format(const struct Cookie *co)
"%s\t" /* tailmatch */ "%s\t" /* tailmatch */
"%s\t" /* path */ "%s\t" /* path */
"%s\t" /* secure */ "%s\t" /* secure */
"%" FORMAT_OFF_T "\t" /* expires */ "%" CURL_FORMAT_CURL_OFF_T "\t" /* expires */
"%s\t" /* name */ "%s\t" /* name */
"%s", /* value */ "%s", /* value */
co->httponly?"#HttpOnly_":"", co->httponly?"#HttpOnly_":"",

View File

@ -139,29 +139,6 @@
Error Compilation_aborted_SIZEOF_CURL_OFF_T_shall_not_be_defined Error Compilation_aborted_SIZEOF_CURL_OFF_T_shall_not_be_defined
#endif #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. * Disable other protocols when http is the only one desired.
*/ */

View File

@ -152,14 +152,14 @@ static CURLcode file_range(struct connectdata *conn)
if((-1 == to) && (from>=0)) { if((-1 == to) && (from>=0)) {
/* X - */ /* X - */
data->state.resume_from = from; 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)); from));
} }
else if(from < 0) { else if(from < 0) {
/* -Y */ /* -Y */
data->req.maxdownload = -from; data->req.maxdownload = -from;
data->state.resume_from = 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)); -from));
} }
else { else {
@ -167,12 +167,13 @@ static CURLcode file_range(struct connectdata *conn)
totalsize = to-from; totalsize = to-from;
data->req.maxdownload = totalsize+1; /* include last byte */ data->req.maxdownload = totalsize+1; /* include last byte */
data->state.resume_from = from; data->state.resume_from = from;
DEBUGF(infof(data, "RANGE from %" FORMAT_OFF_T DEBUGF(infof(data, "RANGE from %" CURL_FORMAT_CURL_OFF_T
" getting %" FORMAT_OFF_T " bytes\n", " getting %" CURL_FORMAT_CURL_OFF_T " bytes\n",
from, data->req.maxdownload)); from, data->req.maxdownload));
} }
DEBUGF(infof(data, "range-download from %" FORMAT_OFF_T DEBUGF(infof(data, "range-download from %" CURL_FORMAT_CURL_OFF_T
" to %" FORMAT_OFF_T ", totally %" FORMAT_OFF_T " bytes\n", " to %" CURL_FORMAT_CURL_OFF_T ", totally %"
CURL_FORMAT_CURL_OFF_T " bytes\n",
from, to, data->req.maxdownload)); from, to, data->req.maxdownload));
} }
else 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) { if(data->set.opt_no_body && data->set.include_header && fstated) {
CURLcode result; CURLcode result;
snprintf(buf, sizeof(data->state.buffer), 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); result = Curl_client_write(conn, CLIENTWRITE_BOTH, buf, 0);
if(result) if(result)
return result; return result;

View File

@ -2263,8 +2263,8 @@ static CURLcode ftp_state_retr(struct connectdata *conn,
if(data->state.resume_from< 0) { if(data->state.resume_from< 0) {
/* We're supposed to download the last abs(from) bytes */ /* We're supposed to download the last abs(from) bytes */
if(filesize < -data->state.resume_from) { if(filesize < -data->state.resume_from) {
failf(data, "Offset (%" FORMAT_OFF_T failf(data, "Offset (%" CURL_FORMAT_CURL_OFF_T
") was beyond file size (%" FORMAT_OFF_T ")", ") was beyond file size (%" CURL_FORMAT_CURL_OFF_T ")",
data->state.resume_from, filesize); data->state.resume_from, filesize);
return CURLE_BAD_DOWNLOAD_RESUME; return CURLE_BAD_DOWNLOAD_RESUME;
} }
@ -2275,8 +2275,8 @@ static CURLcode ftp_state_retr(struct connectdata *conn,
} }
else { else {
if(filesize < data->state.resume_from) { if(filesize < data->state.resume_from) {
failf(data, "Offset (%" FORMAT_OFF_T failf(data, "Offset (%" CURL_FORMAT_CURL_OFF_T
") was beyond file size (%" FORMAT_OFF_T ")", ") was beyond file size (%" CURL_FORMAT_CURL_OFF_T ")",
data->state.resume_from, filesize); data->state.resume_from, filesize);
return CURLE_BAD_DOWNLOAD_RESUME; return CURLE_BAD_DOWNLOAD_RESUME;
} }
@ -2298,13 +2298,13 @@ static CURLcode ftp_state_retr(struct connectdata *conn,
} }
/* Set resume file transfer offset */ /* Set resume file transfer offset */
infof(data, "Instructs server to resume from offset %" FORMAT_OFF_T infof(data, "Instructs server to resume from offset %"
"\n", data->state.resume_from); 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); state(conn, FTP_RETR_REST);
} }
else { else {
/* no resume */ /* no resume */
@ -2331,7 +2331,7 @@ static CURLcode ftp_state_size_resp(struct connectdata *conn,
#ifdef CURL_FTP_HTTPSTYLE_HEAD #ifdef CURL_FTP_HTTPSTYLE_HEAD
if(-1 != filesize) { if(-1 != filesize) {
snprintf(buf, sizeof(data->state.buffer), 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); result = Curl_client_write(conn, CLIENTWRITE_BOTH, buf, 0);
if(result) if(result)
return 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)) else if((instate != FTP_LIST) && (data->set.prefer_ascii))
size = -1; /* kludge for servers that understate ASCII mode file size */ 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) 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: */ /* FTP download: */
conn->proto.ftpc.state_saved = instate; 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.infilesize != *ftp->bytecountp) &&
!data->set.crlf && !data->set.crlf &&
(ftp->transfer == FTPTRANSFER_BODY)) { (ftp->transfer == FTPTRANSFER_BODY)) {
failf(data, "Uploaded unaligned file size (%" FORMAT_OFF_T failf(data, "Uploaded unaligned file size (%" CURL_FORMAT_CURL_OFF_T
" out of %" FORMAT_OFF_T " bytes)", " out of %" CURL_FORMAT_CURL_OFF_T " bytes)",
*ftp->bytecountp, data->set.infilesize); *ftp->bytecountp, data->set.infilesize);
result = CURLE_PARTIAL_FILE; result = CURLE_PARTIAL_FILE;
} }
@ -3385,8 +3387,8 @@ static CURLcode ftp_done(struct connectdata *conn, CURLcode status,
*ftp->bytecountp) && *ftp->bytecountp) &&
#endif /* CURL_DO_LINEEND_CONV */ #endif /* CURL_DO_LINEEND_CONV */
(data->req.maxdownload != *ftp->bytecountp)) { (data->req.maxdownload != *ftp->bytecountp)) {
failf(data, "Received only partial file: %" FORMAT_OFF_T " bytes", failf(data, "Received only partial file: %" CURL_FORMAT_CURL_OFF_T
*ftp->bytecountp); " bytes", *ftp->bytecountp);
result = CURLE_PARTIAL_FILE; result = CURLE_PARTIAL_FILE;
} }
else if(!ftpc->dont_check && else if(!ftpc->dont_check &&
@ -3551,26 +3553,27 @@ static CURLcode ftp_range(struct connectdata *conn)
if((-1 == to) && (from>=0)) { if((-1 == to) && (from>=0)) {
/* X - */ /* X - */
data->state.resume_from = from; data->state.resume_from = from;
DEBUGF(infof(conn->data, "FTP RANGE %" FORMAT_OFF_T " to end of file\n", DEBUGF(infof(conn->data, "FTP RANGE %" CURL_FORMAT_CURL_OFF_T
from)); " to end of file\n", from));
} }
else if(from < 0) { else if(from < 0) {
/* -Y */ /* -Y */
data->req.maxdownload = -from; data->req.maxdownload = -from;
data->state.resume_from = from; data->state.resume_from = from;
DEBUGF(infof(conn->data, "FTP RANGE the last %" FORMAT_OFF_T " bytes\n", DEBUGF(infof(conn->data, "FTP RANGE the last %" CURL_FORMAT_CURL_OFF_T
-from)); " bytes\n", -from));
} }
else { else {
/* X-Y */ /* X-Y */
data->req.maxdownload = (to-from)+1; /* include last byte */ data->req.maxdownload = (to-from)+1; /* include last byte */
data->state.resume_from = from; data->state.resume_from = from;
DEBUGF(infof(conn->data, "FTP RANGE from %" FORMAT_OFF_T DEBUGF(infof(conn->data, "FTP RANGE from %" CURL_FORMAT_CURL_OFF_T
" getting %" FORMAT_OFF_T " bytes\n", " getting %" CURL_FORMAT_CURL_OFF_T " bytes\n",
from, data->req.maxdownload)); from, data->req.maxdownload));
} }
DEBUGF(infof(conn->data, "range-download from %" FORMAT_OFF_T DEBUGF(infof(conn->data, "range-download from %" CURL_FORMAT_CURL_OFF_T
" to %" FORMAT_OFF_T ", totally %" FORMAT_OFF_T " bytes\n", " to %" CURL_FORMAT_CURL_OFF_T ", totally %"
CURL_FORMAT_CURL_OFF_T " bytes\n",
from, to, data->req.maxdownload)); from, to, data->req.maxdownload));
ftpc->dont_check = TRUE; /* dont check for successful transfer */ ftpc->dont_check = TRUE; /* dont check for successful transfer */
} }

View File

@ -414,8 +414,9 @@ static CURLcode http_perhapsrewind(struct connectdata *conn)
/* this is already marked to get closed */ /* this is already marked to get closed */
return CURLE_OK; return CURLE_OK;
infof(data, "NTLM send, close instead of sending %" FORMAT_OFF_T infof(data, "NTLM send, close instead of sending %"
" bytes\n", (curl_off_t)(expectsend - bytessent)); CURL_FORMAT_CURL_OFF_T " bytes\n",
(curl_off_t)(expectsend - bytessent));
} }
/* This is not NTLM or many bytes left to send: close /* 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)) { if((actuallyread == 0) || (actuallyread > readthisamountnow)) {
/* this checks for greater-than only to make sure that the /* this checks for greater-than only to make sure that the
CURL_READFUNC_ABORT return code still aborts */ CURL_READFUNC_ABORT return code still aborts */
failf(data, "Could only read %" FORMAT_OFF_T failf(data, "Could only read %" CURL_FORMAT_CURL_OFF_T
" bytes from the input", " bytes from the input", passed);
passed);
return CURLE_READ_ERROR; return CURLE_READ_ERROR;
} }
} while(passed < data->state.resume_from); } 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 remote part so we tell the server (and act accordingly) that we
upload the whole file (again) */ upload the whole file (again) */
conn->allocptr.rangeline = conn->allocptr.rangeline =
aprintf("Content-Range: bytes 0-%" FORMAT_OFF_T aprintf("Content-Range: bytes 0-%" CURL_FORMAT_CURL_OFF_T
"/%" FORMAT_OFF_T "\r\n", "/%" CURL_FORMAT_CURL_OFF_T "\r\n",
data->set.infilesize - 1, data->set.infilesize); 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= curl_off_t total_expected_size=
data->state.resume_from + data->set.infilesize; data->state.resume_from + data->set.infilesize;
conn->allocptr.rangeline = conn->allocptr.rangeline =
aprintf("Content-Range: bytes %s%" FORMAT_OFF_T aprintf("Content-Range: bytes %s%" CURL_FORMAT_CURL_OFF_T
"/%" FORMAT_OFF_T "\r\n", "/%" CURL_FORMAT_CURL_OFF_T "\r\n",
data->state.range, total_expected_size-1, data->state.range, total_expected_size-1,
total_expected_size); 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 /* 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/%" CURL_FORMAT_CURL_OFF_T "\r\n",
data->state.range, data->set.infilesize); data->state.range, data->set.infilesize);
} }
if(!conn->allocptr.rangeline) if(!conn->allocptr.rangeline)
@ -2294,8 +2294,8 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
!Curl_checkheaders(data, "Content-Length:")) { !Curl_checkheaders(data, "Content-Length:")) {
/* only add Content-Length if not uploading chunked */ /* only add Content-Length if not uploading chunked */
result = Curl_add_bufferf(req_buffer, result = Curl_add_bufferf(req_buffer,
"Content-Length: %" FORMAT_OFF_T "\r\n", "Content-Length: %" CURL_FORMAT_CURL_OFF_T
http->postsize); "\r\n", http->postsize);
if(result) if(result)
return result; return result;
} }
@ -2366,8 +2366,8 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
!Curl_checkheaders(data, "Content-Length:")) { !Curl_checkheaders(data, "Content-Length:")) {
/* only add Content-Length if not uploading chunked */ /* only add Content-Length if not uploading chunked */
result = Curl_add_bufferf(req_buffer, result = Curl_add_bufferf(req_buffer,
"Content-Length: %" FORMAT_OFF_T "\r\n", "Content-Length: %" CURL_FORMAT_CURL_OFF_T
postsize ); "\r\n", postsize);
if(result) if(result)
return 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, /* we allow replacing this header if not during auth negotiation,
although it isn't very wise to actually set your own */ although it isn't very wise to actually set your own */
result = Curl_add_bufferf(req_buffer, result = Curl_add_bufferf(req_buffer,
"Content-Length: %" FORMAT_OFF_T"\r\n", "Content-Length: %" CURL_FORMAT_CURL_OFF_T
postsize); "\r\n", postsize);
if(result) if(result)
return result; return result;
} }
@ -2582,8 +2582,8 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
if(http->writebytecount >= postsize) { if(http->writebytecount >= postsize) {
/* already sent the entire request body, mark the "upload" as /* already sent the entire request body, mark the "upload" as
complete */ complete */
infof(data, "upload completely sent off: %" FORMAT_OFF_T " out of " infof(data, "upload completely sent off: %" CURL_FORMAT_CURL_OFF_T
"%" FORMAT_OFF_T " bytes\n", " out of %" CURL_FORMAT_CURL_OFF_T " bytes\n",
http->writebytecount, postsize); http->writebytecount, postsize);
data->req.upload_done = TRUE; data->req.upload_done = TRUE;
data->req.keepon &= ~KEEP_SEND; /* we're done writing */ 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 happens for example when older Apache servers send large
files */ files */
conn->bits.close = TRUE; 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); ", closing after transfer\n", contentlength);
} }
} }

View File

@ -380,9 +380,9 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn,
keepon = 2; keepon = 2;
if(cl) { if(cl) {
infof(data, "Ignore %" CURL_FORMAT_CURL_OFF_T
infof(data, "Ignore %" FORMAT_OFF_T
" bytes of response-body\n", cl); " bytes of response-body\n", cl);
/* remove the remaining chunk of what we already /* remove the remaining chunk of what we already
read */ read */
cl -= (gotbytes - i); cl -= (gotbytes - i);

View File

@ -775,7 +775,7 @@ static CURLcode imap_perform_append(struct connectdata *conn)
return CURLE_OUT_OF_MEMORY; return CURLE_OUT_OF_MEMORY;
/* Send the APPEND command */ /* 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); mailbox, conn->data->set.infilesize);
Curl_safefree(mailbox); Curl_safefree(mailbox);
@ -1494,7 +1494,7 @@ static CURLcode imap_state_fetch_resp(struct connectdata *conn, int imapcode,
} }
if(parsed) { 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); Curl_pgrsSetDownloadSize(data, size);
if(pp->cache) { if(pp->cache) {
@ -1513,7 +1513,8 @@ static CURLcode imap_state_fetch_resp(struct connectdata *conn, int imapcode,
data->req.bytecount += chunk; 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, " bytes are left for transfer\n", (curl_off_t)chunk,
size - chunk); size - chunk);

View File

@ -986,7 +986,8 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
else { else {
k = &data->req; k = &data->req;
failf(data, "Operation timed out after %ld milliseconds with %" 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, Curl_tvdiff(now, data->progress.t_startsingle), k->bytecount,
k->size); k->size);
} }

View File

@ -85,8 +85,8 @@ bool Curl_pipeline_penalized(struct SessionHandle *data,
(curl_off_t)conn->chunk.datasize > chunk_penalty_size) (curl_off_t)conn->chunk.datasize > chunk_penalty_size)
penalized = TRUE; penalized = TRUE;
infof(data, "Conn: %ld (%p) Receive pipe weight: (%" FORMAT_OFF_T infof(data, "Conn: %ld (%p) Receive pipe weight: (%"
"/%zu), penalized: %s\n", CURL_FORMAT_CURL_OFF_T "/%zu), penalized: %s\n",
conn->connection_id, (void *)conn, recv_size, conn->connection_id, (void *)conn, recv_size,
conn->chunk.datasize, penalized?"TRUE":"FALSE"); conn->chunk.datasize, penalized?"TRUE":"FALSE");
return penalized; return penalized;

View File

@ -42,8 +42,8 @@ static void time2str(char *r, curl_off_t seconds)
if(h <= CURL_OFF_T_C(99)) { if(h <= CURL_OFF_T_C(99)) {
m = (seconds - (h*CURL_OFF_T_C(3600))) / CURL_OFF_T_C(60); 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)); 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, snprintf(r, 9, "%2" CURL_FORMAT_CURL_OFF_T ":%02" CURL_FORMAT_CURL_OFF_T
h, m, s); ":%02" CURL_FORMAT_CURL_OFF_T, h, m, s);
} }
else { else {
/* this equals to more than 99 hours, switch to a more suitable output /* 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); d = seconds / CURL_OFF_T_C(86400);
h = (seconds - (d*CURL_OFF_T_C(86400))) / CURL_OFF_T_C(3600); h = (seconds - (d*CURL_OFF_T_C(86400))) / CURL_OFF_T_C(3600);
if(d <= CURL_OFF_T_C(999)) 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 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) #define ONE_PETABYTE (CURL_OFF_T_C(1024) * ONE_TERABYTE)
if(bytes < CURL_OFF_T_C(100000)) 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) 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) else if(bytes < CURL_OFF_T_C(100) * ONE_MEGABYTE)
/* 'XX.XM' is good as long as we're less than 100 megs */ /* '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", snprintf(max5, 6, "%2" CURL_FORMAT_CURL_OFF_T ".%0"
bytes/ONE_MEGABYTE, CURL_FORMAT_CURL_OFF_T "M", bytes/ONE_MEGABYTE,
(bytes%ONE_MEGABYTE) / (ONE_MEGABYTE/CURL_OFF_T_C(10)) ); (bytes%ONE_MEGABYTE) / (ONE_MEGABYTE/CURL_OFF_T_C(10)) );
#if (CURL_SIZEOF_CURL_OFF_T > 4) #if (CURL_SIZEOF_CURL_OFF_T > 4)
else if(bytes < CURL_OFF_T_C(10000) * ONE_MEGABYTE) else if(bytes < CURL_OFF_T_C(10000) * ONE_MEGABYTE)
/* 'XXXXM' is good until we're at 10000MB or above */ /* '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) else if(bytes < CURL_OFF_T_C(100) * ONE_GIGABYTE)
/* 10000 MB - 100 GB, we show it as XX.XG */ /* 10000 MB - 100 GB, we show it as XX.XG */
snprintf(max5, 6, "%2" FORMAT_OFF_T ".%0" FORMAT_OFF_T "G", snprintf(max5, 6, "%2" CURL_FORMAT_CURL_OFF_T ".%0"
bytes/ONE_GIGABYTE, CURL_FORMAT_CURL_OFF_T "G", bytes/ONE_GIGABYTE,
(bytes%ONE_GIGABYTE) / (ONE_GIGABYTE/CURL_OFF_T_C(10)) ); (bytes%ONE_GIGABYTE) / (ONE_GIGABYTE/CURL_OFF_T_C(10)) );
else if(bytes < CURL_OFF_T_C(10000) * ONE_GIGABYTE) else if(bytes < CURL_OFF_T_C(10000) * ONE_GIGABYTE)
/* up to 10000GB, display without decimal: XXXXG */ /* 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) else if(bytes < CURL_OFF_T_C(10000) * ONE_TERABYTE)
/* up to 10000TB, display without decimal: XXXXT */ /* 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 else
/* up to 10000PB, display without decimal: XXXXP */ /* 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 /* 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. */ 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
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 #endif
@ -392,8 +393,8 @@ int Curl_pgrsUpdate(struct connectdata *conn)
if(!(data->progress.flags & PGRS_HEADERS_OUT)) { if(!(data->progress.flags & PGRS_HEADERS_OUT)) {
if(data->state.resume_from) { if(data->state.resume_from) {
fprintf(data->set.err, fprintf(data->set.err,
"** Resuming transfer from byte position %" FORMAT_OFF_T "\n", "** Resuming transfer from byte position %"
data->state.resume_from); CURL_FORMAT_CURL_OFF_T "\n", data->state.resume_from);
} }
fprintf(data->set.err, fprintf(data->set.err,
" %% Total %% Received %% Xferd Average Speed " " %% Total %% Received %% Xferd Average Speed "
@ -457,9 +458,9 @@ int Curl_pgrsUpdate(struct connectdata *conn)
fprintf(data->set.err, fprintf(data->set.err,
"\r" "\r"
"%3" FORMAT_OFF_T " %s " "%3" CURL_FORMAT_CURL_OFF_T " %s "
"%3" FORMAT_OFF_T " %s " "%3" CURL_FORMAT_CURL_OFF_T " %s "
"%3" FORMAT_OFF_T " %s %s %s %s %s %s %s", "%3" CURL_FORMAT_CURL_OFF_T " %s %s %s %s %s %s %s",
total_percen, /* 3 letters */ /* total % */ total_percen, /* 3 letters */ /* total % */
max5data(total_expected_transfer, max5[2]), /* total size */ max5data(total_expected_transfer, max5[2]), /* total size */
dlpercen, /* 3 letters */ /* rcvd % */ dlpercen, /* 3 letters */ /* rcvd % */

View File

@ -509,7 +509,7 @@ static CURLcode rtsp_do(struct connectdata *conn, bool *done)
* actually set a custom Content-Length in the headers */ * actually set a custom Content-Length in the headers */
if(!Curl_checkheaders(data, "Content-Length:")) { if(!Curl_checkheaders(data, "Content-Length:")) {
result = Curl_add_bufferf(req_buffer, 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)); (data->set.upload ? putsize : postsize));
if(result) if(result)
return result; return result;

View File

@ -582,7 +582,7 @@ static CURLcode smtp_perform_mail(struct connectdata *conn)
/* Calculate the optional SIZE parameter */ /* Calculate the optional SIZE parameter */
if(conn->proto.smtpc.size_supported && conn->data->set.infilesize > 0) { 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) { if(!size) {
Curl_safefree(from); Curl_safefree(from);

View File

@ -1602,7 +1602,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
else { else {
curl_off_t size = attrs.filesize; curl_off_t size = attrs.filesize;
if(size < 0) { 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; return CURLE_BAD_DOWNLOAD_RESUME;
} }
data->state.resume_from = attrs.filesize; 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; curl_off_t size = attrs.filesize;
if(size < 0) { 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; return CURLE_BAD_DOWNLOAD_RESUME;
} }
if(conn->data->state.use_range) { if(conn->data->state.use_range) {
@ -2092,8 +2092,8 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
} }
if(from >= size) { if(from >= size) {
failf(data, "Offset (%" failf(data, "Offset (%"
FORMAT_OFF_T ") was beyond file size (%" FORMAT_OFF_T ")", CURL_FORMAT_CURL_OFF_T ") was beyond file size (%"
from, attrs.filesize); CURL_FORMAT_CURL_OFF_T ")", from, attrs.filesize);
return CURLE_BAD_DOWNLOAD_RESUME; return CURLE_BAD_DOWNLOAD_RESUME;
} }
if(from > to) { 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 */ /* We're supposed to download the last abs(from) bytes */
if((curl_off_t)attrs.filesize < -data->state.resume_from) { if((curl_off_t)attrs.filesize < -data->state.resume_from) {
failf(data, "Offset (%" 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); data->state.resume_from, attrs.filesize);
return CURLE_BAD_DOWNLOAD_RESUME; return CURLE_BAD_DOWNLOAD_RESUME;
} }
@ -2126,8 +2127,8 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
} }
else { else {
if((curl_off_t)attrs.filesize < data->state.resume_from) { if((curl_off_t)attrs.filesize < data->state.resume_from) {
failf(data, "Offset (%" FORMAT_OFF_T failf(data, "Offset (%" CURL_FORMAT_CURL_OFF_T
") was beyond file size (%" FORMAT_OFF_T ")", ") was beyond file size (%" CURL_FORMAT_CURL_OFF_T ")",
data->state.resume_from, attrs.filesize); data->state.resume_from, attrs.filesize);
return CURLE_BAD_DOWNLOAD_RESUME; return CURLE_BAD_DOWNLOAD_RESUME;
} }

View File

@ -499,7 +499,8 @@ static CURLcode tftp_send_first(tftp_state_data_t *state, tftp_event_t event)
/* add tsize option */ /* add tsize option */
if(data->set.upload && (data->set.infilesize != -1)) 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 else
strcpy(buf, "0"); /* the destination is large enough */ strcpy(buf, "0"); /* the destination is large enough */

View File

@ -646,9 +646,9 @@ static CURLcode readwrite_data(struct SessionHandle *data,
always will fit in a size_t */ always will fit in a size_t */
infof(data, infof(data,
"Rewinding stream by : %zu" "Rewinding stream by : %zu"
" bytes on url %s (size = %" FORMAT_OFF_T " bytes on url %s (size = %" CURL_FORMAT_CURL_OFF_T
", maxdownload = %" FORMAT_OFF_T ", maxdownload = %" CURL_FORMAT_CURL_OFF_T
", bytecount = %" FORMAT_OFF_T ", nread = %zd)\n", ", bytecount = %" CURL_FORMAT_CURL_OFF_T ", nread = %zd)\n",
excess, data->state.path, excess, data->state.path,
k->size, k->maxdownload, k->bytecount, nread); k->size, k->maxdownload, k->bytecount, nread);
read_rewind(conn, excess); read_rewind(conn, excess);
@ -657,9 +657,9 @@ static CURLcode readwrite_data(struct SessionHandle *data,
infof(data, infof(data,
"Excess found in a non pipelined read:" "Excess found in a non pipelined read:"
" excess = %zu" " excess = %zu"
", size = %" FORMAT_OFF_T ", size = %" CURL_FORMAT_CURL_OFF_T
", maxdownload = %" FORMAT_OFF_T ", maxdownload = %" CURL_FORMAT_CURL_OFF_T
", bytecount = %" FORMAT_OFF_T "\n", ", bytecount = %" CURL_FORMAT_CURL_OFF_T "\n",
excess, k->size, k->maxdownload, k->bytecount); 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(0 > Curl_timeleft(data, &k->now, FALSE)) {
if(k->size != -1) { if(k->size != -1) {
failf(data, "Operation timed out after %ld milliseconds with %" 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, Curl_tvdiff(k->now, data->progress.t_startsingle), k->bytecount,
k->size); k->size);
} }
else { else {
failf(data, "Operation timed out after %ld milliseconds with %" 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); Curl_tvdiff(k->now, data->progress.t_startsingle), k->bytecount);
} }
return CURLE_OPERATION_TIMEDOUT; return CURLE_OPERATION_TIMEDOUT;
@ -1123,7 +1124,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
(k->bytecount != (k->size + data->state.crlf_conversions)) && (k->bytecount != (k->size + data->state.crlf_conversions)) &&
#endif /* CURL_DO_LINEEND_CONV */ #endif /* CURL_DO_LINEEND_CONV */
!data->req.newurl) { !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", " bytes remaining to read",
k->size - k->bytecount); k->size - k->bytecount);
return CURLE_PARTIAL_FILE; return CURLE_PARTIAL_FILE;

View File

@ -3991,7 +3991,7 @@ static CURLcode setup_range(struct SessionHandle *data)
free(s->range); free(s->range);
if(s->resume_from) 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 else
s->range = strdup(data->set.str[STRING_SET_RANGE]); s->range = strdup(data->set.str[STRING_SET_RANGE]);

View File

@ -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 * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * 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[j] = 'X';
co_test[i].result[BUFSZ-1] = '\0'; 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, if(memcmp(co_test[i].result,
co_test[i].expected, co_test[i].expected,