From 6baa8fbab851e094bc67dbe0dc67817e55a11075 Mon Sep 17 00:00:00 2001 From: kpfleming Date: Mon, 24 Apr 2006 17:41:27 +0000 Subject: Merge Steve Murphy's (murf) complete re-implementation of AEL, which is now no longer considered experimental :-) git-svn-id: http://svn.digium.com/svn/asterisk/trunk@22273 f38db490-d61c-443f-a65b-d21fe96a405b --- utils/ael_main.c | 264 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 264 insertions(+) create mode 100644 utils/ael_main.c (limited to 'utils/ael_main.c') diff --git a/utils/ael_main.c b/utils/ael_main.c new file mode 100644 index 000000000..ee6e815bd --- /dev/null +++ b/utils/ael_main.c @@ -0,0 +1,264 @@ +#include +#include +#include +#include +#include +#include +#if !defined(SOLARIS) && !defined(__CYGWIN__) +#include +#else +#define quad_t int64_t +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include "asterisk/ael_structs.h" +#define AST_CONFIG_MAX_PATH 255 + +int conts=0, extens=0, priors=0; +char last_exten[18000]; +char ast_config_AST_CONFIG_DIR[AST_CONFIG_MAX_PATH]; +char ast_config_AST_VAR_DIR[AST_CONFIG_MAX_PATH]; + +void ast_cli_register_multiple(void); +void ast_register_file_version(void); +void ast_unregister_file_version(void); +int ast_add_extension2(void *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); +void pbx_builtin_setvar(void *chan, void *data); +void ast_context_create(void **extcontexts, const char *name, const char *registrar); +void ast_context_add_ignorepat2(void *con, const char *value, const char *registrar); +void ast_context_add_include2(void *con, const char *value, const char *registrar); +void ast_context_add_switch2(void *con, const char *value, const char *data, int eval, const char *registrar); +void ast_merge_contexts_and_delete(void); +void ast_context_verify_includes(void); +struct ast_context * ast_walk_contexts(void); +void ast_cli_unregister_multiple(void); +void ast_context_destroy(void); +void ast_log(int level, const char *file, int line, const char *function, const char *fmt, ...); +char *ast_process_quotes_and_slashes(char *start, char find, char replace_with); +void ast_verbose(const char *fmt, ...); +struct ast_app *pbx_findapp(const char *app); +static int no_comp = 0; +static int use_curr_dir = 0; + + +struct ast_app *pbx_findapp(const char *app) +{ + return (struct ast_app*)1; /* so as not to trigger an error */ +} + + +void ast_copy_string(char *dst, const char *src, size_t size) +{ + while (*src && size) { + *dst++ = *src++; + size--; + } + if (__builtin_expect(!size, 0)) + dst--; + *dst = '\0'; +} + +void ast_cli_register_multiple(void) +{ + if(!no_comp) + printf("Executed ast_cli_register_multiple();\n"); +} + +void ast_register_file_version(void) +{ + if(!no_comp) + printf("Executed ast_register_file_version();\n"); +} + +void ast_unregister_file_version(void) +{ + if(!no_comp) + printf("Executed ast_unregister_file_version();\n"); + +} +int ast_add_extension2(void *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) +{ + priors++; + if (strcmp(extension,last_exten) != 0) { + extens++; + strcpy(last_exten, extension); + } + if (!label) { + label = "(null)"; + } + if (!callerid) { + callerid = "(null)"; + } + if (!application) { + application = "(null)"; + } + if(!no_comp) + printf("Executed ast_add_extension2(con, rep=%d, exten=%s, priority=%d, label=%s, callerid=%s, appl=%s, data=%s, FREE, registrar=%s);\n", + replace, extension, priority, label, callerid, application, (data?(char*)data:"(null)"), registrar); + + /* since add_extension2 is responsible for the malloc'd data stuff */ + if( data ) + free(data); + return 0; +} + +void pbx_builtin_setvar(void *chan, void *data) +{ + if(!no_comp) + printf("Executed pbx_builtin_setvar(chan, data=%s);\n", (char*)data); +} + + +void ast_context_create(void **extcontexts, const char *name, const char *registrar) +{ + if(!no_comp) + printf("Executed ast_context_create(conts, name=%s, registrar=%s);\n", name, registrar); + conts++; +} + +void ast_context_add_ignorepat2(void *con, const char *value, const char *registrar) +{ + if(!no_comp) + printf("Executed ast_context_add_ignorepat2(con, value=%s, registrar=%s);\n", value, registrar); +} + +void ast_context_add_include2(void *con, const char *value, const char *registrar) +{ + if(!no_comp) + printf("Executed ast_context_add_include2(con, value=%s, registrar=%s);\n", value, registrar); +} + +void ast_context_add_switch2(void *con, const char *value, const char *data, int eval, const char *registrar) +{ + if(!no_comp) + printf("Executed ast_context_add_switch2(con, value=%s, data=%s, eval=%d, registrar=%s);\n", value, data, eval, registrar); +} + +void ast_merge_contexts_and_delete(void) +{ + if(!no_comp) + printf("Executed ast_merge_contexts_and_delete();\n"); +} + +void ast_context_verify_includes(void) +{ + if(!no_comp) + printf("Executed ast_context_verify_includes();\n"); +} + +struct ast_context * ast_walk_contexts(void) +{ + if(!no_comp) + printf("Executed ast_walk_contexts();\n"); + return 0; +} + +void ast_cli_unregister_multiple(void) +{ + if(!no_comp) + printf("Executed ast_cli_unregister_multiple();\n"); +} + +void ast_context_destroy(void) +{ + printf("Executed ast_context_destroy();\n"); +} + +void ast_log(int level, const char *file, int line, const char *function, const char *fmt, ...) +{ + va_list vars; + va_start(vars,fmt); + + printf("LOG: lev:%d file:%s line:%d func: %s ", + level, file, line, function); + vprintf(fmt, vars); + fflush(stdout); + va_end(vars); +} + +void ast_verbose(const char *fmt, ...) +{ + va_list vars; + va_start(vars,fmt); + + printf("VERBOSE: "); + vprintf(fmt, vars); + fflush(stdout); + va_end(vars); +} + +char *ast_process_quotes_and_slashes(char *start, char find, char replace_with) +{ + char *dataPut = start; + int inEscape = 0; + int inQuotes = 0; + + for (; *start; start++) { + if (inEscape) { + *dataPut++ = *start; /* Always goes verbatim */ + inEscape = 0; + } else { + if (*start == '\\') { + inEscape = 1; /* Do not copy \ into the data */ + } else if (*start == '\'') { + inQuotes = 1-inQuotes; /* Do not copy ' into the data */ + } else { + /* Replace , with |, unless in quotes */ + *dataPut++ = inQuotes ? *start : ((*start==find) ? replace_with : *start); + } + } + } + if (start != dataPut) + *dataPut = 0; + return dataPut; +} + +extern struct module_symbols mod_data; + + +int main(int argc, char **argv) +{ + int i; + + for(i=1;i