]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
update
authorAnthony Minessale <anthony.minessale@gmail.com>
Mon, 5 Jun 2006 18:36:02 +0000 (18:36 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Mon, 5 Jun 2006 18:36:02 +0000 (18:36 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@1545 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/include/switch_core.h
src/switch.c
src/switch_core.c

index 4903516f9c6b59e2bdf355bd4a7f82201f964efe..b2d0c991651f36e96c038cb93b840f7b69d22e4c 100644 (file)
@@ -111,9 +111,10 @@ struct switch_core_runtime;
 /*! 
   \brief Initilize the core
   \param console optional FILE stream for output
+  \param a pointer to set any errors to
   \note to be called at application startup
 */
-SWITCH_DECLARE(switch_status_t) switch_core_init(char *console);
+SWITCH_DECLARE(switch_status_t) switch_core_init(char *console, const char **err);
 
 /*! 
   \brief Destroy the core
index a1b62d15c22a9dde4d7f693037a247c16c266544..552262b1c2bb56611591ff2b1d04ad4f9f123eb5 100644 (file)
@@ -70,7 +70,7 @@ int main(int argc, char *argv[])
        char *pfile = "freeswitch.pid";
        char path[256] = "";
        char *ppath = NULL;
-       char *err = NULL;
+       const char *err = NULL;
        switch_event_t *event;
        int bg = 0;
        FILE *f;
@@ -124,8 +124,8 @@ int main(int argc, char *argv[])
        }
 
 
-       if (switch_core_init(ppath) != SWITCH_STATUS_SUCCESS) {
-               fprintf(stderr, "Cannot Initilize\n");
+       if (switch_core_init(ppath, &err) != SWITCH_STATUS_SUCCESS) {
+               fprintf(stderr, "Cannot Initilize [%s]\n", err);
                return 255;
        }
 
@@ -156,8 +156,6 @@ int main(int argc, char *argv[])
 
        fprintf(f, "%d", getpid());
        fclose(f);
-
-
        
        if (!err) {
                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Bringing up environment.\n");
index dac6069e5a887a9c7cb8f5b2236b5d1ca0f66a3e..929bd2dc7a78d10b33d72f51b17081e5a3325803 100644 (file)
@@ -2758,9 +2758,8 @@ SWITCH_DECLARE(void) switch_core_set_globals(void)
 #endif
 }
 
-SWITCH_DECLARE(switch_status_t) switch_core_init(char *console)
+SWITCH_DECLARE(switch_status_t) switch_core_init(char *console, const char **err)
 {
-       const char *err = NULL;
        memset(&runtime, 0, sizeof(runtime));
        
        switch_core_set_globals();
@@ -2768,29 +2767,35 @@ SWITCH_DECLARE(switch_status_t) switch_core_init(char *console)
        /* INIT APR and Create the pool context */
        if (apr_initialize() != SWITCH_STATUS_SUCCESS) {
                apr_terminate();
-               fprintf(stderr, "FATAL ERROR! Could not initilize APR\n");
+               *err = "FATAL ERROR! Could not initilize APR\n";
                return SWITCH_STATUS_MEMERR;
        }
 
        if (apr_pool_create(&runtime.memory_pool, NULL) != SWITCH_STATUS_SUCCESS) {
                apr_terminate();
-               fprintf(stderr, "FATAL ERROR! Could not allocate memory pool\n");
+               *err = "FATAL ERROR! Could not allocate memory pool\n";
                return SWITCH_STATUS_MEMERR;
        }
 
-       if (switch_xml_init(runtime.memory_pool, &err) != SWITCH_STATUS_SUCCESS) {
+       if (switch_xml_init(runtime.memory_pool, err) != SWITCH_STATUS_SUCCESS) {
                apr_terminate();
-               fprintf(stderr, "FATAL ERROR! Could not open XML Registry %s\n", err);
+               *err = "FATAL ERROR! Could not open XML Registry %s\n";
                return SWITCH_STATUS_MEMERR;
        }
 
+       *err = NULL;
+
        if(console) {
                if (*console != '/') {
                        char path[265];
                        snprintf(path, sizeof(path), "%s%s%s", SWITCH_GLOBAL_dirs.log_dir, SWITCH_PATH_SEPARATOR, console);
                        console = path;
                }
-               switch_core_set_console(console);
+               if (switch_core_set_console(console) != SWITCH_STATUS_SUCCESS) {
+                       *err = "FATAL ERROR! Could not open console\n";
+                       apr_terminate();
+                       return SWITCH_STATUS_GENERR;
+               }
        } else {
                runtime.console = stdout;
        }