Generate Random Number.
More...
Go to the source code of this file.
|
static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Random number dialplan function" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, .support_level = AST_MODULE_SUPPORT_CORE, } |
|
static struct ast_custom_function | acf_rand |
|
static const struct ast_module_info * | ast_module_info = &__mod_info |
|
Generate Random Number.
- Author
- Claude Patry cpatr.nosp@m.y@gm.nosp@m.ail.c.nosp@m.om
-
Tilghman Lesher ( http://asterisk.drunkcoder.com/ )
Definition in file func_rand.c.
◆ __reg_module()
static void __reg_module |
( |
void |
| ) |
|
|
static |
◆ __unreg_module()
static void __unreg_module |
( |
void |
| ) |
|
|
static |
◆ acf_rand_exec()
static int acf_rand_exec |
( |
struct ast_channel * |
chan, |
|
|
const char * |
cmd, |
|
|
char * |
parse, |
|
|
char * |
buffer, |
|
|
size_t |
buflen |
|
) |
| |
|
static |
Definition at line 58 of file func_rand.c.
60{
61 int min_int, response_int, max_int;
65 );
66
68
70 min_int = 0;
71
73 max_int = RAND_MAX;
74
75 if (max_int < min_int) {
77
78 max_int = min_int;
81 }
82
83 response_int = min_int + (
ast_random() % (max_int - min_int + 1));
84 ast_debug(1,
"%d was the lucky number in range [%d,%d]\n", response_int, min_int, max_int);
85 snprintf(buffer, buflen, "%d", response_int);
86
87 return 0;
88}
#define AST_APP_ARG(name)
Define an application argument.
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
#define ast_debug(level,...)
Log a DEBUG message.
static force_inline int attribute_pure ast_strlen_zero(const char *s)
long int ast_random(void)
References args, AST_APP_ARG, ast_debug, AST_DECLARE_APP_ARGS, ast_random(), AST_STANDARD_APP_ARGS, ast_strlen_zero(), max, min, and tmp().
◆ AST_MODULE_SELF_SYM()
◆ load_module()
static int load_module |
( |
void |
| ) |
|
|
static |
◆ unload_module()
static int unload_module |
( |
void |
| ) |
|
|
static |
◆ __mod_info
struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Random number dialplan function" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, .support_level = AST_MODULE_SUPPORT_CORE, } |
|
static |
◆ acf_rand
Initial value:= {
.name = "RAND",
.read_max = 12,
}
static int acf_rand_exec(struct ast_channel *chan, const char *cmd, char *parse, char *buffer, size_t buflen)
Definition at line 90 of file func_rand.c.
Referenced by load_module(), and unload_module().
◆ ast_module_info