aboutsummaryrefslogtreecommitdiffstats
path: root/funcs
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2007-07-23 19:51:41 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2007-07-23 19:51:41 +0000
commitfd0b69a4e7f57297f9c011c75820432d693e21a5 (patch)
treec9c73917bfd120da30c16650000c7296781fae50 /funcs
parentb5741f9dd4e38302ab7d62f3999c59f5b9011ac5 (diff)
Merge the dialplan_aesthetics branch. Most of this patch simply converts applications
using old methods of parsing arguments to using the standard macros. However, the big change is that the really old way of specifying application and arguments separated by a comma will no longer work (e.g. NoOp,foo|bar). Instead, the way that has been recommended since long before 1.0 will become the only method available (e.g. NoOp(foo,bar). git-svn-id: http://svn.digium.com/svn/asterisk/trunk@76703 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'funcs')
-rw-r--r--funcs/func_callerid.c4
-rw-r--r--funcs/func_cut.c4
-rw-r--r--funcs/func_env.c2
-rw-r--r--funcs/func_logic.c37
-rw-r--r--funcs/func_odbc.c3
-rw-r--r--funcs/func_rand.c4
-rw-r--r--funcs/func_realtime.c12
-rw-r--r--funcs/func_strings.c36
-rw-r--r--funcs/func_vmcount.c2
9 files changed, 64 insertions, 40 deletions
diff --git a/funcs/func_callerid.c b/funcs/func_callerid.c
index 462f887b5..f218c8edd 100644
--- a/funcs/func_callerid.c
+++ b/funcs/func_callerid.c
@@ -63,10 +63,10 @@ static int callerid_read(struct ast_channel *chan, const char *cmd, char *data,
if (!chan)
return -1;
- if (strchr(opt, '|')) {
+ if (strchr(opt, ',')) {
char name[80], num[80];
- data = strsep(&opt, "|");
+ data = strsep(&opt, ",");
ast_callerid_split(opt, name, sizeof(name), num, sizeof(num));
if (!strncasecmp("all", data, 3)) {
diff --git a/funcs/func_cut.c b/funcs/func_cut.c
index 41710b978..4466e3269 100644
--- a/funcs/func_cut.c
+++ b/funcs/func_cut.c
@@ -78,7 +78,7 @@ static int sort_internal(struct ast_channel *chan, char *data, char *buffer, siz
strings = ast_strdupa(data);
for (ptrkey = strings; *ptrkey; ptrkey++) {
- if (*ptrkey == '|')
+ if (*ptrkey == ',')
count++;
}
@@ -88,7 +88,7 @@ static int sort_internal(struct ast_channel *chan, char *data, char *buffer, siz
/* Parse each into a struct */
count2 = 0;
- while ((ptrkey = strsep(&strings, "|"))) {
+ while ((ptrkey = strsep(&strings, ","))) {
ptrvalue = index(ptrkey, ':');
if (!ptrvalue) {
count--;
diff --git a/funcs/func_env.c b/funcs/func_env.c
index 20af01636..3e69666ce 100644
--- a/funcs/func_env.c
+++ b/funcs/func_env.c
@@ -76,7 +76,7 @@ static int stat_read(struct ast_channel *chan, const char *cmd, char *data,
*buf = '\0';
- action = strsep(&data, "|");
+ action = strsep(&data, ",");
if (stat(data, &s)) {
return -1;
} else {
diff --git a/funcs/func_logic.c b/funcs/func_logic.c
index 24080cc37..92c4f8b17 100644
--- a/funcs/func_logic.c
+++ b/funcs/func_logic.c
@@ -140,6 +140,29 @@ static int set(struct ast_channel *chan, const char *cmd, char *data, char *buf,
return 0;
}
+static int acf_import(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
+{
+ AST_DECLARE_APP_ARGS(args,
+ AST_APP_ARG(channel);
+ AST_APP_ARG(varname);
+ );
+ AST_STANDARD_APP_ARGS(args, data);
+ memset(buf, 0, len);
+
+ if (!ast_strlen_zero(args.varname)) {
+ struct ast_channel *chan2 = ast_get_channel_by_name_locked(args.channel);
+ if (chan2) {
+ char *s = alloca(strlen(args.varname) + 4);
+ if (s) {
+ sprintf(s, "${%s}", args.varname);
+ pbx_substitute_variables_helper(chan2, s, buf, len);
+ }
+ ast_channel_unlock(chan2);
+ }
+ }
+ return 0;
+}
+
static struct ast_custom_function isnull_function = {
.name = "ISNULL",
.synopsis = "NULL Test: Returns 1 if NULL or 0 otherwise",
@@ -164,7 +187,7 @@ static struct ast_custom_function exists_function = {
static struct ast_custom_function if_function = {
.name = "IF",
.synopsis =
- "Conditional: Returns the data following '?' if true else the data following ':'",
+ "Conditional: Returns the data following '?' if true, else the data following ':'",
.syntax = "IF(<expr>?[<true>][:<false>])",
.read = acf_if,
};
@@ -172,11 +195,19 @@ static struct ast_custom_function if_function = {
static struct ast_custom_function if_time_function = {
.name = "IFTIME",
.synopsis =
- "Temporal Conditional: Returns the data following '?' if true else the data following ':'",
+ "Temporal Conditional: Returns the data following '?' if true, else the data following ':'",
.syntax = "IFTIME(<timespec>?[<true>][:<false>])",
.read = iftime,
};
+static struct ast_custom_function import_function = {
+ .name = "IMPORT",
+ .synopsis =
+ "Retrieve the value of a variable from another channel\n",
+ .syntax = "IMPORT(channel,variable)",
+ .read = acf_import,
+};
+
static int unload_module(void)
{
int res = 0;
@@ -186,6 +217,7 @@ static int unload_module(void)
res |= ast_custom_function_unregister(&exists_function);
res |= ast_custom_function_unregister(&if_function);
res |= ast_custom_function_unregister(&if_time_function);
+ res |= ast_custom_function_unregister(&import_function);
return res;
}
@@ -199,6 +231,7 @@ static int load_module(void)
res |= ast_custom_function_register(&exists_function);
res |= ast_custom_function_register(&if_function);
res |= ast_custom_function_register(&if_time_function);
+ res |= ast_custom_function_register(&import_function);
return res;
}
diff --git a/funcs/func_odbc.c b/funcs/func_odbc.c
index 4852a0867..2eac1eeb9 100644
--- a/funcs/func_odbc.c
+++ b/funcs/func_odbc.c
@@ -179,8 +179,7 @@ static int acf_odbc_write(struct ast_channel *chan, const char *cmd, char *s, co
}
/* Parse values, just like arguments */
- /* Can't use the pipe, because app Set removes them */
- AST_NONSTANDARD_APP_ARGS(values, t, ',');
+ AST_STANDARD_APP_ARGS(values, t);
for (i = 0; i < values.argc; i++) {
snprintf(varname, sizeof(varname), "VAL%d", i + 1);
pbx_builtin_pushvar_helper(chan, varname, values.field[i]);
diff --git a/funcs/func_rand.c b/funcs/func_rand.c
index 8885904a9..d989b0ad6 100644
--- a/funcs/func_rand.c
+++ b/funcs/func_rand.c
@@ -76,11 +76,11 @@ static int acf_rand_exec(struct ast_channel *chan, const char *cmd,
static struct ast_custom_function acf_rand = {
.name = "RAND",
.synopsis = "Choose a random number in a range",
- .syntax = "RAND([min][|max])",
+ .syntax = "RAND([min][,max])",
.desc =
"Choose a random number between min and max. Min defaults to 0, if not\n"
"specified, while max defaults to RAND_MAX (2147483647 on many systems).\n"
- " Example: Set(junky=${RAND(1|8)}); \n"
+ " Example: Set(junky=${RAND(1,8)}); \n"
" Sets junky to a random number between 1 and 8, inclusive.\n",
.read = acf_rand_exec,
};
diff --git a/funcs/func_realtime.c b/funcs/func_realtime.c
index 611e6ecc6..1f67fcb46 100644
--- a/funcs/func_realtime.c
+++ b/funcs/func_realtime.c
@@ -60,14 +60,14 @@ static int function_realtime_read(struct ast_channel *chan, const char *cmd, cha
);
if (ast_strlen_zero(data)) {
- ast_log(LOG_WARNING, "Syntax: REALTIME(family|fieldmatch[|value[|delim1[|delim2]]]) - missing argument!\n");
+ ast_log(LOG_WARNING, "Syntax: REALTIME(family,fieldmatch[,value[,delim1[,delim2]]]) - missing argument!\n");
return -1;
}
AST_STANDARD_APP_ARGS(args, data);
if (!args.delim1)
- args.delim1 = "|";
+ args.delim1 = ",";
if (!args.delim2)
args.delim2 = "=";
@@ -102,7 +102,7 @@ static int function_realtime_write(struct ast_channel *chan, const char *cmd, ch
);
if (ast_strlen_zero(data)) {
- ast_log(LOG_WARNING, "Syntax: REALTIME(family|fieldmatch|value|newcol) - missing argument!\n");
+ ast_log(LOG_WARNING, "Syntax: REALTIME(family,fieldmatch,value,newcol) - missing argument!\n");
return -1;
}
@@ -120,14 +120,14 @@ static int function_realtime_write(struct ast_channel *chan, const char *cmd, ch
struct ast_custom_function realtime_function = {
.name = "REALTIME",
.synopsis = "RealTime Read/Write Functions",
- .syntax = "REALTIME(family|fieldmatch[|value[|delim1[|delim2]]]) on read\n"
- "REALTIME(family|fieldmatch|value|field) on write\n",
+ .syntax = "REALTIME(family,fieldmatch[,value[,delim1[,delim2]]]) on read\n"
+ "REALTIME(family,fieldmatch,value,field) on write",
.desc = "This function will read or write values from/to a RealTime repository.\n"
"REALTIME(....) will read names/values from the repository, and \n"
"REALTIME(....)= will write a new value/field to the repository. On a\n"
"read, this function returns a delimited text string. The name/value \n"
"pairs are delimited by delim1, and the name and value are delimited \n"
- "between each other with delim2. The default for delim1 is '|' and \n"
+ "between each other with delim2. The default for delim1 is ',' and \n"
"the default for delim2 is '='. If there is no match, NULL will be \n"
"returned by the function. On a write, this function will always \n"
"return NULL. \n",
diff --git a/funcs/func_strings.c b/funcs/func_strings.c
index c44c49921..5eab9930f 100644
--- a/funcs/func_strings.c
+++ b/funcs/func_strings.c
@@ -88,7 +88,7 @@ static int function_fieldqty(struct ast_channel *chan, const char *cmd,
static struct ast_custom_function fieldqty_function = {
.name = "FIELDQTY",
.synopsis = "Count the fields, with an arbitrary delimiter",
- .syntax = "FIELDQTY(<varname>|<delim>)",
+ .syntax = "FIELDQTY(<varname>,<delim>)",
.read = function_fieldqty,
};
@@ -104,7 +104,7 @@ static int filter(struct ast_channel *chan, const char *cmd, char *parse, char *
AST_STANDARD_APP_ARGS(args, parse);
if (!args.string) {
- ast_log(LOG_ERROR, "Usage: FILTER(<allowed-chars>|<string>)\n");
+ ast_log(LOG_ERROR, "Usage: FILTER(<allowed-chars>,<string>)\n");
return -1;
}
@@ -120,7 +120,7 @@ static int filter(struct ast_channel *chan, const char *cmd, char *parse, char *
static struct ast_custom_function filter_function = {
.name = "FILTER",
.synopsis = "Filter the string to include only the allowed characters",
- .syntax = "FILTER(<allowed-chars>|<string>)",
+ .syntax = "FILTER(<allowed-chars>,<string>)",
.read = filter,
};
@@ -237,15 +237,9 @@ static int array(struct ast_channel *chan, const char *cmd, char *var,
* delimiter, but we'll fall back to vertical bars if commas aren't found.
*/
ast_debug(1, "array (%s=%s)\n", var, value2);
- if (strchr(var, ','))
- AST_NONSTANDARD_APP_ARGS(arg1, var, ',');
- else
- AST_STANDARD_APP_ARGS(arg1, var);
+ AST_STANDARD_APP_ARGS(arg1, var);
- if (strchr(value2, ','))
- AST_NONSTANDARD_APP_ARGS(arg2, value2, ',');
- else
- AST_STANDARD_APP_ARGS(arg2, value2);
+ AST_STANDARD_APP_ARGS(arg2, value2);
for (i = 0; i < arg1.argc; i++) {
ast_debug(1, "array set value (%s=%s)\n", arg1.var[i],
@@ -302,7 +296,7 @@ static int hash_write(struct ast_channel *chan, const char *cmd, char *var, cons
AST_APP_ARG(hashkey);
);
- if (!strchr(var, '|')) {
+ if (!strchr(var, ',')) {
/* Single argument version */
return array(chan, "HASH", var, value);
}
@@ -363,7 +357,7 @@ static int hash_read(struct ast_channel *chan, const char *cmd, char *data, char
static struct ast_custom_function hash_function = {
.name = "HASH",
.synopsis = "Implementation of a dialplan associative array",
- .syntax = "HASH(hashname[|hashkey])",
+ .syntax = "HASH(hashname[,hashkey])",
.write = hash_write,
.read = hash_read,
.desc =
@@ -387,15 +381,13 @@ static struct ast_custom_function hashkeys_function = {
static struct ast_custom_function array_function = {
.name = "ARRAY",
.synopsis = "Allows setting multiple variables at once",
- .syntax = "ARRAY(var1[|var2[...][|varN]])",
+ .syntax = "ARRAY(var1[,var2[...][,varN]])",
.write = array,
.desc =
"The comma-separated list passed as a value to which the function is set will\n"
"be interpreted as a set of values to which the comma-separated list of\n"
"variable names in the argument should be set.\n"
- "Hence, Set(ARRAY(var1|var2)=1\\,2) will set var1 to 1 and var2 to 2\n"
- "Note: remember to either backslash your commas in extensions.conf or quote the\n"
- "entire argument, since Set can take multiple arguments itself.\n",
+ "Hence, Set(ARRAY(var1,var2)=1,2) will set var1 to 1 and var2 to 2.\n",
};
static int acf_sprintf(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
@@ -533,7 +525,7 @@ sprintf_fail:
static struct ast_custom_function sprintf_function = {
.name = "SPRINTF",
.synopsis = "Format a variable according to a format string",
- .syntax = "SPRINTF(<format>|<arg1>[|...<argN>])",
+ .syntax = "SPRINTF(<format>,<arg1>[,...<argN>])",
.read = acf_sprintf,
.desc =
"Parses the format string specified and returns a string matching that format.\n"
@@ -623,7 +615,7 @@ static int acf_strftime(struct ast_channel *chan, const char *cmd, char *parse,
static struct ast_custom_function strftime_function = {
.name = "STRFTIME",
.synopsis = "Returns the current date/time in a specified format.",
- .syntax = "STRFTIME([<epoch>][|[timezone][|format]])",
+ .syntax = "STRFTIME([<epoch>][,[timezone][,format]])",
.desc =
"STRFTIME sports all of the same formats as the underlying C function\n"
"strftime(3) - see the man page for details. It also supports the\n"
@@ -660,7 +652,7 @@ static int acf_strptime(struct ast_channel *chan, const char *cmd, char *data,
if (ast_strlen_zero(args.format)) {
ast_log(LOG_ERROR,
- "No format supplied to STRPTIME(<timestring>|<timezone>|<format>)");
+ "No format supplied to STRPTIME(<timestring>,<timezone>,<format>)");
return -1;
}
@@ -677,14 +669,14 @@ static struct ast_custom_function strptime_function = {
.name = "STRPTIME",
.synopsis =
"Returns the epoch of the arbitrary date/time string structured as described in the format.",
- .syntax = "STRPTIME(<datetime>|<timezone>|<format>)",
+ .syntax = "STRPTIME(<datetime>,<timezone>,<format>)",
.desc =
"This is useful for converting a date into an EPOCH time, possibly to pass to\n"
"an application like SayUnixTime or to calculate the difference between two\n"
"date strings.\n"
"\n"
"Example:\n"
- " ${STRPTIME(2006-03-01 07:30:35|America/Chicago|%Y-%m-%d %H:%M:%S)} returns 1141219835\n",
+ " ${STRPTIME(2006-03-01 07:30:35,America/Chicago,%Y-%m-%d %H:%M:%S)} returns 1141219835\n",
.read = acf_strptime,
};
diff --git a/funcs/func_vmcount.c b/funcs/func_vmcount.c
index 8183b8c74..0e6cfef1e 100644
--- a/funcs/func_vmcount.c
+++ b/funcs/func_vmcount.c
@@ -76,7 +76,7 @@ static int acf_vmcount_exec(struct ast_channel *chan, const char *cmd, char *arg
struct ast_custom_function acf_vmcount = {
.name = "VMCOUNT",
.synopsis = "Counts the voicemail in a specified mailbox",
- .syntax = "VMCOUNT(vmbox[@context][|folder])",
+ .syntax = "VMCOUNT(vmbox[@context][,folder])",
.desc =
" context - defaults to \"default\"\n"
" folder - defaults to \"INBOX\"\n",