cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: progress hook question

From: Daniel Stenberg <daniel-curl_at_haxx.se>
Date: Tue, 4 May 2004 09:31:43 +0200 (CEST)

On Mon, 3 May 2004, Mike Huffman wrote:

> int my_progress_func(void *nothing, double dltotal, double dlnow, double
> ultotal, double ulnow)
> {
> printf("dltotal: %d, dlnow: %d, ultotal: %d, ulnow: %d \n", dltotal, dlnow,
> ultotal, ulnow);
> return 0;
> }

The arguments are passed in to this function as doubles. You print them
telling printf() they are ints. Doubles are usually using more bytes than
ints, so this will effectively make printf() use only a piece of the info you
get.

Try this approach (taken from a test-program I wrote just a few weeks ago):

static int progressfunc(void *clientp,
                        double dltotal,
                        double dlnow,
                        double ultotal,
                        double ulnow)
{
  long now = (long)dlnow;
  long total = (long)dltotal;
  printf("%ld/%ld\n", now, total);
  return 0; /* all is well, continue */
}

-- 
     Daniel Stenberg -- http://curl.haxx.se -- http://daniel.haxx.se
      Dedicated custom curl help for hire: http://haxx.se/curl.html
Received on 2004-05-04