aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/tool_cb_prg.c22
-rw-r--r--src/tool_cb_prg.h3
2 files changed, 14 insertions, 11 deletions
diff --git a/src/tool_cb_prg.c b/src/tool_cb_prg.c
index 7a701b692..9facd9e76 100644
--- a/src/tool_cb_prg.c
+++ b/src/tool_cb_prg.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2012, 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
@@ -49,17 +49,19 @@ int tool_progress_cb(void *clientp,
double percent;
int barwidth;
int num;
- int i;
-
+ time_t now = time(NULL);
struct ProgressData *bar = (struct ProgressData *)clientp;
+ curl_off_t total;
+ curl_off_t point;
+
+ if(bar->prevtime == now) /* wait with update */
+ return 0;
/* expected transfer size */
- curl_off_t total = (curl_off_t)dltotal + (curl_off_t)ultotal +
- bar->initial_size;
+ total = (curl_off_t)dltotal + (curl_off_t)ultotal + bar->initial_size;
/* we've come this far */
- curl_off_t point = (curl_off_t)dlnow + (curl_off_t)ulnow +
- bar->initial_size;
+ point = (curl_off_t)dlnow + (curl_off_t)ulnow + bar->initial_size;
if(point > total)
/* we have got more than the expected total! */
@@ -83,14 +85,14 @@ int tool_progress_cb(void *clientp,
num = (int) (((double)barwidth) * frac);
if(num > MAX_BARLENGTH)
num = MAX_BARLENGTH;
- for(i = 0; i < num; i++)
- line[i] = '#';
- line[i] = '\0';
+ memset(line, '#', num);
+ line[num] = '\0';
snprintf(format, sizeof(format), "\r%%-%ds %%5.1f%%%%", barwidth);
fprintf(bar->out, format, line, percent);
}
fflush(bar->out);
bar->prev = point;
+ bar->prevtime = now;
return 0;
}
diff --git a/src/tool_cb_prg.h b/src/tool_cb_prg.h
index 81915b2d5..ceb85980c 100644
--- a/src/tool_cb_prg.h
+++ b/src/tool_cb_prg.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2012, 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
@@ -29,6 +29,7 @@
struct ProgressData {
int calls;
curl_off_t prev;
+ time_t prevtime;
int width;
FILE *out; /* where to write everything to */
curl_off_t initial_size;