cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Slight bug in the c/c++ API (or maybe just docs)

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Mon, 10 Dec 2001 08:45:07 +0100 (MET)

On Sun, 9 Dec 2001, Ben Greear wrote:

> Returning zero should not be an error, though it should signal
> end-of-file. I think any value > 0 should be valid, and libcurl should
> try again.

Uh. I was being stupid (I spoke about the WRITEFUNCTION). Of course you're
right. The READFUNCTION should return the number of bytes it actually read
into the buffer.

> Zero should mean end-of-file (ie don't ask for more, and we're all done),
> and < 0 is an error.

libcurl doesn't make any such difference. Zero or a negative value (after a
typecast to 'signed int') means "don't read anymore" (end-of-file).

The reason for the 'size_t' return type is that I wanted the callback
functions to match 'fwrite' and 'fread'. Internally in the library, I can
point to either those functions or the user-suplied functions and they'll
work exactly the same.

-- 
    Daniel Stenberg -- curl groks URLs -- http://curl.haxx.se/
Received on 2001-12-10