Merged revisions 141806 via svnmerge from
[asterisk/asterisk.git] / utils / conf2ael.c
index 7616b30..705932a 100644 (file)
  *
  */
 
+/*** MODULEINFO
+       <depend>res_ael_share</depend>
+ ***/
 
+#include "asterisk.h"
+ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 
-#include "asterisk/autoconfig.h"
-
-#include <stdio.h>
-#include <sys/types.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
+#include "asterisk/paths.h"    /* CONFIG_DIR */
 #include <locale.h>
 #include <ctype.h>
 #if !defined(SOLARIS) && !defined(__CYGWIN__)
 #include <err.h>
 #endif
-#include <errno.h>
 #include <regex.h>
-#include <limits.h>
 
-#include "asterisk/compat.h"
+#include "asterisk.h"
 #include "asterisk/pbx.h"
 #include "asterisk/ast_expr.h"
 #include "asterisk/channel.h"
 #include "asterisk/config.h"
 #include "asterisk/options.h"
 #include "asterisk/callerid.h"
+#include "asterisk/lock.h"
+#include "asterisk/hashtab.h"
 #include "asterisk/ael_structs.h"
 #include "asterisk/devicestate.h"
 #include "asterisk/stringfields.h"
 #include "asterisk/pval.h"
 #include "asterisk/extconf.h"
 
+struct ast_flags ast_compat = { 7 };
+const char *ast_config_AST_CONFIG_DIR = "/etc/asterisk";       /* placeholder */
+
 void get_start_stop(unsigned int *word, int bitsperword, int totalbits, int *start, int *end);
 int all_bits_set(unsigned int *word, int bitsperword, int totalbits);
 extern char *days[];
 extern char *months[];
-char ast_config_AST_CONFIG_DIR[PATH_MAX];
 
 char *config = "extensions.conf";
 
@@ -76,26 +77,20 @@ char ast_config_AST_SYSTEM_NAME[20] = ""; */
 /*! Go no deeper than this through includes (not counting loops) */
 #define AST_PBX_MAX_STACK      128
 /* static AST_RWLIST_HEAD_STATIC(acf_root, ast_custom_function); */
-extern char ast_config_AST_CONFIG_DIR[PATH_MAX];
+//extern char ast_config_AST_CONFIG_DIR[PATH_MAX];
 
-/* modulation */
-void ast_register_file_version(void);
-void ast_unregister_file_version(void);
-
-void ast_register_file_version(void)
+void ast_register_file_version(const char *file, const char *version);
+void ast_register_file_version(const char *file, const char *version)
 {
-       /* if(!no_comp)
-          printf("Executed ast_register_file_version();\n"); */
-       /* I'm erasing this, because I don't think anyone really ever needs to see it anyway */
 }
 
-void ast_unregister_file_version(void)
+void ast_unregister_file_version(const char *file);
+void ast_unregister_file_version(const char *file)
 {
-       /* if(!no_comp)
-               printf("Executed ast_unregister_file_version();\n"); */
-       /* I'm erasing this, because I don't think anyone really ever needs to see it anyway */
 }
-
+#if !defined(LOW_MEMORY)
+int ast_add_profile(const char *x, uint64_t scale) { return 0;}
+#endif
 /* Our own version of ast_log, since the expr parser uses it. -- stolen from utils/check_expr.c */
 void ast_log(int level, const char *file, int line, const char *function, const char *fmt, ...) __attribute__ ((format (printf,5,6)));
 
@@ -340,9 +335,17 @@ int main(int argc, char **argv)
        struct ast_sw *sw = 0;
        struct ast_ignorepat *ipi;
        pval *incl=0;
+       int localdir = 0, i;
 
        tree = 0;
        tmptree = 0;
+
+       /* process the command line args */
+       for (i=1; i<argc; i++)
+       {
+               if (strcmp(argv[i],"-d")==0)
+                       localdir =1;
+       }
        
        /* 3 simple steps: */
        /*   1. read in the extensions.conf config file 
@@ -358,11 +361,13 @@ int main(int argc, char **argv)
        printf("         The result will most likely need careful attention to\n");
        printf("         finish the job!!!!!\n");
 
-       strcpy(ast_config_AST_CONFIG_DIR,"/etc/asterisk");
-       
+       if (!localdir)
+               printf(" (You could use -d the use the extensions.conf in the current directory!)\n");
+
        printf("Loading %s/%s...\n", ast_config_AST_CONFIG_DIR, config);
 
-       localized_use_conf_dir();
+       if (!localdir)
+               localized_use_conf_dir();
        localized_pbx_load_module();
        
        printf("... Done!\n");
@@ -491,28 +496,43 @@ int main(int argc, char **argv)
                        pval *exten = pvalCreateNode(PV_EXTENSION);
                        pvalContextAddStatement(tmptree, exten);
                        pvalExtenSetName(exten, ast_strdup(eroot->exten));
-                       
+               
                        if (eroot->peer) {
                                pval *block = pvalCreateNode(PV_STATEMENTBLOCK);
                                pvalExtenSetStatement(exten, block);
                                
                                e = 0;
                                while ( (e = localized_walk_extension_priorities(eroot, e)) ) {
-                                       /* printf("           %s(%s)\n", e->app, (char*)e->data); */
                                        
                                        pval *statemnt = pvalCreateNode(PV_APPLICATION_CALL);
                                        pval *args = pvalCreateNode(PV_WORD);
                                        
+                                       /* printf("           %s(%s)\n", e->app, (char*)e->data); */
+
                                        pvalAppCallSetAppName(statemnt, ast_strdup(e->app));
                                        pvalWordSetString(args, ast_strdup(e->data));
                                        pvalAppCallAddArg(statemnt, args);
                                        
                                        pvalStatementBlockAddStatement(block, statemnt);
                                }
-                       } else {
+                       } else if (eroot->priority == -1) {
+
                                pval *statemnt = pvalCreateNode(PV_APPLICATION_CALL);
                                pval *args = pvalCreateNode(PV_WORD);
 
+                               /* printf("Mike, we have a hint on exten %s with data %s\n", eroot->exten, eroot->app); */
+
+                               pvalAppCallSetAppName(statemnt, "NoOp");
+                               pvalWordSetString(args, ast_strdup(eroot->app));
+
+
+                               pvalExtenSetStatement(exten, statemnt);
+                               pvalExtenSetHints(exten, ast_strdup(eroot->app));
+                       } else {
+
+                               pval *statemnt = pvalCreateNode(PV_APPLICATION_CALL);
+                               pval *args = pvalCreateNode(PV_WORD);
+       
                                /* printf("           %s (%s)\n", eroot->app, (char *)eroot->data); */
                                
                                pvalAppCallSetAppName(statemnt, ast_strdup(eroot->app));
@@ -590,11 +610,11 @@ int ast_context_add_include2(struct ast_context *con, const char *value,
        return localized_context_add_include2(con, value,registrar);
 }
 
-struct ast_context *ast_context_create(struct ast_context **extcontexts, const char *name, const char *registrar)
+struct ast_context *ast_context_find_or_create(struct ast_context **extcontexts, struct ast_hashtab *exttable, const char *name, const char *registrar)
 {
-       printf("Creating context %s, registrar=%s\n", name, registrar);
+       printf("find/Creating context %s, registrar=%s\n", name, registrar);
        
-       return localized_context_create(extcontexts, name, registrar);
+       return localized_context_find_or_create(extcontexts, exttable, name, registrar);
 }
 
 void ast_cli_register_multiple(void);
@@ -637,11 +657,11 @@ int ast_context_verify_includes(struct ast_context *con)
        return  localized_context_verify_includes(con);
 }
 
-void ast_merge_contexts_and_delete(struct ast_context **extcontexts, const char *registrar);
+void ast_merge_contexts_and_delete(struct ast_context **extcontexts, struct ast_hashtab *exttable, const char *registrar);
 
-void ast_merge_contexts_and_delete(struct ast_context **extcontexts, const char *registrar)
+void ast_merge_contexts_and_delete(struct ast_context **extcontexts, struct ast_hashtab *exttable, const char *registrar)
 {
-       localized_merge_contexts_and_delete(extcontexts, registrar);
+       localized_merge_contexts_and_delete(extcontexts, exttable, registrar);
 }
 
 struct ast_exten *pbx_find_extension(struct ast_channel *chan,
@@ -667,3 +687,49 @@ struct ast_exten *pbx_find_extension(struct ast_channel *chan,
        return localized_find_extension(bypass, q, context, exten, priority, label, callerid, action);
 }
 
+int ast_hashtab_compare_contexts(const void *ah_a, const void *ah_b);
+
+int ast_hashtab_compare_contexts(const void *ah_a, const void *ah_b)
+{
+       return 0;
+}
+
+unsigned int ast_hashtab_hash_contexts(const void *obj);
+
+unsigned int ast_hashtab_hash_contexts(const void *obj)
+{
+       return 0;
+}
+
+#ifdef DEBUG_THREADS
+#if !defined(LOW_MEMORY)
+void ast_mark_lock_acquired(void *lock_addr)
+{
+}
+#ifdef HAVE_BKTR
+void ast_remove_lock_info(void *lock_addr, struct ast_bt *bt)
+{
+}
+
+void ast_store_lock_info(enum ast_lock_type type, const char *filename,
+       int line_num, const char *func, const char *lock_name, void *lock_addr, struct ast_bt *bt)
+{
+}
+
+int ast_bt_get_addresses(struct ast_bt *bt)
+{
+       return 0;
+}
+
+#else
+void ast_remove_lock_info(void *lock_addr)
+{
+}
+
+void ast_store_lock_info(enum ast_lock_type type, const char *filename,
+       int line_num, const char *func, const char *lock_name, void *lock_addr)
+{
+}
+#endif /* HAVE_BKTR */
+#endif /* !defined(LOW_MEMORY) */
+#endif /* DEBUG_THREADS */