From 3e5368b763895a5cfea775b6c6fd25c76d4d75ef Mon Sep 17 00:00:00 2001 From: Mark Spencer Date: Sat, 16 Oct 2004 21:14:05 +0000 Subject: [PATCH] Provide module command completion (make twisted happy) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@4022 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- cli.c | 27 +++++++++++++++-- include/asterisk/module.h | 4 ++- loader.c | 63 +++++++++++++++++++++++++++++++++++---- 3 files changed, 84 insertions(+), 10 deletions(-) diff --git a/cli.c b/cli.c index 983c25deab..c6be4fefed 100755 --- a/cli.c +++ b/cli.c @@ -117,11 +117,21 @@ static int handle_load(int fd, int argc, char *argv[]) static int handle_reload(int fd, int argc, char *argv[]) { int x; + int res; if (argc < 1) return RESULT_SHOWUSAGE; if (argc > 1) { - for (x=1;xresource, strlen(word)) && (m->reload || !needsreload)) { + if (++which > state) + break; + } + m = m->next; + } + if (m) { + ret = strdup(m->resource); + } else { + ret = NULL; + if (!strncasecmp(word, "astconfig", strlen(word))) { + if (++which > state) + ret = strdup("astconfig"); + } else if (!strncasecmp(word, "manager", strlen(word))) { + if (++which > state) + ret = strdup("manager"); + } else if (!strncasecmp(word, "enum", strlen(word))) { + if (++which > state) + ret = strdup("enum"); + } else if (!strncasecmp(word, "rtp", strlen(word))) { + if (++which > state) + ret = strdup("rtp"); + } + + } + ast_mutex_unlock(&modlock); + return ret; +} +int ast_module_reload(const char *name) +{ + struct module *m; + int reloaded = 0; /* We'll do the logger and manager the favor of calling its reload here first */ if (ast_mutex_trylock(&reloadlock)) { ast_verbose("The previous reload command didn't finish yet\n"); - return; + return -1; } - if (!name || !strcasecmp(name, "astconfig")) + if (!name || !strcasecmp(name, "astconfig")) { read_ast_cust_config(); - if (!name || !strcasecmp(name, "manager")) + reloaded = 2; + } + if (!name || !strcasecmp(name, "manager")) { reload_manager(); - if (!name || !strcasecmp(name, "enum")) + reloaded = 2; + } + if (!name || !strcasecmp(name, "enum")) { ast_enum_reload(); - if (!name || !strcasecmp(name, "rtp")) + reloaded = 2; + } + if (!name || !strcasecmp(name, "rtp")) { ast_rtp_reload(); + reloaded = 2; + } time(&ast_lastreloadtime); ast_mutex_lock(&modlock); m = module_list; while(m) { if (!name || !strcasecmp(name, m->resource)) { + if (reloaded < 1) + reloaded = 1; if (m->reload) { + reloaded = 2; if (option_verbose > 2) ast_verbose(VERBOSE_PREFIX_3 "Reloading module '%s' (%s)\n", m->resource, m->description()); m->reload(); @@ -181,6 +231,7 @@ void ast_module_reload(const char *name) } ast_mutex_unlock(&modlock); ast_mutex_unlock(&reloadlock); + return reloaded; } int ast_load_resource(char *resource_name)