[asterisk-commits] eliel: branch eliel/appdelim r181208 - in /team/eliel/appdelim: apps/ funcs/ ...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Mar 11 07:16:50 CDT 2009
Author: eliel
Date: Wed Mar 11 07:16:46 2009
New Revision: 181208
URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=181208
Log:
Initial version based on the code uploaded to the review board and kpfleming comments.
http://reviewboard.digium.com/r/79/
Modified:
team/eliel/appdelim/apps/app_dial.c
team/eliel/appdelim/apps/app_macro.c
team/eliel/appdelim/apps/app_meetme.c
team/eliel/appdelim/apps/app_readfile.c
team/eliel/appdelim/funcs/func_callerid.c
team/eliel/appdelim/funcs/func_cut.c
team/eliel/appdelim/funcs/func_env.c
team/eliel/appdelim/funcs/func_realtime.c
team/eliel/appdelim/funcs/func_strings.c
team/eliel/appdelim/include/asterisk/app.h
team/eliel/appdelim/include/asterisk/pbx.h
team/eliel/appdelim/main/pbx.c
team/eliel/appdelim/main/xmldoc.c
team/eliel/appdelim/pbx/pbx_lua.c
Modified: team/eliel/appdelim/apps/app_dial.c
URL: http://svn.digium.com/svn-view/asterisk/team/eliel/appdelim/apps/app_dial.c?view=diff&rev=181208&r1=181207&r2=181208
==============================================================================
--- team/eliel/appdelim/apps/app_dial.c (original)
+++ team/eliel/appdelim/apps/app_dial.c Wed Mar 11 07:16:46 2009
@@ -1532,7 +1532,7 @@
pbx_builtin_setvar_helper(chan, "DIALEDTIME", "");
if (ast_strlen_zero(data)) {
- ast_log(LOG_WARNING, "Dial requires an argument (technology/number)\n");
+ ast_log(LOG_WARNING, "Dial requires an argument %s\n", ast_application_syntax("Dial"));
pbx_builtin_setvar_helper(chan, "DIALSTATUS", pa.status);
return -1;
}
@@ -1548,7 +1548,7 @@
}
if (ast_strlen_zero(args.peers)) {
- ast_log(LOG_WARNING, "Dial requires an argument (technology/number)\n");
+ ast_log(LOG_WARNING, "Dial requires an argument %s\n", ast_application_syntax("Dial"));
pbx_builtin_setvar_helper(chan, "DIALSTATUS", pa.status);
goto done;
}
@@ -2261,7 +2261,7 @@
);
if (ast_strlen_zero(data)) {
- ast_log(LOG_WARNING, "RetryDial requires an argument!\n");
+ ast_log(LOG_WARNING, "RetryDial requires an argument! %s\n", ast_application_syntax("RetryDial"));
return -1;
}
Modified: team/eliel/appdelim/apps/app_macro.c
URL: http://svn.digium.com/svn-view/asterisk/team/eliel/appdelim/apps/app_macro.c?view=diff&rev=181208&r1=181207&r2=181208
==============================================================================
--- team/eliel/appdelim/apps/app_macro.c (original)
+++ team/eliel/appdelim/apps/app_macro.c Wed Mar 11 07:16:46 2009
@@ -36,6 +36,7 @@
#include "asterisk/config.h"
#include "asterisk/utils.h"
#include "asterisk/lock.h"
+#include "asterisk/app.h"
/*** DOCUMENTATION
<application name="Macro" language="en_US">
@@ -289,7 +290,7 @@
tmp = ast_strdupa(data);
rest = tmp;
- macro = strsep(&rest, ",");
+ macro = strsep(&rest, AST_STANDARD_APP_DELIM);
if (ast_strlen_zero(macro)) {
ast_log(LOG_WARNING, "Invalid macro name specified\n");
return 0;
@@ -348,7 +349,7 @@
chan->priority = 1;
ast_channel_lock(chan);
- while((cur = strsep(&rest, ",")) && (argc < MAX_ARGS)) {
+ while ((cur = strsep(&rest, AST_STANDARD_APP_DELIM)) && (argc < MAX_ARGS)) {
const char *argp;
/* Save copy of old arguments if we're overwriting some, otherwise
let them pass through to the other macro */
Modified: team/eliel/appdelim/apps/app_meetme.c
URL: http://svn.digium.com/svn-view/asterisk/team/eliel/appdelim/apps/app_meetme.c?view=diff&rev=181208&r1=181207&r2=181208
==============================================================================
--- team/eliel/appdelim/apps/app_meetme.c (original)
+++ team/eliel/appdelim/apps/app_meetme.c Wed Mar 11 07:16:46 2009
@@ -6317,7 +6317,7 @@
);
if (ast_strlen_zero(data)) {
- ast_log(LOG_ERROR, "Syntax: MEETME_INFO() requires two arguments\n");
+ ast_log(LOG_ERROR, "Syntax: %s requires two arguments\n", ast_custom_function_syntax("MEETME_INFO"));
return -1;
}
@@ -6325,12 +6325,12 @@
AST_STANDARD_APP_ARGS(args, parse);
if (ast_strlen_zero(args.keyword)) {
- ast_log(LOG_ERROR, "Syntax: MEETME_INFO() requires a keyword\n");
+ ast_log(LOG_ERROR, "Syntax: %s requires a keyword\n", ast_custom_function_syntax("MEETME_INFO"));
return -1;
}
if (ast_strlen_zero(args.confno)) {
- ast_log(LOG_ERROR, "Syntax: MEETME_INFO() requires a conference number\n");
+ ast_log(LOG_ERROR, "Syntax: %s requires a conference number\n", ast_custom_function_syntax("MEETME_INFO"));
return -1;
}
Modified: team/eliel/appdelim/apps/app_readfile.c
URL: http://svn.digium.com/svn-view/asterisk/team/eliel/appdelim/apps/app_readfile.c?view=diff&rev=181208&r1=181207&r2=181208
==============================================================================
--- team/eliel/appdelim/apps/app_readfile.c (original)
+++ team/eliel/appdelim/apps/app_readfile.c Wed Mar 11 07:16:46 2009
@@ -82,7 +82,7 @@
s = ast_strdupa(data);
varname = strsep(&s, "=");
- file = strsep(&s, ",");
+ file = strsep(&s, AST_STANDARD_APP_DELIM);
length = s;
if (deprecation_warning++ % 10 == 0)
Modified: team/eliel/appdelim/funcs/func_callerid.c
URL: http://svn.digium.com/svn-view/asterisk/team/eliel/appdelim/funcs/func_callerid.c?view=diff&rev=181208&r1=181207&r2=181208
==============================================================================
--- team/eliel/appdelim/funcs/func_callerid.c (original)
+++ team/eliel/appdelim/funcs/func_callerid.c Wed Mar 11 07:16:46 2009
@@ -127,10 +127,10 @@
if (!chan)
return -1;
- if (strchr(opt, ',')) {
+ if (strchr(opt, AST_STANDARD_APP_DELIM_CHAR)) {
char name[80], num[80];
- data = strsep(&opt, ",");
+ data = strsep(&opt, AST_STANDARD_APP_DELIM);
ast_callerid_split(opt, name, sizeof(name), num, sizeof(num));
if (!strncasecmp("all", data, 3)) {
Modified: team/eliel/appdelim/funcs/func_cut.c
URL: http://svn.digium.com/svn-view/asterisk/team/eliel/appdelim/funcs/func_cut.c?view=diff&rev=181208&r1=181207&r2=181208
==============================================================================
--- team/eliel/appdelim/funcs/func_cut.c (original)
+++ team/eliel/appdelim/funcs/func_cut.c Wed Mar 11 07:16:46 2009
@@ -50,8 +50,8 @@
</parameter>
</syntax>
<description>
- <para>Takes a comma-separated list of keys and values, each separated by a colon, and returns a
- comma-separated list of the keys, sorted by their values. Values will be evaluated as
+ <para>Takes a list of keys and values, each separated by a colon, and returns a
+ comma-separated list of the keys, sorted by their values. Values will be evaluated as
floating-point numbers.</para>
</description>
</function>
@@ -114,8 +114,9 @@
strings = ast_strdupa(data);
for (ptrkey = strings; *ptrkey; ptrkey++) {
- if (*ptrkey == ',')
+ if (*ptrkey == AST_STANDARD_APP_DELIM_CHAR) {
count++;
+ }
}
sortable_keys = alloca(count * sizeof(struct sortable_keys));
@@ -124,7 +125,7 @@
/* Parse each into a struct */
count2 = 0;
- while ((ptrkey = strsep(&strings, ","))) {
+ while ((ptrkey = strsep(&strings, AST_STANDARD_APP_DELIM))) {
ptrvalue = strchr(ptrkey, ':');
if (!ptrvalue) {
count--;
Modified: team/eliel/appdelim/funcs/func_env.c
URL: http://svn.digium.com/svn-view/asterisk/team/eliel/appdelim/funcs/func_env.c?view=diff&rev=181208&r1=181207&r2=181208
==============================================================================
--- team/eliel/appdelim/funcs/func_env.c (original)
+++ team/eliel/appdelim/funcs/func_env.c Wed Mar 11 07:16:46 2009
@@ -124,7 +124,7 @@
ast_copy_string(buf, "0", len);
- action = strsep(&data, ",");
+ action = strsep(&data, AST_STANDARD_APP_DELIM);
if (stat(data, &s)) {
return 0;
} else {
Modified: team/eliel/appdelim/funcs/func_realtime.c
URL: http://svn.digium.com/svn-view/asterisk/team/eliel/appdelim/funcs/func_realtime.c?view=diff&rev=181208&r1=181207&r2=181208
==============================================================================
--- team/eliel/appdelim/funcs/func_realtime.c (original)
+++ team/eliel/appdelim/funcs/func_realtime.c Wed Mar 11 07:16:46 2009
@@ -147,6 +147,7 @@
struct ast_str *out;
size_t resultslen;
int n;
+
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(family);
AST_APP_ARG(fieldmatch);
@@ -156,7 +157,7 @@
);
if (ast_strlen_zero(data)) {
- ast_log(LOG_WARNING, "Syntax: REALTIME(family,fieldmatch[,value[,delim1[,delim2]]]) - missing argument!\n");
+ ast_log(LOG_WARNING, "Syntax: %s - missing argument!\n", ast_custom_function_syntax("REALTIME"));
return -1;
}
@@ -207,7 +208,7 @@
);
if (ast_strlen_zero(data)) {
- ast_log(LOG_WARNING, "Syntax: %s(family,fieldmatch,value,newcol) - missing argument!\n", cmd);
+ ast_log(LOG_WARNING, "Syntax: %s - missing argument!\n", ast_custom_function_syntax(cmd));
return -1;
}
@@ -250,14 +251,14 @@
}
if (ast_strlen_zero(data)) {
- ast_log(LOG_WARNING, "Syntax: %s(family,fieldmatch,value%s) - missing argument!\n", cmd, which == rtfield ? ",fieldname" : "");
+ ast_log(LOG_WARNING, "Syntax: %s - missing argument!\n", ast_custom_function_syntax(cmd));
return -1;
}
AST_STANDARD_APP_ARGS(args, data);
if ((which == rtfield && args.argc != 4) || (which == rthash && args.argc != 3)) {
- ast_log(LOG_WARNING, "Syntax: %s(family,fieldmatch,value%s) - missing argument!\n", cmd, which == rtfield ? ",fieldname" : "");
+ ast_log(LOG_WARNING, "Syntax: %s - missing argument!\n", ast_custom_function_syntax(cmd));
return -1;
}
@@ -319,7 +320,7 @@
);
if (ast_strlen_zero(data)) {
- ast_log(LOG_WARNING, "Syntax: REALTIME_STORE(family,field1,field2,...,field30) - missing argument!\n");
+ ast_log(LOG_WARNING, "Syntax: %s - missing argument!\n", ast_custom_function_syntax("REALTIME_STORE"));
return -1;
}
@@ -367,7 +368,7 @@
);
if (ast_strlen_zero(data)) {
- ast_log(LOG_WARNING, "Syntax: REALTIME_DESTROY(family,fieldmatch[,value[,delim1[,delim2]]]) - missing argument!\n");
+ ast_log(LOG_WARNING, "Syntax: %s - missing argument!\n", ast_custom_function_syntax("REALTIME_DESTROY"));
return -1;
}
Modified: team/eliel/appdelim/funcs/func_strings.c
URL: http://svn.digium.com/svn-view/asterisk/team/eliel/appdelim/funcs/func_strings.c?view=diff&rev=181208&r1=181207&r2=181208
==============================================================================
--- team/eliel/appdelim/funcs/func_strings.c (original)
+++ team/eliel/appdelim/funcs/func_strings.c Wed Mar 11 07:16:46 2009
@@ -328,7 +328,7 @@
AST_STANDARD_APP_ARGS(args, parse);
if (args.argc < 3) {
- ast_log(LOG_ERROR, "Usage: LISTFILTER(<listname>,<delimiter>,<fieldvalue>)\n");
+ ast_log(LOG_ERROR, "Usage: %s - missing parameters\n", ast_custom_function_syntax("LISTFILTER"));
return -1;
}
Modified: team/eliel/appdelim/include/asterisk/app.h
URL: http://svn.digium.com/svn-view/asterisk/team/eliel/appdelim/include/asterisk/app.h?view=diff&rev=181208&r1=181207&r2=181208
==============================================================================
--- team/eliel/appdelim/include/asterisk/app.h (original)
+++ team/eliel/appdelim/include/asterisk/app.h Wed Mar 11 07:16:46 2009
@@ -350,17 +350,24 @@
arglist \
}
+/*! \brief Standard application/function parameter delimiter string. It is defined as a string
+ * but MUST be a single character. */
+#define AST_STANDARD_APP_DELIM ","
+
+/*! \brief Standard application/function parameter delimiter char. */
+#define AST_STANDARD_APP_DELIM_CHAR AST_STANDARD_APP_DELIM[0]
+
/*!
\brief Performs the 'standard' argument separation process for an application.
\param args An argument structure defined using AST_DECLARE_APP_ARGS
\param parse A modifiable buffer containing the input to be parsed
This function will separate the input string using the standard argument
- separator character ',' and fill in the provided structure, including
+ separator character AST_STANDARD_APP_DELIM_CHAR and fill in the provided structure, including
the argc argument counter field.
*/
#define AST_STANDARD_APP_ARGS(args, parse) \
- args.argc = ast_app_separate_args(parse, ',', args.argv, ((sizeof(args) - offsetof(typeof(args), argv)) / sizeof(args.argv[0])))
+ args.argc = ast_app_separate_args(parse, AST_STANDARD_APP_DELIM_CHAR, args.argv, ((sizeof(args) - offsetof(typeof(args), argv)) / sizeof(args.argv[0])))
/*!
\brief Performs the 'nonstandard' argument separation process for an application.
Modified: team/eliel/appdelim/include/asterisk/pbx.h
URL: http://svn.digium.com/svn-view/asterisk/team/eliel/appdelim/include/asterisk/pbx.h?view=diff&rev=181208&r1=181207&r2=181208
==============================================================================
--- team/eliel/appdelim/include/asterisk/pbx.h (original)
+++ team/eliel/appdelim/include/asterisk/pbx.h Wed Mar 11 07:16:46 2009
@@ -1003,6 +1003,16 @@
*/
int __ast_custom_function_register(struct ast_custom_function *acf, struct ast_module *mod);
+/*!
+ * \brief Get the function syntax
+ */
+const char *ast_custom_function_syntax(const char *name);
+
+/*!
+ * \brief Get the application syntax
+ */
+const char *ast_application_syntax(const char *name);
+
/*!
* \brief Retrieve the number of active calls
*/
Modified: team/eliel/appdelim/main/pbx.c
URL: http://svn.digium.com/svn-view/asterisk/team/eliel/appdelim/main/pbx.c?view=diff&rev=181208&r1=181207&r2=181208
==============================================================================
--- team/eliel/appdelim/main/pbx.c (original)
+++ team/eliel/appdelim/main/pbx.c Wed Mar 11 07:16:46 2009
@@ -3261,6 +3261,64 @@
return 0;
}
+AST_THREADSTORAGE(appfun_syntax_buf);
+
+const char *ast_application_syntax(const char *name)
+{
+ char *ret;
+ struct ast_app *cur;
+
+ AST_RWLIST_WRLOCK(&apps);
+ AST_RWLIST_TRAVERSE(&apps, cur, list) {
+ if (!strcasecmp(name, cur->name)) {
+ if (!(ret = ast_threadstorage_get(&appfun_syntax_buf, strlen(cur->syntax) + 2))) {
+ AST_RWLIST_UNLOCK(&apps);
+ return NULL;
+ }
+ ast_copy_string(ret, cur->syntax, strlen(cur->syntax));
+ AST_RWLIST_UNLOCK(&apps);
+ return ret;
+ }
+ }
+ AST_RWLIST_UNLOCK(&apps);
+
+ if (!(ret = ast_threadstorage_get(&appfun_syntax_buf, strlen(name) + 1))) {
+ return NULL;
+ }
+ ast_copy_string(ret, name, strlen(name));
+
+ /* at least return something. */
+ return ret;
+}
+
+const char *ast_custom_function_syntax(const char *name)
+{
+ char *ret;
+ struct ast_custom_function *cur;
+
+ AST_RWLIST_WRLOCK(&acf_root);
+ AST_RWLIST_TRAVERSE(&acf_root, cur, acflist) {
+ if (!strcmp(name, cur->name)) {
+ if (!(ret = ast_threadstorage_get(&appfun_syntax_buf, strlen(cur->syntax) + 2))) {
+ AST_RWLIST_UNLOCK(&acf_root);
+ return NULL;
+ }
+ ast_copy_string(ret, cur->syntax, strlen(cur->syntax) + 1);
+ AST_RWLIST_UNLOCK(&acf_root);
+ return ret;
+ }
+ }
+ AST_RWLIST_UNLOCK(&acf_root);
+
+ if (!(ret = ast_threadstorage_get(&appfun_syntax_buf, strlen(name) + 2))) {
+ return NULL;
+ }
+ ast_copy_string(ret, name, strlen(name) + 1);
+
+ /* at least return something. */
+ return ret;
+}
+
int __ast_custom_function_register(struct ast_custom_function *acf, struct ast_module *mod)
{
struct ast_custom_function *cur;
@@ -8810,8 +8868,10 @@
static int pbx_builtin_goto(struct ast_channel *chan, void *data)
{
int res = ast_parseable_goto(chan, data);
- if (!res)
- ast_verb(3, "Goto (%s,%s,%d)\n", chan->context, chan->exten, chan->priority + 1);
+ if (!res) {
+ ast_verb(3, "Goto (%s%s%s%s%d)\n", chan->context, AST_STANDARD_APP_DELIM, chan->exten,
+ AST_STANDARD_APP_DELIM, chan->priority + 1);
+ }
return res;
}
@@ -9134,8 +9194,8 @@
return -1;
}
ast_copy_string(tmp, data, sizeof(tmp));
- strsep(&number, ",");
- options = strsep(&number, ",");
+ strsep(&number, AST_STANDARD_APP_DELIM);
+ options = strsep(&number, AST_STANDARD_APP_DELIM);
if (options) {
if ( strcasecmp(options, "f") && strcasecmp(options, "m") &&
strcasecmp(options, "c") && strcasecmp(options, "n") ) {
@@ -9483,13 +9543,13 @@
int mode = 0;
if (ast_strlen_zero(goto_string)) {
- ast_log(LOG_WARNING, "Goto requires an argument ([[context,]extension,]priority)\n");
+ ast_log(LOG_WARNING, "Goto requires an argument %s\n", ast_application_syntax("Goto"));
return -1;
}
stringp = ast_strdupa(goto_string);
- context = strsep(&stringp, ","); /* guaranteed non-null */
- exten = strsep(&stringp, ",");
- pri = strsep(&stringp, ",");
+ context = strsep(&stringp, AST_STANDARD_APP_DELIM); /* guaranteed non-null */
+ exten = strsep(&stringp, AST_STANDARD_APP_DELIM);
+ pri = strsep(&stringp, AST_STANDARD_APP_DELIM);
if (!exten) { /* Only a priority in this one */
pri = context;
exten = NULL;
Modified: team/eliel/appdelim/main/xmldoc.c
URL: http://svn.digium.com/svn-view/asterisk/team/eliel/appdelim/main/xmldoc.c?view=diff&rev=181208&r1=181207&r2=181208
==============================================================================
--- team/eliel/appdelim/main/xmldoc.c (original)
+++ team/eliel/appdelim/main/xmldoc.c Wed Mar 11 07:16:46 2009
@@ -32,6 +32,7 @@
#include "asterisk/config.h"
#include "asterisk/term.h"
#include "asterisk/xmldoc.h"
+#include "asterisk/app.h"
#ifdef AST_XML_DOCS
@@ -645,7 +646,7 @@
argsep = ast_strdupa(attrargsep);
ast_xml_free_attr(attrargsep);
} else {
- argsep = ast_strdupa(",");
+ argsep = ast_strdupa(AST_STANDARD_APP_DELIM);
}
/* Get order of evaluation. */
Modified: team/eliel/appdelim/pbx/pbx_lua.c
URL: http://svn.digium.com/svn-view/asterisk/team/eliel/appdelim/pbx/pbx_lua.c?view=diff&rev=181208&r1=181207&r2=181208
==============================================================================
--- team/eliel/appdelim/pbx/pbx_lua.c (original)
+++ team/eliel/appdelim/pbx/pbx_lua.c Wed Mar 11 07:16:46 2009
@@ -206,10 +206,11 @@
ast_build_string(&data_next, &data_left, "%s", luaL_checkstring(L, 2));
for (i = 3; i <= nargs; i++) {
- if (lua_isnil(L, i))
- ast_build_string(&data_next, &data_left, ",");
- else
- ast_build_string(&data_next, &data_left, ",%s", luaL_checkstring(L, i));
+ if (lua_isnil(L, i)) {
+ ast_build_string(&data_next, &data_left, AST_STANDARD_APP_DELIM);
+ } else {
+ ast_build_string(&data_next, &data_left, "%s%s", AST_STANDARD_APP_DELIM, luaL_checkstring(L, i));
+ }
}
}
@@ -607,10 +608,11 @@
ast_build_string(&fullname_next, &fullname_left, "%s", luaL_checkstring(L, 2));
for (i = 3; i <= nargs; i++) {
- if (lua_isnil(L, i))
- ast_build_string(&fullname_next, &fullname_left, ",");
- else
- ast_build_string(&fullname_next, &fullname_left, ",%s", luaL_checkstring(L, i));
+ if (lua_isnil(L, i)) {
+ ast_build_string(&fullname_next, &fullname_left, AST_STANDARD_APP_DELIM);
+ } else {
+ ast_build_string(&fullname_next, &fullname_left, "%s%s", AST_STANDARD_APP_DELIM, luaL_checkstring(L, i));
+ }
}
}
More information about the asterisk-commits
mailing list