diff options
author | Nicolas "Pixel" Noble <pixel@nobis-crew.org> | 2014-06-18 21:32:16 -0700 |
---|---|---|
committer | Nicolas "Pixel" Noble <pixel@nobis-crew.org> | 2014-06-18 21:32:34 -0700 |
commit | 83120f42019feb5ff4947e9bfb22650a2339d583 (patch) | |
tree | 4f98c5f0b528d6c59cd205da3dc27e2df36ac128 /src/CurlTask.cc | |
parent | f889bced4e1b6518904a7f8458d646489d497d0e (diff) |
Adding a bit more curl code.
Diffstat (limited to 'src/CurlTask.cc')
-rw-r--r-- | src/CurlTask.cc | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/CurlTask.cc b/src/CurlTask.cc new file mode 100644 index 0000000..3dce322 --- /dev/null +++ b/src/CurlTask.cc @@ -0,0 +1,27 @@ +#include "CurlTask.h" + +Balau::CurlTask::CurlTask() { + m_curlHandle = curl_easy_init(); + curl_easy_setopt(m_curlHandle, CURLOPT_WRITEFUNCTION, reinterpret_cast<curl_write_callback>(writeFunctionStatic)); + curl_easy_setopt(m_curlHandle, CURLOPT_WRITEDATA, this); + curl_easy_setopt(m_curlHandle, CURLOPT_READFUNCTION, reinterpret_cast<curl_read_callback>(readFunctionStatic)); + curl_easy_setopt(m_curlHandle, CURLOPT_READDATA, this); + curl_easy_setopt(m_curlHandle, CURLOPT_DEBUGFUNCTION, reinterpret_cast<curl_debug_callback>(debugFunctionStatic)); + curl_easy_setopt(m_curlHandle, CURLOPT_DEBUGDATA, this); +} + +size_t Balau::CurlTask::writeFunctionStatic(char * ptr, size_t size, size_t nmemb, void * userdata) { + CurlTask * curlTask = (CurlTask *) userdata; + return curlTask->writeFunction(ptr, size, nmemb); +} + +size_t Balau::CurlTask::readFunctionStatic(void * ptr, size_t size, size_t nmemb, void * userdata) { + CurlTask * curlTask = (CurlTask *) userdata; + return curlTask->readFunction(ptr, size, nmemb); +} + +int Balau::CurlTask::debugFunctionStatic(CURL * easy, curl_infotype info, char * str, size_t str_len, void * userdata) { + CurlTask * curlTask = (CurlTask *) userdata; + IAssert(easy == curlTask->m_curlHandle, "Got a debug callback for a handle that isn't our own."); + return curlTask->debugFunction(info, str, str_len); +} |