From: Mark Spencer Date: Thu, 19 May 2005 20:38:51 +0000 (+0000) Subject: Add SET function (bug #4335) X-Git-Tag: 1.2.0-beta1~600 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f3cbf61cbfc5132676ff869fc51328ae0d480fc3;p=thirdparty%2Fasterisk.git Add SET function (bug #4335) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@5745 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/funcs/func_logic.c b/funcs/func_logic.c index 8df1732ba5..41a50e3599 100755 --- a/funcs/func_logic.c +++ b/funcs/func_logic.c @@ -72,6 +72,29 @@ static char *builtin_function_if(struct ast_channel *chan, char *cmd, char *data return ret; } +static char *builtin_function_set(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) +{ + char *ret = NULL, *varname, *val; + + if ((varname = ast_strdupa(data))) { + if ((val = strchr(varname, '='))) { + *val = '\0'; + val++; + varname = ast_strip(varname); + val = ast_strip(val); + pbx_builtin_setvar_helper(chan, varname, val); + ast_copy_string(buf, val, len); + } else { + ast_log(LOG_WARNING, "Syntax Error!\n"); + } + + } else { + ast_log(LOG_WARNING, "Memory Error!\n"); + } + + return ret; +} + #ifndef BUILTIN_FUNC static #endif @@ -82,6 +105,16 @@ struct ast_custom_function isnull_function = { .read = builtin_function_isnull, }; +#ifndef BUILTIN_FUNC +static +#endif +struct ast_custom_function set_function = { + .name = "SET", + .synopsis = "SET assigns a value to a function call.", + .syntax = "SET(=)", + .read = builtin_function_set, +}; + #ifndef BUILTIN_FUNC static #endif