mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-29 18:19:30 +00:00
Add option for "show modules like" (bug #2643)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@3996 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
25
cli.c
25
cli.c
@@ -213,16 +213,20 @@ static int handle_unload(int fd, int argc, char *argv[])
|
|||||||
AST_MUTEX_DEFINE_STATIC(climodentrylock);
|
AST_MUTEX_DEFINE_STATIC(climodentrylock);
|
||||||
static int climodentryfd = -1;
|
static int climodentryfd = -1;
|
||||||
|
|
||||||
static int modlist_modentry(char *module, char *description, int usecnt)
|
static int modlist_modentry(char *module, char *description, int usecnt, char *like)
|
||||||
{
|
{
|
||||||
ast_cli(climodentryfd, MODLIST_FORMAT, module, description, usecnt);
|
/* Comparing the like with the module */
|
||||||
|
if ( strstr(module,like) != NULL) {
|
||||||
|
ast_cli(climodentryfd, MODLIST_FORMAT, module, description, usecnt);
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char modlist_help[] =
|
static char modlist_help[] =
|
||||||
"Usage: show modules\n"
|
"Usage: show modules [like keyword]\n"
|
||||||
" Shows Asterisk modules currently in use, and usage "
|
" Shows Asterisk modules currently in use, and usage statistics.\n";
|
||||||
"statistics.\n";
|
|
||||||
|
|
||||||
static char version_help[] =
|
static char version_help[] =
|
||||||
"Usage: show version\n"
|
"Usage: show version\n"
|
||||||
@@ -332,12 +336,19 @@ static int handle_showuptime(int fd, int argc, char *argv[])
|
|||||||
|
|
||||||
static int handle_modlist(int fd, int argc, char *argv[])
|
static int handle_modlist(int fd, int argc, char *argv[])
|
||||||
{
|
{
|
||||||
if (argc != 2)
|
char *like = "";
|
||||||
|
if (argc == 3)
|
||||||
return RESULT_SHOWUSAGE;
|
return RESULT_SHOWUSAGE;
|
||||||
|
else if (argc >= 4) {
|
||||||
|
if ( strcmp(argv[2],"like") )
|
||||||
|
return RESULT_SHOWUSAGE;
|
||||||
|
like = argv[3];
|
||||||
|
}
|
||||||
|
|
||||||
ast_mutex_lock(&climodentrylock);
|
ast_mutex_lock(&climodentrylock);
|
||||||
climodentryfd = fd;
|
climodentryfd = fd;
|
||||||
ast_cli(fd, MODLIST_FORMAT2, "Module", "Description", "Use Count");
|
ast_cli(fd, MODLIST_FORMAT2, "Module", "Description", "Use Count");
|
||||||
ast_cli(fd,"%d modules loaded\n",ast_update_module_list(modlist_modentry));
|
ast_cli(fd,"%d modules loaded\n",ast_update_module_list(modlist_modentry,like));
|
||||||
climodentryfd = -1;
|
climodentryfd = -1;
|
||||||
ast_mutex_unlock(&climodentrylock);
|
ast_mutex_unlock(&climodentrylock);
|
||||||
return RESULT_SUCCESS;
|
return RESULT_SUCCESS;
|
||||||
|
@@ -114,7 +114,7 @@ void ast_update_use_count(void);
|
|||||||
* For each of the modules loaded, modentry will be executed with the resource, description,
|
* For each of the modules loaded, modentry will be executed with the resource, description,
|
||||||
* and usecount values of each particular module.
|
* and usecount values of each particular module.
|
||||||
*/
|
*/
|
||||||
int ast_update_module_list(int (*modentry)(char *module, char *description, int usecnt));
|
int ast_update_module_list(int (*modentry)(char *module, char *description, int usecnt, char *like), char *like);
|
||||||
|
|
||||||
//! Ask this procedure to be run with modules have been updated
|
//! Ask this procedure to be run with modules have been updated
|
||||||
/*!
|
/*!
|
||||||
|
13
loader.c
13
loader.c
@@ -314,16 +314,16 @@ int ast_load_resource(char *resource_name)
|
|||||||
ast_verbose(VERBOSE_PREFIX_1 "Loaded %s => (%s)\n", fn, m->description());
|
ast_verbose(VERBOSE_PREFIX_1 "Loaded %s => (%s)\n", fn, m->description());
|
||||||
}
|
}
|
||||||
|
|
||||||
// add module 'm' to end of module_list chain
|
/* add module 'm' to end of module_list chain
|
||||||
// so reload commands will be issued in same order modules were loaded
|
so reload commands will be issued in same order modules were loaded */
|
||||||
m->next = NULL;
|
m->next = NULL;
|
||||||
if (module_list == NULL) {
|
if (module_list == NULL) {
|
||||||
// empty list so far, add at front
|
/* empty list so far, add at front */
|
||||||
module_list = m;
|
module_list = m;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
struct module *i;
|
struct module *i;
|
||||||
// find end of chain, and add there
|
/* find end of chain, and add there */
|
||||||
for (i = module_list; i->next; i = i->next)
|
for (i = module_list; i->next; i = i->next)
|
||||||
;
|
;
|
||||||
i->next = m;
|
i->next = m;
|
||||||
@@ -460,7 +460,7 @@ void ast_update_use_count(void)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int ast_update_module_list(int (*modentry)(char *module, char *description, int usecnt))
|
int ast_update_module_list(int (*modentry)(char *module, char *description, int usecnt, char *like), char *like)
|
||||||
{
|
{
|
||||||
struct module *m;
|
struct module *m;
|
||||||
int unlock = -1;
|
int unlock = -1;
|
||||||
@@ -469,9 +469,8 @@ int ast_update_module_list(int (*modentry)(char *module, char *description, int
|
|||||||
unlock = 0;
|
unlock = 0;
|
||||||
m = module_list;
|
m = module_list;
|
||||||
while(m) {
|
while(m) {
|
||||||
modentry(m->resource, m->description(), m->usecount());
|
total_mod_loaded += modentry(m->resource, m->description(), m->usecount(), like);
|
||||||
m = m->next;
|
m = m->next;
|
||||||
total_mod_loaded++;
|
|
||||||
}
|
}
|
||||||
if (unlock)
|
if (unlock)
|
||||||
ast_mutex_unlock(&modlock);
|
ast_mutex_unlock(&modlock);
|
||||||
|
Reference in New Issue
Block a user