tool_writeout: use off_t getinfo-types instead of doubles

Commit 3b80d3ca46 (June 2017) introduced getinfo replacement
variables that use curl_off_t instead of doubles. Switch the --write-out
function over to use them.

Closes #6248
This commit is contained in:
Daniel Stenberg 2020-11-25 15:06:56 +01:00
parent 12cb7a1fe0
commit fc813f80e1
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2
1 changed files with 29 additions and 30 deletions

View File

@ -112,7 +112,7 @@ void ourWriteOut(CURL *curl, struct per_transfer *per, const char *writeinfo)
const char *ptr = writeinfo; const char *ptr = writeinfo;
char *stringp = NULL; char *stringp = NULL;
long longinfo; long longinfo;
double doubleinfo; curl_off_t offinfo;
while(ptr && *ptr) { while(ptr && *ptr) {
if('%' == *ptr && ptr[1]) { if('%' == *ptr && ptr[1]) {
@ -189,65 +189,64 @@ void ourWriteOut(CURL *curl, struct per_transfer *per, const char *writeinfo)
break; break;
case VAR_REDIRECT_TIME: case VAR_REDIRECT_TIME:
if(CURLE_OK == if(CURLE_OK ==
curl_easy_getinfo(curl, CURLINFO_REDIRECT_TIME, curl_easy_getinfo(curl, CURLINFO_REDIRECT_TIME_T, &offinfo))
&doubleinfo)) fprintf(stream, "%" CURL_FORMAT_CURL_OFF_TU, offinfo);
fprintf(stream, "%.6f", doubleinfo);
break; break;
case VAR_TOTAL_TIME: case VAR_TOTAL_TIME:
if(CURLE_OK == if(CURLE_OK ==
curl_easy_getinfo(curl, CURLINFO_TOTAL_TIME, &doubleinfo)) curl_easy_getinfo(curl, CURLINFO_TOTAL_TIME_T, &offinfo))
fprintf(stream, "%.6f", doubleinfo); fprintf(stream, "%" CURL_FORMAT_CURL_OFF_TU, offinfo);
break; break;
case VAR_NAMELOOKUP_TIME: case VAR_NAMELOOKUP_TIME:
if(CURLE_OK == if(CURLE_OK ==
curl_easy_getinfo(curl, CURLINFO_NAMELOOKUP_TIME, curl_easy_getinfo(curl, CURLINFO_NAMELOOKUP_TIME_T,
&doubleinfo)) &offinfo))
fprintf(stream, "%.6f", doubleinfo); fprintf(stream, "%" CURL_FORMAT_CURL_OFF_TU, offinfo);
break; break;
case VAR_CONNECT_TIME: case VAR_CONNECT_TIME:
if(CURLE_OK == if(CURLE_OK ==
curl_easy_getinfo(curl, CURLINFO_CONNECT_TIME, &doubleinfo)) curl_easy_getinfo(curl, CURLINFO_CONNECT_TIME_T, &offinfo))
fprintf(stream, "%.6f", doubleinfo); fprintf(stream, "%" CURL_FORMAT_CURL_OFF_TU, offinfo);
break; break;
case VAR_APPCONNECT_TIME: case VAR_APPCONNECT_TIME:
if(CURLE_OK == if(CURLE_OK ==
curl_easy_getinfo(curl, CURLINFO_APPCONNECT_TIME, curl_easy_getinfo(curl, CURLINFO_APPCONNECT_TIME_T,
&doubleinfo)) &offinfo))
fprintf(stream, "%.6f", doubleinfo); fprintf(stream, "%" CURL_FORMAT_CURL_OFF_TU, offinfo);
break; break;
case VAR_PRETRANSFER_TIME: case VAR_PRETRANSFER_TIME:
if(CURLE_OK == if(CURLE_OK ==
curl_easy_getinfo(curl, CURLINFO_PRETRANSFER_TIME, curl_easy_getinfo(curl, CURLINFO_PRETRANSFER_TIME_T,
&doubleinfo)) &offinfo))
fprintf(stream, "%.6f", doubleinfo); fprintf(stream, "%" CURL_FORMAT_CURL_OFF_TU, offinfo);
break; break;
case VAR_STARTTRANSFER_TIME: case VAR_STARTTRANSFER_TIME:
if(CURLE_OK == if(CURLE_OK ==
curl_easy_getinfo(curl, CURLINFO_STARTTRANSFER_TIME, curl_easy_getinfo(curl, CURLINFO_STARTTRANSFER_TIME_T,
&doubleinfo)) &offinfo))
fprintf(stream, "%.6f", doubleinfo); fprintf(stream, "%" CURL_FORMAT_CURL_OFF_TU, offinfo);
break; break;
case VAR_SIZE_UPLOAD: case VAR_SIZE_UPLOAD:
if(CURLE_OK == if(CURLE_OK ==
curl_easy_getinfo(curl, CURLINFO_SIZE_UPLOAD, &doubleinfo)) curl_easy_getinfo(curl, CURLINFO_SIZE_UPLOAD_T, &offinfo))
fprintf(stream, "%.0f", doubleinfo); fprintf(stream, "%" CURL_FORMAT_CURL_OFF_TU, offinfo);
break; break;
case VAR_SIZE_DOWNLOAD: case VAR_SIZE_DOWNLOAD:
if(CURLE_OK == if(CURLE_OK ==
curl_easy_getinfo(curl, CURLINFO_SIZE_DOWNLOAD, curl_easy_getinfo(curl, CURLINFO_SIZE_DOWNLOAD_T,
&doubleinfo)) &offinfo))
fprintf(stream, "%.0f", doubleinfo); fprintf(stream, "%" CURL_FORMAT_CURL_OFF_TU, offinfo);
break; break;
case VAR_SPEED_DOWNLOAD: case VAR_SPEED_DOWNLOAD:
if(CURLE_OK == if(CURLE_OK ==
curl_easy_getinfo(curl, CURLINFO_SPEED_DOWNLOAD, curl_easy_getinfo(curl, CURLINFO_SPEED_DOWNLOAD_T,
&doubleinfo)) &offinfo))
fprintf(stream, "%.3f", doubleinfo); fprintf(stream, "%" CURL_FORMAT_CURL_OFF_TU, offinfo);
break; break;
case VAR_SPEED_UPLOAD: case VAR_SPEED_UPLOAD:
if(CURLE_OK == if(CURLE_OK ==
curl_easy_getinfo(curl, CURLINFO_SPEED_UPLOAD, &doubleinfo)) curl_easy_getinfo(curl, CURLINFO_SPEED_UPLOAD_T, &offinfo))
fprintf(stream, "%.3f", doubleinfo); fprintf(stream, "%" CURL_FORMAT_CURL_OFF_TU, offinfo);
break; break;
case VAR_CONTENT_TYPE: case VAR_CONTENT_TYPE:
if((CURLE_OK == if((CURLE_OK ==