98 static int group_count_function_read(
struct ast_channel *chan,
const char *cmd,
99 char *data,
char *buf,
size_t len)
103 char group[80] =
"", category[80] =
"";
106 ast_log(LOG_WARNING,
"No channel was provided to %s function.\n", cmd);
114 if (ast_strlen_zero(group)) {
119 if (gi->chan != chan)
121 if (ast_strlen_zero(category) || (!ast_strlen_zero(gi->category) && !strcasecmp(gi->category, category)))
126 if (!ast_strlen_zero(gi->category))
133 ast_log(LOG_NOTICE,
"No group could be found for channel '%s'\n", ast_channel_name(chan));
135 snprintf(buf, len,
"%d", count);
143 .
name =
"GROUP_COUNT",
144 .read = group_count_function_read,
148 static int group_match_count_function_read(
struct ast_channel *chan,
149 const char *cmd,
char *data,
char *buf,
153 char category[80] =
"";
158 if (!ast_strlen_zero(group)) {
161 snprintf(buf, len,
"%d", count);
169 .
name =
"GROUP_MATCH_COUNT",
170 .read = group_match_count_function_read,
175 static int group_function_read(
struct ast_channel *chan,
const char *cmd,
176 char *data,
char *buf,
size_t len)
182 ast_log(LOG_WARNING,
"No channel was provided to %s function.\n", cmd);
189 if (gi->chan != chan)
191 if (ast_strlen_zero(data))
193 if (!ast_strlen_zero(gi->category) && !strcasecmp(gi->category, data))
207 static int group_function_write(
struct ast_channel *chan,
const char *cmd,
208 char *data,
const char *value)
213 ast_log(LOG_WARNING,
"No channel was provided to %s function.\n", cmd);
221 if (!ast_strlen_zero(data)) {
222 snprintf(grpcat,
sizeof(grpcat),
"%s@%s", value, data);
229 "Setting a group requires an argument (group name)\n");
236 .read = group_function_read,
237 .write = group_function_write,
240 static int group_list_function_read(
struct ast_channel *chan,
const char *cmd,
241 char *data,
char *buf,
size_t len)
244 char tmp1[1024] =
"";
245 char tmp2[1024] =
"";
253 if (gi->chan != chan)
255 if (!ast_strlen_zero(tmp1)) {
257 if (!ast_strlen_zero(gi->category))
258 snprintf(tmp1,
sizeof(tmp1),
"%s %s@%s", tmp2, gi->group, gi->category);
260 snprintf(tmp1,
sizeof(tmp1),
"%s %s", tmp2, gi->group);
262 if (!ast_strlen_zero(gi->category))
263 snprintf(tmp1,
sizeof(tmp1),
"%s@%s", gi->group, gi->category);
265 snprintf(tmp1,
sizeof(tmp1),
"%s", gi->group);
277 .
name =
"GROUP_LIST",
278 .read = group_list_function_read,
282 static int unload_module(
void)
294 static int load_module(
void)
306 AST_MODULE_INFO_STANDARD(
ASTERISK_GPL_KEY,
"Channel group dialplan functions");
Main Channel structure associated with a channel.
Asterisk main include file. File version handling, generic pbx functions.
struct ast_group_info * ast_app_group_list_head(void)
Get the head of the group count list.
#define AST_LIST_NEXT(elm, field)
Returns the next entry in the list after the given entry.
int ast_custom_function_unregister(struct ast_custom_function *acf)
Unregister a custom function.
General Asterisk PBX channel definitions.
Data structure associated with a custom dialplan function.
Core PBX routines and definitions.
int ast_app_group_list_unlock(void)
Unlock the group count list.
int ast_app_group_split_group(const char *data, char *group, int group_max, char *category, int category_max)
Split a group string into group and category, returning a default category if none is provided...
int ast_app_group_match_get_count(const char *groupmatch, const char *category)
Get the current channel count of all groups that match the specified pattern and category.
int ast_app_group_list_rdlock(void)
Read Lock the group count list.
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.
Application convenience functions, designed to give consistent look and feel to Asterisk apps...
#define ast_custom_function_register(acf)
Register a custom function.
int ast_app_group_set_channel(struct ast_channel *chan, const char *data)
Set the group for a channel, splitting the provided data into group and category, if specified...
int ast_app_group_get_count(const char *group, const char *category)
Get the current channel count of the specified group and category.