Asterisk - The Open Source Telephony Project  18.5.0
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 - must remain in sync with fake_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

int __ast_bt_get_addresses (struct ast_bt *bt)
 
struct ast_vector_string * __ast_bt_get_symbols (void **addresses, size_t num_frames)
 
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_mark_lock_acquired (void *lock_addr)
 Mark the last lock as acquired. 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...
 
void ast_remove_lock_info (void *lock_addr, struct ast_bt *bt)
 remove lock info for the current thread More...
 
void ast_restore_lock_info (void *lock_addr)
 
void ast_store_lock_info (enum ast_lock_type type, const char *filename, int line_num, const char *func, const char *lock_name, void *lock_addr, struct ast_bt *bt)
 Store lock info for the current thread. More...
 
void ast_suspend_lock_info (void *lock_addr)
 
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);}

◆ ASTMM_LIBC

#define ASTMM_LIBC   ASTMM_IGNORE

Definition at line 14 of file ael_main.c.

Function Documentation

◆ __ast_bt_get_addresses()

int __ast_bt_get_addresses ( struct ast_bt bt)

Definition at line 615 of file ael_main.c.

616 {
617  return 0;
618 }

◆ __ast_bt_get_symbols()

struct ast_vector_string* __ast_bt_get_symbols ( void **  addresses,
size_t  num_frames 
)

Definition at line 620 of file ael_main.c.

References NULL.

621 {
622  return NULL;
623 }
#define NULL
Definition: resample.c:96

◆ __ast_cli_register_multiple()

void __ast_cli_register_multiple ( void  )

Definition at line 204 of file ael_main.c.

References c, and pbx_substitute_variables_helper().

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

◆ __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_4 are defined.

Version
11 added level parameter

Definition at line 2198 of file logger.c.

References __ast_verbose_ap(), and ast_read_threadstorage_callid().

2199 {
2200  ast_callid callid;
2201  va_list ap;
2202 
2203  callid = ast_read_threadstorage_callid();
2204 
2205  va_start(ap, fmt);
2206  __ast_verbose_ap(file, line, func, level, callid, fmt, ap);
2207  va_end(ap);
2208 }
unsigned int ast_callid
Definition: logger.h:87
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:2193
ast_callid ast_read_threadstorage_callid(void)
extracts the callerid from the thread
Definition: logger.c:1962

◆ ael_external_load_module()

int ael_external_load_module ( void  )

Referenced by filter_newlines(), main(), and reload().

◆ 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.

References ast_context::eswitches, extens, ast_context::extension_count, filter_leading_space_from_exprs(), filter_newlines(), free(), ast_context::ignorepats, ast_context::includes, last_exten, namelist::name, ast_context::name, namelist::name2, namelist::next, priors, and ast_context::switches.

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);
280  filter_leading_space_from_exprs((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 }
struct ast_ignorepats ignorepats
Definition: pbx.c:291
struct namelist * eswitches
Definition: ael_main.c:54
static int FIRST_TIME
Definition: ael_main.c:127
static int priority
void free()
struct namelist * switches
Definition: ael_main.c:53
static int dump_extensions
Definition: ael_main.c:126
structure to hold extensions
static int no_comp
Definition: ael_main.c:124
struct ast_includes includes
Definition: pbx.c:290
struct namelist * globalvars
Definition: ael_main.c:90
struct ast_context * last_context
Definition: ael_main.c:89
char name[0]
Definition: pbx.c:297
static char * registrar
Definition: pbx_ael.c:78
int extens
Definition: ael_main.c:93
void filter_newlines(char *str)
Definition: ael_main.c:472
static FILE * dumpfile
Definition: ael_main.c:128
char name2[100]
Definition: ael_main.c:42
static int replace(struct ast_channel *chan, const char *cmd, char *data, struct ast_str **buf, ssize_t len)
Definition: func_strings.c:790
char name[100]
Definition: ael_main.c:41
void filter_leading_space_from_exprs(char *str)
Definition: ael_main.c:450
char last_exten[18000]
Definition: ael_main.c:94
int priors
Definition: ael_main.c:93
int extension_count
Definition: ael_main.c:48
struct namelist * next
Definition: ael_main.c:43

◆ 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 }
static int no_comp
Definition: ael_main.c:124

◆ 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 }
static int no_comp
Definition: ael_main.c:124

◆ 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.

References ADD_LAST, create_name(), and ast_context::ignorepats.

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 ast_ignorepats ignorepats
Definition: pbx.c:291
int value
Definition: syslog.c:37
static int dump_extensions
Definition: ael_main.c:126
static int no_comp
Definition: ael_main.c:124
#define ADD_LAST(headptr, memptr)
Definition: ael_main.c:64
static char * registrar
Definition: pbx_ael.c:78
struct namelist * create_name(const char *name)
Definition: ael_main.c:79

◆ ast_context_add_include2()

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

Add a context include.

Parameters
concontext to add the include to
valueinclude value to add
registrarwho registered the context

Adds an include taking a struct ast_context as the first parameter

Return values
0on success
-1on failure

Definition at line 359 of file ael_main.c.

References ADD_LAST, create_name(), and ast_context::includes.

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 }
int value
Definition: syslog.c:37
static int dump_extensions
Definition: ael_main.c:126
static int no_comp
Definition: ael_main.c:124
#define ADD_LAST(headptr, memptr)
Definition: ael_main.c:64
struct ast_includes includes
Definition: pbx.c:290
static char * registrar
Definition: pbx_ael.c:78
struct namelist * create_name(const char *name)
Definition: ael_main.c:79

◆ 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.

References ADD_LAST, create_name(), ast_context::eswitches, namelist::name2, and ast_context::switches.

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 }
struct namelist * eswitches
Definition: ael_main.c:54
int value
Definition: syslog.c:37
struct namelist * switches
Definition: ael_main.c:53
static int dump_extensions
Definition: ael_main.c:126
static int no_comp
Definition: ael_main.c:124
#define ADD_LAST(headptr, memptr)
Definition: ael_main.c:64
static char * registrar
Definition: pbx_ael.c:78
struct namelist * create_name(const char *name)
Definition: ael_main.c:79
char name2[100]
Definition: ael_main.c:42

◆ 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.

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

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 }
struct ast_context * context_list
Definition: ael_main.c:88
#define NULL
Definition: resample.c:96
#define calloc(a, b)
Definition: astmm.h:157
struct ast_context * next
Definition: pbx.c:289
char * registrar
Definition: pbx.c:293
int conts
Definition: ael_main.c:93
static int no_comp
Definition: ael_main.c:124
char name[0]
Definition: pbx.c:297
static char * registrar
Definition: pbx_ael.c:78
static const char name[]
Definition: cdr_mysql.c:74
ast_context: An extension context - must remain in sync with fake_context
Definition: pbx.c:284

◆ ast_context_destroy()

void ast_context_destroy ( void  )

Definition at line 414 of file ael_main.c.

References ast_get_context_name().

415 {
416  if( !no_comp)
417  printf("Executed ast_context_destroy();\n");
418 }
static int no_comp
Definition: ael_main.c:124

◆ 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.

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

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 }
struct ast_context * context_list
Definition: ael_main.c:88
#define NULL
Definition: resample.c:96
#define calloc(a, b)
Definition: astmm.h:157
struct ast_context * next
Definition: pbx.c:289
char * registrar
Definition: pbx.c:293
int conts
Definition: ael_main.c:93
static int no_comp
Definition: ael_main.c:124
char name[0]
Definition: pbx.c:297
static char * registrar
Definition: pbx_ael.c:78
static const char name[]
Definition: cdr_mysql.c:74
ast_context: An extension context - must remain in sync with fake_context
Definition: pbx.c:284

◆ 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 }
static int no_comp
Definition: ael_main.c:124

◆ ast_custom_function_find()

struct ast_custom_function* ast_custom_function_find ( const char *  name)

Definition at line 173 of file ael_main.c.

Referenced by pbx_findapp().

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)

Definition at line 421 of file ael_main.c.

References ast_walk_context_extensions(), ast_context::name, and NULL.

Referenced by ast_context_destroy().

422 {
423  return con ? con->name : NULL;
424 }
#define NULL
Definition: resample.c:96
char name[0]
Definition: pbx.c:297

◆ 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.

References ast_hashtab_hash_contexts().

Referenced by main().

590 {
591  return 0;
592 }

◆ ast_hashtab_hash_contexts()

unsigned int ast_hashtab_hash_contexts ( const void *  obj)

Definition at line 596 of file ael_main.c.

Referenced by ast_hashtab_compare_contexts().

597 {
598  return 0;
599 }

◆ 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 }

◆ 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 }

◆ 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.

References context, exten, and pbx_find_extension().

Referenced by main().

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 }

◆ ast_mark_lock_acquired()

void ast_mark_lock_acquired ( void *  lock_addr)

Mark the last lock as acquired.

Definition at line 602 of file ael_main.c.

603 {
604 }

◆ 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 }
static int no_comp
Definition: ael_main.c:124

◆ ast_module_register()

void ast_module_register ( const struct ast_module_info x)

Definition at line 195 of file ael_main.c.

196 {
197 }

◆ ast_module_unregister()

void ast_module_unregister ( const struct ast_module_info x)

Definition at line 199 of file ael_main.c.

200 {
201 }

◆ 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 2104 of file main/utils.c.

2105 {
2106  char *dataPut = start;
2107  int inEscape = 0;
2108  int inQuotes = 0;
2109 
2110  for (; *start; start++) {
2111  if (inEscape) {
2112  *dataPut++ = *start; /* Always goes verbatim */
2113  inEscape = 0;
2114  } else {
2115  if (*start == '\\') {
2116  inEscape = 1; /* Do not copy \ into the data */
2117  } else if (*start == '\'') {
2118  inQuotes = 1 - inQuotes; /* Do not copy ' into the data */
2119  } else {
2120  /* Replace , with |, unless in quotes */
2121  *dataPut++ = inQuotes ? *start : ((*start == find) ? replace_with : *start);
2122  }
2123  }
2124  }
2125  if (start != dataPut)
2126  *dataPut = 0;
2127  return dataPut;
2128 }

◆ ast_remove_lock_info()

void ast_remove_lock_info ( void *  lock_addr,
struct ast_bt bt 
)

remove lock info for the current thread

this gets called by ast_mutex_unlock so that information on the lock can be removed from the current thread's lock info struct.

Definition at line 605 of file ael_main.c.

606 {
607 }

◆ ast_restore_lock_info()

void ast_restore_lock_info ( void *  lock_addr)

Definition at line 628 of file ael_main.c.

629 {
630 }

◆ ast_store_lock_info()

void ast_store_lock_info ( enum ast_lock_type  type,
const char *  filename,
int  line_num,
const char *  func,
const char *  lock_name,
void *  lock_addr,
struct ast_bt bt 
)

Store lock info for the current thread.

This function gets called in ast_mutex_lock() and ast_mutex_trylock() so that information about this lock can be stored in this thread's lock info struct. The lock is marked as pending as the thread is waiting on the lock. ast_mark_lock_acquired() will mark it as held by this thread.

Definition at line 609 of file ael_main.c.

611 {
612 }

◆ ast_suspend_lock_info()

void ast_suspend_lock_info ( void *  lock_addr)

Definition at line 625 of file ael_main.c.

626 {
627 }

◆ 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.

References ast_walk_context_includes(), and NULL.

Referenced by ast_get_context_name().

428 {
429  return NULL;
430 }
#define NULL
Definition: resample.c:96

◆ 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.

References ast_walk_context_switches(), and NULL.

Referenced by ast_walk_context_includes().

440 {
441  return NULL;
442 }
#define NULL
Definition: resample.c:96

◆ 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.

References ast_walk_context_ignorepats(), and NULL.

Referenced by ast_walk_context_extensions().

434 {
435  return NULL;
436 }
#define NULL
Definition: resample.c:96

◆ 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.

References NULL.

Referenced by ast_walk_context_ignorepats().

446 {
447  return NULL;
448 }
#define NULL
Definition: resample.c:96

◆ 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 }
static int no_comp
Definition: ael_main.c:124

◆ create_name()

struct namelist * create_name ( const char *  name)

Definition at line 79 of file ael_main.c.

References calloc, namelist::name, and NULL.

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

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 }
#define NULL
Definition: resample.c:96
#define calloc(a, b)
Definition: astmm.h:157
static const char name[]
Definition: cdr_mysql.c:74
char name[100]
Definition: ael_main.c:41

◆ destroy_namelist()

void destroy_namelist ( struct namelist x)

Definition at line 67 of file ael_main.c.

References create_name(), free(), namelist::name, and namelist::next.

Referenced by main().

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 }
void free()
struct namelist * next
Definition: ael_main.c:43

◆ filter_leading_space_from_exprs()

void filter_leading_space_from_exprs ( char *  str)

Definition at line 450 of file ael_main.c.

References str.

Referenced by ast_add_extension2().

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

◆ filter_newlines()

void filter_newlines ( char *  str)

Definition at line 472 of file ael_main.c.

References ael_external_load_module(), and str.

Referenced by ast_add_extension2().

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 }
const char * str
Definition: app_jack.c:147

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 491 of file ael_main.c.

References ael_external_load_module(), ast_hashtab_compare_contexts(), ast_log(), config_dir, conts, destroy_namelist(), ast_context::eswitches, extens, ast_context::extension_count, free(), ast_context::ignorepats, ast_context::includes, localized_use_conf_dir(), localized_use_local_dir(), namelist::name, ast_context::name, namelist::name2, namelist::next, ast_context::next, priors, ast_context::switches, and var_dir.

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' )
507  dump_extensions =1;
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 
569  if( dump_extensions && dumpfile )
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 }
struct ast_ignorepats ignorepats
Definition: pbx.c:291
struct namelist * eswitches
Definition: ael_main.c:54
static int FIRST_TIME
Definition: ael_main.c:127
static char config_dir[PATH_MAX]
Definition: ael_main.c:96
struct ast_context * context_list
Definition: ael_main.c:88
int ael_external_load_module(void)
static char var_dir[PATH_MAX]
Definition: ael_main.c:97
struct ast_context * next
Definition: pbx.c:289
static int use_curr_dir
Definition: ael_main.c:125
void localized_use_local_dir(void)
Definition: extconf.c:3110
static int quiet
Definition: ael_main.c:123
void free()
struct namelist * switches
Definition: ael_main.c:53
static int dump_extensions
Definition: ael_main.c:126
int conts
Definition: ael_main.c:93
static int no_comp
Definition: ael_main.c:124
struct ast_includes includes
Definition: pbx.c:290
char name[0]
Definition: pbx.c:297
int extens
Definition: ael_main.c:93
static FILE * dumpfile
Definition: ael_main.c:128
void destroy_namelist(struct namelist *x)
Definition: ael_main.c:67
char name2[100]
Definition: ael_main.c:42
char name[100]
Definition: ael_main.c:41
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
int priors
Definition: ael_main.c:93
ast_context: An extension context - must remain in sync with fake_context
Definition: pbx.c:284
int extension_count
Definition: ael_main.c:48
struct namelist * next
Definition: ael_main.c:43
void localized_use_conf_dir(void)
Definition: extconf.c:3115

◆ pbx_builtin_setvar()

void pbx_builtin_setvar ( void *  chan,
void *  data 
)

Definition at line 305 of file ael_main.c.

References ADD_LAST, and create_name().

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);
313  ADD_LAST(globalvars,x);
314  }
315 }
static int dump_extensions
Definition: ael_main.c:126
static int no_comp
Definition: ael_main.c:124
#define ADD_LAST(headptr, memptr)
Definition: ael_main.c:64
struct namelist * globalvars
Definition: ael_main.c:90
struct namelist * create_name(const char *name)
Definition: ael_main.c:79

◆ 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.

References localized_find_extension().

Referenced by ast_log().

161 {
162  return localized_find_extension(bypass, q, context, exten, priority, label, callerid, action);
163 }
static char exten[AST_MAX_EXTENSION]
Definition: chan_alsa.c:118
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:4470
static int priority
static char context[AST_MAX_CONTEXT]
Definition: chan_alsa.c:116

◆ 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.

References ast_custom_function_find(), and namelist::name.

Referenced by aelsub_exec(), answer_exec_run(), ari_channel_thread(), ari_originate_dial(), ast_app_exec_macro(), AST_TEST_DEFINE(), bridge_check_monitor(), bridge_stasis_run_cb(), conf_run(), conf_start_record(), disa_exec(), do_magic_pickup(), dundi_exec(), exec_exec(), execif_exec(), forward_message(), handle_exec(), iax2_exec(), lua_pbx_exec(), page_exec(), pbx_builtin_execiftime(), pbx_extension_helper(), pbx_outgoing_exec(), realtime_exec(), run_app_helper(), snoop_stasis_thread(), try_calling(), and tryexec_exec().

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

◆ 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.

References AST_MAX_EXTENSION.

Referenced by __ast_cli_register_multiple().

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:135

Variable Documentation

◆ ast_config_AST_CONFIG_DIR

const char* ast_config_AST_CONFIG_DIR = config_dir

Definition at line 98 of file ael_main.c.

◆ 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(), and ast_context_find_or_create().

◆ 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

Definition at line 126 of file ael_main.c.

◆ dumpfile

FILE* dumpfile
static

Definition at line 128 of file ael_main.c.

◆ extens

int extens =0

Definition at line 93 of file ael_main.c.

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

◆ FIRST_TIME

int FIRST_TIME = 0
static

Definition at line 127 of file ael_main.c.

◆ globalvars

struct namelist* globalvars

Definition at line 90 of file ael_main.c.

◆ 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.

◆ 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

◆ no_comp

int no_comp = 0
static

Definition at line 124 of file ael_main.c.

◆ 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().

◆ use_curr_dir

int use_curr_dir = 0
static

Definition at line 125 of file ael_main.c.

◆ var_dir

char var_dir[PATH_MAX]
static

Definition at line 97 of file ael_main.c.

Referenced by main().