cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: CURLOPT_DEBUGFUNCTION problem

From: Michael Hecker <Hecker.Michael_at_gmx.de>
Date: Sat, 23 Feb 2008 13:55:30 +0100

Anton Fedorov schrieb:
> Hello, Michael.
>
> Your wrote 23 ôåâðàëÿ 2008 ã. 18:19:48:
>
> MH> I want the debugfunction to be part of my
> MH> communication-class. How can I
> MH> do that?
>
> MH> int Cmy_Communicator::my_trace(CURL *handle, curl_infotype type,
> MH> unsigned char *data, size_t size, void *userp)
> my_trace should be static function.
> And do
> curl_easy_setopt(curl_handle, CURLOPT_DEBUGDATA, this);
>
> then, in my_trace do
> ((*Cmy_Communicator)userp)->my_trace_class(CURL *handle,
> curl_infotype type, unsigned char *data, size_t size);
>
Hello Anton,
thank you for your email, but I think I didn't get you right.

class Cmy_Communicator
{
public:
    Cmy_Communicator();
    virtual ~Cmy_Communicator();
    bool communicate3();

    static int my_trace(CURL *handle, curl_infotype type, unsigned char
*data, size_t size, void *userp)
    {
        TRACE("TRACE ok\n");
        return 0;
    }

    CStringmanager myStringmanager;
    CURL *curl_handle;
};

bool Cmy_Communicator::communicate3()
{
    // Rahmeninformationen der Kommunikation
    curl_easy_setopt(curl_handle, CURLOPT_VERBOSE, 1);
    curl_easy_setopt(curl_handle, CURLOPT_DEBUGFUNCTION, my_trace2);
    curl_easy_setopt(curl_handle, CURLOPT_DEBUGDATA, this);

[...]
}

static
int my_trace2(CURL *handle, curl_infotype type, unsigned char *data,
size_t size, void *userp)
{
    ((*Cmy_Communicator)userp)->my_trace(CURL *handle, curl_infotype
type, unsigned char *data, size_t size);
    return 0;
}

--------------------Konfiguration: xyz - Win32 Debug--------------------
Kompilierung läuft...
my_Communicator.cpp
D:\Jobs\xyz\Client Version\xyz\my_Communicator.cpp(160) : error C2275:
"Cmy_Communicator" : Ungültige Verwendung dieses Typs als Ausdruck
        d:\jobs\xyz\client version\xyz\my_communicator.h(23) : Siehe
Deklaration von 'Cmy_Communicator'
D:\Jobs\xyz\Client Version\xyz\my_Communicator.cpp(160) : error C2146:
Syntaxfehler : Fehlendes ')' vor Bezeichner 'userp'
D:\Jobs\xyz\Client Version\xyz\my_Communicator.cpp(160) : error C2059:
Syntaxfehler : ')'
Fehler beim Ausführen von cl.exe.

xyz.exe - 3 Fehler, 0 Warnung(en)

Thank you,
Michael
Received on 2008-02-23