]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add some more stuff to sho
authorAnthony Minessale <anthony.minessale@gmail.com>
Tue, 22 Jul 2008 17:19:26 +0000 (17:19 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Tue, 22 Jul 2008 17:19:26 +0000 (17:19 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@9134 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/include/switch_core.h
src/mod/applications/mod_commands/mod_commands.c
src/switch_core.c
src/switch_loadable_module.c
src/switch_utils.c

index 8bfdfcf038565001aa4631baf40cc7aadd51baf5..4dab6031d7adfe9c66bd6690c65e5e23aea5dee0 100644 (file)
@@ -593,6 +593,8 @@ SWITCH_DECLARE(char *) switch_core_get_variable(_In_z_ const char *varname);
 */
 SWITCH_DECLARE(void) switch_core_set_variable(_In_z_ const char *varname, _In_opt_z_ const char *value);
 
+SWITCH_DECLARE(void) switch_core_dump_variables(_In_ switch_stream_handle_t *stream);
+
 /*! 
   \brief Hangup All Sessions
   \param cause the hangup cause to apply to the hungup channels
index c04d738517fab2c93e18ed37a50cf35ffc267b20..5b346228ab280828c62ca37496219d792396d0de 100644 (file)
@@ -1977,7 +1977,7 @@ SWITCH_STANDARD_API(alias_function)
        return SWITCH_STATUS_SUCCESS;
 }
 
-#define SHOW_SYNTAX "codec|application|api|dialplan|file|timer|calls [count]|channels [count]|aliases|complete"
+#define SHOW_SYNTAX "codec|application|api|dialplan|file|timer|calls [count]|channels [count]|aliases|complete|chat|endpoint|management|say|interfaces|interface_types"
 SWITCH_STANDARD_API(show_function)
 {
        char sql[1024];
@@ -2018,13 +2018,28 @@ SWITCH_STANDARD_API(show_function)
                return SWITCH_STATUS_SUCCESS;
        }
 
+
        /* If you change the field qty or order of any of these select */
        /* statmements, you must also change show_callback and friends to match! */
        if (!command) {
                stream->write_function(stream, "-USAGE: %s\n", SHOW_SYNTAX);
                return SWITCH_STATUS_SUCCESS;
-       } else if (!strcasecmp(command, "codec") || !strcasecmp(command, "dialplan") || !strcasecmp(command, "file") || !strcasecmp(command, "timer")) {
+       } else if (!strncasecmp(command, "codec", 5) || 
+                          !strncasecmp(command, "dialplan", 8) || 
+                          !strncasecmp(command, "file", 4) || 
+                          !strncasecmp(command, "timer", 5) || 
+                          !strncasecmp(command, "chat", 4) || 
+                          !strncasecmp(command, "say", 3) || 
+                          !strncasecmp(command, "management", 10) || 
+                          !strncasecmp(command, "endpoint", 8)) {
+               if (end_of(command) == 's') {
+                       end_of(command) = '\0';
+               }
                sprintf(sql, "select type, name from interfaces where type = '%s' order by type,name", command);
+       } else if (!strcasecmp(command, "interfaces")) {
+               sprintf(sql, "select type, name from interfaces order by type,name");
+       } else if (!strcasecmp(command, "interface_types")) {
+               sprintf(sql, "select type,count(type) as total from interfaces group by type order by type");
        } else if (!strcasecmp(command, "tasks")) {
                sprintf(sql, "select * from %s", command);
        } else if (!strcasecmp(command, "application") || !strcasecmp(command, "api")) {
@@ -2407,13 +2422,11 @@ SWITCH_STANDARD_API(global_setvar_function)
 SWITCH_STANDARD_API(global_getvar_function)
 {
 
-       if (!switch_strlen_zero(cmd)) {
+       if (switch_strlen_zero(cmd)) {
+               switch_core_dump_variables(stream);
+       } else {
                stream->write_function(stream, "%s", switch_str_nil(switch_core_get_variable(cmd)));
-               goto done;
        }
-
-       stream->write_function(stream, "-USAGE: %s\n", GLOBAL_GETVAR_SYNTAX);
-  done:
        return SWITCH_STATUS_SUCCESS;
 }
 
index 0de5713f74cbd8e0c95afd2195d5e32fc24b1f44..9a6801ed456617102fac123fc9bb11ea3143f963 100644 (file)
@@ -139,6 +139,22 @@ SWITCH_DECLARE(const switch_state_handler_table_t *) switch_core_get_state_handl
        return runtime.state_handlers[index];
 }
 
+SWITCH_DECLARE(void) switch_core_dump_variables(switch_stream_handle_t *stream)
+{
+       switch_hash_index_t *hi;
+       const void *var;
+       void *val;
+       switch_mutex_lock(runtime.global_mutex);
+       for (hi = switch_hash_first(NULL, runtime.global_vars); hi; hi = switch_hash_next(hi)) {
+               char *vvar, *vval;
+               switch_hash_this(hi, &var, NULL, &val);
+               vvar = (char *) var;
+               vval = (char *) val;
+               stream->write_function(stream, "%s=%s\n", vvar, vval);
+       }
+       switch_mutex_unlock(runtime.global_mutex);
+}
+
 SWITCH_DECLARE(char *) switch_core_get_variable(const char *varname)
 {
        char *val;
index 015f8c89f1d9d13ad0f11596ce3251f763b8b00c..43a810bedb51802db77cafb9a3ba23072ff95ef7 100644 (file)
@@ -138,6 +138,11 @@ static switch_status_t switch_loadable_module_process(char *key, switch_loadable
                        } else {
                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Adding Endpoint '%s'\n", ptr->interface_name);
                                switch_core_hash_insert(loadable_modules.endpoint_hash, ptr->interface_name, (const void *) ptr);
+                               if (switch_event_create(&event, SWITCH_EVENT_MODULE_LOAD) == SWITCH_STATUS_SUCCESS) {
+                                       switch_event_add_header(event, SWITCH_STACK_BOTTOM, "type", "%s", "endpoint");
+                                       switch_event_add_header(event, SWITCH_STACK_BOTTOM, "name", "%s", ptr->interface_name);
+                                       switch_event_fire(&event);
+                               }
                        }
                }
        }
index 04c66d2c7a3f1c32de4edeab890cce31af1df146..1ee5fdc2305ae5a040e452cf027dfff6e7b6c895 100644 (file)
@@ -701,13 +701,14 @@ SWITCH_DECLARE(switch_status_t) switch_find_local_ip(char *buf, int len, int fam
                return status;
        }
 
-       switch_copy_string(buf, "127.0.0.1", len);
-
+       
        switch (family) {
        case AF_INET:
+               switch_copy_string(buf, "127.0.0.1", len);
                base = "82.45.148.209";
                break;
        case AF_INET6:
+               switch_copy_string(buf, "::1", len);
                base = "2001:503:BA3E::2:30"; // DNS Root server A 
                break;
        default: