7 #if !defined(SOLARIS) && !defined(__CYGWIN__)
14 #include "asterisk/ast_expr.h"
15 #include "asterisk/logger.h"
16 #include "asterisk/module.h"
17 #include "asterisk/channel.h"
18 #include "asterisk/app.h"
19 #include "asterisk/ael_structs.h"
21 #define AST_CONFIG_MAX_PATH 255
23 int conts=0, extens=0, priors=0;
24 char last_exten[18000];
25 char ast_config_AST_CONFIG_DIR[AST_CONFIG_MAX_PATH];
26 char ast_config_AST_VAR_DIR[AST_CONFIG_MAX_PATH];
28 void ast_cli_register_multiple(void);
29 void ast_register_file_version(void);
30 void ast_unregister_file_version(void);
31 int ast_add_extension2(void *con,
32 int replace, const char *extension, int priority, const char *label, const char *callerid,
33 const char *application, void *data, void (*datad)(void *),
34 const char *registrar);
35 void pbx_builtin_setvar(void *chan, void *data);
36 void ast_context_create(void **extcontexts, const char *name, const char *registrar);
37 void ast_context_add_ignorepat2(void *con, const char *value, const char *registrar);
38 void ast_context_add_include2(void *con, const char *value, const char *registrar);
39 void ast_context_add_switch2(void *con, const char *value, const char *data, int eval, const char *registrar);
40 void ast_merge_contexts_and_delete(void);
41 void ast_context_verify_includes(void);
42 struct ast_context * ast_walk_contexts(void);
43 void ast_cli_unregister_multiple(void);
44 void ast_context_destroy(void);
45 void ast_log(int level, const char *file, int line, const char *function, const char *fmt, ...);
46 char *ast_process_quotes_and_slashes(char *start, char find, char replace_with);
47 void ast_verbose(const char *fmt, ...);
48 struct ast_app *pbx_findapp(const char *app);
49 static int no_comp = 0;
50 static int use_curr_dir = 0;
52 struct ast_app *pbx_findapp(const char *app)
54 return (struct ast_app*)1; /* so as not to trigger an error */
57 void ast_cli_register_multiple(void)
60 printf("Executed ast_cli_register_multiple();\n");
63 void ast_register_file_version(void)
66 printf("Executed ast_register_file_version();\n");
69 void ast_unregister_file_version(void)
72 printf("Executed ast_unregister_file_version();\n");
75 int ast_add_extension2(void *con,
76 int replace, const char *extension, int priority, const char *label, const char *callerid,
77 const char *application, void *data, void (*datad)(void *),
78 const char *registrar)
81 if (strcmp(extension,last_exten) != 0) {
83 strcpy(last_exten, extension);
92 application = "(null)";
95 printf("Executed ast_add_extension2(con, rep=%d, exten=%s, priority=%d, label=%s, callerid=%s, appl=%s, data=%s, FREE, registrar=%s);\n",
96 replace, extension, priority, label, callerid, application, (data?(char*)data:"(null)"), registrar);
98 /* since add_extension2 is responsible for the malloc'd data stuff */
104 void pbx_builtin_setvar(void *chan, void *data)
107 printf("Executed pbx_builtin_setvar(chan, data=%s);\n", (char*)data);
111 void ast_context_create(void **extcontexts, const char *name, const char *registrar)
114 printf("Executed ast_context_create(conts, name=%s, registrar=%s);\n", name, registrar);
118 void ast_context_add_ignorepat2(void *con, const char *value, const char *registrar)
121 printf("Executed ast_context_add_ignorepat2(con, value=%s, registrar=%s);\n", value, registrar);
124 void ast_context_add_include2(void *con, const char *value, const char *registrar)
127 printf("Executed ast_context_add_include2(con, value=%s, registrar=%s);\n", value, registrar);
130 void ast_context_add_switch2(void *con, const char *value, const char *data, int eval, const char *registrar)
133 printf("Executed ast_context_add_switch2(con, value=%s, data=%s, eval=%d, registrar=%s);\n", value, data, eval, registrar);
136 void ast_merge_contexts_and_delete(void)
139 printf("Executed ast_merge_contexts_and_delete();\n");
142 void ast_context_verify_includes(void)
145 printf("Executed ast_context_verify_includes();\n");
148 struct ast_context * ast_walk_contexts(void)
151 printf("Executed ast_walk_contexts();\n");
155 void ast_cli_unregister_multiple(void)
158 printf("Executed ast_cli_unregister_multiple();\n");
161 void ast_context_destroy(void)
163 printf("Executed ast_context_destroy();\n");
166 void ast_log(int level, const char *file, int line, const char *function, const char *fmt, ...)
171 printf("LOG: lev:%d file:%s line:%d func: %s ",
172 level, file, line, function);
178 void ast_verbose(const char *fmt, ...)
189 char *ast_process_quotes_and_slashes(char *start, char find, char replace_with)
191 char *dataPut = start;
195 for (; *start; start++) {
197 *dataPut++ = *start; /* Always goes verbatim */
200 if (*start == '\\') {
201 inEscape = 1; /* Do not copy \ into the data */
202 } else if (*start == '\'') {
203 inQuotes = 1-inQuotes; /* Do not copy ' into the data */
205 /* Replace , with |, unless in quotes */
206 *dataPut++ = inQuotes ? *start : ((*start==find) ? replace_with : *start);
210 if (start != dataPut)
215 extern struct module_symbols mod_data;
218 int main(int argc, char **argv)
224 if( argv[i][0] == '-' && argv[i][1] == 'n' )
226 if( argv[i][0] == '-' && argv[i][1] == 'd' )
232 printf("\n(You can use the -n option if you aren't interested in seeing all the instructions generated by the compiler)\n\n");
234 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");
238 strcpy(ast_config_AST_CONFIG_DIR, ".");
242 strcpy(ast_config_AST_CONFIG_DIR, "/etc/asterisk");
244 strcpy(ast_config_AST_VAR_DIR, "/var/lib/asterisk");
246 mod_data.load_module(0);
248 ast_log(4, "ael2_parse", __LINE__, "main", "%d contexts, %d extensions, %d priorities\n", conts, extens, priors);