73 #define LOOPBACK_COMMON \
76 char *newexten=(char *)exten, *newcontext=(char *)context; \
77 int newpriority=priority; \
78 char *newpattern=NULL; \
79 loopback_subst(buf, sizeof(buf), exten, context, priority, data); \
80 loopback_parse(&newexten, &newcontext, &newpriority, &newpattern, buf); \
81 ast_debug(1, "Parsed into %s @ %s priority %d pattern %s\n", newexten, newcontext, newpriority, newpattern); \
82 if (!strcasecmp(newcontext, context)) return -1
84 static char *loopback_subst(
char *buf,
int buflen,
const char *exten,
const char *context,
int priority,
const char *data)
90 snprintf(tmp,
sizeof(tmp),
"%d", priority);
92 if ((newvariable = ast_var_assign(
"EXTEN", exten))) {
95 if ((newvariable = ast_var_assign(
"CONTEXT", context))) {
98 if ((newvariable = ast_var_assign(
"PRIORITY", tmp))) {
102 pbx_substitute_variables_varshead(&headp, data, buf, buflen);
105 ast_var_delete(newvariable);
109 static void loopback_parse(
char **newexten,
char **newcontext,
int *priority,
char **newpattern,
char *buf)
113 *newpattern = strchr(buf,
'/');
115 *(*newpattern)++ =
'\0';
116 con = strchr(buf,
'@');
119 pri = strchr(con,
':');
121 pri = strchr(buf,
':');
122 if (!ast_strlen_zero(buf))
124 if (!ast_strlen_zero(con))
126 if (!ast_strlen_zero(pri))
127 sscanf(pri,
"%30d", priority);
130 static int loopback_exists(
struct ast_channel *chan,
const char *context,
const char *exten,
int priority,
const char *callerid,
const char *data)
140 static int loopback_canmatch(
struct ast_channel *chan,
const char *context,
const char *exten,
int priority,
const char *callerid,
const char *data)
150 static int loopback_exec(
struct ast_channel *chan,
const char *context,
const char *exten,
int priority,
const char *callerid,
const char *data)
158 static int loopback_matchmore(
struct ast_channel *chan,
const char *context,
const char *exten,
int priority,
const char *callerid,
const char *data)
171 .description =
"Loopback Dialplan Switch",
172 .exists = loopback_exists,
173 .canmatch = loopback_canmatch,
174 .exec = loopback_exec,
175 .matchmore = loopback_matchmore,
178 static int unload_module(
void)
184 static int load_module(
void)
int ast_matchmore_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
Looks to see if adding anything to this extension might match something. (exists ^ canmatch) ...
Main Channel structure associated with a channel.
Asterisk locking-related definitions:
Asterisk main include file. File version handling, generic pbx functions.
void ast_unregister_switch(struct ast_switch *sw)
Unregister an alternative switch.
Generic File Format Support. Should be included by clients of the file handling routines. File service providers should instead include mod_format.h.
I/O Management (derived from Cheops-NG)
int ast_canmatch_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
Looks for a valid matching extension.
Configuration File Parser.
General Asterisk PBX channel definitions.
Scheduler Routines (derived from cheops)
Asterisk internal frame definitions.
A set of macros to manage forward-linked lists.
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
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.
#define AST_LIST_INSERT_HEAD(head, elm, field)
Inserts a list entry at the head of a list.
int ast_extension_match(const char *pattern, const char *extension)
Determine if a given extension matches a given pattern (in NXX format)
int ast_register_switch(struct ast_switch *sw)
Register an alternative dialplan switch.
Module could not be loaded properly.
Support for logging to various files, console and syslog Configuration in file logger.conf.
int ast_spawn_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid, int *found, int combined_find_spawn)
Launch a new extension (i.e. new stack)
#define AST_LIST_HEAD_INIT_NOLOCK(head)
Initializes a list head structure.
Standard Command Line Interface.
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.
Persistent data storage (akin to *doze registry)