Index: funcs/func_groupcount.c =================================================================== --- funcs/func_groupcount.c (revision 87019) +++ funcs/func_groupcount.c (working copy) @@ -42,11 +42,27 @@ { int count = -1; char group[80] = "", category[80] = ""; + struct ast_group_info *gi = NULL; ast_app_group_split_group(data, group, sizeof(group), category, sizeof(category)); + if (!ast_strlen_zero(group)) + count = ast_app_group_get_count(group, category); + else { + 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) + count = ast_app_group_get_count(gi->group, gi->category); + ast_app_group_list_unlock(); + } - if ((count = ast_app_group_get_count(group, category)) == -1) + if (count == -1) ast_log(LOG_NOTICE, "No group could be found for channel '%s'\n", chan->name); else snprintf(buf, len, "%d", count);