aboutsummaryrefslogtreecommitdiffstats
path: root/apps/app_exec.c
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2008-06-06 17:34:21 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2008-06-06 17:34:21 +0000
commitd7d5ebe84a078e4c5fe422411f6caddb4888ea3f (patch)
tree7536e3cf4af2974b7535fb2fb0cabb43563e1768 /apps/app_exec.c
parent92a68fd2a8a14693ec56bb0388fecfdd600aef01 (diff)
For the purpose of making the changed syntax to ExecIf easier to transition,
allow the deprecated syntax (fixed for jmls on -dev). git-svn-id: http://svn.digium.com/svn/asterisk/trunk@120904 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps/app_exec.c')
-rw-r--r--apps/app_exec.c57
1 files changed, 41 insertions, 16 deletions
diff --git a/apps/app_exec.c b/apps/app_exec.c
index 88c81822b..285b8b2f0 100644
--- a/apps/app_exec.c
+++ b/apps/app_exec.c
@@ -148,7 +148,7 @@ static int tryexec_exec(struct ast_channel *chan, void *data)
static int execif_exec(struct ast_channel *chan, void *data)
{
int res = 0;
- char *truedata = NULL, *falsedata = NULL, *end;
+ char *truedata = NULL, *falsedata = NULL, *end, *firstcomma, *firstquestion;
struct ast_app *app = NULL;
AST_DECLARE_APP_ARGS(expr,
AST_APP_ARG(expr);
@@ -160,24 +160,49 @@ static int execif_exec(struct ast_channel *chan, void *data)
);
char *parse = ast_strdupa(data);
- AST_NONSTANDARD_APP_ARGS(expr, parse, '?');
- if (ast_strlen_zero(expr.remainder)) {
- ast_log(LOG_ERROR, "Usage: ExecIf(<expr>?<appiftrue>(<args>)[:<appiffalse>(<args)])\n");
- return -1;
- }
+ firstcomma = strchr(parse, ',');
+ firstquestion = strchr(parse, '?');
+
+ if ((firstcomma != NULL && firstquestion != NULL && firstcomma < firstquestion) || (firstquestion == NULL)) {
+ /* Deprecated syntax */
+ AST_DECLARE_APP_ARGS(depr,
+ AST_APP_ARG(expr);
+ AST_APP_ARG(appname);
+ AST_APP_ARG(appargs);
+ );
+ AST_STANDARD_APP_ARGS(depr, parse);
+
+ ast_log(LOG_WARNING, "Deprecated syntax found. Please upgrade to using ExecIf(<expr>?%s(%s))\n", depr.appname, depr.appargs);
+
+ /* Make the two syntaxes look the same */
+ expr.expr = depr.expr;
+ apps.t = depr.appname;
+ apps.f = NULL;
+ truedata = depr.appargs;
+ } else {
+ /* Preferred syntax */
+
+ AST_NONSTANDARD_APP_ARGS(expr, parse, '?');
+ if (ast_strlen_zero(expr.remainder)) {
+ ast_log(LOG_ERROR, "Usage: ExecIf(<expr>?<appiftrue>(<args>)[:<appiffalse>(<args)])\n");
+ return -1;
+ }
- AST_NONSTANDARD_APP_ARGS(apps, expr.remainder, ':');
+ AST_NONSTANDARD_APP_ARGS(apps, expr.remainder, ':');
- if (apps.t && (truedata = strchr(apps.t, '('))) {
- *truedata++ = '\0';
- if ((end = strrchr(truedata, ')')))
- *end = '\0';
- }
+ if (apps.t && (truedata = strchr(apps.t, '('))) {
+ *truedata++ = '\0';
+ if ((end = strrchr(truedata, ')'))) {
+ *end = '\0';
+ }
+ }
- if (apps.f && (falsedata = strchr(apps.f, '('))) {
- *falsedata++ = '\0';
- if ((end = strrchr(falsedata, ')')))
- *end = '\0';
+ if (apps.f && (falsedata = strchr(apps.f, '('))) {
+ *falsedata++ = '\0';
+ if ((end = strrchr(falsedata, ')'))) {
+ *end = '\0';
+ }
+ }
}
if (pbx_checkcondition(expr.expr)) {