diff options
author | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2005-05-19 20:38:51 +0000 |
---|---|---|
committer | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2005-05-19 20:38:51 +0000 |
commit | d9270da55003d1db0c193ea3fa52d90428b967c2 (patch) | |
tree | 72f43ce1f130aeceaea7f9d112c228f9aa4ae2fd | |
parent | 75ba0f6860ad973f2fd8acc901000b8624a5ef1c (diff) |
Add SET function (bug #4335)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@5745 f38db490-d61c-443f-a65b-d21fe96a405b
-rwxr-xr-x | funcs/func_logic.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/funcs/func_logic.c b/funcs/func_logic.c index 8df1732ba..41a50e359 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 @@ -85,6 +108,16 @@ struct ast_custom_function isnull_function = { #ifndef BUILTIN_FUNC static #endif +struct ast_custom_function set_function = { + .name = "SET", + .synopsis = "SET assigns a value to a function call.", + .syntax = "SET(<varname>=<value>)", + .read = builtin_function_set, +}; + +#ifndef BUILTIN_FUNC +static +#endif struct ast_custom_function exists_function = { .name = "EXISTS", .synopsis = "Existence Test: Returns 1 if exists, 0 otherwise", |