cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: callback function problem

From: Dave Halbakken <YetAnotherDev_at_netscape.net>
Date: Tue, 15 Apr 2003 10:30:29 -0700

I forgot to mention that in the example below, CurlHeaderCallback() is a
static member function. I probably should have written it so that it is
a C function like this:

size_t CurlHeaderCallback(void *aBuffer,
        size_t aMemberSize,
        size_t aMemberCount,
        void *myObjectThisPtr)
{
    return myObjectThisPtr->MyHeaderCallback(aBuffer, aMemberSize,
aMembercount);
}

YetAnotherDev_at_netscape.net wrote:
> I'll just take a wild guess and suggest that the problem might be
> related to the need for a "this" pointer on your method.
>
> You might try creating a C callback, and use the object's "this" pointer
> as the callback's client pointer. Then the C callback just calls a
> handler in the COM object where the actual work is done. Something like:
>
> size_t FTPNetChannelProcessor::CurlHeaderCallback(void *aBuffer,
> size_t aMemberSize,
> size_t aMemberCount,
> void *myObjectThisPtr)
> {
> return myObjectThisPtr->MyHeaderCallback(aBuffer, aMemberSize,
> aMembercount);
> }
>
> If you look at code automatically generated by VC6++ from a COM object's
> type library, you'll likely see that there's a C as well as a C++
> interface. You might be able to use that C interface instead in the call
> shown above to your object.
>
> Dave
>
>
>
> daniel_at_haxx.se wrote:
>
>> On Tue, 15 Apr 2003, Nelson Ricardo Gomes wrote:
>>
>> (I'm cc'ing this reply to the libcurl mailing list, please take
>> follow-ups
>> there.)
>>
>>
>>> I'm doing a https post COM (ATL) and I'm having problems with the
>>> callback
>>> function. I have tested the same code with standard C and it works fine.
>>
>>
>>
>> Then it sounds like there's a problem with your binding/adjustments.
>>
>>
>>> I believe the problem is the callback address, It's not been called
>>> by the
>>> libcurl. How can I make sure the address I pass to libcurl is
>>> correct, when
>>> doing a COM object?
>>
>>
>>
>> I don't think I understand your problem.
>>
>> 1. If you would pass a bad address, then libcurl would still call that
>> and
>> you would most likely experience a crash.
>>
>> 2. I have no idea how COM objects work or how you're supposed to pass
>> callbacks around using them.
>>
>
>
>
>
> -------------------------------------------------------
> This sf.net email is sponsored by:ThinkGeek
> Welcome to geek heaven.
> http://thinkgeek.com/sf
>

-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
Received on 2003-04-15