summaryrefslogtreecommitdiff
path: root/funcs/func_groupcount.c
diff options
context:
space:
mode:
authorJoshua Colp <jcolp@digium.com>2008-01-08 19:55:56 +0000
committerJoshua Colp <jcolp@digium.com>2008-01-08 19:55:56 +0000
commitd1a42bbcd9c9e135b20e577995b81d9b851d5ba8 (patch)
tree4336f9d10f5b08360eb9fad517c7aff676df0d51 /funcs/func_groupcount.c
parent3ad9a66e0f44e6abdc64117d95ddf1cb44f41658 (diff)
Merged revisions 97152 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r97152 | file | 2008-01-08 15:53:52 -0400 (Tue, 08 Jan 2008) | 4 lines If no group has been provided to the GROUP_COUNT dialplan function then use the first one specific to the channel. (closes issue #11077) Reported by: m4him ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@97153 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'funcs/func_groupcount.c')
-rw-r--r--funcs/func_groupcount.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/funcs/func_groupcount.c b/funcs/func_groupcount.c
index 89d92d8a5..a4476955d 100644
--- a/funcs/func_groupcount.c
+++ b/funcs/func_groupcount.c
@@ -40,6 +40,24 @@ static int group_count_function_read(struct ast_channel *chan, const char *cmd,
ast_app_group_split_group(data, group, sizeof(group), category,
sizeof(category));
+ /* If no group has been provided let's find one */
+ if (ast_strlen_zero(group)) {
+ struct ast_group_info *gi = NULL;
+
+ ast_app_group_list_rdlock();
+ for (gi = ast_app_group_list_head(); gi; gi = AST_LIST_NEXT(gi, list)) {
+ if (gi->chan != chan)
+ continue;
+ if (ast_strlen_zero(category) || (!ast_strlen_zero(gi->category) && !strcasecmp(gi->category, category)))
+ break;
+ }
+ if (gi) {
+ ast_copy_string(group, gi->group, sizeof(group));
+ ast_copy_string(category, gi->category, sizeof(category));
+ }
+ ast_app_group_list_unlock();
+ }
+
if ((count = ast_app_group_get_count(group, category)) == -1)
ast_log(LOG_NOTICE, "No group could be found for channel '%s'\n", chan->name);
else