2
* XXX this file probably need a fair amount of cleanup, at the very least:
4
* - documenting its purpose;
5
* - removing all unnecessary headers and other stuff from the sources
7
* - fixing the formatting
10
14
#include <limits.h>
16
ASTERISK_FILE_VERSION(__FILE__, "$Revision: 165071 $")
18
#include "asterisk/channel.h"
12
19
#include "asterisk/ast_expr.h"
13
#include "asterisk/channel.h"
14
20
#include "asterisk/module.h"
15
21
#include "asterisk/app.h"
22
#include "asterisk/lock.h"
23
#include "asterisk/hashtab.h"
16
24
#include "asterisk/ael_structs.h"
25
#include "asterisk/extconf.h"
28
int option_verbose = 0;
29
void ast_register_file_version(const char *file, const char *version) { }
30
void ast_unregister_file_version(const char *file) { }
32
struct ast_flags ast_compat = { 7 };
19
<depend>pbx_ael</depend>
35
<depend>res_ael_share</depend>
76
92
int conts=0, extens=0, priors=0;
77
93
char last_exten[18000];
78
char ast_config_AST_CONFIG_DIR[PATH_MAX];
79
char ast_config_AST_VAR_DIR[PATH_MAX];
81
void ast_add_profile(void);
95
static char config_dir[PATH_MAX];
96
static char var_dir[PATH_MAX];
97
const char *ast_config_AST_CONFIG_DIR = config_dir;
98
const char *ast_config_AST_VAR_DIR = var_dir;
82
100
void ast_cli_register_multiple(void);
83
void ast_register_file_version(void);
84
void ast_unregister_file_version(void);
85
101
int ast_add_extension2(struct ast_context *con,
86
102
int replace, const char *extension, int priority, const char *label, const char *callerid,
87
103
const char *application, void *data, void (*datad)(void *),
88
104
const char *registrar);
89
105
void pbx_builtin_setvar(void *chan, void *data);
90
106
struct ast_context * ast_context_create(void **extcontexts, const char *name, const char *registrar);
91
struct ast_context * ast_context_find_or_create(void **extcontexts, const char *name, const char *registrar);
107
struct ast_context * ast_context_find_or_create(void **extcontexts, void *tab, const char *name, const char *registrar);
92
108
void ast_context_add_ignorepat2(struct ast_context *con, const char *value, const char *registrar);
93
109
void ast_context_add_include2(struct ast_context *con, const char *value, const char *registrar);
94
110
void ast_context_add_switch2(struct ast_context *con, const char *value, const char *data, int eval, const char *registrar);
99
115
void ast_context_destroy(void);
100
116
void ast_log(int level, const char *file, int line, const char *function, const char *fmt, ...);
101
117
char *ast_process_quotes_and_slashes(char *start, char find, char replace_with);
102
void ast_verbose(const char *fmt, ...);
118
void __ast_verbose(const char *file, int line, const char *func, const char *fmt, ...);
103
119
struct ast_app *pbx_findapp(const char *app);
104
120
void filter_leading_space_from_exprs(char *str);
105
121
void filter_newlines(char *str);
110
126
static int FIRST_TIME = 0;
111
127
static FILE *dumpfile;
129
void ast_log(int level, const char *file, int line, const char *function, const char *fmt, ...)
134
printf("LOG: lev:%d file:%s line:%d func: %s ",
135
level, file, line, function);
141
struct ast_exten *pbx_find_extension(struct ast_channel *chan,
142
struct ast_context *bypass,
143
struct pbx_find_info *q,
148
const char *callerid,
149
enum ext_match_t action);
151
struct ast_exten *pbx_find_extension(struct ast_channel *chan,
152
struct ast_context *bypass,
153
struct pbx_find_info *q,
158
const char *callerid,
159
enum ext_match_t action)
161
return localized_find_extension(bypass, q, context, exten, priority, label, callerid, action);
113
164
struct ast_app *pbx_findapp(const char *app)
115
166
return (struct ast_app*)1; /* so as not to trigger an error */
118
void ast_add_profile(void)
169
struct ast_custom_function *ast_custom_function_find(const char *name);
172
struct ast_custom_function *ast_custom_function_find(const char *name)
174
return 0; /* in "standalone" mode, functions are just not avail */
177
#if !defined(LOW_MEMORY)
178
int ast_add_profile(const char *x, uint64_t scale)
121
181
printf("Executed ast_add_profile();\n");
124
187
int ast_loader_register(int (*updater)(void))
145
208
printf("Executed ast_cli_register_multiple();\n");
148
void ast_register_file_version(void)
151
printf("Executed ast_register_file_version();\n"); */
152
/* I'm erasing this, because I don't think anyone really ever needs to see it anyway */
155
void ast_unregister_file_version(void)
158
printf("Executed ast_unregister_file_version();\n"); */
159
/* I'm erasing this, because I don't think anyone really ever needs to see it anyway */
162
211
void pbx_substitute_variables_helper(struct ast_channel *c,const char *cp1,char *cp2,int count);
163
212
void pbx_substitute_variables_helper(struct ast_channel *c,const char *cp1,char *cp2,int count)
233
280
filter_newlines((char*)data);
234
281
filter_leading_space_from_exprs((char*)data);
282
/* in previous versions, commas were converted to '|' to separate
283
args in app calls, but now, commas are used. There used to be
284
code here to insert backslashes (escapes) before any commas
285
that may have been embedded in the app args. This code is no more. */
236
/* compiling turns commas into vertical bars in the app data, and also removes the backslash from before escaped commas;
237
we have to restore the escaping backslash in front of any commas; the vertical bars are OK to leave as-is */
238
for (data2 = data; *data2; data2++) {
240
commacount++; /* we need to know how much bigger the string will grow-- one backslash for each comma */
246
data2 = (char*)malloc(strlen(data)+commacount+1);
252
*d4++ = '\\'; /* put a backslash in front of each comma */
255
*d4++ = *d3++; /* or just copy the char */
257
*d4++ = 0; /* cap off the new string */
262
287
if( strcmp(label,"(null)") != 0 )
263
288
fprintf(dumpfile,"exten => %s,%d(%s),%s(%s)\n", extension, priority, label, application, (char*)data);
265
290
fprintf(dumpfile,"exten => %s,%d,%s(%s)\n", extension, priority, application, (char*)data);
270
data = data3; /* restore data to pre-messedup state */
275
294
if( strcmp(label,"(null)") != 0 )
316
struct ast_context * ast_context_find_or_create(void **extcontexts, const char *name, const char *registrar)
335
struct ast_context * ast_context_find_or_create(void **extcontexts, void *tab, const char *name, const char *registrar)
318
337
struct ast_context *x = calloc(1, sizeof(*x));
400
419
printf("Executed ast_context_destroy();\n");
403
void ast_log(int level, const char *file, int line, const char *function, const char *fmt, ...)
407
if( !quiet || level > 2 ) {
408
printf("LOG: lev:%d file:%s line:%d func: %s ",
409
level, file, line, function);
416
void ast_verbose(const char *fmt, ...)
427
char *ast_process_quotes_and_slashes(char *start, char find, char replace_with)
429
char *dataPut = start;
433
for (; *start; start++) {
435
*dataPut++ = *start; /* Always goes verbatim */
438
if (*start == '\\') {
439
inEscape = 1; /* Do not copy \ into the data */
440
} else if (*start == '\'') {
441
inQuotes = 1-inQuotes; /* Do not copy ' into the data */
443
/* Replace , with |, unless in quotes */
444
*dataPut++ = inQuotes ? *start : ((*start==find) ? replace_with : *start);
448
if (start != dataPut)
453
422
void filter_leading_space_from_exprs(char *str)
455
424
/* Mainly for aesthetics */
490
459
extern struct module_symbols mod_data;
491
extern int ael_external_load_module(void);
460
int ael_external_load_module(void);
493
463
int main(int argc, char **argv)
522
492
if( use_curr_dir ) {
523
strcpy(ast_config_AST_CONFIG_DIR, ".");
493
strcpy(config_dir, ".");
494
localized_use_local_dir();
526
strcpy(ast_config_AST_CONFIG_DIR, "/etc/asterisk");
497
strcpy(config_dir, "/etc/asterisk");
498
localized_use_conf_dir();
528
strcpy(ast_config_AST_VAR_DIR, "/var/lib/asterisk");
500
strcpy(var_dir, "/var/lib/asterisk");
530
502
if( dump_extensions ) {
531
503
dumpfile = fopen("extensions.conf.aeldump","w");
559
int ast_hashtab_compare_contexts(const void *ah_a, const void *ah_b);
561
int ast_hashtab_compare_contexts(const void *ah_a, const void *ah_b)
566
unsigned int ast_hashtab_hash_contexts(const void *obj);
568
unsigned int ast_hashtab_hash_contexts(const void *obj)
574
#if !defined(LOW_MEMORY)
575
void ast_mark_lock_acquired(void *lock_addr)
579
void ast_remove_lock_info(void *lock_addr, struct ast_bt *bt)
583
void ast_store_lock_info(enum ast_lock_type type, const char *filename,
584
int line_num, const char *func, const char *lock_name, void *lock_addr, struct ast_bt *bt)
588
int ast_bt_get_addresses(struct ast_bt *bt)
594
void ast_remove_lock_info(void *lock_addr)
598
void ast_store_lock_info(enum ast_lock_type type, const char *filename,
599
int line_num, const char *func, const char *lock_name, void *lock_addr)
602
#endif /* HAVE_BKTR */
603
#endif /* !defined(LOW_MEMORY) */
604
#endif /* DEBUG_THREADS */