#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include "asterisk.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/logger.h"
#include "asterisk/utils.h"
#include "asterisk/app.h"
Include dependency graph for func_groupcount.c:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.
Functions | |
| static char * | group_count_function_read (struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) |
| static char * | group_function_read (struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) |
| static void | group_function_write (struct ast_channel *chan, char *cmd, char *data, const char *value) |
| static char * | group_list_function_read (struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) |
| static char * | group_match_count_function_read (struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) |
Variables | |
| static struct ast_custom_function | group_count_function |
| static struct ast_custom_function | group_function |
| static struct ast_custom_function | group_list_function |
| static struct ast_custom_function | group_match_count_function |
Definition in file func_groupcount.c.
|
||||||||||||||||||||||||
|
Definition at line 38 of file func_groupcount.c. References ast_app_group_get_count(), ast_app_group_split_group(), ast_log(), ast_strlen_zero(), group, LOG_NOTICE, ast_channel::name, and pbx_builtin_getvar_helper(). 00039 {
00040 int count;
00041 char group[80] = "";
00042 char category[80] = "";
00043 char *grp;
00044
00045 ast_app_group_split_group(data, group, sizeof(group), category, sizeof(category));
00046
00047 if (ast_strlen_zero(group)) {
00048 if ((grp = pbx_builtin_getvar_helper(chan, category)))
00049 ast_copy_string(group, grp, sizeof(group));
00050 else
00051 ast_log(LOG_NOTICE, "No group could be found for channel '%s'\n", chan->name);
00052 }
00053
00054 count = ast_app_group_get_count(group, category);
00055 snprintf(buf, len, "%d", count);
00056
00057 return buf;
00058 }
|
|
||||||||||||||||||||||||
|
Definition at line 101 of file func_groupcount.c. References ast_strlen_zero(), group, GROUP_CATEGORY_PREFIX, and pbx_builtin_getvar_helper(). 00102 {
00103 char varname[256];
00104 char *group;
00105
00106 if (!ast_strlen_zero(data)) {
00107 snprintf(varname, sizeof(varname), "%s_%s", GROUP_CATEGORY_PREFIX, data);
00108 } else {
00109 ast_copy_string(varname, GROUP_CATEGORY_PREFIX, sizeof(varname));
00110 }
00111
00112 group = pbx_builtin_getvar_helper(chan, varname);
00113 if (group)
00114 ast_copy_string(buf, group, len);
00115
00116 return buf;
00117 }
|
|
||||||||||||||||||||
|
Definition at line 119 of file func_groupcount.c. References ast_app_group_set_channel(), ast_log(), ast_strlen_zero(), and LOG_WARNING. 00120 {
00121 char grpcat[256];
00122
00123 if (!ast_strlen_zero(data)) {
00124 snprintf(grpcat, sizeof(grpcat), "%s@%s", value, data);
00125 } else {
00126 ast_copy_string(grpcat, value, sizeof(grpcat));
00127 }
00128
00129 if (ast_app_group_set_channel(chan, grpcat))
00130 ast_log(LOG_WARNING, "Setting a group requires an argument (group name)\n");
00131 }
|
|
||||||||||||||||||||||||
|
Definition at line 145 of file func_groupcount.c. References AST_LIST_TRAVERSE, ast_strlen_zero(), ast_var_name(), ast_var_value(), GROUP_CATEGORY_PREFIX, and ast_channel::varshead. 00146 {
00147 struct ast_var_t *current;
00148 struct varshead *headp;
00149 char tmp1[1024] = "";
00150 char tmp2[1024] = "";
00151
00152 headp=&chan->varshead;
00153 AST_LIST_TRAVERSE(headp,current,entries) {
00154 if (!strncmp(ast_var_name(current), GROUP_CATEGORY_PREFIX "_", strlen(GROUP_CATEGORY_PREFIX) + 1)) {
00155 if (!ast_strlen_zero(tmp1)) {
00156 ast_copy_string(tmp2, tmp1, sizeof(tmp2));
00157 snprintf(tmp1, sizeof(tmp1), "%s %s@%s", tmp2, ast_var_value(current), (ast_var_name(current) + strlen(GROUP_CATEGORY_PREFIX) + 1));
00158 } else {
00159 snprintf(tmp1, sizeof(tmp1), "%s@%s", ast_var_value(current), (ast_var_name(current) + strlen(GROUP_CATEGORY_PREFIX) + 1));
00160 }
00161 } else if (!strcmp(ast_var_name(current), GROUP_CATEGORY_PREFIX)) {
00162 if (!ast_strlen_zero(tmp1)) {
00163 ast_copy_string(tmp2, tmp1, sizeof(tmp2));
00164 snprintf(tmp1, sizeof(tmp1), "%s %s", tmp2, ast_var_value(current));
00165 } else {
00166 snprintf(tmp1, sizeof(tmp1), "%s", ast_var_value(current));
00167 }
00168 }
00169 }
00170 ast_copy_string(buf, tmp1, len);
00171 return buf;
00172 }
|
|
||||||||||||||||||||||||
|
Definition at line 72 of file func_groupcount.c. References ast_app_group_match_get_count(), ast_app_group_split_group(), ast_strlen_zero(), and group. 00073 {
00074 int count;
00075 char group[80] = "";
00076 char category[80] = "";
00077
00078 ast_app_group_split_group(data, group, sizeof(group), category, sizeof(category));
00079
00080 if (!ast_strlen_zero(group)) {
00081 count = ast_app_group_match_get_count(group, category);
00082 snprintf(buf, len, "%d", count);
00083 }
00084
00085 return buf;
00086 }
|
|
|
Definition at line 63 of file func_groupcount.c. |
|
|
Definition at line 136 of file func_groupcount.c. |
|
|
Definition at line 177 of file func_groupcount.c. |
|
|
Definition at line 91 of file func_groupcount.c. |
1.4.2