aboutsummaryrefslogtreecommitdiffstats
path: root/funcs/func_groupcount.c
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2008-10-06 21:09:05 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2008-10-06 21:09:05 +0000
commit74ecba3091505ff537561b075f028675d514ea55 (patch)
treee9c0dfb82bcb18454c0f9a712acbe7933fc7ad81 /funcs/func_groupcount.c
parentdc8b7c68a3cb790827b79a9d12d072f8acfa72e6 (diff)
Merged revisions 146799 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r146799 | tilghman | 2008-10-06 15:52:04 -0500 (Mon, 06 Oct 2008) | 8 lines Dialplan functions should not actually return 0, unless they have modified the workspace. To signal an error (and no change to the workspace), -1 should be returned instead. (closes issue #13340) Reported by: kryptolus Patches: 20080827__bug13340__2.diff.txt uploaded by Corydon76 (license 14) ........ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@146802 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'funcs/func_groupcount.c')
-rw-r--r--funcs/func_groupcount.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/funcs/func_groupcount.c b/funcs/func_groupcount.c
index f0d7df1b5..b70a42e94 100644
--- a/funcs/func_groupcount.c
+++ b/funcs/func_groupcount.c
@@ -34,6 +34,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
static int group_count_function_read(struct ast_channel *chan, const char *cmd,
char *data, char *buf, size_t len)
{
+ int ret = -1;
int count = -1;
char group[80] = "", category[80] = "";
@@ -59,12 +60,14 @@ static int group_count_function_read(struct ast_channel *chan, const char *cmd,
ast_app_group_list_unlock();
}
- if ((count = ast_app_group_get_count(group, category)) == -1)
+ 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
+ } else {
snprintf(buf, len, "%d", count);
+ ret = 0;
+ }
- return 0;
+ return ret;
}
static struct ast_custom_function group_count_function = {
@@ -91,9 +94,10 @@ static int group_match_count_function_read(struct ast_channel *chan,
if (!ast_strlen_zero(group)) {
count = ast_app_group_match_get_count(group, category);
snprintf(buf, len, "%d", count);
+ return 0;
}
- return 0;
+ return -1;
}
static struct ast_custom_function group_match_count_function = {
@@ -111,6 +115,7 @@ static struct ast_custom_function group_match_count_function = {
static int group_function_read(struct ast_channel *chan, const char *cmd,
char *data, char *buf, size_t len)
{
+ int ret = -1;
struct ast_group_info *gi = NULL;
ast_app_group_list_rdlock();
@@ -124,12 +129,14 @@ static int group_function_read(struct ast_channel *chan, const char *cmd,
break;
}
- if (gi)
+ if (gi) {
ast_copy_string(buf, gi->group, len);
+ ret = 0;
+ }
ast_app_group_list_unlock();
- return 0;
+ return ret;
}
static int group_function_write(struct ast_channel *chan, const char *cmd,