mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-02 19:16:15 +00:00
major dialplan functions update
deprecate LANGUAGE() and MUSICCLASS(), in favor of CHANNEL() git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@9674 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -43,48 +43,42 @@ STANDARD_LOCAL_USER;
|
||||
|
||||
LOCAL_USER_DECL;
|
||||
|
||||
static char *acf_rand_exec(struct ast_channel *chan, char *cmd, char *data, char *buffer, size_t buflen)
|
||||
static int acf_rand_exec(struct ast_channel *chan, char *cmd,
|
||||
char *parse, char *buffer, size_t buflen)
|
||||
{
|
||||
struct localuser *u;
|
||||
int min_int, response_int, max_int;
|
||||
char *parse;
|
||||
|
||||
AST_DECLARE_APP_ARGS(args,
|
||||
AST_APP_ARG(min);
|
||||
AST_APP_ARG(max);
|
||||
AST_APP_ARG(min);
|
||||
AST_APP_ARG(max);
|
||||
);
|
||||
|
||||
if (!(parse = ast_strdupa(data))) {
|
||||
*buffer = '\0';
|
||||
return buffer;
|
||||
}
|
||||
|
||||
LOCAL_USER_ACF_ADD(u);
|
||||
|
||||
AST_STANDARD_APP_ARGS(args, parse);
|
||||
|
||||
if (ast_strlen_zero(args.min) || sscanf(args.min, "%d", &min_int) != 1) {
|
||||
|
||||
if (ast_strlen_zero(args.min) || sscanf(args.min, "%d", &min_int) != 1)
|
||||
min_int = 0;
|
||||
}
|
||||
|
||||
|
||||
if (ast_strlen_zero(args.max) || sscanf(args.max, "%d", &max_int) != 1) {
|
||||
if (ast_strlen_zero(args.max) || sscanf(args.max, "%d", &max_int) != 1)
|
||||
max_int = RAND_MAX;
|
||||
}
|
||||
|
||||
if (max_int < min_int) {
|
||||
int tmp = max_int;
|
||||
|
||||
max_int = min_int;
|
||||
min_int = tmp;
|
||||
ast_log(LOG_DEBUG, "max<min\n");
|
||||
}
|
||||
|
||||
response_int = min_int + (ast_random() % (max_int - min_int + 1));
|
||||
ast_log(LOG_DEBUG, "%d was the lucky number in range [%d,%d]\n", response_int, min_int, max_int);
|
||||
ast_log(LOG_DEBUG, "%d was the lucky number in range [%d,%d]\n",
|
||||
response_int, min_int, max_int);
|
||||
snprintf(buffer, buflen, "%d", response_int);
|
||||
|
||||
LOCAL_USER_REMOVE(u);
|
||||
return buffer;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct ast_custom_function acf_rand = {
|
||||
@@ -92,10 +86,10 @@ static struct ast_custom_function acf_rand = {
|
||||
.synopsis = "Choose a random number in a range",
|
||||
.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"
|
||||
" Sets junky to a random number between 1 and 8, inclusive.\n",
|
||||
"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"
|
||||
" Sets junky to a random number between 1 and 8, inclusive.\n",
|
||||
.read = acf_rand_exec,
|
||||
};
|
||||
|
||||
@@ -116,7 +110,7 @@ int load_module(void)
|
||||
|
||||
char *description(void)
|
||||
{
|
||||
return tdesc;
|
||||
return tdesc;
|
||||
}
|
||||
|
||||
int usecount(void)
|
||||
@@ -126,5 +120,5 @@ int usecount(void)
|
||||
|
||||
char *key()
|
||||
{
|
||||
return ASTERISK_GPL_KEY;
|
||||
return ASTERISK_GPL_KEY;
|
||||
}
|
||||
|
Reference in New Issue
Block a user