7 #if !defined(SOLARIS) && !defined(__CYGWIN__)
15 #define AST_API_MODULE
16 #include "asterisk/strings.h"
18 /* ensure that _ast_calloc works */
19 #define AST_API_MODULE
20 #include "asterisk/utils.h"
22 #include "asterisk/ast_expr.h"
23 #include "asterisk/logger.h"
24 #include "asterisk/module.h"
25 #include "asterisk/channel.h"
26 #include "asterisk/app.h"
27 #include "asterisk/ael_structs.h"
29 #define AST_CONFIG_MAX_PATH 255
31 int conts=0, extens=0, priors=0;
32 char last_exten[18000];
33 char ast_config_AST_CONFIG_DIR[AST_CONFIG_MAX_PATH];
34 char ast_config_AST_VAR_DIR[AST_CONFIG_MAX_PATH];
36 void ast_cli_register_multiple(void);
37 void ast_register_file_version(void);
38 void ast_unregister_file_version(void);
39 int ast_add_extension2(void *con,
40 int replace, const char *extension, int priority, const char *label, const char *callerid,
41 const char *application, void *data, void (*datad)(void *),
42 const char *registrar);
43 void pbx_builtin_setvar(void *chan, void *data);
44 void ast_context_create(void **extcontexts, const char *name, const char *registrar);
45 void ast_context_add_ignorepat2(void *con, const char *value, const char *registrar);
46 void ast_context_add_include2(void *con, const char *value, const char *registrar);
47 void ast_context_add_switch2(void *con, const char *value, const char *data, int eval, const char *registrar);
48 void ast_merge_contexts_and_delete(void);
49 void ast_context_verify_includes(void);
50 struct ast_context * ast_walk_contexts(void);
51 void ast_cli_unregister_multiple(void);
52 void ast_context_destroy(void);
53 void ast_log(int level, const char *file, int line, const char *function, const char *fmt, ...);
54 char *ast_process_quotes_and_slashes(char *start, char find, char replace_with);
55 void ast_verbose(const char *fmt, ...);
56 struct ast_app *pbx_findapp(const char *app);
57 static int no_comp = 0;
58 static int use_curr_dir = 0;
61 struct ast_app *pbx_findapp(const char *app)
63 return (struct ast_app*)1; /* so as not to trigger an error */
66 void ast_cli_register_multiple(void)
69 printf("Executed ast_cli_register_multiple();\n");
72 void ast_register_file_version(void)
75 printf("Executed ast_register_file_version();\n");
78 void ast_unregister_file_version(void)
81 printf("Executed ast_unregister_file_version();\n");
84 int ast_add_extension2(void *con,
85 int replace, const char *extension, int priority, const char *label, const char *callerid,
86 const char *application, void *data, void (*datad)(void *),
87 const char *registrar)
90 if (strcmp(extension,last_exten) != 0) {
92 strcpy(last_exten, extension);
101 application = "(null)";
104 printf("Executed ast_add_extension2(con, rep=%d, exten=%s, priority=%d, label=%s, callerid=%s, appl=%s, data=%s, FREE, registrar=%s);\n",
105 replace, extension, priority, label, callerid, application, (data?(char*)data:"(null)"), registrar);
107 /* since add_extension2 is responsible for the malloc'd data stuff */
113 void pbx_builtin_setvar(void *chan, void *data)
116 printf("Executed pbx_builtin_setvar(chan, data=%s);\n", (char*)data);
120 void ast_context_create(void **extcontexts, const char *name, const char *registrar)
123 printf("Executed ast_context_create(conts, name=%s, registrar=%s);\n", name, registrar);
127 void ast_context_add_ignorepat2(void *con, const char *value, const char *registrar)
130 printf("Executed ast_context_add_ignorepat2(con, value=%s, registrar=%s);\n", value, registrar);
133 void ast_context_add_include2(void *con, const char *value, const char *registrar)
136 printf("Executed ast_context_add_include2(con, value=%s, registrar=%s);\n", value, registrar);
139 void ast_context_add_switch2(void *con, const char *value, const char *data, int eval, const char *registrar)
142 printf("Executed ast_context_add_switch2(con, value=%s, data=%s, eval=%d, registrar=%s);\n", value, data, eval, registrar);
145 void ast_merge_contexts_and_delete(void)
148 printf("Executed ast_merge_contexts_and_delete();\n");
151 void ast_context_verify_includes(void)
154 printf("Executed ast_context_verify_includes();\n");
157 struct ast_context * ast_walk_contexts(void)
160 printf("Executed ast_walk_contexts();\n");
164 void ast_cli_unregister_multiple(void)
167 printf("Executed ast_cli_unregister_multiple();\n");
170 void ast_context_destroy(void)
172 printf("Executed ast_context_destroy();\n");
175 void ast_log(int level, const char *file, int line, const char *function, const char *fmt, ...)
180 printf("LOG: lev:%d file:%s line:%d func: %s ",
181 level, file, line, function);
187 void ast_verbose(const char *fmt, ...)
198 char *ast_process_quotes_and_slashes(char *start, char find, char replace_with)
200 char *dataPut = start;
204 for (; *start; start++) {
206 *dataPut++ = *start; /* Always goes verbatim */
209 if (*start == '\\') {
210 inEscape = 1; /* Do not copy \ into the data */
211 } else if (*start == '\'') {
212 inQuotes = 1-inQuotes; /* Do not copy ' into the data */
214 /* Replace , with |, unless in quotes */
215 *dataPut++ = inQuotes ? *start : ((*start==find) ? replace_with : *start);
219 if (start != dataPut)
224 extern struct module_symbols mod_data;
227 int main(int argc, char **argv)
233 if( argv[i][0] == '-' && argv[i][1] == 'n' )
235 if( argv[i][0] == '-' && argv[i][1] == 'd' )
241 printf("\n(You can use the -n option if you aren't interested in seeing all the instructions generated by the compiler)\n\n");
243 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");
247 strcpy(ast_config_AST_CONFIG_DIR, ".");
251 strcpy(ast_config_AST_CONFIG_DIR, "/etc/asterisk");
253 strcpy(ast_config_AST_VAR_DIR, "/var/lib/asterisk");
255 mod_data.load_module(0);
257 ast_log(4, "ael2_parse", __LINE__, "main", "%d contexts, %d extensions, %d priorities\n", conts, extens, priors);