cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: progress hook question

From: Mike Huffman <mike_at_snowcompanies.com>
Date: Tue, 4 May 2004 10:30:00 -0400

Thanks for the reply.
After these changes, I still get zeros. Note that I also wrote a seperate c++
minimal app like this and got zeros sending the parameters to cout.

On Tuesday 04 May 2004 03:31, Daniel Stenberg wrote:
> 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 */
> }
Received on 2004-05-04