switch_curl.h File Reference

#include "curl/curl.h"

Include dependency graph for switch_curl.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef void switch_CURL
typedef curl_slist switch_curl_slist_t
typedef int switch_CURLINFO
typedef int switch_CURLcode
typedef int switch_CURLoption

Functions

switch_CURLswitch_curl_easy_init (void)
switch_CURLcode switch_curl_easy_perform (switch_CURL *handle)
switch_CURLcode switch_curl_easy_getinfo (switch_CURL *curl, switch_CURLINFO info,...)
void switch_curl_easy_cleanup (switch_CURL *handle)
switch_curl_slist_tswitch_curl_slist_append (switch_curl_slist_t *list, const char *string)
void switch_curl_slist_free_all (switch_curl_slist_t *list)
switch_CURLcode switch_curl_easy_setopt (CURL *handle, switch_CURLoption option,...)
const char * switch_curl_easy_strerror (switch_CURLcode errornum)
void switch_curl_init (void)
void switch_curl_destroy (void)
switch_status_t switch_curl_process_form_post_params (switch_event_t *event, switch_CURL *curl_handle, struct curl_httppost **formpostp)


Typedef Documentation

typedef void switch_CURL

Definition at line 36 of file switch_curl.h.

typedef struct curl_slist switch_curl_slist_t

Definition at line 37 of file switch_curl.h.

typedef int switch_CURLcode

Definition at line 39 of file switch_curl.h.

typedef int switch_CURLINFO

Definition at line 38 of file switch_curl.h.

typedef int switch_CURLoption

Definition at line 40 of file switch_curl.h.


Function Documentation

void switch_curl_destroy ( void   ) 

Definition at line 71 of file switch_curl.c.

00072 {
00073         curl_global_cleanup();
00074 }

void switch_curl_easy_cleanup ( switch_CURL handle  ) 

Definition at line 31 of file switch_curl.c.

00032 {
00033         curl_easy_cleanup((CURL *)handle);
00034 }

switch_CURLcode switch_curl_easy_getinfo ( switch_CURL curl,
switch_CURLINFO  info,
  ... 
)

Definition at line 19 of file switch_curl.c.

00020 {
00021         va_list ap;
00022         switch_CURLcode code;
00023 
00024         va_start(ap, info);
00025         code = curl_easy_getinfo(curl, info, va_arg(ap, void *));
00026         va_end(ap);
00027 
00028         return code;
00029 }

switch_CURL* switch_curl_easy_init ( void   ) 

Definition at line 8 of file switch_curl.c.

00009 {
00010         return curl_easy_init();
00011 }

switch_CURLcode switch_curl_easy_perform ( switch_CURL handle  ) 

Definition at line 13 of file switch_curl.c.

00014 {
00015         return curl_easy_perform((CURL *)handle);
00016 }

switch_CURLcode switch_curl_easy_setopt ( CURL *  handle,
switch_CURLoption  option,
  ... 
)

Definition at line 49 of file switch_curl.c.

References Curl_setopt().

00050 {
00051         va_list ap;
00052         switch_CURLcode code;
00053 
00054         va_start(ap, option);
00055         code = Curl_setopt(handle, option, ap);
00056         va_end(ap);
00057 
00058         return code;
00059 }

const char* switch_curl_easy_strerror ( switch_CURLcode  errornum  ) 

Definition at line 61 of file switch_curl.c.

00062 {
00063         return curl_easy_strerror(errornum);
00064 }

void switch_curl_init ( void   ) 

Definition at line 66 of file switch_curl.c.

Referenced by switch_core_init().

00067 {
00068         curl_global_init(CURL_GLOBAL_ALL);
00069 }

switch_status_t switch_curl_process_form_post_params ( switch_event_t event,
switch_CURL curl_handle,
struct curl_httppost **  formpostp 
)

Definition at line 76 of file switch_curl.c.

References switch_event_header::name, switch_event_header::next, SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, and switch_event_header::value.

00077 {
00078 
00079         struct curl_httppost *formpost=NULL;
00080         struct curl_httppost *lastptr=NULL;
00081         switch_event_header_t *hp;
00082         int go = 0;
00083 
00084         for (hp = event->headers; hp; hp = hp->next) {
00085                 if (!strncasecmp(hp->name, "attach_file:", 12)) {
00086                         go = 1;
00087                         break;
00088                 }
00089         }
00090 
00091         if (!go) {
00092                 return SWITCH_STATUS_FALSE;
00093         }
00094 
00095         for (hp = event->headers; hp; hp = hp->next) {
00096 
00097                 if (!strncasecmp(hp->name, "attach_file:", 12)) {
00098                         char *pname = strdup(hp->name + 12);
00099                         char *fname = strchr(pname, ':');
00100                         
00101                         if (fname && pname) {
00102                                 *fname++ = '\0';
00103 
00104                                 curl_formadd(&formpost,
00105                                                          &lastptr,
00106                                                          CURLFORM_COPYNAME, pname,
00107                                                          CURLFORM_FILENAME, fname,
00108                                                          CURLFORM_FILE, hp->value,
00109                                                          CURLFORM_END);
00110                         }
00111 
00112                         free(pname);
00113 
00114                 } else {
00115                         curl_formadd(&formpost,
00116                                                  &lastptr,
00117                                                  CURLFORM_COPYNAME, hp->name,
00118                                                  CURLFORM_COPYCONTENTS, hp->value,
00119                                                  CURLFORM_END);
00120 
00121                 }
00122         }
00123 
00124         *formpostp = formpost;
00125 
00126         return SWITCH_STATUS_SUCCESS;
00127 
00128 }

switch_curl_slist_t* switch_curl_slist_append ( switch_curl_slist_t list,
const char *  string 
)

Definition at line 38 of file switch_curl.c.

00039 {
00040         return (switch_curl_slist_t *) curl_slist_append((struct curl_slist *)list, string);
00041 }

void switch_curl_slist_free_all ( switch_curl_slist_t list  ) 

Definition at line 44 of file switch_curl.c.

00045 {
00046         curl_slist_free_all((struct curl_slist *) list);
00047 }


Generated on Sun May 20 04:00:10 2012 for FreeSWITCH API Documentation by  doxygen 1.4.7