aboutsummaryrefslogtreecommitdiffstats
path: root/apps/app_groupcount.c
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2005-11-06 18:42:39 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2005-11-06 18:42:39 +0000
commit34ddd2633bcda4d3fc57ebf7028c34a37ec2f29f (patch)
treee07be65c7eb13e83090bda2ba8410bc3e0ad1c8e /apps/app_groupcount.c
parentcc1e66bff35882e710df4c43c4f8836b9c8d03fd (diff)
issue #5623
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@6983 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps/app_groupcount.c')
-rwxr-xr-xapps/app_groupcount.c53
1 files changed, 41 insertions, 12 deletions
diff --git a/apps/app_groupcount.c b/apps/app_groupcount.c
index f47468acd..95aa92781 100755
--- a/apps/app_groupcount.c
+++ b/apps/app_groupcount.c
@@ -140,27 +140,50 @@ static int group_check_exec(struct ast_channel *chan, void *data)
char limit[80]="";
char category[80]="";
static int deprecation_warning = 0;
+ char *parse;
+ int priority_jump = 0;
+ AST_DECLARE_APP_ARGS(args,
+ AST_APP_ARG(max);
+ AST_APP_ARG(options);
+ );
+
+ LOCAL_USER_ADD(u);
if (!deprecation_warning) {
ast_log(LOG_WARNING, "The CheckGroup application has been deprecated, please use a combination of the GotoIf application and the GROUP_COUNT() function.\n");
deprecation_warning = 1;
}
- if (ast_strlen_zero(data)) {
- ast_log(LOG_WARNING, "CheckGroup requires an argument(max[@category])\n");
- return res;
+ if (!(parse = ast_strdupa(data))) {
+ ast_log(LOG_WARNING, "Memory Error!\n");
+ LOCAL_USER_REMOVE(u);
+ return -1;
}
- LOCAL_USER_ADD(u);
+ AST_STANDARD_APP_ARGS(args, parse);
- ast_app_group_split_group(data, limit, sizeof(limit), category, sizeof(category));
+ if (args.options) {
+ if (strchr(args.options, 'j'))
+ priority_jump = 1;
+ }
+
+ if (ast_strlen_zero(args.max)) {
+ ast_log(LOG_WARNING, "CheckGroup requires an argument(max[@category][|options])\n");
+ return res;
+ }
+
+ ast_app_group_split_group(args.max, limit, sizeof(limit), category, sizeof(category));
if ((sscanf(limit, "%d", &max) == 1) && (max > -1)) {
count = ast_app_group_get_count(pbx_builtin_getvar_helper(chan, category), category);
if (count > max) {
- if (!ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101))
- res = -1;
- }
+ pbx_builtin_setvar_helper(chan, "CHECKGROUPSTATUS", "OVERMAX");
+ if (priority_jump || option_priority_jumping) {
+ if (!ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101))
+ res = -1;
+ }
+ } else
+ pbx_builtin_setvar_helper(chan, "CHECKGROUPSTATUS", "OK");
} else
ast_log(LOG_WARNING, "CheckGroup requires a positive integer argument (max)\n");
@@ -243,12 +266,18 @@ static char *group_set_descrip =
"Set(GROUP=group). Always returns 0.\n";
static char *group_check_descrip =
-"Usage: CheckGroup(max[@category])\n"
+"Usage: CheckGroup(max[@category][|options])\n"
" Checks that the current number of total channels in the\n"
"current channel's group does not exceed 'max'. If the number\n"
-"does not exceed 'max', we continue to the next step. If the\n"
-"number does in fact exceed max, if priority n+101 exists, then\n"
-"execution continues at that step, otherwise -1 is returned.\n";
+"does not exceed 'max', we continue to the next step. \n"
+" The option string may contain zero of the following character:\n"
+" 'j' -- jump to n+101 priority if the number does in fact exceed max,\n"
+" and priority n+101 exists. Execuation then continues at that\n"
+" step, otherwise -1 is returned.\n"
+" This application sets the following channel variable upon successful completion:\n"
+" CHECKGROUPSTATUS The status of the check that the current channel's\n"
+" group does not exceed 'max'. It's value is one of\n"
+" OK | OVERMAX \n";
static char *group_match_count_descrip =
"Usage: GetGroupMatchCount(groupmatch[@category])\n"