summaryrefslogtreecommitdiff
path: root/apps/app_exec.c
diff options
context:
space:
mode:
authorTilghman Lesher <tilghman@meg.abyt.es>2009-04-29 18:53:01 +0000
committerTilghman Lesher <tilghman@meg.abyt.es>2009-04-29 18:53:01 +0000
commita866a7590085a1f635ca92459c3917e5cded257a (patch)
tree972bdf8f96c18f1b9667469307af69385f4a75f3 /apps/app_exec.c
parent0ea83eab4811c8519e4e04bf4c59b1744cf1efc9 (diff)
Merge str_substitution branch.
This branch adds additional methods to dialplan functions, whereby the result buffers are now dynamic buffers, which can be expanded to the size of any result. No longer are variable substitutions limited to 4095 bytes of data. In addition, the common case of needing buffers much smaller than that will enable substitution to only take up the amount of memory actually needed. The existing variable substitution routines are still available, but users of those API calls should transition to using the dynamic-buffer APIs. Reviewboard: http://reviewboard.digium.com/r/174/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@191140 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'apps/app_exec.c')
-rw-r--r--apps/app_exec.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/apps/app_exec.c b/apps/app_exec.c
index 3b831ba6c..3c5be33b6 100644
--- a/apps/app_exec.c
+++ b/apps/app_exec.c
@@ -132,56 +132,61 @@ static char *app_execif = "ExecIf";
static int exec_exec(struct ast_channel *chan, void *data)
{
int res = 0;
- char *s, *appname, *endargs, args[MAXRESULT];
+ char *s, *appname, *endargs;
struct ast_app *app;
+ struct ast_str *args = NULL;
if (ast_strlen_zero(data))
return 0;
s = ast_strdupa(data);
- args[0] = 0;
appname = strsep(&s, "(");
if (s) {
endargs = strrchr(s, ')');
if (endargs)
*endargs = '\0';
- pbx_substitute_variables_helper(chan, s, args, MAXRESULT - 1);
+ if ((args = ast_str_create(16))) {
+ ast_str_substitute_variables(&args, 0, chan, s);
+ }
}
if (appname) {
app = pbx_findapp(appname);
if (app) {
- res = pbx_exec(chan, app, args);
+ res = pbx_exec(chan, app, args ? ast_str_buffer(args) : NULL);
} else {
ast_log(LOG_WARNING, "Could not find application (%s)\n", appname);
res = -1;
}
}
+ ast_free(args);
return res;
}
static int tryexec_exec(struct ast_channel *chan, void *data)
{
int res = 0;
- char *s, *appname, *endargs, args[MAXRESULT];
+ char *s, *appname, *endargs;
struct ast_app *app;
+ struct ast_str *args = NULL;
if (ast_strlen_zero(data))
return 0;
s = ast_strdupa(data);
- args[0] = 0;
appname = strsep(&s, "(");
if (s) {
endargs = strrchr(s, ')');
if (endargs)
*endargs = '\0';
- pbx_substitute_variables_helper(chan, s, args, MAXRESULT - 1);
+ if ((args = ast_str_create(16))) {
+ ast_str_substitute_variables(&args, 0, chan, s);
+ }
}
if (appname) {
app = pbx_findapp(appname);
if (app) {
- res = pbx_exec(chan, app, args);
+ res = pbx_exec(chan, app, args ? ast_str_buffer(args) : NULL);
pbx_builtin_setvar_helper(chan, "TRYSTATUS", res ? "FAILED" : "SUCCESS");
} else {
ast_log(LOG_WARNING, "Could not find application (%s)\n", appname);
@@ -189,6 +194,7 @@ static int tryexec_exec(struct ast_channel *chan, void *data)
}
}
+ ast_free(args);
return 0;
}