cURL / Mailing Lists / curl-library / Single Mail

curl-library

[PATCH 1/2] tool: use XFERFUNCTION to save some casts

From: Dave Reisner <dreisner_at_archlinux.org>
Date: Sun, 13 Oct 2013 13:39:41 -0400

---
 src/tool_cb_prg.c  | 10 +++++-----
 src/tool_cb_prg.h  |  4 ++--
 src/tool_operate.c |  4 ++--
 3 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/src/tool_cb_prg.c b/src/tool_cb_prg.c
index b049377..00078d0 100644
--- a/src/tool_cb_prg.c
+++ b/src/tool_cb_prg.c
@@ -32,14 +32,14 @@
 #include "memdebug.h" /* keep this as LAST include */
 
 /*
-** callback for CURLOPT_PROGRESSFUNCTION
+** callback for CURLOPT_XFERINFOFUNCTION
 */
 
 #define MAX_BARLENGTH 256
 
 int tool_progress_cb(void *clientp,
-                     double dltotal, double dlnow,
-                     double ultotal, double ulnow)
+                     curl_off_t dltotal, curl_off_t dlnow,
+                     curl_off_t ultotal, curl_off_t ulnow)
 {
   /* The original progress-bar source code was written for curl by Lars Aas,
      and this new edition inherits some of his concepts. */
@@ -60,10 +60,10 @@ int tool_progress_cb(void *clientp,
     return 0;
 
   /* expected transfer size */
-  total = (curl_off_t)dltotal + (curl_off_t)ultotal + bar->initial_size;
+  total = dltotal + ultotal + bar->initial_size;
 
   /* we've come this far */
-  point = (curl_off_t)dlnow + (curl_off_t)ulnow + bar->initial_size;
+  point = dlnow + ulnow + bar->initial_size;
 
   if(point > total)
     /* we have got more than the expected total! */
diff --git a/src/tool_cb_prg.h b/src/tool_cb_prg.h
index a20645e..d80e845 100644
--- a/src/tool_cb_prg.h
+++ b/src/tool_cb_prg.h
@@ -43,8 +43,8 @@ void progressbarinit(struct ProgressData *bar,
 */
 
 int tool_progress_cb(void *clientp,
-                     double dltotal, double dlnow,
-                     double ultotal, double ulnow);
+                     curl_off_t dltotal, curl_off_t dlnow,
+                     curl_off_t ultotal, curl_off_t ulnow);
 
 #endif /* HEADER_CURL_TOOL_CB_PRG_H */
 
diff --git a/src/tool_operate.c b/src/tool_operate.c
index 6615270..7b43691 100644
--- a/src/tool_operate.c
+++ b/src/tool_operate.c
@@ -1235,8 +1235,8 @@ int operate(struct Configurable *config, int argc, argv_item_t argv[])
            !config->noprogress && !config->mute) {
           /* we want the alternative style, then we have to implement it
              ourselves! */
-          my_setopt(curl, CURLOPT_PROGRESSFUNCTION, tool_progress_cb);
-          my_setopt(curl, CURLOPT_PROGRESSDATA, &progressbar);
+          my_setopt(curl, CURLOPT_XFERINFOFUNCTION, tool_progress_cb);
+          my_setopt(curl, CURLOPT_XFERINFODATA, &progressbar);
         }
 
         /* new in libcurl 7.24.0: */
-- 
1.8.4
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2013-10-13