56#define MODE_MATCHMORE 1
57#define MODE_CANMATCH 2
59#define EXT_DATA_SIZE 256
86static int cache_cmp(
void *obj,
void *arg,
int flags)
89 return e->
priority != f->priority ? 0 :
90 strcmp(e->
exten, f->exten) ? 0 :
91 strcmp(e->
context, f->context) ? 0 :
98 for (; v; v = v->
next) {
120 struct timeval *now = arg;
126 struct timespec forever = { 999999999, 0 }, one_second = { 1, 0 };
130 pthread_testcancel();
132 nanosleep(&forever,
NULL);
134 pthread_testcancel();
137 pthread_testcancel();
138 nanosleep(&one_second,
NULL);
149 return strlen(extenp) - strlen(extenq);
180 snprintf(pri,
sizeof(pri),
"%d",
priority);
183 ematch =
"exten LIKE";
184 snprintf(rexten,
sizeof(rexten),
"%s_%%", exten);
187 ematch =
"exten LIKE";
188 snprintf(rexten,
sizeof(rexten),
"%s%%", exten);
231 const char *ctx =
NULL;
239 } cache_search = { { .priority =
priority, .context = (
char *)
context }, };
243 char *opts = strchr(
buf,
'/');
276 strcpy(ce->
exten, exten);
315 char *appdata_tmp =
"";
319 for (v =
var; v ; v = v->
next) {
320 if (!strcasecmp(v->
name,
"app"))
322 else if (!strcasecmp(v->
name,
"appdata")) {
338 ast_verb(3,
"Executing [%s@%s:%d] %s(\"%s\", \"%s\")\n",
395 .description =
"Realtime Dialplan Switch",
Persistent data storage (akin to *doze registry)
Asterisk main include file. File version handling, generic pbx functions.
#define ast_strdupa(s)
duplicate a string in memory from the stack
#define ao2_link(container, obj)
Add an object to a container.
@ AO2_ALLOC_OPT_LOCK_MUTEX
#define ao2_callback(c, flags, cb_fn, arg)
ao2_callback() is a generic function that applies cb_fn() to all objects in a container,...
int ao2_container_count(struct ao2_container *c)
Returns the number of elements in a container.
#define ao2_find(container, arg, flags)
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
#define ao2_alloc(data_size, destructor_fn)
#define ao2_container_alloc_hash(ao2_options, container_options, n_buckets, hash_fn, sort_fn, cmp_fn)
Allocate and initialize a hash container with the desired number of buckets.
static int match(struct ast_sockaddr *addr, unsigned short callno, unsigned short dcallno, const struct chan_iax2_pvt *cur, int check_dcallno)
General Asterisk PBX channel definitions.
const char * ast_channel_name(const struct ast_channel *chan)
void ast_channel_appl_set(struct ast_channel *chan, const char *value)
const char * ast_channel_data(const struct ast_channel *chan)
#define ast_channel_lock(chan)
void ast_channel_data_set(struct ast_channel *chan, const char *value)
int ast_channel_priority(const struct ast_channel *chan)
const char * ast_channel_context(const struct ast_channel *chan)
const char * ast_channel_appl(const struct ast_channel *chan)
const char * ast_channel_exten(const struct ast_channel *chan)
#define ast_channel_unlock(chan)
#define AST_MAX_EXTENSION
Standard Command Line Interface.
Generic File Format Support. Should be included by clients of the file handling routines....
void ast_channel_snapshot_invalidate_segment(struct ast_channel *chan, enum ast_channel_snapshot_segment_invalidation segment)
Invalidate a channel snapshot segment from being reused.
struct stasis_message_type * ast_channel_snapshot_type(void)
Message type for ast_channel_snapshot_update.
void ast_channel_publish_snapshot(struct ast_channel *chan)
Publish a ast_channel_snapshot for a channel.
@ AST_CHANNEL_SNAPSHOT_INVALIDATE_DIALPLAN
Application convenience functions, designed to give consistent look and feel to Asterisk apps.
#define AST_APP_OPTIONS(holder, options...)
Declares an array of options for an application.
#define AST_APP_OPTION(option, flagno)
Declares an application option that does not accept an argument.
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.
Configuration File Parser.
struct ast_variable * ast_category_detach_variables(struct ast_category *cat)
char * ast_category_browse(struct ast_config *config, const char *prev_name)
Browse categories.
void ast_config_sort_categories(struct ast_config *config, int descending, int(*comparator)(struct ast_category *p, struct ast_category *q))
Sorts categories in a config in the order of a numerical value contained within them.
struct ast_config * ast_load_realtime_multientry(const char *family,...) attribute_sentinel
Retrieve realtime configuration.
#define ast_variable_new(name, value, filename)
void ast_config_destroy(struct ast_config *cfg)
Destroys a config.
const char * ast_variable_retrieve(struct ast_config *config, const char *category, const char *variable)
struct ast_variable * ast_load_realtime(const char *family,...) attribute_sentinel
void ast_variables_destroy(struct ast_variable *var)
Free variable list.
const char * ast_variable_find(const struct ast_category *category, const char *variable)
Gets a variable value from a specific category structure by name.
struct ast_category * ast_category_get(const struct ast_config *config, const char *category_name, const char *filter)
Retrieve a category if it exists.
Asterisk internal frame definitions.
Support for logging to various files, console and syslog Configuration in file logger....
#define ast_verb(level,...)
I/O Management (derived from Cheops-NG)
A set of macros to manage forward-linked lists.
Asterisk locking-related definitions:
The AMI - Asterisk Manager Interface - is a TCP protocol created to manage Asterisk with third-party ...
Asterisk module definitions.
#define ASTERISK_GPL_KEY
The text the key() function should return.
@ AST_MODULE_LOAD_FAILURE
Module could not be loaded properly.
@ AST_MODULE_LOAD_SUCCESS
Core PBX routines and definitions.
void ast_unregister_switch(struct ast_switch *sw)
Unregister an alternative switch.
int ast_register_switch(struct ast_switch *sw)
Register an alternative dialplan switch.
int pbx_exec(struct ast_channel *c, struct ast_app *app, const char *data)
Execute an application.
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)
struct ast_app * pbx_findapp(const char *app)
Look up an application.
void pbx_substitute_variables_helper(struct ast_channel *c, const char *cp1, char *cp2, int count)
static void * cleanup(void *unused)
static struct ast_variable * realtime_common(const char *context, const char *exten, int priority, const char *data, int mode)
static int cache_hash(const void *obj, const int flags)
@ OPTION_PATTERNS_DISABLED
static int realtime_exec(struct ast_channel *chan, const char *context, const char *exten, int priority, const char *callerid, const char *data)
static const struct ast_app_option switch_opts[128]
static struct ast_switch realtime_switch
static int cache_cmp(void *obj, void *arg, int flags)
static int extension_length_comparator(struct ast_category *p, struct ast_category *q)
static struct ast_variable * dup_vars(struct ast_variable *v)
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 realtime_canmatch(struct ast_channel *chan, const char *context, const char *exten, int priority, const char *callerid, const char *data)
static int realtime_exists(struct ast_channel *chan, const char *context, const char *exten, int priority, const char *callerid, const char *data)
static int load_module(void)
static void free_entry(void *obj)
static int realtime_matchmore(struct ast_channel *chan, const char *context, const char *exten, int priority, const char *callerid, const char *data)
static int unload_module(void)
struct ao2_container * cache
static int purge_old_fn(void *obj, void *arg, int flags)
AST_MODULE_INFO_STANDARD_EXTENDED(ASTERISK_GPL_KEY, "Realtime Switch")
Scheduler Routines (derived from cheops)
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one.
static force_inline int attribute_pure ast_strlen_zero(const char *s)
static force_inline int attribute_pure ast_str_case_hash(const char *str)
Compute a hash value on a case-insensitive string.
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
ast_app: A registered application
Main Channel structure associated with a channel.
Structure used to handle boolean flags.
Structure for variables, used for configurations and for channel variables.
struct ast_variable * next
struct ast_variable * var
Handy terminal functions for vt* terms.
char * term_color(char *outbuf, const char *inbuf, int fgcolor, int bgcolor, int maxout)
Colorize a specified string by adding terminal color codes.
int64_t ast_tvdiff_ms(struct timeval end, struct timeval start)
Computes the difference (in milliseconds) between two struct timeval instances.
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
#define ast_test_flag(p, flag)
#define ast_pthread_create(a, b, c, d)