57 #define MODE_MATCHMORE 1
58 #define MODE_CANMATCH 2
60 #define EXT_DATA_SIZE 256
87 static int cache_cmp(
void *obj,
void *arg,
int flags)
90 return e->
priority != f->priority ? 0 :
91 strcmp(e->
exten, f->exten) ? 0 :
92 strcmp(e->
context, f->context) ? 0 :
99 for (; v; v = v->
next) {
121 struct timeval *now = arg;
127 struct timespec forever = { 999999999, 0 }, one_second = { 1, 0 };
131 pthread_testcancel();
133 nanosleep(&forever, NULL);
135 pthread_testcancel();
138 pthread_testcancel();
139 nanosleep(&one_second, NULL);
174 snprintf(pri,
sizeof(pri),
"%d", priority);
177 ematch =
"exten LIKE";
178 snprintf(rexten,
sizeof(rexten),
"%s_%%", exten);
181 ematch =
"exten LIKE";
182 snprintf(rexten,
sizeof(rexten),
"%s%%", exten);
221 const char *ctx = NULL;
229 } cache_search = { { .
priority =
priority, .context = (
char *) context }, };
233 char *opts = strchr(buf,
'/');
236 table = strchr(buf,
'@');
241 ctx =
S_OR(ctx, context);
242 table =
S_OR(table,
"extensions");
246 ast_copy_string(cache_search.exten, exten,
sizeof(cache_search.exten));
266 strcpy(ce->
exten, exten);
272 pthread_kill(cleanup_thread, SIGURG);
279 static int realtime_exists(
struct ast_channel *chan,
const char *context,
const char *exten,
int priority,
const char *callerid,
const char *data)
299 static int realtime_exec(
struct ast_channel *chan,
const char *context,
const char *exten,
int priority,
const char *callerid,
const char *data)
309 for (v = var; v ; v = v->
next) {
310 if (!strcasecmp(v->
name,
"app"))
312 else if (!strcasecmp(v->
name,
"appdata")) {
318 if (*v->
value ==
',') {
321 }
else if (*v->
value ==
'|' && !in) {
328 if (v->
value[0] ==
'[' && v->
value[-1] ==
'$') {
330 }
else if (v->
value[0] ==
']' && in) {
352 ast_verb(3,
"Executing [%s@%s:%d] %s(\"%s\", \"%s\")\n",
362 "Application: %s\r\n"
369 ast_log(
LOG_NOTICE,
"No such application '%s' for extension '%s' in context '%s'\n", app, exten, context);
371 ast_log(
LOG_WARNING,
"No application specified for realtime extension '%s' in context '%s'\n", exten, context);
390 .description =
"Realtime Dialplan Switch",
400 pthread_cancel(cleanup_thread);
401 pthread_kill(cleanup_thread, SIGURG);
402 pthread_join(cleanup_thread, NULL);
static int cache_cmp(void *obj, void *arg, int flags)
void pbx_substitute_variables_helper(struct ast_channel *c, const char *cp1, char *cp2, int count)
static char exten[AST_MAX_EXTENSION]
Main Channel structure associated with a channel.
#define AST_MODULE_INFO_STANDARD(keystr, desc)
Asterisk locking-related definitions:
Asterisk main include file. File version handling, generic pbx functions.
#define ao2_link(arg1, arg2)
int ao2_container_count(struct ao2_container *c)
Returns the number of elements in a container.
#define AST_APP_OPTIONS(holder, options...)
Declares an array of options for an application.
struct ast_app * pbx_findapp(const char *app)
Look up an application.
int pbx_exec(struct ast_channel *c, struct ast_app *app, const char *data)
Execute an application.
const ast_string_field uniqueid
struct ast_variable * ast_category_detach_variables(struct ast_category *cat)
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
#define ast_test_flag(p, flag)
char context[AST_MAX_CONTEXT]
#define ao2_callback(c, flags, cb_fn, arg)
int ast_app_parse_options(const struct ast_app_option *options, struct ast_flags *flags, char **args, char *optstr)
Parses a string containing application options and sets flags/arguments.
Structure for variables, used for configurations and for channel variables.
static struct ast_variable * dup_vars(struct ast_variable *v)
static int realtime_exists(struct ast_channel *chan, const char *context, const char *exten, int priority, const char *callerid, const char *data)
Configuration File Parser.
void ast_unregister_switch(struct ast_switch *sw)
Unregister an alternative switch.
struct ast_variable * ast_load_realtime(const char *family,...) attribute_sentinel
Retrieve realtime configuration.
static struct ast_variable * realtime_switch_common(const char *table, const char *context, const char *exten, int priority, int mode, struct ast_flags flags)
static int cache_hash(const void *obj, const int flags)
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
int64_t ast_tvdiff_ms(struct timeval end, struct timeval start)
Computes the difference (in milliseconds) between two struct timeval instances.
void ast_variables_destroy(struct ast_variable *var)
Free variable list.
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)
static int realtime_canmatch(struct ast_channel *chan, const char *context, const char *exten, int priority, const char *callerid, const char *data)
#define EVENT_FLAG_DIALPLAN
#define ast_verb(level,...)
void ast_config_destroy(struct ast_config *config)
Destroys a config.
static int purge_old_fn(void *obj, void *arg, int flags)
static int load_module(void)
struct ast_category * ast_category_get(const struct ast_config *config, const char *category_name)
Retrieve a category if it exists.
static int unload_module(void)
General Asterisk PBX channel definitions.
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Asterisk internal frame definitions.
#define AST_MAX_EXTENSION
Scheduler Routines (derived from cheops)
#define ao2_ref(o, delta)
char * ast_category_browse(struct ast_config *config, const char *prev)
Goes through categories.
#define ast_compat_pbx_realtime
static struct ast_app_option switch_opts[128]
A set of macros to manage forward-linked lists.
Core PBX routines and definitions.
char * term_color(char *outbuf, const char *inbuf, int fgcolor, int bgcolor, int maxout)
The AMI - Asterisk Manager Interface - is a TCP protocol created to manage Asterisk with third-party ...
#define ast_strdupa(s)
duplicate a string in memory from the stack
static struct ast_variable * realtime_common(const char *context, const char *exten, int priority, const char *data, int mode)
struct ast_variable * var
const ast_string_field name
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
#define ao2_alloc(data_size, destructor_fn)
#define ao2_find(arg1, arg2, arg3)
#define ast_pthread_create(a, b, c, d)
int ast_register_switch(struct ast_switch *sw)
Register an alternative dialplan switch.
int ast_extension_close(const char *pattern, const char *data, int needmore)
int ast_extension_match(const char *pattern, const char *extension)
Determine if a given extension matches a given pattern (in NXX format)
static void free_entry(void *obj)
static int realtime_exec(struct ast_channel *chan, const char *context, const char *exten, int priority, const char *callerid, const char *data)
static void * cleanup(void *unused)
Structure used to handle boolean flags.
Support for logging to various files, console and syslog Configuration in file logger.conf.
struct ao2_container * cache
Standard Command Line Interface.
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
#define ao2_container_alloc(arg1, arg2, arg3)
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
ast_app: A registered application
Application convenience functions, designed to give consistent look and feel to Asterisk apps...
Handy terminal functions for vt* terms.
struct ast_variable * next
static char context[AST_MAX_CONTEXT]
#define ASTERISK_GPL_KEY
The text the key() function should return.
#define manager_event(category, event, contents,...)
External routines may send asterisk manager events this way.
Asterisk module definitions.
static int match(struct sockaddr_in *sin, unsigned short callno, unsigned short dcallno, const struct chan_iax2_pvt *cur, int check_dcallno)
Persistant data storage (akin to *doze registry)
char exten[AST_MAX_EXTENSION]
static struct ast_switch realtime_switch
struct ast_variable * ast_variable_new(const char *name, const char *value, const char *filename)
static force_inline int attribute_pure ast_str_case_hash(const char *str)
Compute a hash value on a case-insensitive string.
#define ASTERISK_FILE_VERSION(file, version)
Register/unregister a source code file with the core.
static int realtime_matchmore(struct ast_channel *chan, const char *context, const char *exten, int priority, const char *callerid, const char *data)
struct ast_config * ast_load_realtime_multientry(const char *family,...) attribute_sentinel
Retrieve realtime configuration.
#define AST_APP_OPTION(option, flagno)
Declares an application option that does not accept an argument.