mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-19 08:11:21 +00:00
use app arg parsing macros (issue #5679)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@7236 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -40,6 +40,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
|||||||
#include "asterisk/cli.h"
|
#include "asterisk/cli.h"
|
||||||
#include "asterisk/options.h"
|
#include "asterisk/options.h"
|
||||||
#include "asterisk/module.h"
|
#include "asterisk/module.h"
|
||||||
|
#include "asterisk/app.h"
|
||||||
|
|
||||||
static char *tdesc = "Load external URL";
|
static char *tdesc = "Load external URL";
|
||||||
|
|
||||||
@@ -120,9 +121,13 @@ static int curl_exec(struct ast_channel *chan, void *data)
|
|||||||
{
|
{
|
||||||
int res = 0;
|
int res = 0;
|
||||||
struct localuser *u;
|
struct localuser *u;
|
||||||
char *info, *post_data=NULL, *url;
|
char *info;
|
||||||
struct MemoryStruct chunk = { NULL, 0 };
|
struct MemoryStruct chunk = { NULL, 0 };
|
||||||
static int dep_warning = 0;
|
static int dep_warning = 0;
|
||||||
|
AST_DECLARE_APP_ARGS(args,
|
||||||
|
AST_APP_ARG(url);
|
||||||
|
AST_APP_ARG(postdata);
|
||||||
|
);
|
||||||
|
|
||||||
if (!dep_warning) {
|
if (!dep_warning) {
|
||||||
ast_log(LOG_WARNING, "The application Curl is deprecated. Please use the CURL() function instead.\n");
|
ast_log(LOG_WARNING, "The application Curl is deprecated. Please use the CURL() function instead.\n");
|
||||||
@@ -137,15 +142,14 @@ static int curl_exec(struct ast_channel *chan, void *data)
|
|||||||
LOCAL_USER_ADD(u);
|
LOCAL_USER_ADD(u);
|
||||||
|
|
||||||
if ((info = ast_strdupa(data))) {
|
if ((info = ast_strdupa(data))) {
|
||||||
url = strsep(&info, "|");
|
AST_STANDARD_APP_ARGS(args, info);
|
||||||
post_data = info;
|
|
||||||
} else {
|
} else {
|
||||||
ast_log(LOG_ERROR, "Out of memory\n");
|
ast_log(LOG_ERROR, "Out of memory\n");
|
||||||
LOCAL_USER_REMOVE(u);
|
LOCAL_USER_REMOVE(u);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! curl_internal(&chunk, url, post_data)) {
|
if (! curl_internal(&chunk, args.url, args.postdata)) {
|
||||||
if (chunk.memory) {
|
if (chunk.memory) {
|
||||||
chunk.memory[chunk.size] = '\0';
|
chunk.memory[chunk.size] = '\0';
|
||||||
if (chunk.memory[chunk.size - 1] == 10)
|
if (chunk.memory[chunk.size - 1] == 10)
|
||||||
@@ -167,8 +171,12 @@ static int curl_exec(struct ast_channel *chan, void *data)
|
|||||||
static char *acf_curl_exec(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
|
static char *acf_curl_exec(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
|
||||||
{
|
{
|
||||||
struct localuser *u;
|
struct localuser *u;
|
||||||
char *info, *post_data=NULL, *url;
|
char *info;
|
||||||
struct MemoryStruct chunk = { NULL, 0 };
|
struct MemoryStruct chunk = { NULL, 0 };
|
||||||
|
AST_DECLARE_APP_ARGS(args,
|
||||||
|
AST_APP_ARG(url);
|
||||||
|
AST_APP_ARG(postdata);
|
||||||
|
);
|
||||||
|
|
||||||
*buf = '\0';
|
*buf = '\0';
|
||||||
|
|
||||||
@@ -186,10 +194,9 @@ static char *acf_curl_exec(struct ast_channel *chan, char *cmd, char *data, char
|
|||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
url = strsep(&info, "|");
|
AST_STANDARD_APP_ARGS(args, info);
|
||||||
post_data = info;
|
|
||||||
|
|
||||||
if (! curl_internal(&chunk, url, post_data)) {
|
if (! curl_internal(&chunk, args.url, args.postdata)) {
|
||||||
if (chunk.memory) {
|
if (chunk.memory) {
|
||||||
chunk.memory[chunk.size] = '\0';
|
chunk.memory[chunk.size] = '\0';
|
||||||
if (chunk.memory[chunk.size - 1] == 10)
|
if (chunk.memory[chunk.size - 1] == 10)
|
||||||
|
|||||||
Reference in New Issue
Block a user