Asterisk - The Open Source Telephony Project GIT-master-f36a736
Data Structures | Macros | Functions | Variables
ael_main.c File Reference
#include "asterisk.h"
#include <locale.h>
#include <ctype.h>
#include <regex.h>
#include <limits.h>
#include "asterisk/backtrace.h"
#include "asterisk/channel.h"
#include "asterisk/ast_expr.h"
#include "asterisk/module.h"
#include "asterisk/app.h"
#include "asterisk/lock.h"
#include "asterisk/hashtab.h"
#include "asterisk/ael_structs.h"
#include "asterisk/extconf.h"
Include dependency graph for ael_main.c:

Go to the source code of this file.

Data Structures

struct  ast_context
 ast_context: An extension context More...
 
struct  namelist
 

Macros

#define ADD_LAST(headptr, memptr)   if(!headptr){ headptr=(memptr); (headptr##_last)=(memptr);} else {(headptr##_last)->next = (memptr); (headptr##_last) = (memptr);}
 
#define ASTMM_LIBC   ASTMM_IGNORE
 

Functions

void __ast_cli_register_multiple (void)
 
void __ast_verbose (const char *file, int line, const char *func, int level, const char *fmt,...)
 Send a verbose message (based on verbose level) More...
 
int ael_external_load_module (void)
 
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)
 
int ast_add_profile (const char *x, uint64_t scale)
 support for event profiling More...
 
void ast_cli_unregister_multiple (void)
 
void ast_context_add_ignorepat2 (struct ast_context *con, const char *value, const char *registrar)
 
void ast_context_add_include2 (struct ast_context *con, const char *value, const char *registrar)
 Add a context include. More...
 
void ast_context_add_switch2 (struct ast_context *con, const char *value, const char *data, int eval, const char *registrar)
 Adds a switch (first param is a ast_context) More...
 
struct ast_contextast_context_create (void **extcontexts, const char *name, const char *registrar)
 
void ast_context_destroy (void)
 
struct ast_contextast_context_find_or_create (void **extcontexts, void *tab, const char *name, const char *registrar)
 
void ast_context_verify_includes (void)
 
struct ast_custom_functionast_custom_function_find (const char *name)
 
const char * ast_get_context_name (struct ast_context *con)
 
int ast_hashtab_compare_contexts (const void *ah_a, const void *ah_b)
 hashtable functions for contexts More...
 
unsigned int ast_hashtab_hash_contexts (const void *obj)
 
int ast_loader_register (int(*updater)(void))
 Add a procedure to be run when modules have been updated. More...
 
int ast_loader_unregister (int(*updater)(void))
 Remove a procedure to be run when modules are updated. More...
 
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 invoke it would be something like this: ast_log(AST_LOG_WHATEVER, "Problem with the %s Captain. We should get some more. Will %d be enough?\n", "flux capacitor", 10); where WHATEVER is one of ERROR, DEBUG, EVENT, NOTICE, or WARNING depending on which log you wish to output to. These are implemented as macros, that will provide the function with the needed arguments. More...
 
void ast_merge_contexts_and_delete (void)
 
void ast_module_register (const struct ast_module_info *x)
 
void ast_module_unregister (const struct ast_module_info *x)
 
char * ast_process_quotes_and_slashes (char *start, char find, char replace_with)
 Process a string to find and replace characters. More...
 
struct ast_extenast_walk_context_extensions (struct ast_context *con, struct ast_exten *exten)
 
struct ast_ignorepatast_walk_context_ignorepats (struct ast_context *con, struct ast_ignorepat *ip)
 
struct ast_includeast_walk_context_includes (struct ast_context *con, struct ast_include *inc)
 
struct ast_swast_walk_context_switches (struct ast_context *con, struct ast_sw *sw)
 
struct ast_contextast_walk_contexts (void)
 
struct namelistcreate_name (const char *name)
 
void destroy_namelist (struct namelist *x)
 
void filter_leading_space_from_exprs (char *str)
 
void filter_newlines (char *str)
 
int main (int argc, char **argv)
 
void pbx_builtin_setvar (void *chan, void *data)
 
struct ast_extenpbx_find_extension (struct ast_channel *chan, struct ast_context *bypass, struct pbx_find_info *q, const char *context, const char *exten, int priority, const char *label, const char *callerid, enum ext_match_t action)
 
struct ast_apppbx_findapp (const char *app)
 Look up an application. More...
 
void pbx_substitute_variables_helper (struct ast_channel *c, const char *cp1, char *cp2, int count)
 

Variables

const char * ast_config_AST_CONFIG_DIR = config_dir
 
const char * ast_config_AST_VAR_DIR = var_dir
 
static char config_dir [PATH_MAX]
 
struct ast_contextcontext_list
 
int conts =0
 
static int dump_extensions = 0
 
static FILE * dumpfile
 
int extens =0
 
static int FIRST_TIME = 0
 
struct namelistglobalvars
 
struct namelistglobalvars_last
 
struct ast_contextlast_context
 
char last_exten [18000]
 
struct module_symbols mod_data
 
static int no_comp = 0
 
int option_debug = 0
 
int option_verbose = 0
 
int priors =0
 
static int quiet = 0
 
static int use_curr_dir = 0
 
static char var_dir [PATH_MAX]
 

Macro Definition Documentation

◆ ADD_LAST

#define ADD_LAST (   headptr,
  memptr 
)    if(!headptr){ headptr=(memptr); (headptr##_last)=(memptr);} else {(headptr##_last)->next = (memptr); (headptr##_last) = (memptr);}

Definition at line 64 of file ael_main.c.

◆ ASTMM_LIBC

#define ASTMM_LIBC   ASTMM_IGNORE

Definition at line 14 of file ael_main.c.

Function Documentation

◆ __ast_cli_register_multiple()

void __ast_cli_register_multiple ( void  )

Definition at line 204 of file ael_main.c.

205{
206 if(!no_comp)
207 printf("Executed ast_cli_register_multiple();\n");
208}
static int no_comp
Definition: ael_main.c:124

References no_comp.

◆ __ast_verbose()

void __ast_verbose ( const char *  file,
int  line,
const char *  func,
int  level,
const char *  fmt,
  ... 
)

Send a verbose message (based on verbose level)

This works like ast_log, but prints verbose messages to the console depending on verbosity level set.

ast_verbose(VERBOSE_PREFIX_3 "Whatever %s is happening\n", "nothing");

This will print the message to the console if the verbose level is set to a level >= 3

Note the absence of a comma after the VERBOSE_PREFIX_3. This is important. VERBOSE_PREFIX_1 through VERBOSE_PREFIX_10 are defined.

Version
11 added level parameter

Definition at line 2550 of file logger.c.

2551{
2552 ast_callid callid;
2553 va_list ap;
2554
2556
2557 va_start(ap, fmt);
2558 __ast_verbose_ap(file, line, func, level, callid, fmt, ap);
2559 va_end(ap);
2560}
unsigned int ast_callid
void __ast_verbose_ap(const char *file, int line, const char *func, int level, ast_callid callid, const char *fmt, va_list ap)
Definition: logger.c:2545
ast_callid ast_read_threadstorage_callid(void)
extracts the callerid from the thread
Definition: logger.c:2298

◆ ael_external_load_module()

int ael_external_load_module ( void  )

Referenced by main().

◆ ast_add_extension2()

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(*)(void *)  datad,
const char *  registrar 
)

Definition at line 221 of file ael_main.c.

225{
226 priors++;
227 con->extension_count++;
228 if (strcmp(extension,last_exten) != 0) {
229 extens++;
230 strcpy(last_exten, extension);
231 }
232 if (!label) {
233 label = "(null)";
234 }
235 if (!callerid) {
236 callerid = "(null)";
237 }
238 if (!application) {
239 application = "(null)";
240 }
241
242 if(!no_comp)
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);
245
246 if( dump_extensions && dumpfile ) {
247 struct namelist *n;
248
249 if( FIRST_TIME ) {
250 FIRST_TIME = 0;
251
252 if( globalvars )
253 fprintf(dumpfile,"[globals]\n");
254
255 for(n=globalvars;n;n=n->next) {
256 fprintf(dumpfile, "%s\n", n->name);
257 }
258 }
259
260 /* print out each extension , possibly the context header also */
261 if( con != last_context ) {
262 fprintf(dumpfile,"\n\n[%s]\n", con->name);
263 last_context = con;
264 for(n=con->ignorepats;n;n=n->next) {
265 fprintf(dumpfile, "ignorepat => %s\n", n->name);
266 }
267 for(n=con->includes;n;n=n->next) {
268 fprintf(dumpfile, "include => %s\n", n->name);
269 }
270 for(n=con->switches;n;n=n->next) {
271 fprintf(dumpfile, "switch => %s/%s\n", n->name, n->name2);
272 }
273 for(n=con->eswitches;n;n=n->next) {
274 fprintf(dumpfile, "eswitch => %s/%s\n", n->name, n->name2);
275 }
276
277 }
278 if( data ) {
279 filter_newlines((char*)data);
281 /* in previous versions, commas were converted to '|' to separate
282 args in app calls, but now, commas are used. There used to be
283 code here to insert backslashes (escapes) before any commas
284 that may have been embedded in the app args. This code is no more. */
285
286 if( strcmp(label,"(null)") != 0 )
287 fprintf(dumpfile,"exten => %s,%d(%s),%s(%s)\n", extension, priority, label, application, (char*)data);
288 else
289 fprintf(dumpfile,"exten => %s,%d,%s(%s)\n", extension, priority, application, (char*)data);
290
291 } else {
292
293 if( strcmp(label,"(null)") != 0 )
294 fprintf(dumpfile,"exten => %s,%d(%s),%s\n", extension, priority, label, application);
295 else
296 fprintf(dumpfile,"exten => %s,%d,%s\n", extension, priority, application);
297 }
298 }
299
300 /* since add_extension2 is responsible for the malloc'd data stuff */
301 free(data);
302 return 0;
303}
void filter_leading_space_from_exprs(char *str)
Definition: ael_main.c:450
int extens
Definition: ael_main.c:93
static FILE * dumpfile
Definition: ael_main.c:128
static int FIRST_TIME
Definition: ael_main.c:127
void filter_newlines(char *str)
Definition: ael_main.c:472
struct ast_context * last_context
Definition: ael_main.c:89
static int dump_extensions
Definition: ael_main.c:126
char last_exten[18000]
Definition: ael_main.c:94
int priors
Definition: ael_main.c:93
struct namelist * globalvars
Definition: ael_main.c:90
static int priority
static int replace(struct ast_channel *chan, const char *cmd, char *data, struct ast_str **buf, ssize_t len)
Definition: func_strings.c:888
void free()
static char * registrar
Definition: pbx_ael.c:78
int extension_count
Definition: ael_main.c:48
struct namelist * switches
Definition: ael_main.c:53
struct ast_ignorepats ignorepats
Definition: pbx.c:294
struct ast_includes includes
Definition: pbx.c:293
struct namelist * eswitches
Definition: ael_main.c:54
const char * name
Definition: pbx.c:285
structure to hold extensions
struct namelist * next
Definition: ael_main.c:43
char name2[100]
Definition: ael_main.c:42
char name[100]
Definition: ael_main.c:41

References dump_extensions, dumpfile, ast_context::eswitches, extens, ast_context::extension_count, filter_leading_space_from_exprs(), filter_newlines(), FIRST_TIME, free(), globalvars, ast_context::ignorepats, ast_context::includes, last_context, last_exten, ast_context::name, namelist::name, namelist::name2, namelist::next, no_comp, priority, priors, registrar, replace(), and ast_context::switches.

◆ ast_add_profile()

int ast_add_profile ( const char *  x,
uint64_t  scale 
)

support for event profiling

(note, this must be documented a lot more) ast_add_profile allocates a generic 'counter' with a given name, which can be shown with the command 'core show profile <name>'

The counter accumulates positive or negative values supplied by

See also
ast_add_profile(), dividing them by the 'scale' value passed in the create call, and also counts the number of 'events'. Values can also be taked by the TSC counter on ia32 architectures, in which case you can mark the start of an event calling ast_mark(id, 1) and then the end of the event with ast_mark(id, 0). For non-i386 architectures, these two calls return 0.

support for event profiling

Returns
Returns the identifier of the counter.

Definition at line 178 of file ael_main.c.

179{
180 if (!no_comp)
181 printf("Executed ast_add_profile();\n");
182
183 return 0;
184}

References no_comp.

◆ ast_cli_unregister_multiple()

void ast_cli_unregister_multiple ( void  )

Definition at line 408 of file ael_main.c.

409{
410 if(!no_comp)
411 printf("Executed ast_cli_unregister_multiple();\n");
412}

References no_comp.

◆ ast_context_add_ignorepat2()

void ast_context_add_ignorepat2 ( struct ast_context con,
const char *  value,
const char *  registrar 
)

Definition at line 348 of file ael_main.c.

349{
350 if(!no_comp)
351 printf("Executed ast_context_add_ignorepat2(con, value=%s, registrar=%s);\n", value, registrar);
352 if( dump_extensions ) {
353 struct namelist *x;
354 x = create_name(value);
355 ADD_LAST(con->ignorepats,x);
356 }
357}
struct namelist * create_name(const char *name)
Definition: ael_main.c:79
#define ADD_LAST(headptr, memptr)
Definition: ael_main.c:64
int value
Definition: syslog.c:37

References ADD_LAST, create_name(), dump_extensions, ast_context::ignorepats, no_comp, registrar, and value.

Referenced by ast_compile_ael2(), and pbx_load_config().

◆ ast_context_add_include2()

void ast_context_add_include2 ( struct ast_context con,
const char *  value,
const char *  registrar 
)

Add a context include.

Adds an include taking a struct ast_context as the first parameter

Note
See ast_context_add_include for information on arguments

Definition at line 359 of file ael_main.c.

360{
361 if(!no_comp)
362 printf("Executed ast_context_add_include2(con, value=%s, registrar=%s);\n", value, registrar);
363 if( dump_extensions ) {
364 struct namelist *x;
365 x = create_name((char*)value);
366 ADD_LAST(con->includes,x);
367 }
368}

References ADD_LAST, create_name(), dump_extensions, ast_context::includes, no_comp, registrar, and value.

Referenced by ast_compile_ael2(), and pbx_load_config().

◆ ast_context_add_switch2()

void ast_context_add_switch2 ( struct ast_context con,
const char *  value,
const char *  data,
int  eval,
const char *  registrar 
)

Adds a switch (first param is a ast_context)

Note
See ast_context_add_switch() for argument information, with the exception of the first argument. In this case, it's a pointer to an ast_context structure as opposed to the name.

Definition at line 370 of file ael_main.c.

371{
372 if(!no_comp)
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 ) {
375 struct namelist *x;
376 x = create_name((char*)value);
377 strncpy(x->name2, data, 99);
378 if( eval ) {
379
380 ADD_LAST(con->switches,x);
381
382 } else {
383
384 ADD_LAST(con->eswitches,x);
385 }
386 }
387}

References ADD_LAST, create_name(), dump_extensions, ast_context::eswitches, namelist::name2, no_comp, registrar, ast_context::switches, and value.

Referenced by ast_compile_ael2(), lua_register_switches(), and pbx_load_config().

◆ ast_context_create()

struct ast_context * ast_context_create ( void **  extcontexts,
const char *  name,
const char *  registrar 
)

Definition at line 318 of file ael_main.c.

319{
320 struct ast_context *x = calloc(1, sizeof(*x));
321 if (!x)
322 return NULL;
323 x->next = context_list;
324 context_list = x;
325 if (!no_comp)
326 printf("Executed ast_context_create(conts, name=%s, registrar=%s);\n", name, registrar);
327 conts++;
328 strncpy(x->name, name, sizeof(x->name) - 1);
329 strncpy(x->registrar, registrar, sizeof(x->registrar) - 1);
330 return x;
331}
int conts
Definition: ael_main.c:93
struct ast_context * context_list
Definition: ael_main.c:88
#define calloc(a, b)
Definition: astmm.h:155
static const char name[]
Definition: format_mp3.c:68
#define NULL
Definition: resample.c:96
ast_context: An extension context
Definition: pbx.c:284
const char * registrar
Definition: pbx.c:286
struct ast_context * next
Definition: pbx.c:292

References calloc, context_list, conts, name, ast_context::name, ast_context::next, no_comp, NULL, ast_context::registrar, and registrar.

◆ ast_context_destroy()

void ast_context_destroy ( void  )

Definition at line 414 of file ael_main.c.

415{
416 if( !no_comp)
417 printf("Executed ast_context_destroy();\n");
418}

References no_comp.

◆ ast_context_find_or_create()

struct ast_context * ast_context_find_or_create ( void **  extcontexts,
void *  tab,
const char *  name,
const char *  registrar 
)

Definition at line 333 of file ael_main.c.

334{
335 struct ast_context *x = calloc(1, sizeof(*x));
336 if (!x)
337 return NULL;
338 x->next = context_list;
339 context_list = x;
340 if (!no_comp)
341 printf("Executed ast_context_find_or_create(conts, name=%s, registrar=%s);\n", name, registrar);
342 conts++;
343 strncpy(x->name, name, sizeof(x->name) - 1);
344 strncpy(x->registrar, registrar, sizeof(x->registrar) - 1);
345 return x;
346}

References calloc, context_list, conts, name, ast_context::name, ast_context::next, no_comp, NULL, ast_context::registrar, and registrar.

◆ ast_context_verify_includes()

void ast_context_verify_includes ( void  )

Definition at line 395 of file ael_main.c.

396{
397 if(!no_comp)
398 printf("Executed ast_context_verify_includes();\n");
399}

References no_comp.

◆ ast_custom_function_find()

struct ast_custom_function * ast_custom_function_find ( const char *  name)

Definition at line 173 of file ael_main.c.

174{
175 return 0; /* in "standalone" mode, functions are just not avail */
176}

◆ ast_get_context_name()

const char * ast_get_context_name ( struct ast_context con)

◆ ast_hashtab_compare_contexts()

int ast_hashtab_compare_contexts ( const void *  ah_a,
const void *  ah_b 
)

hashtable functions for contexts

Definition at line 589 of file ael_main.c.

590{
591 return 0;
592}

Referenced by lua_register_hints(), lua_register_switches(), and pbx_load_module().

◆ ast_hashtab_hash_contexts()

unsigned int ast_hashtab_hash_contexts ( const void *  obj)

Definition at line 596 of file ael_main.c.

597{
598 return 0;
599}

Referenced by lua_register_hints(), lua_register_switches(), and pbx_load_module().

◆ ast_loader_register()

int ast_loader_register ( int(*)(void)  updater)

Add a procedure to be run when modules have been updated.

Parameters
updaterThe function to run when modules have been updated.

This function adds the given function to a linked list of functions to be run when the modules are updated.

Return values
0on success
-1on failure.

Definition at line 186 of file ael_main.c.

187{
188 return 1;
189}

References AST_LIST_INSERT_HEAD, AST_LIST_LOCK, AST_LIST_UNLOCK, ast_malloc, and tmp().

◆ ast_loader_unregister()

int ast_loader_unregister ( int(*)(void)  updater)

Remove a procedure to be run when modules are updated.

Parameters
updaterThe updater function to unregister.

This removes the given function from the updater list.

Return values
0on success
-1on failure.

Definition at line 191 of file ael_main.c.

192{
193 return 1;
194}

References AST_LIST_LOCK, AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, AST_LIST_UNLOCK, and loadupdate::updater.

◆ ast_log()

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 invoke it would be something like this: ast_log(AST_LOG_WHATEVER, "Problem with the %s Captain. We should get some more. Will %d be enough?\n", "flux capacitor", 10); where WHATEVER is one of ERROR, DEBUG, EVENT, NOTICE, or WARNING depending on which log you wish to output to. These are implemented as macros, that will provide the function with the needed arguments.

Parameters
levelType of log event
fileWill be provided by the AST_LOG_* macro
lineWill be provided by the AST_LOG_* macro
functionWill be provided by the AST_LOG_* macro
fmtThis is what is important. The format is the same as your favorite breed of printf. You know how that works, right? :-)

Definition at line 130 of file ael_main.c.

131{
132 va_list vars;
133 va_start(vars,fmt);
134
135 printf("LOG: lev:%d file:%s line:%d func: %s ",
136 level, file, line, function);
137 vprintf(fmt, vars);
138 fflush(stdout);
139 va_end(vars);
140}

Referenced by main().

◆ ast_merge_contexts_and_delete()

void ast_merge_contexts_and_delete ( void  )

Definition at line 389 of file ael_main.c.

390{
391 if(!no_comp)
392 printf("Executed ast_merge_contexts_and_delete();\n");
393}

References no_comp.

◆ ast_module_register()

void ast_module_register ( const struct ast_module_info x)

◆ ast_module_unregister()

void ast_module_unregister ( const struct ast_module_info x)

◆ ast_process_quotes_and_slashes()

char * ast_process_quotes_and_slashes ( char *  start,
char  find,
char  replace_with 
)

Process a string to find and replace characters.

Parameters
startThe string to analyze
findThe character to find
replace_withThe character that will replace the one we are looking for

Definition at line 2352 of file utils.c.

2353{
2354 char *dataPut = start;
2355 int inEscape = 0;
2356 int inQuotes = 0;
2357
2358 for (; *start; start++) {
2359 if (inEscape) {
2360 *dataPut++ = *start; /* Always goes verbatim */
2361 inEscape = 0;
2362 } else {
2363 if (*start == '\\') {
2364 inEscape = 1; /* Do not copy \ into the data */
2365 } else if (*start == '\'') {
2366 inQuotes = 1 - inQuotes; /* Do not copy ' into the data */
2367 } else {
2368 /* Replace , with |, unless in quotes */
2369 *dataPut++ = inQuotes ? *start : ((*start == find) ? replace_with : *start);
2370 }
2371 }
2372 }
2373 if (start != dataPut)
2374 *dataPut = 0;
2375 return dataPut;
2376}

◆ ast_walk_context_extensions()

struct ast_exten * ast_walk_context_extensions ( struct ast_context con,
struct ast_exten exten 
)

Definition at line 427 of file ael_main.c.

428{
429 return NULL;
430}

References NULL.

Referenced by complete_dialplan_remove_extension(), context_used(), dundi_precache_full(), find_matching_priority(), and handle_cli_dialplan_save().

◆ ast_walk_context_ignorepats()

static struct ast_ignorepat * ast_walk_context_ignorepats ( struct ast_context con,
struct ast_ignorepat ip 
)

Definition at line 439 of file ael_main.c.

440{
441 return NULL;
442}

References NULL.

◆ ast_walk_context_includes()

static struct ast_include * ast_walk_context_includes ( struct ast_context con,
struct ast_include inc 
)

Definition at line 433 of file ael_main.c.

434{
435 return NULL;
436}

References NULL.

◆ ast_walk_context_switches()

static struct ast_sw * ast_walk_context_switches ( struct ast_context con,
struct ast_sw sw 
)

Definition at line 445 of file ael_main.c.

446{
447 return NULL;
448}

References NULL.

◆ ast_walk_contexts()

struct ast_context * ast_walk_contexts ( void  )

Definition at line 401 of file ael_main.c.

402{
403 if(!no_comp)
404 printf("Executed ast_walk_contexts();\n");
405 return 0;
406}

References no_comp.

◆ create_name()

struct namelist * create_name ( const char *  name)

Definition at line 79 of file ael_main.c.

80{
81 struct namelist *x = calloc(1, sizeof(*x));
82 if (!x)
83 return NULL;
84 strncpy(x->name, name, sizeof(x->name) - 1);
85 return x;
86}

References calloc, namelist::name, name, and NULL.

Referenced by ast_context_add_ignorepat2(), ast_context_add_include2(), ast_context_add_switch2(), and pbx_builtin_setvar().

◆ destroy_namelist()

void destroy_namelist ( struct namelist x)

Definition at line 67 of file ael_main.c.

68{
69 struct namelist *z,*z2;
70 for(z=x; z; z = z2)
71 {
72 z2 = z->next;
73 z->next = 0;
74 free(z);
75 }
76}

References free(), and namelist::next.

Referenced by main().

◆ filter_leading_space_from_exprs()

void filter_leading_space_from_exprs ( char *  str)

Definition at line 450 of file ael_main.c.

451{
452 /* Mainly for aesthetics */
453 char *t, *v, *u = str;
454
455 while ( u && *u ) {
456
457 if( *u == '$' && *(u+1) == '[' ) {
458 t = u+2;
459 while( *t == '\n' || *t == '\r' || *t == '\t' || *t == ' ' ) {
460 v = t;
461 while ( *v ) {
462 *v = *(v+1);
463 v++;
464 }
465 }
466 }
467
468 u++;
469 }
470}
const char * str
Definition: app_jack.c:147

References str.

Referenced by ast_add_extension2().

◆ filter_newlines()

void filter_newlines ( char *  str)

Definition at line 472 of file ael_main.c.

473{
474 /* remove all newlines, returns */
475 char *t=str;
476 while( t && *t ) {
477 if( *t == '\n' || *t == '\r' ) {
478 *t = ' '; /* just replace newlines and returns with spaces; they act as
479 token separators, and just blindly removing them could be
480 harmful. */
481 }
482 t++;
483 }
484}

References str.

Referenced by ast_add_extension2().

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 491 of file ael_main.c.

492{
493 int i;
494 struct namelist *n;
495 struct ast_context *lp,*lp2;
496
497 for(i=1;i<argc;i++) {
498 if( argv[i][0] == '-' && argv[i][1] == 'n' )
499 no_comp =1;
500 if( argv[i][0] == '-' && argv[i][1] == 'q' ) {
501 quiet = 1;
502 no_comp =1;
503 }
504 if( argv[i][0] == '-' && argv[i][1] == 'd' )
505 use_curr_dir =1;
506 if( argv[i][0] == '-' && argv[i][1] == 'w' )
508 }
509
510 if( !quiet ) {
511 printf("\n(If you find progress and other non-error messages irritating, you can use -q to suppress them)\n");
512 if( !no_comp )
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");
514 if( !use_curr_dir )
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");
518 }
519
520 if( use_curr_dir ) {
521 strcpy(config_dir, ".");
523 }
524 else {
525 strcpy(config_dir, "/etc/asterisk");
527 }
528 strcpy(var_dir, "/var/lib/asterisk");
529
530 if( dump_extensions ) {
531 dumpfile = fopen("extensions.conf.aeldump","w");
532 if( !dumpfile ) {
533 printf("\n\nSorry, cannot open extensions.conf.aeldump for writing! Correct the situation and try again!\n\n");
534 exit(10);
535 }
536
537 }
538
539 FIRST_TIME = 1;
540
542
543 ast_log(4, "ael2_parse", __LINE__, "main", "%d contexts, %d extensions, %d priorities\n", conts, extens, priors);
544
545 if( dump_extensions && dumpfile ) {
546
547 for( lp = context_list; lp; lp = lp->next ) { /* print out any contexts that didn't have any
548 extensions in them */
549 if( lp->extension_count == 0 ) {
550
551 fprintf(dumpfile,"\n\n[%s]\n", lp->name);
552
553 for(n=lp->ignorepats;n;n=n->next) {
554 fprintf(dumpfile, "ignorepat => %s\n", n->name);
555 }
556 for(n=lp->includes;n;n=n->next) {
557 fprintf(dumpfile, "include => %s\n", n->name);
558 }
559 for(n=lp->switches;n;n=n->next) {
560 fprintf(dumpfile, "switch => %s/%s\n", n->name, n->name2);
561 }
562 for(n=lp->eswitches;n;n=n->next) {
563 fprintf(dumpfile, "eswitch => %s/%s\n", n->name, n->name2);
564 }
565 }
566 }
567 }
568
570 fclose(dumpfile);
571
572 for( lp = context_list; lp; lp = lp2 ) { /* free the ast_context structs */
573 lp2 = lp->next;
574 lp->next = 0;
575
580
581 free(lp);
582 }
583
584 return 0;
585}
int ael_external_load_module(void)
static int use_curr_dir
Definition: ael_main.c:125
static char config_dir[PATH_MAX]
Definition: ael_main.c:96
static int quiet
Definition: ael_main.c:123
static char var_dir[PATH_MAX]
Definition: ael_main.c:97
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...
Definition: ael_main.c:130
void destroy_namelist(struct namelist *x)
Definition: ael_main.c:67
void localized_use_conf_dir(void)
Definition: extconf.c:3113
void localized_use_local_dir(void)
Definition: extconf.c:3108

References ael_external_load_module(), ast_log(), config_dir, context_list, conts, destroy_namelist(), dump_extensions, dumpfile, ast_context::eswitches, extens, ast_context::extension_count, FIRST_TIME, free(), ast_context::ignorepats, ast_context::includes, localized_use_conf_dir(), localized_use_local_dir(), ast_context::name, namelist::name, namelist::name2, ast_context::next, namelist::next, no_comp, priors, quiet, ast_context::switches, use_curr_dir, and var_dir.

◆ pbx_builtin_setvar()

void pbx_builtin_setvar ( void *  chan,
void *  data 
)

Definition at line 305 of file ael_main.c.

306{
307 struct namelist *x = create_name(data);
308 if(!no_comp)
309 printf("Executed pbx_builtin_setvar(chan, data=%s);\n", (char*)data);
310
311 if( dump_extensions ) {
312 x = create_name(data);
314 }
315}

References ADD_LAST, create_name(), dump_extensions, globalvars, and no_comp.

◆ pbx_find_extension()

struct ast_exten * pbx_find_extension ( struct ast_channel chan,
struct ast_context bypass,
struct pbx_find_info q,
const char *  context,
const char *  exten,
int  priority,
const char *  label,
const char *  callerid,
enum ext_match_t  action 
)

Definition at line 152 of file ael_main.c.

161{
162 return localized_find_extension(bypass, q, context, exten, priority, label, callerid, action);
163}
struct ast_exten * localized_find_extension(struct ast_context *bypass, struct pbx_find_info *q, const char *context, const char *exten, int priority, const char *label, const char *callerid, enum ext_match_t action)
Definition: extconf.c:4468

References voicemailpwcheck::context, ast_exten::exten, ast_exten::label, localized_find_extension(), and priority.

Referenced by add_extension(), ast_sip_persistent_endpoint_update_state(), check_goto(), check_pval_item(), conf_ended(), delete_extens(), parking_blind_transfer_park(), parking_duration_callback(), parking_is_exten_park(), parking_lot_cfg_create_extensions(), and test_exten().

◆ pbx_findapp()

struct ast_app * pbx_findapp ( const char *  app)

Look up an application.

Parameters
appname of the app

This function searches for the ast_app structure within the apps that are registered for the one with the name you passed in.

Returns
the ast_app structure that matches on success, or NULL on failure

Definition at line 165 of file ael_main.c.

166{
167 return (struct ast_app*)1; /* so as not to trigger an error */
168}
ast_app: A registered application
Definition: pbx_app.c:45

Referenced by aelsub_exec(), ari_channel_thread(), ari_originate_dial(), AST_TEST_DEFINE(), bridge_stasis_run_cb(), conf_run(), conf_start_record(), exec_exec(), execif_exec(), forward_message(), handle_exec(), iax2_exec(), lua_pbx_exec(), page_exec(), pbx_extension_helper(), pbx_outgoing_exec(), realtime_exec(), try_calling(), and tryexec_exec().

◆ pbx_substitute_variables_helper()

void pbx_substitute_variables_helper ( struct ast_channel c,
const char *  cp1,
char *  cp2,
int  count 
)

Definition at line 211 of file ael_main.c.

212{
213 if (cp1 && *cp1)
214 strncpy(cp2,cp1,AST_MAX_EXTENSION); /* Right now, this routine is ONLY being called for
215 a possible var substitution on extension names,
216 so....! */
217 else
218 *cp2 = 0;
219}
#define AST_MAX_EXTENSION
Definition: channel.h:134

References AST_MAX_EXTENSION.

Referenced by add_extensions(), ast_add_extension2_lockopt(), dtmf_store_framehook(), escape_and_substitute(), function_eval(), get_mapping_weight(), import_helper(), launch_monitor_thread(), manager_log(), pbx_extension_helper(), pbx_find_extension(), pbx_load_config(), realtime_exec(), rotate_file(), substituted(), test_chan_function(), test_chan_integer(), test_chan_integer_accessor(), test_chan_string(), test_chan_variable(), waitforcond_exec(), write_cdr(), and write_cel().

Variable Documentation

◆ ast_config_AST_CONFIG_DIR

const char* ast_config_AST_CONFIG_DIR = config_dir

◆ ast_config_AST_VAR_DIR

const char* ast_config_AST_VAR_DIR = var_dir

◆ config_dir

char config_dir[PATH_MAX]
static

Definition at line 96 of file ael_main.c.

Referenced by main().

◆ context_list

struct ast_context* context_list

Definition at line 88 of file ael_main.c.

Referenced by ast_context_create(), ast_context_find_or_create(), and main().

◆ conts

int conts =0

Definition at line 93 of file ael_main.c.

Referenced by ast_context_create(), ast_context_find_or_create(), and main().

◆ dump_extensions

int dump_extensions = 0
static

◆ dumpfile

FILE* dumpfile
static

Definition at line 128 of file ael_main.c.

Referenced by ast_add_extension2(), and main().

◆ extens

int extens =0

Definition at line 93 of file ael_main.c.

Referenced by ast_add_extension2(), AST_TEST_DEFINE(), and main().

◆ FIRST_TIME

int FIRST_TIME = 0
static

Definition at line 127 of file ael_main.c.

Referenced by ast_add_extension2(), and main().

◆ globalvars

struct namelist* globalvars

Definition at line 90 of file ael_main.c.

Referenced by ast_add_extension2(), and pbx_builtin_setvar().

◆ globalvars_last

struct namelist* globalvars_last

Definition at line 91 of file ael_main.c.

◆ last_context

struct ast_context* last_context

Definition at line 89 of file ael_main.c.

Referenced by ast_add_extension2().

◆ last_exten

char last_exten[18000]

Definition at line 94 of file ael_main.c.

Referenced by ast_add_extension2().

◆ mod_data

struct module_symbols mod_data
extern

◆ no_comp

int no_comp = 0
static

◆ priors

int priors =0

Definition at line 93 of file ael_main.c.

Referenced by ast_add_extension2(), and main().

◆ quiet

int quiet = 0
static

Definition at line 123 of file ael_main.c.

Referenced by confbridge_exec(), and main().

◆ use_curr_dir

int use_curr_dir = 0
static

Definition at line 125 of file ael_main.c.

Referenced by main().

◆ var_dir

char var_dir[PATH_MAX]
static

Definition at line 97 of file ael_main.c.

Referenced by main().