[Asterisk-cvs] asterisk/funcs func_strings.c,1.3,1.4
kpfleming at lists.digium.com
kpfleming at lists.digium.com
Sun May 15 19:47:48 CDT 2005
Update of /usr/cvsroot/asterisk/funcs
In directory mongoose.digium.com:/tmp/cvs-serv19278/funcs
Modified Files:
func_strings.c
Log Message:
add EVAL function, deprecate Eval application (bug #4277)
Index: func_strings.c
===================================================================
RCS file: /usr/cvsroot/asterisk/funcs/func_strings.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- func_strings.c 5 May 2005 12:48:52 -0000 1.3
+++ func_strings.c 15 May 2005 23:53:11 -0000 1.4
@@ -171,3 +171,35 @@
.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,
+};
+
More information about the svn-commits
mailing list