I'm building a worker class that should download stuff, via cURL.
however, cURL has some oddities in it (using my functions to buffer and send progress, etc) and i'm far from understanding classes and pointers right.
Basically, one of the options requires access to one of my functions (pointer), and it passes it what it downloaded. I'll have to do the rest, like writing it to a file, displaying or processing the data.
It works fine as a 'standard' program, but I have no idea how i should make cURL access a class function. I've tried a few workarounds, but my program crashed everytime.
Basically,
Code:
class pw
{
public:
int state;
string target;
string file;
string contents;
int progress;
pw();
private:
CURL *curl;
CURLcode result;
int gauge;
string buffer;
char errorBuffer[CURL_ERROR_SIZE];
//functions
int progressUpdater(int* gauge, double dltotal, double dlnow, double ultotal, double ulnow);
int writer(char *data, size_t size, size_t nmemb, std::string *buffer);
};
..and somewhere in the constructor:
Code:
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &writer);
I need the last parameter to point individual instance function "writer".
I've tried:
&pw::writer
this->writer
&writer
this->writer
None works. How can I do it?