aboutsummaryrefslogtreecommitdiffstats
path: root/funcs/func_groupcount.c
diff options
context:
space:
mode:
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 bb2bcf49c..7f6f8937b 100644
--- a/funcs/func_groupcount.c
+++ b/funcs/func_groupcount.c
@@ -39,6 +39,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
static int group_count_function_read(struct ast_channel *chan, char *cmd,
char *data, char *buf, size_t len)
{
+ int ret = -1;
int count = -1;
char group[80] = "", category[80] = "";
@@ -64,12 +65,14 @@ static int group_count_function_read(struct ast_channel *chan, 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 = {
@@ -96,9 +99,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 = {
@@ -116,6 +120,7 @@ static struct ast_custom_function group_match_count_function = {
static int group_function_read(struct ast_channel *chan, char *cmd,
char *data, char *buf, size_t len)
{
+ int ret = -1;
struct ast_group_info *gi = NULL;
ast_app_group_list_lock();
@@ -129,12 +134,14 @@ static int group_function_read(struct ast_channel *chan, 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, char *cmd,