Merged revisions 85517 via svnmerge from
[asterisk/asterisk.git] / utils / ael_main.c
index df8a01c..58939f9 100644 (file)
 #include <limits.h>
 
 #include "asterisk/compat.h"
-#include "asterisk/ast_expr.h"
 #include "asterisk/channel.h"
+#include "asterisk/ast_expr.h"
+#include "asterisk/ast_expr.h"
 #include "asterisk/module.h"
 #include "asterisk/app.h"
 #include "asterisk/ael_structs.h"
+#include "asterisk/extconf.h"
+
+/*** MODULEINFO
+       <depend>res_ael_share</depend>
+ ***/
 
 struct namelist
 {
@@ -55,8 +61,8 @@ void destroy_namelist(struct namelist *x)
        }
 }
 
-struct namelist *create_name(char *name);
-struct namelist *create_name(char *name)
+struct namelist *create_name(const char *name);
+struct namelist *create_name(const char *name)
 {
        struct namelist *x = calloc(1, sizeof(*x));
        if (!x)
@@ -106,6 +112,41 @@ static int dump_extensions = 0;
 static int FIRST_TIME = 0;
 static FILE *dumpfile;
 
+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);
+}
+
+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);
+
+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)
+{
+       return localized_find_extension(bypass, q, context, exten, priority, label, callerid, action);
+}
+
 struct ast_app *pbx_findapp(const char *app)
 {
        return (struct ast_app*)1; /* so as not to trigger an error */
@@ -164,6 +205,17 @@ void ast_unregister_file_version(void)
        /* I'm erasing this, because I don't think anyone really ever needs to see it anyway */
 
 }
+void pbx_substitute_variables_helper(struct ast_channel *c,const char *cp1,char *cp2,int count);
+void pbx_substitute_variables_helper(struct ast_channel *c,const char *cp1,char *cp2,int count)
+{
+       if (cp1 && *cp1)
+               strncpy(cp2,cp1,AST_MAX_EXTENSION); /* Right now, this routine is ONLY being called for 
+                                                                                          a possible var substitution on extension names,
+                                                                                          so....! */
+       else
+               *cp2 = 0;
+}
+
 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 *),
@@ -281,12 +333,12 @@ int ast_add_extension2(struct ast_context *con,
 
 void pbx_builtin_setvar(void *chan, void *data)
 {
-       struct namelist *x = create_name((char*)data);
+       struct namelist *x = create_name(data);
        if(!no_comp)
                printf("Executed pbx_builtin_setvar(chan, data=%s);\n", (char*)data);
 
        if( dump_extensions ) {
-               x = create_name((char*)data);
+               x = create_name(data);
                ADD_LAST(globalvars,x);
        }
 }
@@ -313,7 +365,7 @@ void ast_context_add_ignorepat2(struct ast_context *con, const char *value, cons
                printf("Executed ast_context_add_ignorepat2(con, value=%s, registrar=%s);\n", value, registrar);
        if( dump_extensions ) {
                struct namelist *x;
-               x = create_name((char*)value);
+               x = create_name(value);
                ADD_LAST(con->ignorepats,x);
        }
 }
@@ -379,56 +431,6 @@ 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);
-       if( !quiet || level > 2 ) {
-           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;
-}
-
 void filter_leading_space_from_exprs(char *str)
 {
        /*  Mainly for aesthetics */
@@ -467,7 +469,8 @@ void filter_newlines(char *str)
 
 
 extern struct module_symbols mod_data;
-extern int ael_external_load_module(void);
+int ael_external_load_module(void);
+
 
 int main(int argc, char **argv)
 {
@@ -500,9 +503,11 @@ int main(int argc, char **argv)
 
        if( use_curr_dir ) {
                strcpy(ast_config_AST_CONFIG_DIR, ".");
+               localized_use_local_dir();
        }
        else {
                strcpy(ast_config_AST_CONFIG_DIR, "/etc/asterisk");
+               localized_use_conf_dir();
        }
        strcpy(ast_config_AST_VAR_DIR, "/var/lib/asterisk");