[asterisk-commits] eliel: branch group/appdocsxml r145199 - in /team/group/appdocsxml: funcs/ main/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Sep 30 14:19:55 CDT 2008
Author: eliel
Date: Tue Sep 30 14:19:54 2008
New Revision: 145199
URL: http://svn.digium.com/view/asterisk?view=rev&rev=145199
Log:
Introduce XML documentation for SORT and CUT functions.
Add in the syntax a way to represent multiple arguments like [sep...] where sep is the actual separator.
Modified:
team/group/appdocsxml/funcs/func_cut.c
team/group/appdocsxml/main/pbx.c
Modified: team/group/appdocsxml/funcs/func_cut.c
URL: http://svn.digium.com/view/asterisk/team/group/appdocsxml/funcs/func_cut.c?view=diff&rev=145199&r1=145198&r2=145199
==============================================================================
--- team/group/appdocsxml/funcs/func_cut.c (original)
+++ team/group/appdocsxml/funcs/func_cut.c Tue Sep 30 14:19:54 2008
@@ -33,6 +33,50 @@
#include "asterisk/pbx.h"
#include "asterisk/module.h"
#include "asterisk/app.h"
+
+/*** DOCUMENTATION
+
+ <function name="SORT" language="en_US">
+ <synopsis>
+ Sorts a list of key/vals into a list of keys, based upon the vals.
+ </synopsis>
+ <syntax>
+ <parameter name="keyval" required="true" argsep=":">
+ <argument name="key1" required="true" />
+ <argument name="val1" required="true" />
+ </parameter>
+ <parameter name="keyvaln" multiple="true" argsep=":">
+ <argument name="key2" required="true" />
+ <argument name="val2" required="true" />
+ </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
+ floating-point numbers.</para>
+ </description>
+ </function>
+ <function name="CUT" language="en_US">
+ <synopsis>
+ Slices and dices strings, based upon a named delimiter.
+ </synopsis>
+ <syntax>
+ <parameter name="varname" required="true">
+ <para>Variable you want cut</para>
+ </parameter>
+ <parameter name="char-delim" required="true">
+ <para>Delimiter, defaults to <literal>-</literal></para>
+ </parameter>
+ <parameter name="range-spec" required="true">
+ <para>Number of the field you want (1-based offset), may also be specified as a range (with <literal>-</literal>)
+ or group of ranges and fields (with <literal>&</literal>)</para>
+ </parameter>
+ </syntax>
+ <description>
+ <para>Cut out information from a string (<replaceable>varname</replaceable>), based upon a named delimiter.</para>
+ </description>
+ </function>
+ ***/
/* Maximum length of any variable */
#define MAXRESULT 1024
@@ -255,25 +299,11 @@
struct ast_custom_function acf_sort = {
.name = "SORT",
- .synopsis = "Sorts a list of key/vals into a list of keys, based upon the vals",
- .syntax = "SORT(key1:val1[...][,keyN:valN])",
- .desc =
-"Takes a comma-separated list of keys and values, each separated by a colon, and returns a\n"
-"comma-separated list of the keys, sorted by their values. Values will be evaluated as\n"
-"floating-point numbers.\n",
.read = acf_sort_exec,
};
struct ast_custom_function acf_cut = {
.name = "CUT",
- .synopsis = "Slices and dices strings, based upon a named delimiter.",
- .syntax = "CUT(<varname>,<char-delim>,<range-spec>)",
- .desc =
-" varname - variable you want cut\n"
-" char-delim - defaults to '-'\n"
-" range-spec - number of the field you want (1-based offset)\n"
-" may also be specified as a range (with -)\n"
-" or group of ranges and fields (with &)\n",
.read = acf_cut_exec,
};
Modified: team/group/appdocsxml/main/pbx.c
URL: http://svn.digium.com/view/asterisk/team/group/appdocsxml/main/pbx.c?view=diff&rev=145199&r1=145198&r2=145199
==============================================================================
--- team/group/appdocsxml/main/pbx.c (original)
+++ team/group/appdocsxml/main/pbx.c Tue Sep 30 14:19:54 2008
@@ -3272,12 +3272,13 @@
{
#define GOTONEXT(__rev, __a) (__rev ? __a->AST_XML_PREV : __a->AST_XML_NEXT)
#define ISLAST(__rev, __a) (__rev == 1 ? (__a->AST_XML_PREV ? 0 : 1) : (__a->AST_XML_NEXT ? 0 : 1))
+#define MP(__a) ((multiple ? __a : ""))
ast_xml_node *node = NULL, *firstparam = NULL, *lastparam = NULL;
- ast_xml_attr *paramtype, *paramname, *attrargsep;
+ ast_xml_attr *paramtype, *multipletype, *paramname, *attrargsep;
int reverse, required, paramcount = 0, openbrackets = 0, len = 0, hasparams=0;
int reqfinode = 0, reqlanode = 0, optmidnode = 0;
char *syntax = NULL, *argsep;
- int paramnamemalloc;
+ int paramnamemalloc, multiple;
if (ast_strlen_zero(rootname) || ast_strlen_zero(childname)) {
ast_log(LOG_WARNING, "Tried to look in XML tree with faulty rootname or childname while creating a syntax.\n");
@@ -3393,6 +3394,15 @@
}
}
+ /* Defaults to 'false'. */
+ multiple = 0;
+ if ((multipletype = ast_xml_get_attribute(node, "multiple"))) {
+ if (ast_true((char *)multipletype)) {
+ multiple = 1;
+ }
+ ast_xml_free_attr(multipletype);
+ }
+
required = 0; /* Defaults to 'false'. */
if ((paramtype = ast_xml_get_attribute(node, "required"))) {
if (ast_true((char *)paramtype)) {
@@ -3417,23 +3427,28 @@
} else {
xmldoc_reverse_helper(reverse, &len, &syntax, "%s%s", argsep, paramname);
}
+ xmldoc_reverse_helper(reverse, &len, &syntax, "%s%s%s", MP("["), MP(argsep), MP("...]"));
}
} else {
/* First parameter */
if (!paramcount) {
- xmldoc_reverse_helper(reverse, &len, &syntax, "[%s]", paramname);
+ xmldoc_reverse_helper(reverse, &len, &syntax, "[%s%s%s%s]", paramname, MP("["), MP(argsep), MP("...]"));
} else {
if (ISLAST(reverse, node)) {
if (reverse) {
- xmldoc_reverse_helper(reverse, &len, &syntax, "[%s]%s", paramname, argsep);
+ xmldoc_reverse_helper(reverse, &len, &syntax, "[%s%s%s%s]%s", paramname,
+ MP("["), MP(argsep), MP("...]"), argsep);
} else {
- xmldoc_reverse_helper(reverse, &len, &syntax, "%s[%s]", argsep, paramname);
+ xmldoc_reverse_helper(reverse, &len, &syntax, "%s[%s%s%s%s]", argsep, paramname,
+ MP("["), MP(argsep), MP("...]"));
}
} else {
if (reverse) {
- xmldoc_reverse_helper(reverse, &len, &syntax, "%s%s]", paramname, argsep);
+ xmldoc_reverse_helper(reverse, &len, &syntax, "%s%s%s%s%s]", paramname, argsep,
+ MP("["), MP(argsep), MP("...]"));
} else {
- xmldoc_reverse_helper(reverse, &len, &syntax, "[%s%s", argsep, paramname);
+ xmldoc_reverse_helper(reverse, &len, &syntax, "[%s%s%s%s%s", argsep, paramname,
+ MP("["), MP(argsep), MP("...]"));
}
openbrackets++;
}
@@ -3464,6 +3479,7 @@
return syntax;
#undef ISLAST
#undef GOTONEXT
+#undef MP
}
/*! \internal
More information about the asterisk-commits
mailing list