progress.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583
  1. /***************************************************************************
  2. * _ _ ____ _
  3. * Project ___| | | | _ \| |
  4. * / __| | | | |_) | |
  5. * | (__| |_| | _ <| |___
  6. * \___|\___/|_| \_\_____|
  7. *
  8. * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
  9. *
  10. * This software is licensed as described in the file COPYING, which
  11. * you should have received as part of this distribution. The terms
  12. * are also available at https://curl.haxx.se/docs/copyright.html.
  13. *
  14. * You may opt to use, copy, modify, merge, publish, distribute and/or sell
  15. * copies of the Software, and permit persons to whom the Software is
  16. * furnished to do so, under the terms of the COPYING file.
  17. *
  18. * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  19. * KIND, either express or implied.
  20. *
  21. ***************************************************************************/
  22. #include "curl_setup.h"
  23. #include "urldata.h"
  24. #include "sendf.h"
  25. #include "progress.h"
  26. #include "curl_printf.h"
  27. /* Provide a string that is 2 + 1 + 2 + 1 + 2 = 8 letters long (plus the zero
  28. byte) */
  29. static void time2str(char *r, curl_off_t seconds)
  30. {
  31. curl_off_t d, h, m, s;
  32. if(seconds <= 0) {
  33. strcpy(r, "--:--:--");
  34. return;
  35. }
  36. h = seconds / CURL_OFF_T_C(3600);
  37. if(h <= CURL_OFF_T_C(99)) {
  38. m = (seconds - (h*CURL_OFF_T_C(3600))) / CURL_OFF_T_C(60);
  39. s = (seconds - (h*CURL_OFF_T_C(3600))) - (m*CURL_OFF_T_C(60));
  40. snprintf(r, 9, "%2" CURL_FORMAT_CURL_OFF_T ":%02" CURL_FORMAT_CURL_OFF_T
  41. ":%02" CURL_FORMAT_CURL_OFF_T, h, m, s);
  42. }
  43. else {
  44. /* this equals to more than 99 hours, switch to a more suitable output
  45. format to fit within the limits. */
  46. d = seconds / CURL_OFF_T_C(86400);
  47. h = (seconds - (d*CURL_OFF_T_C(86400))) / CURL_OFF_T_C(3600);
  48. if(d <= CURL_OFF_T_C(999))
  49. snprintf(r, 9, "%3" CURL_FORMAT_CURL_OFF_T
  50. "d %02" CURL_FORMAT_CURL_OFF_T "h", d, h);
  51. else
  52. snprintf(r, 9, "%7" CURL_FORMAT_CURL_OFF_T "d", d);
  53. }
  54. }
  55. /* The point of this function would be to return a string of the input data,
  56. but never longer than 5 columns (+ one zero byte).
  57. Add suffix k, M, G when suitable... */
  58. static char *max5data(curl_off_t bytes, char *max5)
  59. {
  60. #define ONE_KILOBYTE CURL_OFF_T_C(1024)
  61. #define ONE_MEGABYTE (CURL_OFF_T_C(1024) * ONE_KILOBYTE)
  62. #define ONE_GIGABYTE (CURL_OFF_T_C(1024) * ONE_MEGABYTE)
  63. #define ONE_TERABYTE (CURL_OFF_T_C(1024) * ONE_GIGABYTE)
  64. #define ONE_PETABYTE (CURL_OFF_T_C(1024) * ONE_TERABYTE)
  65. if(bytes < CURL_OFF_T_C(100000))
  66. snprintf(max5, 6, "%5" CURL_FORMAT_CURL_OFF_T, bytes);
  67. else if(bytes < CURL_OFF_T_C(10000) * ONE_KILOBYTE)
  68. snprintf(max5, 6, "%4" CURL_FORMAT_CURL_OFF_T "k", bytes/ONE_KILOBYTE);
  69. else if(bytes < CURL_OFF_T_C(100) * ONE_MEGABYTE)
  70. /* 'XX.XM' is good as long as we're less than 100 megs */
  71. snprintf(max5, 6, "%2" CURL_FORMAT_CURL_OFF_T ".%0"
  72. CURL_FORMAT_CURL_OFF_T "M", bytes/ONE_MEGABYTE,
  73. (bytes%ONE_MEGABYTE) / (ONE_MEGABYTE/CURL_OFF_T_C(10)) );
  74. #if (CURL_SIZEOF_CURL_OFF_T > 4)
  75. else if(bytes < CURL_OFF_T_C(10000) * ONE_MEGABYTE)
  76. /* 'XXXXM' is good until we're at 10000MB or above */
  77. snprintf(max5, 6, "%4" CURL_FORMAT_CURL_OFF_T "M", bytes/ONE_MEGABYTE);
  78. else if(bytes < CURL_OFF_T_C(100) * ONE_GIGABYTE)
  79. /* 10000 MB - 100 GB, we show it as XX.XG */
  80. snprintf(max5, 6, "%2" CURL_FORMAT_CURL_OFF_T ".%0"
  81. CURL_FORMAT_CURL_OFF_T "G", bytes/ONE_GIGABYTE,
  82. (bytes%ONE_GIGABYTE) / (ONE_GIGABYTE/CURL_OFF_T_C(10)) );
  83. else if(bytes < CURL_OFF_T_C(10000) * ONE_GIGABYTE)
  84. /* up to 10000GB, display without decimal: XXXXG */
  85. snprintf(max5, 6, "%4" CURL_FORMAT_CURL_OFF_T "G", bytes/ONE_GIGABYTE);
  86. else if(bytes < CURL_OFF_T_C(10000) * ONE_TERABYTE)
  87. /* up to 10000TB, display without decimal: XXXXT */
  88. snprintf(max5, 6, "%4" CURL_FORMAT_CURL_OFF_T "T", bytes/ONE_TERABYTE);
  89. else
  90. /* up to 10000PB, display without decimal: XXXXP */
  91. snprintf(max5, 6, "%4" CURL_FORMAT_CURL_OFF_T "P", bytes/ONE_PETABYTE);
  92. /* 16384 petabytes (16 exabytes) is the maximum a 64 bit unsigned number
  93. can hold, but our data type is signed so 8192PB will be the maximum. */
  94. #else
  95. else
  96. snprintf(max5, 6, "%4" CURL_FORMAT_CURL_OFF_T "M", bytes/ONE_MEGABYTE);
  97. #endif
  98. return max5;
  99. }
  100. /*
  101. New proposed interface, 9th of February 2000:
  102. pgrsStartNow() - sets start time
  103. pgrsSetDownloadSize(x) - known expected download size
  104. pgrsSetUploadSize(x) - known expected upload size
  105. pgrsSetDownloadCounter() - amount of data currently downloaded
  106. pgrsSetUploadCounter() - amount of data currently uploaded
  107. pgrsUpdate() - show progress
  108. pgrsDone() - transfer complete
  109. */
  110. int Curl_pgrsDone(struct connectdata *conn)
  111. {
  112. int rc;
  113. struct Curl_easy *data = conn->data;
  114. data->progress.lastshow = 0;
  115. rc = Curl_pgrsUpdate(conn); /* the final (forced) update */
  116. if(rc)
  117. return rc;
  118. if(!(data->progress.flags & PGRS_HIDE) &&
  119. !data->progress.callback)
  120. /* only output if we don't use a progress callback and we're not
  121. * hidden */
  122. fprintf(data->set.err, "\n");
  123. data->progress.speeder_c = 0; /* reset the progress meter display */
  124. return 0;
  125. }
  126. /* reset the known transfer sizes */
  127. void Curl_pgrsResetTransferSizes(struct Curl_easy *data)
  128. {
  129. Curl_pgrsSetDownloadSize(data, -1);
  130. Curl_pgrsSetUploadSize(data, -1);
  131. }
  132. /*
  133. * @unittest: 1399
  134. */
  135. void Curl_pgrsTime(struct Curl_easy *data, timerid timer)
  136. {
  137. struct curltime now = Curl_now();
  138. time_t *delta = NULL;
  139. switch(timer) {
  140. default:
  141. case TIMER_NONE:
  142. /* mistake filter */
  143. break;
  144. case TIMER_STARTOP:
  145. /* This is set at the start of a transfer */
  146. data->progress.t_startop = now;
  147. break;
  148. case TIMER_STARTSINGLE:
  149. /* This is set at the start of each single fetch */
  150. data->progress.t_startsingle = now;
  151. data->progress.is_t_startransfer_set = false;
  152. break;
  153. case TIMER_STARTACCEPT:
  154. data->progress.t_acceptdata = now;
  155. break;
  156. case TIMER_NAMELOOKUP:
  157. delta = &data->progress.t_nslookup;
  158. break;
  159. case TIMER_CONNECT:
  160. delta = &data->progress.t_connect;
  161. break;
  162. case TIMER_APPCONNECT:
  163. delta = &data->progress.t_appconnect;
  164. break;
  165. case TIMER_PRETRANSFER:
  166. delta = &data->progress.t_pretransfer;
  167. break;
  168. case TIMER_STARTTRANSFER:
  169. delta = &data->progress.t_starttransfer;
  170. /* prevent updating t_starttransfer unless:
  171. * 1) this is the first time we're setting t_starttransfer
  172. * 2) a redirect has occurred since the last time t_starttransfer was set
  173. * This prevents repeated invocations of the function from incorrectly
  174. * changing the t_starttransfer time.
  175. */
  176. if(data->progress.is_t_startransfer_set) {
  177. return;
  178. }
  179. else {
  180. data->progress.is_t_startransfer_set = true;
  181. break;
  182. }
  183. case TIMER_POSTRANSFER:
  184. /* this is the normal end-of-transfer thing */
  185. break;
  186. case TIMER_REDIRECT:
  187. data->progress.t_redirect = Curl_timediff_us(now, data->progress.start);
  188. break;
  189. }
  190. if(delta) {
  191. timediff_t us = Curl_timediff_us(now, data->progress.t_startsingle);
  192. if(us < 1)
  193. us = 1; /* make sure at least one microsecond passed */
  194. *delta += us;
  195. }
  196. }
  197. void Curl_pgrsStartNow(struct Curl_easy *data)
  198. {
  199. data->progress.speeder_c = 0; /* reset the progress meter display */
  200. data->progress.start = Curl_now();
  201. data->progress.is_t_startransfer_set = false;
  202. data->progress.ul_limit_start.tv_sec = 0;
  203. data->progress.ul_limit_start.tv_usec = 0;
  204. data->progress.dl_limit_start.tv_sec = 0;
  205. data->progress.dl_limit_start.tv_usec = 0;
  206. /* clear all bits except HIDE and HEADERS_OUT */
  207. data->progress.flags &= PGRS_HIDE|PGRS_HEADERS_OUT;
  208. }
  209. /*
  210. * This is used to handle speed limits, calculating how much milliseconds we
  211. * need to wait until we're back under the speed limit, if needed.
  212. *
  213. * The way it works is by having a "starting point" (time & amount of data
  214. * transferred by then) used in the speed computation, to be used instead of
  215. * the start of the transfer. This starting point is regularly moved as
  216. * transfer goes on, to keep getting accurate values (instead of average over
  217. * the entire transfer).
  218. *
  219. * This function takes the current amount of data transferred, the amount at
  220. * the starting point, the limit (in bytes/s), the time of the starting point
  221. * and the current time.
  222. *
  223. * Returns -1 if no waiting is needed (not enough data transferred since
  224. * starting point yet), 0 when no waiting is needed but the starting point
  225. * should be reset (to current), or the number of milliseconds to wait to get
  226. * back under the speed limit.
  227. */
  228. long Curl_pgrsLimitWaitTime(curl_off_t cursize,
  229. curl_off_t startsize,
  230. curl_off_t limit,
  231. struct curltime start,
  232. struct curltime now)
  233. {
  234. curl_off_t size = cursize - startsize;
  235. time_t minimum;
  236. time_t actual;
  237. /* we don't have a starting point yet -- return 0 so it gets (re)set */
  238. if(start.tv_sec == 0 && start.tv_usec == 0)
  239. return 0;
  240. /* not enough data yet */
  241. if(size < limit)
  242. return -1;
  243. minimum = (time_t) (CURL_OFF_T_C(1000) * size / limit);
  244. actual = Curl_timediff(now, start);
  245. if(actual < minimum)
  246. /* this is a conversion on some systems (64bit time_t => 32bit long) */
  247. return (long)(minimum - actual);
  248. return 0;
  249. }
  250. void Curl_pgrsSetDownloadCounter(struct Curl_easy *data, curl_off_t size)
  251. {
  252. struct curltime now = Curl_now();
  253. data->progress.downloaded = size;
  254. /* download speed limit */
  255. if((data->set.max_recv_speed > 0) &&
  256. (Curl_pgrsLimitWaitTime(data->progress.downloaded,
  257. data->progress.dl_limit_size,
  258. data->set.max_recv_speed,
  259. data->progress.dl_limit_start,
  260. now) == 0)) {
  261. data->progress.dl_limit_start = now;
  262. data->progress.dl_limit_size = size;
  263. }
  264. }
  265. void Curl_pgrsSetUploadCounter(struct Curl_easy *data, curl_off_t size)
  266. {
  267. struct curltime now = Curl_now();
  268. data->progress.uploaded = size;
  269. /* upload speed limit */
  270. if((data->set.max_send_speed > 0) &&
  271. (Curl_pgrsLimitWaitTime(data->progress.uploaded,
  272. data->progress.ul_limit_size,
  273. data->set.max_send_speed,
  274. data->progress.ul_limit_start,
  275. now) == 0)) {
  276. data->progress.ul_limit_start = now;
  277. data->progress.ul_limit_size = size;
  278. }
  279. }
  280. void Curl_pgrsSetDownloadSize(struct Curl_easy *data, curl_off_t size)
  281. {
  282. if(size >= 0) {
  283. data->progress.size_dl = size;
  284. data->progress.flags |= PGRS_DL_SIZE_KNOWN;
  285. }
  286. else {
  287. data->progress.size_dl = 0;
  288. data->progress.flags &= ~PGRS_DL_SIZE_KNOWN;
  289. }
  290. }
  291. void Curl_pgrsSetUploadSize(struct Curl_easy *data, curl_off_t size)
  292. {
  293. if(size >= 0) {
  294. data->progress.size_ul = size;
  295. data->progress.flags |= PGRS_UL_SIZE_KNOWN;
  296. }
  297. else {
  298. data->progress.size_ul = 0;
  299. data->progress.flags &= ~PGRS_UL_SIZE_KNOWN;
  300. }
  301. }
  302. /*
  303. * Curl_pgrsUpdate() returns 0 for success or the value returned by the
  304. * progress callback!
  305. */
  306. int Curl_pgrsUpdate(struct connectdata *conn)
  307. {
  308. struct curltime now;
  309. int result;
  310. char max5[6][10];
  311. curl_off_t dlpercen = 0;
  312. curl_off_t ulpercen = 0;
  313. curl_off_t total_percen = 0;
  314. curl_off_t total_transfer;
  315. curl_off_t total_expected_transfer;
  316. curl_off_t timespent;
  317. curl_off_t timespent_ms; /* milliseconds */
  318. struct Curl_easy *data = conn->data;
  319. int nowindex = data->progress.speeder_c% CURR_TIME;
  320. int checkindex;
  321. int countindex; /* amount of seconds stored in the speeder array */
  322. char time_left[10];
  323. char time_total[10];
  324. char time_spent[10];
  325. curl_off_t ulestimate = 0;
  326. curl_off_t dlestimate = 0;
  327. curl_off_t total_estimate;
  328. bool shownow = FALSE;
  329. curl_off_t dl = data->progress.downloaded;
  330. curl_off_t ul = data->progress.uploaded;
  331. now = Curl_now(); /* what time is it */
  332. /* The time spent so far (from the start) */
  333. data->progress.timespent = Curl_timediff_us(now, data->progress.start);
  334. timespent = (curl_off_t)data->progress.timespent/1000000; /* seconds */
  335. timespent_ms = (curl_off_t)data->progress.timespent/1000; /* ms */
  336. /* The average download speed this far */
  337. if(dl < CURL_OFF_T_MAX/1000)
  338. data->progress.dlspeed = (dl * 1000 / (timespent_ms>0?timespent_ms:1));
  339. else
  340. data->progress.dlspeed = (dl / (timespent>0?timespent:1));
  341. /* The average upload speed this far */
  342. if(ul < CURL_OFF_T_MAX/1000)
  343. data->progress.ulspeed = (ul * 1000 / (timespent_ms>0?timespent_ms:1));
  344. else
  345. data->progress.ulspeed = (ul / (timespent>0?timespent:1));
  346. /* Calculations done at most once a second, unless end is reached */
  347. if(data->progress.lastshow != now.tv_sec) {
  348. shownow = TRUE;
  349. data->progress.lastshow = now.tv_sec;
  350. /* Let's do the "current speed" thing, with the dl + ul speeds
  351. combined. Store the speed at entry 'nowindex'. */
  352. data->progress.speeder[ nowindex ] =
  353. data->progress.downloaded + data->progress.uploaded;
  354. /* remember the exact time for this moment */
  355. data->progress.speeder_time [ nowindex ] = now;
  356. /* advance our speeder_c counter, which is increased every time we get
  357. here and we expect it to never wrap as 2^32 is a lot of seconds! */
  358. data->progress.speeder_c++;
  359. /* figure out how many index entries of data we have stored in our speeder
  360. array. With N_ENTRIES filled in, we have about N_ENTRIES-1 seconds of
  361. transfer. Imagine, after one second we have filled in two entries,
  362. after two seconds we've filled in three entries etc. */
  363. countindex = ((data->progress.speeder_c >= CURR_TIME)?
  364. CURR_TIME:data->progress.speeder_c) - 1;
  365. /* first of all, we don't do this if there's no counted seconds yet */
  366. if(countindex) {
  367. timediff_t span_ms;
  368. /* Get the index position to compare with the 'nowindex' position.
  369. Get the oldest entry possible. While we have less than CURR_TIME
  370. entries, the first entry will remain the oldest. */
  371. checkindex = (data->progress.speeder_c >= CURR_TIME)?
  372. data->progress.speeder_c%CURR_TIME:0;
  373. /* Figure out the exact time for the time span */
  374. span_ms = Curl_timediff(now,
  375. data->progress.speeder_time[checkindex]);
  376. if(0 == span_ms)
  377. span_ms = 1; /* at least one millisecond MUST have passed */
  378. /* Calculate the average speed the last 'span_ms' milliseconds */
  379. {
  380. curl_off_t amount = data->progress.speeder[nowindex]-
  381. data->progress.speeder[checkindex];
  382. if(amount > CURL_OFF_T_C(4294967) /* 0xffffffff/1000 */)
  383. /* the 'amount' value is bigger than would fit in 32 bits if
  384. multiplied with 1000, so we use the double math for this */
  385. data->progress.current_speed = (curl_off_t)
  386. ((double)amount/((double)span_ms/1000.0));
  387. else
  388. /* the 'amount' value is small enough to fit within 32 bits even
  389. when multiplied with 1000 */
  390. data->progress.current_speed = amount*CURL_OFF_T_C(1000)/span_ms;
  391. }
  392. }
  393. else
  394. /* the first second we use the average */
  395. data->progress.current_speed =
  396. data->progress.ulspeed + data->progress.dlspeed;
  397. } /* Calculations end */
  398. if(!(data->progress.flags & PGRS_HIDE)) {
  399. /* progress meter has not been shut off */
  400. if(data->set.fxferinfo) {
  401. /* There's a callback set, call that */
  402. result = data->set.fxferinfo(data->set.progress_client,
  403. data->progress.size_dl,
  404. data->progress.downloaded,
  405. data->progress.size_ul,
  406. data->progress.uploaded);
  407. if(result)
  408. failf(data, "Callback aborted");
  409. return result;
  410. }
  411. if(data->set.fprogress) {
  412. /* The older deprecated callback is set, call that */
  413. result = data->set.fprogress(data->set.progress_client,
  414. (double)data->progress.size_dl,
  415. (double)data->progress.downloaded,
  416. (double)data->progress.size_ul,
  417. (double)data->progress.uploaded);
  418. if(result)
  419. failf(data, "Callback aborted");
  420. return result;
  421. }
  422. if(!shownow)
  423. /* only show the internal progress meter once per second */
  424. return 0;
  425. /* If there's no external callback set, use internal code to show
  426. progress */
  427. if(!(data->progress.flags & PGRS_HEADERS_OUT)) {
  428. if(data->state.resume_from) {
  429. fprintf(data->set.err,
  430. "** Resuming transfer from byte position %"
  431. CURL_FORMAT_CURL_OFF_T "\n", data->state.resume_from);
  432. }
  433. fprintf(data->set.err,
  434. " %% Total %% Received %% Xferd Average Speed "
  435. "Time Time Time Current\n"
  436. " Dload Upload "
  437. "Total Spent Left Speed\n");
  438. data->progress.flags |= PGRS_HEADERS_OUT; /* headers are shown */
  439. }
  440. /* Figure out the estimated time of arrival for the upload */
  441. if((data->progress.flags & PGRS_UL_SIZE_KNOWN) &&
  442. (data->progress.ulspeed > CURL_OFF_T_C(0))) {
  443. ulestimate = data->progress.size_ul / data->progress.ulspeed;
  444. if(data->progress.size_ul > CURL_OFF_T_C(10000))
  445. ulpercen = data->progress.uploaded /
  446. (data->progress.size_ul/CURL_OFF_T_C(100));
  447. else if(data->progress.size_ul > CURL_OFF_T_C(0))
  448. ulpercen = (data->progress.uploaded*100) /
  449. data->progress.size_ul;
  450. }
  451. /* ... and the download */
  452. if((data->progress.flags & PGRS_DL_SIZE_KNOWN) &&
  453. (data->progress.dlspeed > CURL_OFF_T_C(0))) {
  454. dlestimate = data->progress.size_dl / data->progress.dlspeed;
  455. if(data->progress.size_dl > CURL_OFF_T_C(10000))
  456. dlpercen = data->progress.downloaded /
  457. (data->progress.size_dl/CURL_OFF_T_C(100));
  458. else if(data->progress.size_dl > CURL_OFF_T_C(0))
  459. dlpercen = (data->progress.downloaded*100) /
  460. data->progress.size_dl;
  461. }
  462. /* Now figure out which of them is slower and use that one for the
  463. total estimate! */
  464. total_estimate = ulestimate>dlestimate?ulestimate:dlestimate;
  465. /* create the three time strings */
  466. time2str(time_left, total_estimate > 0?(total_estimate - timespent):0);
  467. time2str(time_total, total_estimate);
  468. time2str(time_spent, timespent);
  469. /* Get the total amount of data expected to get transferred */
  470. total_expected_transfer =
  471. (data->progress.flags & PGRS_UL_SIZE_KNOWN?
  472. data->progress.size_ul:data->progress.uploaded)+
  473. (data->progress.flags & PGRS_DL_SIZE_KNOWN?
  474. data->progress.size_dl:data->progress.downloaded);
  475. /* We have transferred this much so far */
  476. total_transfer = data->progress.downloaded + data->progress.uploaded;
  477. /* Get the percentage of data transferred so far */
  478. if(total_expected_transfer > CURL_OFF_T_C(10000))
  479. total_percen = total_transfer /
  480. (total_expected_transfer/CURL_OFF_T_C(100));
  481. else if(total_expected_transfer > CURL_OFF_T_C(0))
  482. total_percen = (total_transfer*100) / total_expected_transfer;
  483. fprintf(data->set.err,
  484. "\r"
  485. "%3" CURL_FORMAT_CURL_OFF_T " %s "
  486. "%3" CURL_FORMAT_CURL_OFF_T " %s "
  487. "%3" CURL_FORMAT_CURL_OFF_T " %s %s %s %s %s %s %s",
  488. total_percen, /* 3 letters */ /* total % */
  489. max5data(total_expected_transfer, max5[2]), /* total size */
  490. dlpercen, /* 3 letters */ /* rcvd % */
  491. max5data(data->progress.downloaded, max5[0]), /* rcvd size */
  492. ulpercen, /* 3 letters */ /* xfer % */
  493. max5data(data->progress.uploaded, max5[1]), /* xfer size */
  494. max5data(data->progress.dlspeed, max5[3]), /* avrg dl speed */
  495. max5data(data->progress.ulspeed, max5[4]), /* avrg ul speed */
  496. time_total, /* 8 letters */ /* total time */
  497. time_spent, /* 8 letters */ /* time spent */
  498. time_left, /* 8 letters */ /* time left */
  499. max5data(data->progress.current_speed, max5[5]) /* current speed */
  500. );
  501. /* we flush the output stream to make it appear as soon as possible */
  502. fflush(data->set.err);
  503. } /* !(data->progress.flags & PGRS_HIDE) */
  504. return 0;
  505. }