73 static int isexten_function_read(
struct ast_channel *chan,
const char *cmd,
char *data,
74 char *buf,
size_t len)
85 if (ast_strlen_zero(data)) {
86 ast_log(LOG_ERROR,
"DIALPLAN_EXISTS() requires an argument\n");
93 if (!ast_strlen_zero(args.priority)) {
95 if (sscanf(args.priority,
"%30d", &priority_num) == 1 && priority_num > 0) {
99 S_COR(ast_channel_caller(chan)->
id.
number.valid, ast_channel_caller(chan)->
id.
number.str, NULL));
106 S_COR(ast_channel_caller(chan)->
id.
number.valid, ast_channel_caller(chan)->
id.
number.str, NULL));
110 }
else if (!ast_strlen_zero(args.exten)) {
114 S_COR(ast_channel_caller(chan)->
id.
number.valid, ast_channel_caller(chan)->
id.
number.str, NULL));
117 }
else if (!ast_strlen_zero(args.context)) {
121 ast_log(LOG_ERROR,
"Invalid arguments provided to DIALPLAN_EXISTS\n");
128 static int acf_isexten_exec(
struct ast_channel *chan,
const char *cmd,
char *parse,
char *buffer,
size_t buflen)
138 ast_log(LOG_WARNING,
"No channel was provided to %s function.\n", cmd);
144 if (ast_strlen_zero(args.context)) {
145 args.context =
ast_strdupa(ast_channel_context(chan));
148 if (ast_strlen_zero(args.extension)) {
149 ast_log(LOG_WARNING,
"Syntax: VALID_EXTEN([<context>],<extension>[,<priority>]) - missing argument <extension>!\n");
153 if (ast_strlen_zero(args.priority)) {
156 priority_int = atoi(args.priority);
160 S_COR(ast_channel_caller(chan)->
id.
number.valid, ast_channel_caller(chan)->
id.
number.str, NULL))) {
170 .
name =
"DIALPLAN_EXISTS",
171 .read = isexten_function_read,
176 .
name =
"VALID_EXTEN",
177 .read = acf_isexten_exec,
180 static int unload_module(
void)
187 static int load_module(
void)
194 AST_MODULE_INFO(
ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER,
"Dialplan Context/Extension/Priority Checking Functions",
195 .support_level = AST_MODULE_SUPPORT_CORE,
197 .unload = unload_module,
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.
struct ast_context * ast_context_find(const char *name)
Find a context.
General Asterisk PBX channel definitions.
#define ast_strdupa(s)
duplicate a string in memory from the stack
Data structure associated with a custom dialplan function.
structure to hold extensions
#define S_COR(a, b, c)
returns the equivalent of logic or for strings, with an additional boolean check: second one if not e...
int ast_exists_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
Determine whether an extension exists.
Core PBX routines and definitions.
int ast_findlabel_extension(struct ast_channel *c, const char *context, const char *exten, const char *label, const char *callerid)
Find the priority of an extension that has the specified label.
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
#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.