Files correlati : xvturl Commento : Inizio implementazione xvturl con primordiale gestione chiamate post http git-svn-id: svn://10.65.10.50/branches/R_10_00@24200 c028cbd2-c16b-5b4b-a496-9718f37d4682
127 lines
3.1 KiB
C++
127 lines
3.1 KiB
C++
#include "xvturl.h"
|
|
#include <curl/curl.h>
|
|
|
|
/**********************************************************************
|
|
* xvturl_global episode I: THE PHANTOM FUNCTIONS *
|
|
**********************************************************************/
|
|
XVT_HANDLE xvturl_get_handle()
|
|
{
|
|
return curl_easy_init();
|
|
}
|
|
|
|
bool xvturl_exec(XVT_HANDLE handle, int& err)
|
|
{
|
|
err = curl_easy_perform(handle);
|
|
return err == CURLE_OK;
|
|
}
|
|
|
|
const char* xvturl_get_error_string(int err)
|
|
{
|
|
return curl_easy_strerror((CURLcode)err);
|
|
}
|
|
|
|
void xvturl_cleanup(XVT_HANDLE handle)
|
|
{
|
|
curl_easy_cleanup(handle);
|
|
}
|
|
|
|
void xvturl_global_setup(bool on)
|
|
{
|
|
static bool initialized;
|
|
if(!initialized && on)
|
|
{
|
|
initialized = true;
|
|
curl_global_init(CURL_GLOBAL_ALL);
|
|
}
|
|
else if(initialized && !on)
|
|
{
|
|
curl_global_cleanup();
|
|
}
|
|
}
|
|
|
|
/**********************************************************************
|
|
* xvturl_global episode II: ATTACK OF THE LINKER *
|
|
**********************************************************************/
|
|
|
|
URLDLL const char* xvturl_version()
|
|
{
|
|
static char version[50];
|
|
if(version[0] == '\0')
|
|
sprintf_s(version, "cURL %s", LIBCURL_VERSION);
|
|
return version;
|
|
}
|
|
|
|
URLDLL void xvturl_global_init()
|
|
{
|
|
xvturl_global_setup(true);
|
|
}
|
|
|
|
URLDLL void xvturl_global_cleanup()
|
|
{
|
|
xvturl_global_setup(false);
|
|
}
|
|
|
|
/**********************************************************************
|
|
* xvt_email_manager *
|
|
**********************************************************************/
|
|
/*
|
|
URLDLL XVT_HANDLE xvt_email_get_handle()
|
|
{
|
|
return xvturl_get_handle();
|
|
}
|
|
|
|
int xvt_email_init(XVT_HANDLE handle, const char* address, int port, const char* usr, const char* psw, XVT_SSL_STATUS ssl)
|
|
{
|
|
bool ok = handle != NULL;
|
|
|
|
if(ok)
|
|
{
|
|
curl_easy_setopt(handle, CURLOPT_URL, address);
|
|
// You can add the port to the address
|
|
if(port > -1)
|
|
curl_easy_setopt(handle, CURLOPT_PORT, port);
|
|
curl_easy_setopt(handle, CURLOPT_USERNAME, usr);
|
|
curl_easy_setopt(handle, CURLOPT_PASSWORD, psw);
|
|
curl_easy_setopt(handle, CURLOPT_USE_SSL, ssl);
|
|
}
|
|
return ok;
|
|
}
|
|
|
|
*/
|
|
|
|
/**********************************************************************
|
|
* xvt_http_manager *
|
|
**********************************************************************/
|
|
URLDLL XVT_HANDLE xvt_http_get_handle()
|
|
{
|
|
return xvturl_get_handle();
|
|
}
|
|
|
|
URLDLL void xvt_http_set_address(XVT_HANDLE handle, const char* address)
|
|
{
|
|
curl_easy_setopt(handle, CURLOPT_URL, address);
|
|
}
|
|
|
|
URLDLL void xvt_http_set_data(XVT_HANDLE handle, const char* data)
|
|
{
|
|
curl_easy_setopt(handle, CURLOPT_POSTFIELDS, data);
|
|
}
|
|
|
|
URLDLL int xvt_http_exec(XVT_HANDLE handle, int& errorCode)
|
|
{
|
|
return xvturl_exec(handle, errorCode);
|
|
}
|
|
|
|
URLDLL const char * xvt_http_exec(int errorCode)
|
|
{
|
|
return xvturl_get_error_string(errorCode);
|
|
}
|
|
|
|
URLDLL void xvt_http_clean(XVT_HANDLE handle)
|
|
{
|
|
xvturl_cleanup(handle);
|
|
}
|
|
|
|
/**********************************************************************
|
|
* xvt_ftp_manager *
|
|
**********************************************************************/ |