aboutsummaryrefslogtreecommitdiffstats
path: root/funcs
diff options
context:
space:
mode:
authorkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2005-05-15 23:53:11 +0000
committerkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2005-05-15 23:53:11 +0000
commit6fa490c732613ed6a3465ea6ca2453fdcfdbd3d2 (patch)
treee1a61dbf2f4b127c3fc1e0dae670c806d71e6672 /funcs
parent8dfde59f959b35f75c99654ada9321f373f84466 (diff)
add EVAL function, deprecate Eval application (bug #4277)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@5689 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'funcs')
-rwxr-xr-xfuncs/func_strings.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/funcs/func_strings.c b/funcs/func_strings.c
index 4d571bf9f..0385fc5dd 100755
--- a/funcs/func_strings.c
+++ b/funcs/func_strings.c
@@ -171,3 +171,35 @@ struct ast_custom_function strftime_function = {
.syntax = "STRFTIME([<epoch>][,[timezone][,format]])",
.read = acf_strftime,
};
+
+static char *function_eval(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
+{
+ if (!data || ast_strlen_zero(data)) {
+ ast_log(LOG_WARNING, "EVAL requires an argument: EVAL(<variable>)\n");
+ return buf;
+ }
+
+ pbx_substitute_variables_helper(chan, data, buf, len - 1);
+
+ return buf;
+}
+
+#ifndef BUILTIN_FUNC
+static
+#endif
+struct ast_custom_function eval_function = {
+ .name = "EVAL",
+ .synopsis = "Evaluate stored variables.",
+ .syntax = "EVAL(<variable>)",
+ .desc = "Using EVAL basically causes a string to be evaluated twice.\n"
+ "When a variable or expression is in the dialplan, it will be\n"
+ "evaluated at runtime. However, if the result of the evaluation\n"
+ "is in fact a variable or expression, using EVAL will have it\n"
+ "evaluated a second time. For example, if the variable ${MYVAR}\n"
+ "contains \"${OTHERVAR}\", then the result of putting ${EVAL(${MYVAR})}\n"
+ "in the dialplan will be the contents of the variable, OTHERVAR.\n"
+ "Normally, by just putting ${MYVAR} in the dialplan, you would be\n"
+ "left with \"${OTHERVAR}\".\n",
+ .read = function_eval,
+};
+