Pages

Sunday, February 17, 2013

SSL context function with cCURLpp

The function signature for cURL can't be used with cURLpp.

Expected code (not working)

If you're familiar with cURL, you would probably try this first.

CURLcode sslContextCallback(CURL* curl, void* ctx, void* param) {
    return CURLE_OK;
}

// ...
using namespace curlpp;
Easy easy;
// ...
easy.setOpt(new options::SslCtxFunction(sslContextCallback)); // CURLOPT_SSL_CTX_FUNCTION in cURL

This would give the following error (VC++):

error C2198: 'CURLcode (__cdecl *)(CURL *,void *,void *)' : too few arguments for call

Code for cURLpp

CURLcode sslContextCallback(void* ctx) {
    return CURLE_OK;
}

// ...
using namespace curlpp;
Easy easy;
// ...
easy.setOpt(new options::SslCtxFunction(sslContextCallback)); // CURLOPT_SSL_CTX_FUNCTION in cURL

I'm not sure at this time how to get the optional extra data, but for now, I don't need it either.

No comments:

Post a Comment