]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
move func in the core to hide the need to wrap it
authorAnthony Minessale <anthm@freeswitch.org>
Thu, 5 Jan 2012 22:57:31 +0000 (16:57 -0600)
committerAnthony Minessale <anthm@freeswitch.org>
Thu, 5 Jan 2012 22:57:31 +0000 (16:57 -0600)
src/include/switch_curl.h
src/mod/applications/mod_httapi/mod_httapi.c
src/switch_curl.c

index 17c4bd6ce1c88b305c78014b03ce71ff06830a72..a404bffb3413d430bbcf6670c98203b30a556c1b 100644 (file)
@@ -49,7 +49,7 @@ SWITCH_DECLARE(switch_CURLcode) switch_curl_easy_setopt(CURL *handle, switch_CUR
 SWITCH_DECLARE(const char *) switch_curl_easy_strerror(switch_CURLcode errornum );
 SWITCH_DECLARE(void) switch_curl_init(void);
 SWITCH_DECLARE(void) switch_curl_destroy(void);
-
+SWITCH_DECLARE(switch_status_t) switch_curl_process_form_post_params(switch_event_t *event, switch_CURL *curl_handle, struct curl_httppost **formpostp);
                                                                                                                                
 #endif
 
index 5d68c548f27dc83025b618d7dc7a8485d76b17a5..08ef37d4464f1f18ccc79c42436a4e8a412be4cd 100644 (file)
@@ -1106,58 +1106,6 @@ static void cleanup_attachments(client_t *client)
        }
 }
 
-static switch_status_t process_form_post_params(client_t *client, switch_CURL *curl_handle, struct curl_httppost **formpostp)
-{
-
-       struct curl_httppost *formpost=NULL;
-       struct curl_httppost *lastptr=NULL;
-       switch_event_header_t *hp;
-       int go = 0;
-
-       for (hp = client->params->headers; hp; hp = hp->next) {
-               if (!strncasecmp(hp->name, "attach_file:", 12)) {
-                       go = 1;
-                       break;
-               }
-       }
-
-       if (!go) {
-               return SWITCH_STATUS_FALSE;
-       }
-
-       for (hp = client->params->headers; hp; hp = hp->next) {
-
-               if (!strncasecmp(hp->name, "attach_file:", 12)) {
-                       char *pname = switch_core_strdup(client->pool, hp->name + 12);
-                       char *fname = strchr(pname, ':');
-                       
-                       if (fname && pname) {
-                               *fname++ = '\0';
-
-                               curl_formadd(&formpost,
-                                                        &lastptr,
-                                                        CURLFORM_COPYNAME, pname,
-                                                        CURLFORM_FILENAME, fname,
-                                                        CURLFORM_FILE, hp->value,
-                                                        CURLFORM_END);
-                       }
-
-               } else {
-                       curl_formadd(&formpost,
-                                                &lastptr,
-                                                CURLFORM_COPYNAME, hp->name,
-                                                CURLFORM_COPYCONTENTS, hp->value,
-                                                CURLFORM_END);
-
-               }
-       }
-
-       *formpostp = formpost;
-
-       return SWITCH_STATUS_SUCCESS;
-
-}
-
 static switch_status_t httapi_sync(client_t *client)
                                                                  
 {
@@ -1208,7 +1156,7 @@ static switch_status_t httapi_sync(client_t *client)
 
        dynamic_url = switch_event_expand_headers(client->params, url);
 
-       process_form_post_params(client, curl_handle, &formpost);
+       switch_curl_process_form_post_params(client->params, curl_handle, &formpost);
 
        if (formpost) {
                get_style_method = 1;
index 5f22b94df0d0eeb32462607946da21ebc8d55de5..1e37b2a074c9d4c5bc106dbc97c907ffc1eb04ca 100644 (file)
@@ -73,3 +73,56 @@ SWITCH_DECLARE(void) switch_curl_destroy(void)
        curl_global_cleanup();
 }
 
+SWITCH_DECLARE(switch_status_t) switch_curl_process_form_post_params(switch_event_t *event, switch_CURL *curl_handle, struct curl_httppost **formpostp)
+{
+
+       struct curl_httppost *formpost=NULL;
+       struct curl_httppost *lastptr=NULL;
+       switch_event_header_t *hp;
+       int go = 0;
+
+       for (hp = event->headers; hp; hp = hp->next) {
+               if (!strncasecmp(hp->name, "attach_file:", 12)) {
+                       go = 1;
+                       break;
+               }
+       }
+
+       if (!go) {
+               return SWITCH_STATUS_FALSE;
+       }
+
+       for (hp = event->headers; hp; hp = hp->next) {
+
+               if (!strncasecmp(hp->name, "attach_file:", 12)) {
+                       char *pname = strdup(hp->name + 12);
+                       char *fname = strchr(pname, ':');
+                       
+                       if (fname && pname) {
+                               *fname++ = '\0';
+
+                               curl_formadd(&formpost,
+                                                        &lastptr,
+                                                        CURLFORM_COPYNAME, pname,
+                                                        CURLFORM_FILENAME, fname,
+                                                        CURLFORM_FILE, hp->value,
+                                                        CURLFORM_END);
+                       }
+
+                       free(pname);
+
+               } else {
+                       curl_formadd(&formpost,
+                                                &lastptr,
+                                                CURLFORM_COPYNAME, hp->name,
+                                                CURLFORM_COPYCONTENTS, hp->value,
+                                                CURLFORM_END);
+
+               }
+       }
+
+       *formpostp = formpost;
+
+       return SWITCH_STATUS_SUCCESS;
+
+}