14 #define ASTMM_LIBC ASTMM_IGNORE
64 #define ADD_LAST(headptr,memptr) if(!headptr){ headptr=(memptr); (headptr##_last)=(memptr);} else {(headptr##_last)->next = (memptr); (headptr##_last) = (memptr);}
66 void destroy_namelist(
struct namelist *x);
67 void destroy_namelist(
struct namelist *x)
78 struct namelist *create_name(
const char *name);
79 struct namelist *create_name(
const char *name)
81 struct namelist *x = calloc(1,
sizeof(*x));
84 strncpy(x->name, name,
sizeof(x->name) - 1);
93 int conts=0, extens=0, priors=0;
94 char last_exten[18000];
96 static char config_dir[PATH_MAX];
97 static char var_dir[PATH_MAX];
98 const char *ast_config_AST_CONFIG_DIR = config_dir;
99 const char *ast_config_AST_VAR_DIR = var_dir;
101 void __ast_cli_register_multiple(
void);
103 int replace,
const char *
extension,
int priority,
const char *label,
const char *callerid,
104 const char *application,
void *data,
void (*datad)(
void *),
105 const char *registrar);
107 struct ast_context * ast_context_create(
void **extcontexts,
const char *name,
const char *
registrar);
109 void ast_context_add_ignorepat2(
struct ast_context *con,
const char *value,
const char *
registrar);
117 void ast_log(
int level,
const char *file,
int line,
const char *
function,
const char *fmt, ...);
119 void __ast_verbose(
const char *file,
int line,
const char *func,
int level,
const char *fmt, ...);
121 void filter_leading_space_from_exprs(
char *str);
122 void filter_newlines(
char *str);
123 static int quiet = 0;
124 static int no_comp = 0;
125 static int use_curr_dir = 0;
126 static int dump_extensions = 0;
127 static int FIRST_TIME = 0;
128 static FILE *dumpfile;
130 void ast_log(
int level,
const char *file,
int line,
const char *
function,
const char *fmt, ...)
135 printf(
"LOG: lev:%d file:%s line:%d func: %s ",
136 level, file, line,
function);
149 const char *callerid,
159 const char *callerid,
162 return localized_find_extension(bypass, q, context, exten, priority, label, callerid, action);
181 printf(
"Executed ast_add_profile();\n");
204 void __ast_cli_register_multiple(
void)
207 printf(
"Executed ast_cli_register_multiple();\n");
210 void pbx_substitute_variables_helper(
struct ast_channel *c,
const char *cp1,
char *cp2,
int count);
211 void pbx_substitute_variables_helper(
struct ast_channel *c,
const char *cp1,
char *cp2,
int count)
222 int replace,
const char *extension,
int priority,
const char *label,
const char *callerid,
223 const char *application,
void *data,
void (*datad)(
void *),
224 const char *registrar)
227 con->extension_count++;
228 if (strcmp(extension,last_exten) != 0) {
230 strcpy(last_exten, extension);
239 application =
"(null)";
243 printf(
"Executed ast_add_extension2(context=%s, rep=%d, exten=%s, priority=%d, label=%s, callerid=%s, appl=%s, data=%s, FREE, registrar=%s);\n",
244 con->
name, replace, extension, priority, label, callerid, application, (data?(
char*)data:
"(null)"), registrar);
246 if( dump_extensions && dumpfile ) {
253 fprintf(dumpfile,
"[globals]\n");
255 for(n=globalvars;n;n=n->next) {
256 fprintf(dumpfile,
"%s\n", n->name);
261 if( con != last_context ) {
262 fprintf(dumpfile,
"\n\n[%s]\n", con->
name);
265 fprintf(dumpfile,
"ignorepat => %s\n", n->name);
268 fprintf(dumpfile,
"include => %s\n", n->name);
270 for(n=con->switches;n;n=n->next) {
271 fprintf(dumpfile,
"switch => %s/%s\n", n->name, n->name2);
273 for(n=con->eswitches;n;n=n->next) {
274 fprintf(dumpfile,
"eswitch => %s/%s\n", n->name, n->name2);
279 filter_newlines((
char*)data);
280 filter_leading_space_from_exprs((
char*)data);
286 if( strcmp(label,
"(null)") != 0 )
287 fprintf(dumpfile,
"exten => %s,%d(%s),%s(%s)\n", extension, priority, label, application, (
char*)data);
289 fprintf(dumpfile,
"exten => %s,%d,%s(%s)\n", extension, priority, application, (
char*)data);
293 if( strcmp(label,
"(null)") != 0 )
294 fprintf(dumpfile,
"exten => %s,%d(%s),%s\n", extension, priority, label, application);
296 fprintf(dumpfile,
"exten => %s,%d,%s\n", extension, priority, application);
307 struct namelist *x = create_name(data);
309 printf(
"Executed pbx_builtin_setvar(chan, data=%s);\n", (
char*)data);
311 if( dump_extensions ) {
312 x = create_name(data);
313 ADD_LAST(globalvars,x);
318 struct ast_context * ast_context_create(
void **extcontexts,
const char *name,
const char *registrar)
323 x->
next = context_list;
326 printf(
"Executed ast_context_create(conts, name=%s, registrar=%s);\n", name, registrar);
328 strncpy(x->
name, name,
sizeof(x->
name) - 1);
338 x->
next = context_list;
341 printf(
"Executed ast_context_find_or_create(conts, name=%s, registrar=%s);\n", name, registrar);
343 strncpy(x->
name, name,
sizeof(x->
name) - 1);
348 void ast_context_add_ignorepat2(
struct ast_context *con,
const char *value,
const char *registrar)
351 printf(
"Executed ast_context_add_ignorepat2(con, value=%s, registrar=%s);\n", value, registrar);
352 if( dump_extensions ) {
354 x = create_name(value);
362 printf(
"Executed ast_context_add_include2(con, value=%s, registrar=%s);\n", value, registrar);
363 if( dump_extensions ) {
365 x = create_name((
char*)value);
373 printf(
"Executed ast_context_add_switch2(con, value=%s, data=%s, eval=%d, registrar=%s);\n", value, data, eval, registrar);
374 if( dump_extensions ) {
376 x = create_name((
char*)value);
377 strncpy(x->name2, data, 99);
380 ADD_LAST(con->switches,x);
384 ADD_LAST(con->eswitches,x);
392 printf(
"Executed ast_merge_contexts_and_delete();\n");
398 printf(
"Executed ast_context_verify_includes();\n");
404 printf(
"Executed ast_walk_contexts();\n");
411 printf(
"Executed ast_cli_unregister_multiple();\n");
417 printf(
"Executed ast_context_destroy();\n");
420 const char *ast_get_context_name(
struct ast_context *con);
421 const char *ast_get_context_name(
struct ast_context *con)
423 return con ? con->
name : NULL;
450 void filter_leading_space_from_exprs(
char *str)
453 char *t, *v, *u = str;
457 if( *u ==
'$' && *(u+1) ==
'[' ) {
459 while( *t ==
'\n' || *t ==
'\r' || *t ==
'\t' || *t ==
' ' ) {
472 void filter_newlines(
char *str)
477 if( *t ==
'\n' || *t ==
'\r' ) {
487 extern struct module_symbols mod_data;
488 int ael_external_load_module(
void);
491 int main(
int argc,
char **argv)
497 for(i=1;i<argc;i++) {
498 if( argv[i][0] ==
'-' && argv[i][1] ==
'n' )
500 if( argv[i][0] ==
'-' && argv[i][1] ==
'q' ) {
504 if( argv[i][0] ==
'-' && argv[i][1] ==
'd' )
506 if( argv[i][0] ==
'-' && argv[i][1] ==
'w' )
511 printf(
"\n(If you find progress and other non-error messages irritating, you can use -q to suppress them)\n");
513 printf(
"\n(You can use the -n option if you aren't interested in seeing all the instructions generated by the compiler)\n\n");
515 printf(
"\n(You can use the -d option if you want to use the current working directory as the CONFIG_DIR. I will look in this dir for extensions.ael* and its included files)\n\n");
516 if( !dump_extensions )
517 printf(
"\n(You can use the -w option to dump extensions.conf format to extensions.conf.aeldump)\n");
521 strcpy(config_dir,
".");
522 localized_use_local_dir();
525 strcpy(config_dir,
"/etc/asterisk");
526 localized_use_conf_dir();
528 strcpy(var_dir,
"/usr/share/asterisk");
530 if( dump_extensions ) {
531 dumpfile = fopen(
"extensions.conf.aeldump",
"w");
533 printf(
"\n\nSorry, cannot open extensions.conf.aeldump for writing! Correct the situation and try again!\n\n");
541 ael_external_load_module();
543 ast_log(4,
"ael2_parse", __LINE__,
"main",
"%d contexts, %d extensions, %d priorities\n", conts, extens, priors);
545 if( dump_extensions && dumpfile ) {
547 for( lp = context_list; lp; lp = lp->
next ) {
549 if( lp->extension_count == 0 ) {
551 fprintf(dumpfile,
"\n\n[%s]\n", lp->
name);
554 fprintf(dumpfile,
"ignorepat => %s\n", n->name);
557 fprintf(dumpfile,
"include => %s\n", n->name);
559 for(n=lp->switches;n;n=n->next) {
560 fprintf(dumpfile,
"switch => %s/%s\n", n->name, n->name2);
562 for(n=lp->eswitches;n;n=n->next) {
563 fprintf(dumpfile,
"eswitch => %s/%s\n", n->name, n->name2);
569 if( dump_extensions && dumpfile )
572 for( lp = context_list; lp; lp = lp2 ) {
578 destroy_namelist(lp->switches);
579 destroy_namelist(lp->eswitches);
594 unsigned int ast_hashtab_hash_contexts(
const void *obj);
596 unsigned int ast_hashtab_hash_contexts(
const void *obj)
602 void ast_mark_lock_acquired(
void *lock_addr)
605 void ast_remove_lock_info(
void *lock_addr,
struct ast_bt *bt)
609 void ast_store_lock_info(
enum ast_lock_type type,
const char *filename,
610 int line_num,
const char *func,
const char *lock_name,
void *lock_addr,
struct ast_bt *bt)
615 int __ast_bt_get_addresses(
struct ast_bt *bt)
620 struct ast_vector_string *__ast_bt_get_symbols(
void **addresses,
size_t num_frames)
625 void ast_suspend_lock_info(
void *lock_addr)
628 void ast_restore_lock_info(
void *lock_addr)
ast_include: include= support in extensions.conf
int ast_hashtab_compare_contexts(const void *ah_a, const void *ah_b)
hashtable functions for contexts
Main Channel structure associated with a channel.
Asterisk locking-related definitions:
Asterisk main include file. File version handling, generic pbx functions.
ast_exten: An extension The dialplan is saved as a linked list with each context having it's own link...
Asterisk backtrace generation.
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
Generic (perhaps overly so) hashtable implementation Hash Table support in Asterisk.
int ast_context_add_switch2(struct ast_context *con, const char *sw, const char *data, int eval, const char *registrar)
Adds a switch (first param is a ast_context)
char * ast_process_quotes_and_slashes(char *start, char find, char replace_with)
Process a string to find and replace characters.
struct ast_context * next
void __ast_verbose(const char *file, int line, const char *func, int level, const char *fmt,...)
Send a verbose message (based on verbose level)
A structure to hold backtrace information. This structure provides an easy means to store backtrace i...
ast_sw: Switch statement in extensions.conf
General Asterisk PBX channel definitions.
Data structure associated with a custom dialplan function.
#define AST_MAX_EXTENSION
structure to hold extensions
External configuration handlers (realtime and static configuration)
int ast_add_profile(const char *, uint64_t scale)
support for event profiling
struct ast_ignorepats ignorepats
void ast_merge_contexts_and_delete(struct ast_context **extcontexts, struct ast_hashtab *exttable, const char *registrar)
Merge the temporary contexts into a global contexts list and delete from the global list the ones tha...
int ast_loader_unregister(int(*updater)(void))
Remove a procedure to be run when modules are updated.
ast_ignorepat: Ignore patterns in dial plan
int ast_context_add_include2(struct ast_context *con, const char *value, const char *registrar)
Add a context include.
Structures for AEL - the Asterisk extension language.
int ast_loader_register(int(*updater)(void))
Add a procedure to be run when modules have been updated.
int pbx_builtin_setvar(struct ast_channel *chan, const char *data)
Parse and set a single channel variable, where the name and value are separated with an '=' character...
struct ast_includes includes
int ast_add_extension2(struct ast_context *con, int replace, const char *extension, int priority, const char *label, const char *callerid, const char *application, void *data, void(*datad)(void *), const char *registrar, const char *registrar_file, int registrar_line)
Add an extension to an extension context, this time with an ast_context *.
ast_app: A registered application
void ast_context_destroy(struct ast_context *con, const char *registrar)
Destroy a context (matches the specified context or ANY context if NULL)
int ast_context_verify_includes(struct ast_context *con)
Verifies includes in an ast_contect structure.
String vector definitions.
struct ast_context * ast_context_find_or_create(struct ast_context **extcontexts, struct ast_hashtab *exttable, const char *name, const char *registrar)
Register a new context or find an existing one.
int main(int argc, char *argv[])
struct ast_app * pbx_findapp(const char *app)
Look up an application.
Asterisk module definitions.
Application convenience functions, designed to give consistent look and feel to Asterisk apps...
ast_context: An extension context