aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorfile <file@f38db490-d61c-443f-a65b-d21fe96a405b>2007-04-25 18:52:50 +0000
committerfile <file@f38db490-d61c-443f-a65b-d21fe96a405b>2007-04-25 18:52:50 +0000
commit46218b546b269f611f3ab9558586e9091e6cc473 (patch)
treeefde09d37f3497fb38ebf4de92dc852dc5724c1e /apps
parent16ed3051f748e190ab73a2e326c958af9ab3e9a6 (diff)
Merge rewritten group counting support. No more storing data on the variable list of the channels. That was bad, mmmk? (issue #7497 reported by sabbathbh)
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.2@61804 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps')
-rw-r--r--apps/app_groupcount.c32
1 files changed, 12 insertions, 20 deletions
diff --git a/apps/app_groupcount.c b/apps/app_groupcount.c
index 87d313209..496f62b8f 100644
--- a/apps/app_groupcount.c
+++ b/apps/app_groupcount.c
@@ -201,10 +201,8 @@ static int group_show_channels(int fd, int argc, char *argv[])
{
#define FORMAT_STRING "%-25s %-20s %-20s\n"
- struct ast_channel *c = NULL;
int numchans = 0;
- struct ast_var_t *current;
- struct varshead *headp;
+ struct ast_group_info *gi = NULL;
regex_t regexbuf;
int havepattern = 0;
@@ -218,26 +216,20 @@ static int group_show_channels(int fd, int argc, char *argv[])
}
ast_cli(fd, FORMAT_STRING, "Channel", "Group", "Category");
- while ( (c = ast_channel_walk_locked(c)) != NULL) {
- headp=&c->varshead;
- AST_LIST_TRAVERSE(headp,current,entries) {
- if (!strncmp(ast_var_name(current), GROUP_CATEGORY_PREFIX "_", strlen(GROUP_CATEGORY_PREFIX) + 1)) {
- if (!havepattern || !regexec(&regexbuf, ast_var_value(current), 0, NULL, 0)) {
- ast_cli(fd, FORMAT_STRING, c->name, ast_var_value(current),
- (ast_var_name(current) + strlen(GROUP_CATEGORY_PREFIX) + 1));
- numchans++;
- }
- } else if (!strcmp(ast_var_name(current), GROUP_CATEGORY_PREFIX)) {
- if (!havepattern || !regexec(&regexbuf, ast_var_value(current), 0, NULL, 0)) {
- ast_cli(fd, FORMAT_STRING, c->name, ast_var_value(current), "(default)");
- numchans++;
- }
- }
+
+ ast_app_group_list_lock();
+
+ gi = ast_app_group_list_head();
+ while (gi) {
+ if (!havepattern || !regexec(&regexbuf, gi->group, 0, NULL, 0)) {
+ ast_cli(fd, FORMAT_STRING, gi->chan->name, gi->group, (ast_strlen_zero(gi->category) ? "(default)" : gi->category));
+ numchans++;
}
- numchans++;
- ast_mutex_unlock(&c->lock);
+ gi = AST_LIST_NEXT(gi, list);
}
+ ast_app_group_list_unlock();
+
if (havepattern)
regfree(&regexbuf);