FreeSWITCH API Documentation  1.7.0
Macros | Typedefs | Functions | Variables
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.

Macros

#define switch_curl_easy_setopt   curl_easy_setopt
 

Typedefs

typedef struct 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)
 

Variables

SWITCH_BEGIN_EXTERN_C typedef void switch_CURL
 

Macro Definition Documentation

#define switch_curl_easy_setopt   curl_easy_setopt

Definition at line 54 of file switch_curl.h.

Typedef Documentation

typedef struct curl_slist switch_curl_slist_t

Definition at line 38 of file switch_curl.h.

typedef int switch_CURLcode

Definition at line 40 of file switch_curl.h.

typedef int switch_CURLINFO

Definition at line 39 of file switch_curl.h.

typedef int switch_CURLoption

Definition at line 41 of file switch_curl.h.

Function Documentation

void switch_curl_destroy ( void  )

Definition at line 56 of file switch_curl.c.

57 {
58  curl_global_cleanup();
59 }
void switch_curl_easy_cleanup ( switch_CURL handle)

Definition at line 28 of file switch_curl.c.

29 {
30  curl_easy_cleanup((CURL *)handle);
31 }
switch_CURLcode switch_curl_easy_getinfo ( switch_CURL curl,
switch_CURLINFO  info,
  ... 
)

Definition at line 16 of file switch_curl.c.

17 {
18  va_list ap;
19  switch_CURLcode code;
20 
21  va_start(ap, info);
22  code = curl_easy_getinfo(curl, info, va_arg(ap, void *));
23  va_end(ap);
24 
25  return code;
26 }
int switch_CURLcode
Definition: switch_curl.h:40
switch_CURL* switch_curl_easy_init ( void  )

Definition at line 5 of file switch_curl.c.

6 {
7  return curl_easy_init();
8 }
switch_CURLcode switch_curl_easy_perform ( switch_CURL handle)

Definition at line 10 of file switch_curl.c.

11 {
12  return curl_easy_perform((CURL *)handle);
13 }
switch_CURLcode switch_curl_easy_setopt ( CURL *  handle,
switch_CURLoption  option,
  ... 
)
const char* switch_curl_easy_strerror ( switch_CURLcode  errornum)

Definition at line 46 of file switch_curl.c.

47 {
48  return curl_easy_strerror(errornum);
49 }
void switch_curl_init ( void  )

Definition at line 51 of file switch_curl.c.

Referenced by switch_core_init().

52 {
53  curl_global_init(CURL_GLOBAL_ALL);
54 }
switch_status_t switch_curl_process_form_post_params ( switch_event_t event,
switch_CURL curl_handle,
struct curl_httppost **  formpostp 
)

Definition at line 61 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.

62 {
63 
64  struct curl_httppost *formpost=NULL;
65  struct curl_httppost *lastptr=NULL;
67  int go = 0;
68 
69  for (hp = event->headers; hp; hp = hp->next) {
70  if (!strncasecmp(hp->name, "attach_file:", 12)) {
71  go = 1;
72  break;
73  }
74  }
75 
76  if (!go) {
77  return SWITCH_STATUS_FALSE;
78  }
79 
80  for (hp = event->headers; hp; hp = hp->next) {
81 
82  if (!strncasecmp(hp->name, "attach_file:", 12)) {
83  char *pname = strdup(hp->name + 12);
84 
85  if (pname) {
86  char *fname = strchr(pname, ':');
87  if (fname) {
88  *fname++ = '\0';
89 
90  curl_formadd(&formpost,
91  &lastptr,
92  CURLFORM_COPYNAME, pname,
93  CURLFORM_FILENAME, fname,
94  CURLFORM_FILE, hp->value,
95  CURLFORM_END);
96  }
97  free(pname);
98  }
99  } else {
100  curl_formadd(&formpost,
101  &lastptr,
102  CURLFORM_COPYNAME, hp->name,
103  CURLFORM_COPYCONTENTS, hp->value,
104  CURLFORM_END);
105 
106  }
107  }
108 
109  *formpostp = formpost;
110 
111  return SWITCH_STATUS_SUCCESS;
112 
113 }
An event Header.
Definition: switch_event.h:65
struct switch_event_header * next
Definition: switch_event.h:76
switch_event_header_t * headers
Definition: switch_event.h:90
switch_curl_slist_t* switch_curl_slist_append ( switch_curl_slist_t list,
const char *  string 
)

Definition at line 35 of file switch_curl.c.

36 {
37  return (switch_curl_slist_t *) curl_slist_append((struct curl_slist *)list, string);
38 }
struct curl_slist switch_curl_slist_t
Definition: switch_curl.h:38
void switch_curl_slist_free_all ( switch_curl_slist_t list)

Definition at line 41 of file switch_curl.c.

42 {
43  curl_slist_free_all((struct curl_slist *) list);
44 }

Variable Documentation

SWITCH_BEGIN_EXTERN_C typedef void switch_CURL

Definition at line 37 of file switch_curl.h.