7 return curl_easy_init();
12 return curl_easy_perform((CURL *)handle);
22 code = curl_easy_getinfo(curl, info, va_arg(ap,
void *));
30 curl_easy_cleanup((CURL *)handle);
43 curl_slist_free_all((
struct curl_slist *) list);
48 return curl_easy_strerror(errornum);
53 curl_global_init(CURL_GLOBAL_ALL);
58 curl_global_cleanup();
63 #if defined(LIBCURL_VERSION_NUM) && (LIBCURL_VERSION_NUM >= 0x073800) 64 curl_mime *mime = NULL;
65 curl_mimepart *part = NULL;
69 struct curl_httppost *formpost=NULL;
70 struct curl_httppost *lastptr=NULL;
76 if (!strncasecmp(hp->
name,
"attach_file:", 12)) {
86 #if defined(LIBCURL_VERSION_NUM) && (LIBCURL_VERSION_NUM >= 0x073800) 87 mime = curl_mime_init(curl_handle);
91 if (!strncasecmp(hp->
name,
"attach_file:", 12)) {
92 char *pname = strdup(hp->
name + 12);
95 char *fname = strchr(pname,
':');
100 #if defined(LIBCURL_VERSION_NUM) && (LIBCURL_VERSION_NUM >= 0x073800) 101 part = curl_mime_addpart(mime);
102 if ((curl_code = curl_mime_name(part, pname))) {
107 if ((curl_code = curl_mime_filename(part, fname))) {
112 if ((curl_code = curl_mime_filedata(part, hp->
value))) {
119 curl_formadd(&formpost,
121 CURLFORM_COPYNAME, pname,
122 CURLFORM_FILENAME, fname,
123 CURLFORM_FILE, hp->
value,
131 #if defined(LIBCURL_VERSION_NUM) && (LIBCURL_VERSION_NUM >= 0x073800) 132 part = curl_mime_addpart(mime);
133 if ((curl_code = curl_mime_name(part, hp->
name))) {
137 if ((curl_code = curl_mime_data(part, hp->
value, CURL_ZERO_TERMINATED))) {
143 curl_formadd(&formpost,
145 CURLFORM_COPYNAME, hp->
name,
146 CURLFORM_COPYCONTENTS, hp->
value,
152 #if defined(LIBCURL_VERSION_NUM) && (LIBCURL_VERSION_NUM >= 0x073800) 159 curl_mime_free(mime);
173 if (mimep && *mimep) {
174 #if defined(LIBCURL_VERSION_NUM) && (LIBCURL_VERSION_NUM >= 0x073800) 175 curl_mime_free(*mimep);
177 curl_formfree(*mimep);
185 #if defined(LIBCURL_VERSION_NUM) && (LIBCURL_VERSION_NUM >= 0x073800) 186 return curl_easy_setopt(curl_handle, CURLOPT_MIMEPOST, mime);
188 return curl_easy_setopt(curl_handle, CURLOPT_HTTPPOST, mime);
void switch_curl_init(void)
void switch_curl_destroy(void)
#define SWITCH_CHANNEL_LOG
Representation of an event.
switch_curl_slist_t * switch_curl_slist_append(switch_curl_slist_t *list, const char *string)
switch_CURLcode switch_curl_easy_getinfo(switch_CURL *curl, switch_CURLINFO info,...)
switch_CURLcode switch_curl_easy_perform(switch_CURL *handle)
switch_CURL * switch_curl_easy_init(void)
void switch_curl_mime_free(switch_curl_mime **mimep)
SWITCH_BEGIN_EXTERN_C typedef void switch_CURL
struct curl_slist switch_curl_slist_t
switch_CURLcode switch_curl_easy_setopt_mime(switch_CURL *curl_handle, switch_curl_mime *mime)
switch_status_t
Common return values.
void switch_curl_easy_cleanup(switch_CURL *handle)
void switch_log_printf(_In_ switch_text_channel_t channel, _In_z_ const char *file, _In_z_ const char *func, _In_ int line, _In_opt_z_ const char *userdata, _In_ switch_log_level_t level, _In_z_ _Printf_format_string_ const char *fmt,...) PRINTF_FUNCTION(7
Write log data to the logging engine.
switch_status_t switch_curl_process_mime(switch_event_t *event, switch_CURL *curl_handle, switch_curl_mime **mimep)
const char * switch_curl_easy_strerror(switch_CURLcode errornum)
void switch_curl_slist_free_all(switch_curl_slist_t *list)
switch_event_header_t * headers