58 static int acf_rand_exec(
struct ast_channel *chan,
const char *cmd,
59 char *parse,
char *buffer,
size_t buflen)
61 int min_int, response_int, max_int;
69 if (ast_strlen_zero(args.min) || sscanf(args.min,
"%30d", &min_int) != 1)
72 if (ast_strlen_zero(args.max) || sscanf(args.max,
"%30d", &max_int) != 1)
75 if (max_int < min_int) {
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);
92 .read = acf_rand_exec,
96 static int unload_module(
void)
103 static int load_module(
void)
108 AST_MODULE_INFO_STANDARD(
ASTERISK_GPL_KEY,
"Random number dialplan function");
Main Channel structure associated with a channel.
Asterisk main include file. File version handling, generic pbx functions.
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
int ast_custom_function_unregister(struct ast_custom_function *acf)
Unregister a custom function.
General Asterisk PBX channel definitions.
Data structure associated with a custom dialplan function.
#define ast_debug(level,...)
Log a DEBUG message.
Core PBX routines and definitions.
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
Application convenience functions, designed to give consistent look and feel to Asterisk apps...
#define ast_custom_function_register(acf)
Register a custom function.
#define AST_APP_ARG(name)
Define an application argument.