Coverage Report

Created: 2025-11-23 06:13

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/curl/lib/progress.c
Line
Count
Source
1
/***************************************************************************
2
 *                                  _   _ ____  _
3
 *  Project                     ___| | | |  _ \| |
4
 *                             / __| | | | |_) | |
5
 *                            | (__| |_| |  _ <| |___
6
 *                             \___|\___/|_| \_\_____|
7
 *
8
 * Copyright (C) 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.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
 * SPDX-License-Identifier: curl
22
 *
23
 ***************************************************************************/
24
25
#include "curl_setup.h"
26
27
#include "urldata.h"
28
#include "sendf.h"
29
#include "multiif.h"
30
#include "progress.h"
31
#include "curlx/timeval.h"
32
33
/* check rate limits within this many recent milliseconds, at minimum. */
34
0
#define MIN_RATE_LIMIT_PERIOD 3000
35
36
#ifndef CURL_DISABLE_PROGRESS_METER
37
/* Provide a string that is 2 + 1 + 2 + 1 + 2 = 8 letters long (plus the zero
38
   byte) */
39
static void time2str(char *r, curl_off_t seconds)
40
0
{
41
0
  curl_off_t h;
42
0
  if(seconds <= 0) {
43
0
    strcpy(r, "--:--:--");
44
0
    return;
45
0
  }
46
0
  h = seconds / 3600;
47
0
  if(h <= 99) {
48
0
    curl_off_t m = (seconds - (h * 3600)) / 60;
49
0
    curl_off_t s = (seconds - (h * 3600)) - (m * 60);
50
0
    curl_msnprintf(r, 9, "%2" FMT_OFF_T ":%02" FMT_OFF_T ":%02" FMT_OFF_T,
51
0
                   h, m, s);
52
0
  }
53
0
  else {
54
    /* this equals to more than 99 hours, switch to a more suitable output
55
       format to fit within the limits. */
56
0
    curl_off_t d = seconds / 86400;
57
0
    h = (seconds - (d * 86400)) / 3600;
58
0
    if(d <= 999)
59
0
      curl_msnprintf(r, 9, "%3" FMT_OFF_T "d %02" FMT_OFF_T "h", d, h);
60
0
    else
61
0
      curl_msnprintf(r, 9, "%7" FMT_OFF_T "d", d);
62
0
  }
63
0
}
64
65
/* The point of this function would be to return a string of the input data,
66
   but never longer than 6 columns (+ one zero byte).
67
   Add suffix k, M, G when suitable... */
68
static char *max6data(curl_off_t bytes, char *max6)
69
0
{
70
  /* a signed 64-bit value is 8192 petabytes maximum, shown as
71
     8.0E (exabytes)*/
72
0
  if(bytes < 100000)
73
0
    curl_msnprintf(max6, 7, "%6" CURL_FORMAT_CURL_OFF_T, bytes);
74
0
  else {
75
0
    const char unit[] = { 'k', 'M', 'G', 'T', 'P', 'E', 0 };
76
0
    int k = 0;
77
0
    curl_off_t nbytes;
78
0
    do {
79
0
      nbytes = bytes / 1024;
80
0
      if(nbytes < 1000)
81
0
        break;
82
0
      bytes = nbytes;
83
0
      k++;
84
0
      DEBUGASSERT(unit[k]);
85
0
    } while(unit[k]);
86
    /* xxx.yU */
87
0
    curl_msnprintf(max6, 7, "%3" CURL_FORMAT_CURL_OFF_T
88
0
                   ".%" CURL_FORMAT_CURL_OFF_T "%c", nbytes,
89
0
                   (bytes%1024) / (1024/10), unit[k]);
90
0
  }
91
0
  return max6;
92
0
}
93
#endif
94
95
/*
96
97
   New proposed interface, 9th of February 2000:
98
99
   pgrsStartNow() - sets start time
100
   pgrsSetDownloadSize(x) - known expected download size
101
   pgrsSetUploadSize(x) - known expected upload size
102
   pgrsSetDownloadCounter() - amount of data currently downloaded
103
   pgrsSetUploadCounter() - amount of data currently uploaded
104
   pgrsUpdate() - show progress
105
   pgrsDone() - transfer complete
106
107
*/
108
109
int Curl_pgrsDone(struct Curl_easy *data)
110
0
{
111
0
  int rc;
112
0
  data->progress.lastshow = 0;
113
0
  rc = Curl_pgrsUpdate(data); /* the final (forced) update */
114
0
  if(rc)
115
0
    return rc;
116
117
0
  if(!data->progress.hide && !data->progress.callback)
118
    /* only output if we do not use a progress callback and we are not
119
     * hidden */
120
0
    curl_mfprintf(data->set.err, "\n");
121
122
0
  data->progress.speeder_c = 0; /* reset the progress meter display */
123
0
  return 0;
124
0
}
125
126
/* reset the known transfer sizes */
127
void Curl_pgrsResetTransferSizes(struct Curl_easy *data)
128
0
{
129
0
  Curl_pgrsSetDownloadSize(data, -1);
130
0
  Curl_pgrsSetUploadSize(data, -1);
131
0
}
132
133
/*
134
 *
135
 * Curl_pgrsTimeWas(). Store the timestamp time at the given label.
136
 */
137
void Curl_pgrsTimeWas(struct Curl_easy *data, timerid timer,
138
                      struct curltime timestamp)
139
0
{
140
0
  timediff_t *delta = NULL;
141
142
0
  switch(timer) {
143
0
  default:
144
0
  case TIMER_NONE:
145
    /* mistake filter */
146
0
    break;
147
0
  case TIMER_STARTOP:
148
    /* This is set at the start of a transfer */
149
0
    data->progress.t_startop = timestamp;
150
0
    data->progress.t_startqueue = timestamp;
151
0
    data->progress.t_postqueue = 0;
152
0
    break;
153
0
  case TIMER_STARTSINGLE:
154
    /* This is set at the start of each single transfer */
155
0
    data->progress.t_startsingle = timestamp;
156
0
    data->progress.is_t_startransfer_set = FALSE;
157
0
    break;
158
0
  case TIMER_POSTQUEUE:
159
    /* Queue time is accumulative from all involved redirects */
160
0
    data->progress.t_postqueue +=
161
0
      curlx_timediff_us(timestamp, data->progress.t_startqueue);
162
0
    break;
163
0
  case TIMER_STARTACCEPT:
164
0
    data->progress.t_acceptdata = timestamp;
165
0
    break;
166
0
  case TIMER_NAMELOOKUP:
167
0
    delta = &data->progress.t_nslookup;
168
0
    break;
169
0
  case TIMER_CONNECT:
170
0
    delta = &data->progress.t_connect;
171
0
    break;
172
0
  case TIMER_APPCONNECT:
173
0
    delta = &data->progress.t_appconnect;
174
0
    break;
175
0
  case TIMER_PRETRANSFER:
176
0
    delta = &data->progress.t_pretransfer;
177
0
    break;
178
0
  case TIMER_STARTTRANSFER:
179
0
    delta = &data->progress.t_starttransfer;
180
    /* prevent updating t_starttransfer unless:
181
     *   1) this is the first time we are setting t_starttransfer
182
     *   2) a redirect has occurred since the last time t_starttransfer was set
183
     * This prevents repeated invocations of the function from incorrectly
184
     * changing the t_starttransfer time.
185
     */
186
0
    if(data->progress.is_t_startransfer_set) {
187
0
      return;
188
0
    }
189
0
    else {
190
0
      data->progress.is_t_startransfer_set = TRUE;
191
0
      break;
192
0
    }
193
0
  case TIMER_POSTRANSFER:
194
0
    delta = &data->progress.t_posttransfer;
195
0
    break;
196
0
  case TIMER_REDIRECT:
197
0
    data->progress.t_redirect = curlx_timediff_us(timestamp,
198
0
                                                 data->progress.start);
199
0
    data->progress.t_startqueue = timestamp;
200
0
    break;
201
0
  }
202
0
  if(delta) {
203
0
    timediff_t us = curlx_timediff_us(timestamp, data->progress.t_startsingle);
204
0
    if(us < 1)
205
0
      us = 1; /* make sure at least one microsecond passed */
206
0
    *delta += us;
207
0
  }
208
0
}
209
210
/*
211
 *
212
 * Curl_pgrsTime(). Store the current time at the given label. This fetches a
213
 * fresh "now" and returns it.
214
 *
215
 * @unittest: 1399
216
 */
217
struct curltime Curl_pgrsTime(struct Curl_easy *data, timerid timer)
218
0
{
219
0
  struct curltime now = curlx_now();
220
221
0
  Curl_pgrsTimeWas(data, timer, now);
222
0
  return now;
223
0
}
224
225
void Curl_pgrsStartNow(struct Curl_easy *data)
226
0
{
227
0
  struct Progress *p = &data->progress;
228
0
  p->speeder_c = 0; /* reset the progress meter display */
229
0
  p->start = curlx_now();
230
0
  p->is_t_startransfer_set = FALSE;
231
0
  p->ul.limit.start = p->start;
232
0
  p->dl.limit.start = p->start;
233
0
  p->ul.limit.start_size = 0;
234
0
  p->dl.limit.start_size = 0;
235
0
  p->dl.cur_size = 0;
236
0
  p->ul.cur_size = 0;
237
  /* the sizes are unknown at start */
238
0
  p->dl_size_known = FALSE;
239
0
  p->ul_size_known = FALSE;
240
0
  Curl_ratelimit(data, p->start);
241
0
}
242
243
/*
244
 * This is used to handle speed limits, calculating how many milliseconds to
245
 * wait until we are back under the speed limit, if needed.
246
 *
247
 * The way it works is by having a "starting point" (time & amount of data
248
 * transferred by then) used in the speed computation, to be used instead of
249
 * the start of the transfer. This starting point is regularly moved as
250
 * transfer goes on, to keep getting accurate values (instead of average over
251
 * the entire transfer).
252
 *
253
 * This function takes the current amount of data transferred, the amount at
254
 * the starting point, the limit (in bytes/s), the time of the starting point
255
 * and the current time.
256
 *
257
 * Returns 0 if no waiting is needed or when no waiting is needed but the
258
 * starting point should be reset (to current); or the number of milliseconds
259
 * to wait to get back under the speed limit.
260
 */
261
timediff_t Curl_pgrsLimitWaitTime(struct pgrs_dir *d,
262
                                  curl_off_t bytes_per_sec,
263
                                  struct curltime now)
264
0
{
265
0
  curl_off_t bytes = d->cur_size - d->limit.start_size;
266
0
  timediff_t should_ms;
267
0
  timediff_t took_ms;
268
269
  /* no limit or we did not get to any bytes yet */
270
0
  if(!bytes_per_sec || !bytes)
271
0
    return 0;
272
273
  /* The time it took us to have `bytes` */
274
0
  took_ms = curlx_timediff_ceil_ms(now, d->limit.start);
275
276
  /* The time it *should* have taken us to have `bytes`
277
   * when obeying the bytes_per_sec speed_limit. */
278
0
  if(bytes < CURL_OFF_T_MAX/1000) {
279
    /* (1000 * bytes / (bytes / sec)) = 1000 * sec = ms */
280
0
    should_ms = (timediff_t) (1000 * bytes / bytes_per_sec);
281
0
  }
282
0
  else {
283
    /* large `bytes`, first calc the seconds it should have taken.
284
     * if that is small enough, convert to milliseconds. */
285
0
    should_ms = (timediff_t) (bytes / bytes_per_sec);
286
0
    if(should_ms < TIMEDIFF_T_MAX/1000)
287
0
      should_ms *= 1000;
288
0
    else
289
0
      should_ms = TIMEDIFF_T_MAX;
290
0
  }
291
292
0
  if(took_ms < should_ms) {
293
    /* when gotten to `bytes` too fast, wait the difference */
294
0
    return should_ms - took_ms;
295
0
  }
296
0
  return 0;
297
0
}
298
299
/*
300
 * Set the number of downloaded bytes so far.
301
 */
302
void Curl_pgrsSetDownloadCounter(struct Curl_easy *data, curl_off_t size)
303
0
{
304
0
  data->progress.dl.cur_size = size;
305
0
}
306
307
/*
308
 * Update the timestamp and sizestamp to use for rate limit calculations.
309
 */
310
void Curl_ratelimit(struct Curl_easy *data, struct curltime now)
311
0
{
312
  /* do not set a new stamp unless the time since last update is long enough */
313
0
  if(data->set.max_recv_speed) {
314
0
    if(curlx_timediff_ms(now, data->progress.dl.limit.start) >=
315
0
       MIN_RATE_LIMIT_PERIOD) {
316
0
      data->progress.dl.limit.start = now;
317
0
      data->progress.dl.limit.start_size = data->progress.dl.cur_size;
318
0
    }
319
0
  }
320
0
  if(data->set.max_send_speed) {
321
0
    if(curlx_timediff_ms(now, data->progress.ul.limit.start) >=
322
0
       MIN_RATE_LIMIT_PERIOD) {
323
0
      data->progress.ul.limit.start = now;
324
0
      data->progress.ul.limit.start_size = data->progress.ul.cur_size;
325
0
    }
326
0
  }
327
0
}
328
329
/*
330
 * Set the number of uploaded bytes so far.
331
 */
332
void Curl_pgrsSetUploadCounter(struct Curl_easy *data, curl_off_t size)
333
0
{
334
0
  data->progress.ul.cur_size = size;
335
0
}
336
337
void Curl_pgrsSetDownloadSize(struct Curl_easy *data, curl_off_t size)
338
0
{
339
0
  if(size >= 0) {
340
0
    data->progress.dl.total_size = size;
341
0
    data->progress.dl_size_known = TRUE;
342
0
  }
343
0
  else {
344
0
    data->progress.dl.total_size = 0;
345
0
    data->progress.dl_size_known = FALSE;
346
0
  }
347
0
}
348
349
void Curl_pgrsSetUploadSize(struct Curl_easy *data, curl_off_t size)
350
0
{
351
0
  if(size >= 0) {
352
0
    data->progress.ul.total_size = size;
353
0
    data->progress.ul_size_known = TRUE;
354
0
  }
355
0
  else {
356
0
    data->progress.ul.total_size = 0;
357
0
    data->progress.ul_size_known = FALSE;
358
0
  }
359
0
}
360
361
void Curl_pgrsEarlyData(struct Curl_easy *data, curl_off_t sent)
362
0
{
363
0
    data->progress.earlydata_sent = sent;
364
0
}
365
366
/* returns the average speed in bytes / second */
367
static curl_off_t trspeed(curl_off_t size, /* number of bytes */
368
                          curl_off_t us)   /* microseconds */
369
0
{
370
0
  if(us < 1)
371
0
    return size * 1000000;
372
0
  else if(size < CURL_OFF_T_MAX/1000000)
373
0
    return (size * 1000000) / us;
374
0
  else if(us >= 1000000)
375
0
    return size / (us / 1000000);
376
0
  else
377
0
    return CURL_OFF_T_MAX;
378
0
}
379
380
/* returns TRUE if it is time to show the progress meter */
381
static bool progress_calc(struct Curl_easy *data, struct curltime now)
382
0
{
383
0
  bool timetoshow = FALSE;
384
0
  struct Progress * const p = &data->progress;
385
386
  /* The time spent so far (from the start) in microseconds */
387
0
  p->timespent = curlx_timediff_us(now, p->start);
388
0
  p->dl.speed = trspeed(p->dl.cur_size, p->timespent);
389
0
  p->ul.speed = trspeed(p->ul.cur_size, p->timespent);
390
391
  /* Calculations done at most once a second, unless end is reached */
392
0
  if(p->lastshow != now.tv_sec) {
393
0
    int countindex; /* amount of seconds stored in the speeder array */
394
0
    int nowindex = p->speeder_c% CURR_TIME;
395
0
    p->lastshow = now.tv_sec;
396
0
    timetoshow = TRUE;
397
398
    /* Let's do the "current speed" thing, with the dl + ul speeds
399
       combined. Store the speed at entry 'nowindex'. */
400
0
    p->speeder[ nowindex ] = p->dl.cur_size + p->ul.cur_size;
401
402
    /* remember the exact time for this moment */
403
0
    p->speeder_time [ nowindex ] = now;
404
405
    /* advance our speeder_c counter, which is increased every time we get
406
       here and we expect it to never wrap as 2^32 is a lot of seconds! */
407
0
    p->speeder_c++;
408
409
    /* figure out how many index entries of data we have stored in our speeder
410
       array. With N_ENTRIES filled in, we have about N_ENTRIES-1 seconds of
411
       transfer. Imagine, after one second we have filled in two entries,
412
       after two seconds we have filled in three entries etc. */
413
0
    countindex = ((p->speeder_c >= CURR_TIME) ? CURR_TIME : p->speeder_c) - 1;
414
415
    /* first of all, we do not do this if there is no counted seconds yet */
416
0
    if(countindex) {
417
0
      int checkindex;
418
0
      timediff_t span_ms;
419
0
      curl_off_t amount;
420
421
      /* Get the index position to compare with the 'nowindex' position.
422
         Get the oldest entry possible. While we have less than CURR_TIME
423
         entries, the first entry will remain the oldest. */
424
0
      checkindex = (p->speeder_c >= CURR_TIME) ? p->speeder_c%CURR_TIME : 0;
425
426
      /* Figure out the exact time for the time span */
427
0
      span_ms = curlx_timediff_ms(now, p->speeder_time[checkindex]);
428
0
      if(span_ms == 0)
429
0
        span_ms = 1; /* at least one millisecond MUST have passed */
430
431
      /* Calculate the average speed the last 'span_ms' milliseconds */
432
0
      amount = p->speeder[nowindex]- p->speeder[checkindex];
433
434
0
      if(amount > (0xffffffff/1000))
435
        /* the 'amount' value is bigger than would fit in 32 bits if
436
           multiplied with 1000, so we use the double math for this */
437
0
        p->current_speed = (curl_off_t)
438
0
          ((double)amount/((double)span_ms/1000.0));
439
0
      else
440
        /* the 'amount' value is small enough to fit within 32 bits even
441
           when multiplied with 1000 */
442
0
        p->current_speed = amount * 1000/span_ms;
443
0
    }
444
0
    else
445
      /* the first second we use the average */
446
0
      p->current_speed = p->ul.speed + p->dl.speed;
447
448
0
  } /* Calculations end */
449
0
  return timetoshow;
450
0
}
451
452
#ifndef CURL_DISABLE_PROGRESS_METER
453
454
struct pgrs_estimate {
455
  curl_off_t secs;
456
  curl_off_t percent;
457
};
458
459
static curl_off_t pgrs_est_percent(curl_off_t total, curl_off_t cur)
460
0
{
461
0
  if(total > 10000)
462
0
    return cur / (total / 100);
463
0
  else if(total > 0)
464
0
    return (cur*100) / total;
465
0
  return 0;
466
0
}
467
468
static void pgrs_estimates(struct pgrs_dir *d,
469
                           bool total_known,
470
                           struct pgrs_estimate *est)
471
0
{
472
0
  est->secs = 0;
473
0
  est->percent = 0;
474
0
  if(total_known && (d->speed > 0)) {
475
0
    est->secs = d->total_size / d->speed;
476
0
    est->percent = pgrs_est_percent(d->total_size, d->cur_size);
477
0
  }
478
0
}
479
480
static void progress_meter(struct Curl_easy *data)
481
0
{
482
0
  struct Progress *p = &data->progress;
483
0
  char max6[6][7];
484
0
  struct pgrs_estimate dl_estm;
485
0
  struct pgrs_estimate ul_estm;
486
0
  struct pgrs_estimate total_estm;
487
0
  curl_off_t total_cur_size;
488
0
  curl_off_t total_expected_size;
489
0
  curl_off_t dl_size;
490
0
  char time_left[10];
491
0
  char time_total[10];
492
0
  char time_spent[10];
493
0
  curl_off_t cur_secs = (curl_off_t)p->timespent/1000000; /* seconds */
494
495
0
  if(!p->headers_out) {
496
0
    if(data->state.resume_from) {
497
0
      curl_mfprintf(data->set.err,
498
0
                    "** Resuming transfer from byte position %" FMT_OFF_T "\n",
499
0
                    data->state.resume_from);
500
0
    }
501
0
    curl_mfprintf(data->set.err,
502
0
                  "  %% Total    %% Received %% Xferd  Average Speed   "
503
0
                  "Time    Time     Time  Current\n"
504
0
                  "                                 Dload  Upload   "
505
0
                  "Total   Spent    Left  Speed\n");
506
0
    p->headers_out = TRUE; /* headers are shown */
507
0
  }
508
509
  /* Figure out the estimated time of arrival for upload and download */
510
0
  pgrs_estimates(&p->ul, (bool)p->ul_size_known, &ul_estm);
511
0
  pgrs_estimates(&p->dl, (bool)p->dl_size_known, &dl_estm);
512
513
  /* Since both happen at the same time, total expected duration is max. */
514
0
  total_estm.secs = CURLMAX(ul_estm.secs, dl_estm.secs);
515
  /* create the three time strings */
516
0
  time2str(time_left, total_estm.secs > 0 ? (total_estm.secs - cur_secs) : 0);
517
0
  time2str(time_total, total_estm.secs);
518
0
  time2str(time_spent, cur_secs);
519
520
  /* Get the total amount of data expected to get transferred */
521
0
  total_expected_size =
522
0
    p->ul_size_known ? p->ul.total_size : p->ul.cur_size;
523
524
0
  dl_size =
525
0
    p->dl_size_known ? p->dl.total_size : p->dl.cur_size;
526
527
  /* integer overflow check */
528
0
  if((CURL_OFF_T_MAX - total_expected_size) < dl_size)
529
0
    total_expected_size = CURL_OFF_T_MAX; /* capped */
530
0
  else
531
0
    total_expected_size += dl_size;
532
533
  /* We have transferred this much so far */
534
0
  total_cur_size = p->dl.cur_size + p->ul.cur_size;
535
536
  /* Get the percentage of data transferred so far */
537
0
  total_estm.percent = pgrs_est_percent(total_expected_size, total_cur_size);
538
539
0
  curl_mfprintf(data->set.err,
540
0
                "\r"
541
0
                "%3" FMT_OFF_T " %s "
542
0
                "%3" FMT_OFF_T " %s "
543
0
                "%3" FMT_OFF_T " %s %s %s  %s %s %s %s",
544
0
                total_estm.percent, /* 3 letters */         /* total % */
545
0
                max6data(total_expected_size, max6[2]),     /* total size */
546
0
                dl_estm.percent, /* 3 letters */            /* rcvd % */
547
0
                max6data(p->dl.cur_size, max6[0]),          /* rcvd size */
548
0
                ul_estm.percent, /* 3 letters */            /* xfer % */
549
0
                max6data(p->ul.cur_size, max6[1]),          /* xfer size */
550
0
                max6data(p->dl.speed, max6[3]),             /* avrg dl speed */
551
0
                max6data(p->ul.speed, max6[4]),             /* avrg ul speed */
552
0
                time_total,    /* 8 letters */              /* total time */
553
0
                time_spent,    /* 8 letters */              /* time spent */
554
0
                time_left,     /* 8 letters */              /* time left */
555
0
                max6data(p->current_speed, max6[5])
556
0
    );
557
558
  /* we flush the output stream to make it appear as soon as possible */
559
0
  fflush(data->set.err);
560
0
}
561
#else
562
 /* progress bar disabled */
563
#define progress_meter(x) Curl_nop_stmt
564
#endif
565
566
567
/*
568
 * Curl_pgrsUpdate() returns 0 for success or the value returned by the
569
 * progress callback!
570
 */
571
static int pgrsupdate(struct Curl_easy *data, bool showprogress)
572
0
{
573
0
  if(!data->progress.hide) {
574
0
    if(data->set.fxferinfo) {
575
0
      int result;
576
      /* There is a callback set, call that */
577
0
      Curl_set_in_callback(data, TRUE);
578
0
      result = data->set.fxferinfo(data->set.progress_client,
579
0
                                   data->progress.dl.total_size,
580
0
                                   data->progress.dl.cur_size,
581
0
                                   data->progress.ul.total_size,
582
0
                                   data->progress.ul.cur_size);
583
0
      Curl_set_in_callback(data, FALSE);
584
0
      if(result != CURL_PROGRESSFUNC_CONTINUE) {
585
0
        if(result)
586
0
          failf(data, "Callback aborted");
587
0
        return result;
588
0
      }
589
0
    }
590
0
    else if(data->set.fprogress) {
591
0
      int result;
592
      /* The older deprecated callback is set, call that */
593
0
      Curl_set_in_callback(data, TRUE);
594
0
      result = data->set.fprogress(data->set.progress_client,
595
0
                                   (double)data->progress.dl.total_size,
596
0
                                   (double)data->progress.dl.cur_size,
597
0
                                   (double)data->progress.ul.total_size,
598
0
                                   (double)data->progress.ul.cur_size);
599
0
      Curl_set_in_callback(data, FALSE);
600
0
      if(result != CURL_PROGRESSFUNC_CONTINUE) {
601
0
        if(result)
602
0
          failf(data, "Callback aborted");
603
0
        return result;
604
0
      }
605
0
    }
606
607
0
    if(showprogress)
608
0
      progress_meter(data);
609
0
  }
610
611
0
  return 0;
612
0
}
613
614
int Curl_pgrsUpdate(struct Curl_easy *data)
615
0
{
616
0
  struct curltime now = curlx_now(); /* what time is it */
617
0
  bool showprogress = progress_calc(data, now);
618
0
  return pgrsupdate(data, showprogress);
619
0
}
620
621
/*
622
 * Update all progress, do not do progress meter/callbacks.
623
 */
624
void Curl_pgrsUpdate_nometer(struct Curl_easy *data)
625
0
{
626
0
  struct curltime now = curlx_now(); /* what time is it */
627
0
  (void)progress_calc(data, now);
628
0
}