summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorMark Michelson <mmichelson@digium.com>2014-07-25 16:47:17 +0000
committerMark Michelson <mmichelson@digium.com>2014-07-25 16:47:17 +0000
commitdcf1ad14da48db3476dcaeeb3d3fb6b7d00a28ca (patch)
treebd9312d3192f4fbb97cb217093b85e75d1346cf6 /main
parent355dc3d2ad98db624184a797206ccb88f4b8a526 (diff)
Add module support level to ast_module_info structure. Print it in CLI "module show" .
ASTERISK-23919 #close Reported by Malcolm Davenport Review: https://reviewboard.asterisk.org/r/3802 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@419592 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main')
-rw-r--r--main/cli.c13
-rw-r--r--main/loader.c20
2 files changed, 25 insertions, 8 deletions
diff --git a/main/cli.c b/main/cli.c
index bb8e33e44..b7e5c1586 100644
--- a/main/cli.c
+++ b/main/cli.c
@@ -772,17 +772,20 @@ static char *handle_unload(struct ast_cli_entry *e, int cmd, struct ast_cli_args
return CLI_SUCCESS;
}
-#define MODLIST_FORMAT "%-30s %-40.40s %-10d %s\n"
-#define MODLIST_FORMAT2 "%-30s %-40.40s %-10s %s\n"
+#define MODLIST_FORMAT "%-30s %-40.40s %-10d %-11s %13s\n"
+#define MODLIST_FORMAT2 "%-30s %-40.40s %-10s %-11s %13s\n"
AST_MUTEX_DEFINE_STATIC(climodentrylock);
static int climodentryfd = -1;
-static int modlist_modentry(const char *module, const char *description, int usecnt, const char *status, const char *like)
+static int modlist_modentry(const char *module, const char *description,
+ int usecnt, const char *status, const char *like,
+ enum ast_module_support_level support_level)
{
/* Comparing the like with the module */
if (strcasestr(module, like) ) {
- ast_cli(climodentryfd, MODLIST_FORMAT, module, description, usecnt, status);
+ ast_cli(climodentryfd, MODLIST_FORMAT, module, description, usecnt,
+ status, ast_module_support_level_to_string(support_level));
return 1;
}
return 0;
@@ -909,7 +912,7 @@ static char *handle_modlist(struct ast_cli_entry *e, int cmd, struct ast_cli_arg
ast_mutex_lock(&climodentrylock);
climodentryfd = a->fd; /* global, protected by climodentrylock */
- ast_cli(a->fd, MODLIST_FORMAT2, "Module", "Description", "Use Count", "Status");
+ ast_cli(a->fd, MODLIST_FORMAT2, "Module", "Description", "Use Count", "Status", "Support Level");
ast_cli(a->fd,"%d modules loaded\n", ast_update_module_list(modlist_modentry, like));
climodentryfd = -1;
ast_mutex_unlock(&climodentrylock);
diff --git a/main/loader.c b/main/loader.c
index b44a1a489..343863a03 100644
--- a/main/loader.c
+++ b/main/loader.c
@@ -1350,8 +1350,10 @@ void ast_update_use_count(void)
AST_LIST_UNLOCK(&updaters);
}
-int ast_update_module_list(int (*modentry)(const char *module, const char *description, int usecnt, const char *status, const char *like),
- const char *like)
+int ast_update_module_list(int (*modentry)(const char *module, const char *description,
+ int usecnt, const char *status, const char *like,
+ enum ast_module_support_level support_level),
+ const char *like)
{
struct ast_module *cur;
int unlock = -1;
@@ -1368,7 +1370,7 @@ int ast_update_module_list(int (*modentry)(const char *module, const char *descr
AST_LIST_TRAVERSE(&alpha_module_list, cur, list_entry) {
total_mod_loaded += modentry(cur->resource, cur->info->description, cur->usecount,
- cur->flags.running ? "Running" : "Not Running", like);
+ cur->flags.running ? "Running" : "Not Running", like, cur->info->support_level);
}
if (unlock) {
@@ -1445,3 +1447,15 @@ void ast_module_unref(struct ast_module *mod)
ast_atomic_fetchadd_int(&mod->usecount, -1);
ast_update_use_count();
}
+
+const char *support_level_map [] = {
+ [AST_MODULE_SUPPORT_UNKNOWN] = "unknown",
+ [AST_MODULE_SUPPORT_CORE] = "core",
+ [AST_MODULE_SUPPORT_EXTENDED] = "extended",
+ [AST_MODULE_SUPPORT_DEPRECATED] = "deprecated",
+};
+
+const char *ast_module_support_level_to_string(enum ast_module_support_level support_level)
+{
+ return support_level_map[support_level];
+}