forked from enlightenment/efl
ecore-con-url- split out the curl dleopener and resolver and headers
this splits out out "manual" dlopen (eina_module_load) of curl into its own .c file and special header out of ecore_con_url.c to tidy up that code a bit and isolate our curl magic loading/handling
This commit is contained in:
parent
62d6ab54a4
commit
7eba161414
|
@ -51,6 +51,8 @@ lib/ecore_con/ecore_con_eet.c \
|
|||
lib/ecore_con/ecore_con_socks.c \
|
||||
lib/ecore_con/ecore_con_ssl.c \
|
||||
lib/ecore_con/ecore_con_url.c \
|
||||
lib/ecore_con/ecore_con_url_curl.c \
|
||||
lib/ecore_con/ecore_con_url_curl.h \
|
||||
lib/ecore_con/ecore_con_private.h
|
||||
|
||||
EXTRA_DIST += lib/ecore_con/ecore_con_legacy.c
|
||||
|
|
|
@ -29,160 +29,10 @@
|
|||
#include "ecore_private.h"
|
||||
#include "Ecore_Con.h"
|
||||
#include "ecore_con_private.h"
|
||||
#include "ecore_con_url_curl.h"
|
||||
|
||||
#define MY_CLASS EFL_NETWORK_URL_CLASS
|
||||
|
||||
// all the types, defines, enums etc. from curl that we actually USE.
|
||||
// we have to add to this if we use more things from curl not already
|
||||
// defined here. see curl headers to get them from
|
||||
typedef enum
|
||||
{
|
||||
CURLM_CALL_MULTI_PERFORM = -1,
|
||||
CURLM_OK = 0
|
||||
} CURLMcode;
|
||||
typedef enum
|
||||
{
|
||||
CURLE_OK = 0,
|
||||
CURLE_OPERATION_TIMEDOUT = 28
|
||||
} CURLcode;
|
||||
#define CURLOPTTYPE_LONG 0
|
||||
#define CURLOPTTYPE_OBJECTPOINT 10000
|
||||
#define CURLOPTTYPE_FUNCTIONPOINT 20000
|
||||
#define CURLOPTTYPE_OFF_T 30000
|
||||
#define CINIT(na, t, nu) CURLOPT_ ## na = CURLOPTTYPE_ ## t + nu
|
||||
typedef enum
|
||||
{
|
||||
CINIT(FILE, OBJECTPOINT, 1),
|
||||
CINIT(URL, OBJECTPOINT, 2),
|
||||
CINIT(PROXY, OBJECTPOINT, 4),
|
||||
CINIT(USERPWD, OBJECTPOINT, 5),
|
||||
CINIT(INFILE, OBJECTPOINT, 9),
|
||||
CINIT(WRITEFUNCTION, FUNCTIONPOINT, 11),
|
||||
CINIT(READFUNCTION, FUNCTIONPOINT, 12),
|
||||
CINIT(POSTFIELDS, OBJECTPOINT, 15),
|
||||
CINIT(HTTPHEADER, OBJECTPOINT, 23),
|
||||
CINIT(WRITEHEADER, OBJECTPOINT, 29),
|
||||
CINIT(COOKIEFILE, OBJECTPOINT, 31),
|
||||
CINIT(TIMECONDITION, LONG, 33),
|
||||
CINIT(TIMEVALUE, LONG, 34),
|
||||
CINIT(CUSTOMREQUEST, OBJECTPOINT, 36),
|
||||
CINIT(VERBOSE, LONG, 41),
|
||||
CINIT(NOPROGRESS, LONG, 43),
|
||||
CINIT(NOBODY, LONG, 44),
|
||||
CINIT(UPLOAD, LONG, 46),
|
||||
CINIT(POST, LONG, 47),
|
||||
CINIT(FOLLOWLOCATION, LONG, 52),
|
||||
CINIT(PROGRESSFUNCTION, FUNCTIONPOINT, 56),
|
||||
CINIT(PROGRESSDATA, OBJECTPOINT, 57),
|
||||
CINIT(POSTFIELDSIZE, LONG, 60),
|
||||
CINIT(SSL_VERIFYPEER, LONG, 64),
|
||||
CINIT(CAINFO, OBJECTPOINT, 65),
|
||||
CINIT(CONNECTTIMEOUT, LONG, 78),
|
||||
CINIT(HEADERFUNCTION, FUNCTIONPOINT, 79),
|
||||
CINIT(COOKIEJAR, OBJECTPOINT, 82),
|
||||
CINIT(HTTP_VERSION, LONG, 84),
|
||||
CINIT(FTP_USE_EPSV, LONG, 85),
|
||||
CINIT(COOKIESESSION, LONG, 96),
|
||||
CINIT(PROXYTYPE, LONG, 101),
|
||||
CINIT(ACCEPT_ENCODING, OBJECTPOINT, 102),
|
||||
CINIT(HTTPAUTH, LONG, 107),
|
||||
CINIT(INFILESIZE_LARGE, OFF_T, 115),
|
||||
CINIT(COOKIELIST, OBJECTPOINT, 135),
|
||||
CINIT(USERNAME, OBJECTPOINT, 173),
|
||||
CINIT(PASSWORD, OBJECTPOINT, 174)
|
||||
} CURLoption;
|
||||
#define CURLINFO_STRING 0x100000
|
||||
#define CURLINFO_LONG 0x200000
|
||||
#define CURLINFO_DOUBLE 0x300000
|
||||
#define CURLINFO_SLIST 0x400000
|
||||
#define CURLINFO_MASK 0x0fffff
|
||||
#define CURLINFO_TYPEMASK 0xf00000
|
||||
typedef enum
|
||||
{
|
||||
CURLINFO_RESPONSE_CODE = CURLINFO_LONG + 2,
|
||||
} CURLINFO;
|
||||
typedef enum
|
||||
{
|
||||
CURLVERSION_FOURTH = 3
|
||||
} CURLversion;
|
||||
typedef enum
|
||||
{
|
||||
CURLMSG_DONE = 1
|
||||
} CURLMSG;
|
||||
#undef CINIT
|
||||
#define CINIT(name, type, num) CURLMOPT_ ## name = CURLOPTTYPE_ ## type + num
|
||||
typedef enum
|
||||
{
|
||||
CINIT(PIPELINING, LONG, 3)
|
||||
} CURLMoption;
|
||||
typedef enum
|
||||
{
|
||||
CURL_TIMECOND_NONE = 0,
|
||||
CURL_TIMECOND_IFMODSINCE = 1,
|
||||
CURL_TIMECOND_IFUNMODSINCE = 2
|
||||
} curl_TimeCond;
|
||||
enum
|
||||
{
|
||||
CURL_HTTP_VERSION_1_0 = 1,
|
||||
CURL_HTTP_VERSION_1_1 = 2,
|
||||
};
|
||||
typedef enum
|
||||
{
|
||||
CURLPROXY_HTTP = 0,
|
||||
CURLPROXY_SOCKS4 = 4,
|
||||
CURLPROXY_SOCKS5 = 5,
|
||||
CURLPROXY_SOCKS4A = 6,
|
||||
CURLPROXY_SOCKS5_HOSTNAME = 7
|
||||
} curl_proxytype;
|
||||
|
||||
#define CURL_GLOBAL_SSL (1 << 0)
|
||||
#define CURL_GLOBAL_WIN32 (1 << 1)
|
||||
#define CURL_GLOBAL_ALL (CURL_GLOBAL_SSL | CURL_GLOBAL_WIN32)
|
||||
#define CURLOPT_ENCODING CURLOPT_ACCEPT_ENCODING
|
||||
#define CURLOPT_WRITEDATA CURLOPT_FILE
|
||||
#define CURLOPT_READDATA CURLOPT_INFILE
|
||||
#define CURLOPT_HEADERDATA CURLOPT_WRITEHEADER
|
||||
#define CURLVERSION_NOW CURLVERSION_FOURTH
|
||||
#define CURLAUTH_BASIC (((unsigned long)1) << 0)
|
||||
#define CURLAUTH_DIGEST_IE (((unsigned long)1) << 4)
|
||||
#define CURLAUTH_ANY (~CURLAUTH_DIGEST_IE)
|
||||
#define CURLAUTH_ANYSAFE (~(CURLAUTH_BASIC | CURLAUTH_DIGEST_IE))
|
||||
#define CURL_READFUNC_ABORT 0x10000000
|
||||
|
||||
typedef void CURLM;
|
||||
typedef void CURL;
|
||||
struct curl_slist
|
||||
{
|
||||
char *data;
|
||||
struct curl_slist *next;
|
||||
};
|
||||
typedef struct
|
||||
{
|
||||
CURLversion age;
|
||||
const char *version;
|
||||
unsigned int version_num;
|
||||
const char *host;
|
||||
int features;
|
||||
const char *ssl_version;
|
||||
long ssl_version_num;
|
||||
const char *libz_version;
|
||||
const char *const *protocols;
|
||||
const char *ares;
|
||||
int ares_num;
|
||||
const char *libidn;
|
||||
int iconv_ver_num;
|
||||
const char *libssh_version;
|
||||
} curl_version_info_data;
|
||||
typedef struct
|
||||
{
|
||||
CURLMSG msg;
|
||||
CURL *easy_handle;
|
||||
union
|
||||
{
|
||||
void *whatever;
|
||||
CURLcode result;
|
||||
} data;
|
||||
} CURLMsg;
|
||||
|
||||
typedef enum _Ecore_Con_Url_Mode
|
||||
{
|
||||
|
@ -192,47 +42,6 @@ typedef enum _Ecore_Con_Url_Mode
|
|||
ECORE_CON_URL_MODE_HEAD = 3,
|
||||
} Ecore_Con_Url_Mode;
|
||||
|
||||
typedef struct _Ecore_Con_Curl Ecore_Con_Curl;
|
||||
|
||||
struct _Ecore_Con_Curl
|
||||
{
|
||||
Eina_Module *mod;
|
||||
|
||||
CURLM *_curlm;
|
||||
|
||||
CURLcode (*curl_global_init)(long flags);
|
||||
void (*curl_global_cleanup)(void);
|
||||
CURLM *(*curl_multi_init)(void);
|
||||
CURLMcode (*curl_multi_timeout)(CURLM *multi_handle,
|
||||
long *milliseconds);
|
||||
CURLMcode (*curl_multi_cleanup)(CURLM *multi_handle);
|
||||
CURLMcode (*curl_multi_remove_handle)(CURLM *multi_handle,
|
||||
CURL *curl_handle);
|
||||
const char *(*curl_multi_strerror)(CURLMcode);
|
||||
CURLMsg *(*curl_multi_info_read)(CURLM * multi_handle,
|
||||
int *msgs_in_queue);
|
||||
CURLMcode (*curl_multi_fdset)(CURLM *multi_handle,
|
||||
fd_set *read_fd_set,
|
||||
fd_set *write_fd_set,
|
||||
fd_set *exc_fd_set,
|
||||
int *max_fd);
|
||||
CURLMcode (*curl_multi_perform)(CURLM *multi_handle,
|
||||
int *running_handles);
|
||||
CURLMcode (*curl_multi_add_handle)(CURLM *multi_handle,
|
||||
CURL *curl_handle);
|
||||
CURLMcode (*curl_multi_setopt)(CURLM *multi_handle,
|
||||
CURLMoption option, ...);
|
||||
CURL *(*curl_easy_init)(void);
|
||||
CURLcode (*curl_easy_setopt)(CURL *curl, CURLoption option, ...);
|
||||
const char *(*curl_easy_strerror)(CURLcode);
|
||||
void (*curl_easy_cleanup)(CURL *curl);
|
||||
CURLcode (*curl_easy_getinfo)(CURL *curl, CURLINFO info, ...);
|
||||
void (*curl_slist_free_all)(struct curl_slist *);
|
||||
struct curl_slist *(*curl_slist_append)(struct curl_slist *list,
|
||||
const char *string);
|
||||
curl_version_info_data *(*curl_version_info)(CURLversion);
|
||||
};
|
||||
|
||||
struct _Ecore_Con_Url_Data
|
||||
{
|
||||
void *curl_easy;
|
||||
|
@ -262,8 +71,6 @@ struct _Ecore_Con_Url_Data
|
|||
typedef struct _Ecore_Con_Url_Data Ecore_Con_Url_Data;
|
||||
typedef struct _Ecore_Con_Url_Data Efl_Network_Url_Data;
|
||||
|
||||
#define CURL_MIN_TIMEOUT 100
|
||||
|
||||
int ECORE_CON_EVENT_URL_DATA = 0;
|
||||
int ECORE_CON_EVENT_URL_COMPLETE = 0;
|
||||
int ECORE_CON_EVENT_URL_PROGRESS = 0;
|
||||
|
@ -287,104 +94,14 @@ static int _init_count = 0;
|
|||
static Ecore_Timer *_curl_timer = NULL;
|
||||
static Eina_Bool pipelining = EINA_FALSE;
|
||||
|
||||
static Ecore_Con_Curl *_c = NULL;
|
||||
static Eina_Bool _c_fail = EINA_FALSE;
|
||||
|
||||
static Eina_Bool
|
||||
_c_init(void)
|
||||
{
|
||||
long ms = 0;
|
||||
|
||||
if (_c) return EINA_TRUE;
|
||||
if (_c_fail) return EINA_FALSE;
|
||||
_c = calloc(1, sizeof(Ecore_Con_Curl));
|
||||
if (!_c) goto error;
|
||||
|
||||
#define LOAD(x) \
|
||||
if (!_c->mod) { \
|
||||
if ((_c->mod = eina_module_new(x))) { \
|
||||
if (!eina_module_load(_c->mod)) { \
|
||||
eina_module_free(_c->mod); \
|
||||
_c->mod = NULL; \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
#if defined(_WIN32) || defined(__CYGWIN__)
|
||||
LOAD("libcurl-5.dll"); // try correct dll first
|
||||
LOAD("libcurl-4.dll"); // try correct dll first
|
||||
LOAD("libcurl.dll"); // try 1
|
||||
LOAD("curllib.dll"); // if fail try 2
|
||||
#elif defined(__APPLE__) && defined(__MACH__)
|
||||
LOAD("libcurl.5.dylib"); // try 1
|
||||
LOAD("libcurl.4.dylib"); // try 1
|
||||
LOAD("libcurl.so.5"); // if fail try 2
|
||||
LOAD("libcurl.so.4"); // if fail try 2
|
||||
#else
|
||||
LOAD("libcurl.so.5"); // try only
|
||||
LOAD("libcurl.so.4"); // try only
|
||||
#endif
|
||||
if (!_c->mod) goto error;
|
||||
|
||||
#define SYM(x) if (!(_c->x = eina_module_symbol_get(_c->mod, #x))) \
|
||||
goto error
|
||||
SYM(curl_global_init);
|
||||
SYM(curl_global_cleanup);
|
||||
SYM(curl_multi_init);
|
||||
SYM(curl_multi_timeout);
|
||||
SYM(curl_multi_cleanup);
|
||||
SYM(curl_multi_remove_handle);
|
||||
SYM(curl_multi_strerror);
|
||||
SYM(curl_multi_info_read);
|
||||
SYM(curl_multi_fdset);
|
||||
SYM(curl_multi_perform);
|
||||
SYM(curl_multi_add_handle);
|
||||
SYM(curl_multi_setopt);
|
||||
SYM(curl_easy_init);
|
||||
SYM(curl_easy_setopt);
|
||||
SYM(curl_easy_strerror);
|
||||
SYM(curl_easy_cleanup);
|
||||
SYM(curl_easy_getinfo);
|
||||
SYM(curl_slist_free_all);
|
||||
SYM(curl_slist_append);
|
||||
SYM(curl_version_info);
|
||||
|
||||
// curl_global_init() is not thread safe!
|
||||
if (_c->curl_global_init(CURL_GLOBAL_ALL)) goto error;
|
||||
_c->_curlm = _c->curl_multi_init();
|
||||
if (!_c->_curlm)
|
||||
{
|
||||
_c->curl_global_cleanup();
|
||||
goto error;
|
||||
}
|
||||
_c->curl_multi_timeout(_c->_curlm, &ms);
|
||||
if ((ms >= CURL_MIN_TIMEOUT) || (ms < 0)) ms = CURL_MIN_TIMEOUT;
|
||||
_curl_timer = ecore_timer_add((double)ms / 1000.0,
|
||||
_ecore_con_url_timer, NULL);
|
||||
ecore_timer_freeze(_curl_timer);
|
||||
return EINA_TRUE;
|
||||
error:
|
||||
if (_c)
|
||||
{
|
||||
if (_c->mod) eina_module_free(_c->mod);
|
||||
free(_c);
|
||||
_c = NULL;
|
||||
}
|
||||
_c_fail = EINA_TRUE;
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
_c_shutdown(void)
|
||||
_ecore_con_post_init(void)
|
||||
{
|
||||
if (!_c) return;
|
||||
if (_c->_curlm)
|
||||
if (!_curl_timer)
|
||||
{
|
||||
_c->curl_multi_cleanup(_c->_curlm);
|
||||
_curl_timer = ecore_timer_add(_c_timeout, _ecore_con_url_timer, NULL);
|
||||
ecore_timer_freeze(_curl_timer);
|
||||
}
|
||||
_c->curl_global_cleanup();
|
||||
if (_c->mod) eina_module_free(_c->mod);
|
||||
free(_c);
|
||||
_c = NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -430,6 +147,7 @@ EAPI void
|
|||
ecore_con_url_pipeline_set(Eina_Bool enable)
|
||||
{
|
||||
if (!_c_init()) return;
|
||||
_ecore_con_post_init();
|
||||
if (enable == pipelining) return;
|
||||
_c->curl_multi_setopt(_c->_curlm, CURLMOPT_PIPELINING, !!enable);
|
||||
pipelining = enable;
|
||||
|
@ -527,6 +245,7 @@ _efl_network_url_eo_base_constructor(Efl_Network_Url *url_obj, Efl_Network_Url_D
|
|||
ERR("Failed");
|
||||
return NULL;
|
||||
}
|
||||
_ecore_con_post_init();
|
||||
|
||||
url_con->curl_easy = _c->curl_easy_init();
|
||||
if (!url_con->curl_easy)
|
||||
|
@ -631,6 +350,7 @@ ecore_con_url_custom_new(const char *url,
|
|||
|
||||
if (!_init_count) return NULL;
|
||||
if (!_c_init()) return NULL;
|
||||
_ecore_con_post_init();
|
||||
if (!url) return NULL;
|
||||
if (!custom_request) return NULL;
|
||||
url_obj = ecore_con_url_new(url);
|
||||
|
|
|
@ -0,0 +1,122 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef HAVE_WS2TCPIP_H
|
||||
# include <ws2tcpip.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_ESCAPE
|
||||
# include <Escape.h>
|
||||
#endif
|
||||
|
||||
#include "Ecore.h"
|
||||
#include "ecore_private.h"
|
||||
#include "Ecore_Con.h"
|
||||
#include "ecore_con_private.h"
|
||||
#include "ecore_con_url_curl.h"
|
||||
|
||||
Ecore_Con_Curl *_c = NULL;
|
||||
Eina_Bool _c_fail = EINA_FALSE;
|
||||
double _c_timeout = 0.0;
|
||||
|
||||
Eina_Bool
|
||||
_c_init(void)
|
||||
{
|
||||
long ms = 0;
|
||||
|
||||
if (_c) return EINA_TRUE;
|
||||
if (_c_fail) return EINA_FALSE;
|
||||
_c = calloc(1, sizeof(Ecore_Con_Curl));
|
||||
if (!_c) goto error;
|
||||
|
||||
#define LOAD(x) \
|
||||
if (!_c->mod) { \
|
||||
if ((_c->mod = eina_module_new(x))) { \
|
||||
if (!eina_module_load(_c->mod)) { \
|
||||
eina_module_free(_c->mod); \
|
||||
_c->mod = NULL; \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
#if defined(_WIN32) || defined(__CYGWIN__)
|
||||
LOAD("libcurl-5.dll"); // try correct dll first
|
||||
LOAD("libcurl-4.dll"); // try correct dll first
|
||||
LOAD("libcurl.dll"); // try 1
|
||||
LOAD("curllib.dll"); // if fail try 2
|
||||
#elif defined(__APPLE__) && defined(__MACH__)
|
||||
LOAD("libcurl.5.dylib"); // try 1
|
||||
LOAD("libcurl.4.dylib"); // try 1
|
||||
LOAD("libcurl.so.5"); // if fail try 2
|
||||
LOAD("libcurl.so.4"); // if fail try 2
|
||||
#else
|
||||
LOAD("libcurl.so.5"); // try only
|
||||
LOAD("libcurl.so.4"); // try only
|
||||
#endif
|
||||
if (!_c->mod) goto error;
|
||||
|
||||
#define SYM(x) if (!(_c->x = eina_module_symbol_get(_c->mod, #x))) \
|
||||
goto error
|
||||
SYM(curl_global_init);
|
||||
SYM(curl_global_cleanup);
|
||||
SYM(curl_multi_init);
|
||||
SYM(curl_multi_timeout);
|
||||
SYM(curl_multi_cleanup);
|
||||
SYM(curl_multi_remove_handle);
|
||||
SYM(curl_multi_strerror);
|
||||
SYM(curl_multi_info_read);
|
||||
SYM(curl_multi_fdset);
|
||||
SYM(curl_multi_perform);
|
||||
SYM(curl_multi_add_handle);
|
||||
SYM(curl_multi_setopt);
|
||||
SYM(curl_easy_init);
|
||||
SYM(curl_easy_setopt);
|
||||
SYM(curl_easy_strerror);
|
||||
SYM(curl_easy_cleanup);
|
||||
SYM(curl_easy_getinfo);
|
||||
SYM(curl_slist_free_all);
|
||||
SYM(curl_slist_append);
|
||||
SYM(curl_version_info);
|
||||
|
||||
// curl_global_init() is not thread safe!
|
||||
if (_c->curl_global_init(CURL_GLOBAL_ALL)) goto error;
|
||||
_c->_curlm = _c->curl_multi_init();
|
||||
if (!_c->_curlm)
|
||||
{
|
||||
_c->curl_global_cleanup();
|
||||
goto error;
|
||||
}
|
||||
_c->curl_multi_timeout(_c->_curlm, &ms);
|
||||
if ((ms >= CURL_MIN_TIMEOUT) || (ms < 0)) ms = CURL_MIN_TIMEOUT;
|
||||
_c_timeout = ms / 1000.0;
|
||||
return EINA_TRUE;
|
||||
error:
|
||||
if (_c)
|
||||
{
|
||||
if (_c->mod) eina_module_free(_c->mod);
|
||||
free(_c);
|
||||
_c = NULL;
|
||||
}
|
||||
_c_fail = EINA_TRUE;
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
_c_shutdown(void)
|
||||
{
|
||||
if (!_c) return;
|
||||
if (_c->_curlm)
|
||||
{
|
||||
_c->curl_multi_cleanup(_c->_curlm);
|
||||
}
|
||||
_c->curl_global_cleanup();
|
||||
if (_c->mod) eina_module_free(_c->mod);
|
||||
free(_c);
|
||||
_c = NULL;
|
||||
}
|
|
@ -0,0 +1,206 @@
|
|||
#ifndef ECORE_CON_URL_CURL_H
|
||||
#define ECORE_CON_URL_CURL_H 1
|
||||
|
||||
// all the types, defines, enums etc. from curl that we actually USE.
|
||||
// we have to add to this if we use more things from curl not already
|
||||
// defined here. see curl headers to get them from
|
||||
typedef enum
|
||||
{
|
||||
CURLM_CALL_MULTI_PERFORM = -1,
|
||||
CURLM_OK = 0
|
||||
} CURLMcode;
|
||||
typedef enum
|
||||
{
|
||||
CURLE_OK = 0,
|
||||
CURLE_OPERATION_TIMEDOUT = 28
|
||||
} CURLcode;
|
||||
#define CURLOPTTYPE_LONG 0
|
||||
#define CURLOPTTYPE_OBJECTPOINT 10000
|
||||
#define CURLOPTTYPE_FUNCTIONPOINT 20000
|
||||
#define CURLOPTTYPE_OFF_T 30000
|
||||
#define CINIT(na, t, nu) CURLOPT_ ## na = CURLOPTTYPE_ ## t + nu
|
||||
typedef enum
|
||||
{
|
||||
CINIT(FILE, OBJECTPOINT, 1),
|
||||
CINIT(URL, OBJECTPOINT, 2),
|
||||
CINIT(PROXY, OBJECTPOINT, 4),
|
||||
CINIT(USERPWD, OBJECTPOINT, 5),
|
||||
CINIT(INFILE, OBJECTPOINT, 9),
|
||||
CINIT(WRITEFUNCTION, FUNCTIONPOINT, 11),
|
||||
CINIT(READFUNCTION, FUNCTIONPOINT, 12),
|
||||
CINIT(POSTFIELDS, OBJECTPOINT, 15),
|
||||
CINIT(HTTPHEADER, OBJECTPOINT, 23),
|
||||
CINIT(WRITEHEADER, OBJECTPOINT, 29),
|
||||
CINIT(COOKIEFILE, OBJECTPOINT, 31),
|
||||
CINIT(TIMECONDITION, LONG, 33),
|
||||
CINIT(TIMEVALUE, LONG, 34),
|
||||
CINIT(CUSTOMREQUEST, OBJECTPOINT, 36),
|
||||
CINIT(VERBOSE, LONG, 41),
|
||||
CINIT(NOPROGRESS, LONG, 43),
|
||||
CINIT(NOBODY, LONG, 44),
|
||||
CINIT(UPLOAD, LONG, 46),
|
||||
CINIT(POST, LONG, 47),
|
||||
CINIT(FOLLOWLOCATION, LONG, 52),
|
||||
CINIT(PROGRESSFUNCTION, FUNCTIONPOINT, 56),
|
||||
CINIT(PROGRESSDATA, OBJECTPOINT, 57),
|
||||
CINIT(POSTFIELDSIZE, LONG, 60),
|
||||
CINIT(SSL_VERIFYPEER, LONG, 64),
|
||||
CINIT(CAINFO, OBJECTPOINT, 65),
|
||||
CINIT(CONNECTTIMEOUT, LONG, 78),
|
||||
CINIT(HEADERFUNCTION, FUNCTIONPOINT, 79),
|
||||
CINIT(COOKIEJAR, OBJECTPOINT, 82),
|
||||
CINIT(HTTP_VERSION, LONG, 84),
|
||||
CINIT(FTP_USE_EPSV, LONG, 85),
|
||||
CINIT(COOKIESESSION, LONG, 96),
|
||||
CINIT(PROXYTYPE, LONG, 101),
|
||||
CINIT(ACCEPT_ENCODING, OBJECTPOINT, 102),
|
||||
CINIT(HTTPAUTH, LONG, 107),
|
||||
CINIT(INFILESIZE_LARGE, OFF_T, 115),
|
||||
CINIT(COOKIELIST, OBJECTPOINT, 135),
|
||||
CINIT(USERNAME, OBJECTPOINT, 173),
|
||||
CINIT(PASSWORD, OBJECTPOINT, 174)
|
||||
} CURLoption;
|
||||
#define CURLINFO_STRING 0x100000
|
||||
#define CURLINFO_LONG 0x200000
|
||||
#define CURLINFO_DOUBLE 0x300000
|
||||
#define CURLINFO_SLIST 0x400000
|
||||
#define CURLINFO_MASK 0x0fffff
|
||||
#define CURLINFO_TYPEMASK 0xf00000
|
||||
typedef enum
|
||||
{
|
||||
CURLINFO_RESPONSE_CODE = CURLINFO_LONG + 2,
|
||||
} CURLINFO;
|
||||
typedef enum
|
||||
{
|
||||
CURLVERSION_FOURTH = 3
|
||||
} CURLversion;
|
||||
typedef enum
|
||||
{
|
||||
CURLMSG_DONE = 1
|
||||
} CURLMSG;
|
||||
#undef CINIT
|
||||
#define CINIT(name, type, num) CURLMOPT_ ## name = CURLOPTTYPE_ ## type + num
|
||||
typedef enum
|
||||
{
|
||||
CINIT(PIPELINING, LONG, 3)
|
||||
} CURLMoption;
|
||||
typedef enum
|
||||
{
|
||||
CURL_TIMECOND_NONE = 0,
|
||||
CURL_TIMECOND_IFMODSINCE = 1,
|
||||
CURL_TIMECOND_IFUNMODSINCE = 2
|
||||
} curl_TimeCond;
|
||||
enum
|
||||
{
|
||||
CURL_HTTP_VERSION_1_0 = 1,
|
||||
CURL_HTTP_VERSION_1_1 = 2,
|
||||
};
|
||||
typedef enum
|
||||
{
|
||||
CURLPROXY_HTTP = 0,
|
||||
CURLPROXY_SOCKS4 = 4,
|
||||
CURLPROXY_SOCKS5 = 5,
|
||||
CURLPROXY_SOCKS4A = 6,
|
||||
CURLPROXY_SOCKS5_HOSTNAME = 7
|
||||
} curl_proxytype;
|
||||
|
||||
#define CURL_GLOBAL_SSL (1 << 0)
|
||||
#define CURL_GLOBAL_WIN32 (1 << 1)
|
||||
#define CURL_GLOBAL_ALL (CURL_GLOBAL_SSL | CURL_GLOBAL_WIN32)
|
||||
#define CURLOPT_ENCODING CURLOPT_ACCEPT_ENCODING
|
||||
#define CURLOPT_WRITEDATA CURLOPT_FILE
|
||||
#define CURLOPT_READDATA CURLOPT_INFILE
|
||||
#define CURLOPT_HEADERDATA CURLOPT_WRITEHEADER
|
||||
#define CURLVERSION_NOW CURLVERSION_FOURTH
|
||||
#define CURLAUTH_BASIC (((unsigned long)1) << 0)
|
||||
#define CURLAUTH_DIGEST_IE (((unsigned long)1) << 4)
|
||||
#define CURLAUTH_ANY (~CURLAUTH_DIGEST_IE)
|
||||
#define CURLAUTH_ANYSAFE (~(CURLAUTH_BASIC | CURLAUTH_DIGEST_IE))
|
||||
#define CURL_READFUNC_ABORT 0x10000000
|
||||
|
||||
typedef void CURLM;
|
||||
typedef void CURL;
|
||||
struct curl_slist
|
||||
{
|
||||
char *data;
|
||||
struct curl_slist *next;
|
||||
};
|
||||
typedef struct
|
||||
{
|
||||
CURLversion age;
|
||||
const char *version;
|
||||
unsigned int version_num;
|
||||
const char *host;
|
||||
int features;
|
||||
const char *ssl_version;
|
||||
long ssl_version_num;
|
||||
const char *libz_version;
|
||||
const char *const *protocols;
|
||||
const char *ares;
|
||||
int ares_num;
|
||||
const char *libidn;
|
||||
int iconv_ver_num;
|
||||
const char *libssh_version;
|
||||
} curl_version_info_data;
|
||||
typedef struct
|
||||
{
|
||||
CURLMSG msg;
|
||||
CURL *easy_handle;
|
||||
union
|
||||
{
|
||||
void *whatever;
|
||||
CURLcode result;
|
||||
} data;
|
||||
} CURLMsg;
|
||||
|
||||
typedef struct _Ecore_Con_Curl Ecore_Con_Curl;
|
||||
|
||||
struct _Ecore_Con_Curl
|
||||
{
|
||||
Eina_Module *mod;
|
||||
|
||||
CURLM *_curlm;
|
||||
|
||||
CURLcode (*curl_global_init)(long flags);
|
||||
void (*curl_global_cleanup)(void);
|
||||
CURLM *(*curl_multi_init)(void);
|
||||
CURLMcode (*curl_multi_timeout)(CURLM *multi_handle,
|
||||
long *milliseconds);
|
||||
CURLMcode (*curl_multi_cleanup)(CURLM *multi_handle);
|
||||
CURLMcode (*curl_multi_remove_handle)(CURLM *multi_handle,
|
||||
CURL *curl_handle);
|
||||
const char *(*curl_multi_strerror)(CURLMcode);
|
||||
CURLMsg *(*curl_multi_info_read)(CURLM * multi_handle,
|
||||
int *msgs_in_queue);
|
||||
CURLMcode (*curl_multi_fdset)(CURLM *multi_handle,
|
||||
fd_set *read_fd_set,
|
||||
fd_set *write_fd_set,
|
||||
fd_set *exc_fd_set,
|
||||
int *max_fd);
|
||||
CURLMcode (*curl_multi_perform)(CURLM *multi_handle,
|
||||
int *running_handles);
|
||||
CURLMcode (*curl_multi_add_handle)(CURLM *multi_handle,
|
||||
CURL *curl_handle);
|
||||
CURLMcode (*curl_multi_setopt)(CURLM *multi_handle,
|
||||
CURLMoption option, ...);
|
||||
CURL *(*curl_easy_init)(void);
|
||||
CURLcode (*curl_easy_setopt)(CURL *curl, CURLoption option, ...);
|
||||
const char *(*curl_easy_strerror)(CURLcode);
|
||||
void (*curl_easy_cleanup)(CURL *curl);
|
||||
CURLcode (*curl_easy_getinfo)(CURL *curl, CURLINFO info, ...);
|
||||
void (*curl_slist_free_all)(struct curl_slist *);
|
||||
struct curl_slist *(*curl_slist_append)(struct curl_slist *list,
|
||||
const char *string);
|
||||
curl_version_info_data *(*curl_version_info)(CURLversion);
|
||||
};
|
||||
|
||||
#define CURL_MIN_TIMEOUT 100
|
||||
|
||||
extern Ecore_Con_Curl *_c;
|
||||
extern Eina_Bool _c_fail;
|
||||
extern double _c_timeout;
|
||||
|
||||
Eina_Bool _c_init(void);
|
||||
void _c_shutdown(void);
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue