From 445731eea186ffd2fa7ac2b268180a5ebd6438b5 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Fri, 17 Sep 2010 14:10:30 -0500 Subject: [PATCH] add inline lists for tab complete db using ::[a:b syntax --- src/mod/endpoints/mod_sofia/mod_sofia.c | 6 ++++-- src/switch_console.c | 25 +++++++++++++++++++++++-- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index 68c99f1ac2..5039fefe50 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -4618,8 +4618,10 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_sofia_load) switch_console_set_complete("add sofia help"); switch_console_set_complete("add sofia status"); switch_console_set_complete("add sofia xmlstatus"); - switch_console_set_complete("add sofia loglevel"); - switch_console_set_complete("add sofia tracelevel"); + + switch_console_set_complete("add sofia loglevel ::[all:default:tport:iptsec:nea:nta:nth_client:nth_server:nua:soa:sresolv:stun ::[0:1:2:3:4:5:6:7:8:9"); + switch_console_set_complete("add sofia tracelevel ::[console:alert:crit:err:warning:notice:info:debug"); + switch_console_set_complete("add sofia profile"); switch_console_set_complete("add sofia profile restart all"); diff --git a/src/switch_console.c b/src/switch_console.c index 30d1d97fed..06a7e0de7a 100644 --- a/src/switch_console.c +++ b/src/switch_console.c @@ -483,9 +483,29 @@ static int comp_callback(void *pArg, int argc, char **argv, char **columnNames) return -1; } + if (!zstr(target) && *target == ':' && *(target + 1) == ':' && *(target + 2) == '[') { + char *p = target + 3, *list = NULL; + + if (p) { + char *argv[100] = { 0 }; + char *r_argv[1] = { 0 }, *r_cols[1] = {0}; + list = strdup(p); + + argc = switch_separate_string(list, ':', argv, (sizeof(argv) / sizeof(argv[0]))); + + for (i = 0; i < argc; i++) { + if (!cur || !strncmp(argv[i], cur, strlen(cur))) { + r_argv[0] = argv[i]; + comp_callback(h, 1, r_argv, r_cols); + } + } + switch_safe_free(list); + } + return 0; + } + if (!zstr(target) && *target == ':' && *(target + 1) == ':') { - char *r_argv[1] = { 0 }, *r_cols[1] = { - 0}; + char *r_argv[1] = { 0 }, *r_cols[1] = {0}; switch_console_callback_match_t *matches; if (switch_console_run_complete_func(target, str, cur, &matches) == SWITCH_STATUS_SUCCESS) { switch_console_callback_match_node_t *m; @@ -797,6 +817,7 @@ SWITCH_DECLARE(unsigned char) switch_console_complete(const char *line, const ch } stream.write_function(&stream, " and hostname='%s' order by a%d", switch_core_get_variable("hostname"), h.words + 1); + switch_cache_db_execute_sql_callback(db, stream.data, comp_callback, &h, &errmsg); if (errmsg) {