Channel group related dialplan functions. More...
#include "asterisk.h"#include "asterisk/module.h"#include "asterisk/channel.h"#include "asterisk/pbx.h"#include "asterisk/utils.h"#include "asterisk/app.h"
Go to the source code of this file.
Functions | |
| AST_MODULE_INFO_STANDARD (ASTERISK_GPL_KEY,"Channel group dialplan functions") | |
| static int | group_count_function_read (struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len) |
| static int | group_function_read (struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len) |
| static int | group_function_write (struct ast_channel *chan, const char *cmd, char *data, const char *value) |
| static int | group_list_function_read (struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len) |
| static int | group_match_count_function_read (struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len) |
| static int | load_module (void) |
| static int | unload_module (void) |
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 |
Channel group related dialplan functions.
Definition in file func_groupcount.c.
| AST_MODULE_INFO_STANDARD | ( | ASTERISK_GPL_KEY | , | |
| "Channel group dialplan functions" | ||||
| ) |
| static int group_count_function_read | ( | struct ast_channel * | chan, | |
| const char * | cmd, | |||
| char * | data, | |||
| char * | buf, | |||
| size_t | len | |||
| ) | [static] |
Definition at line 95 of file func_groupcount.c.
References ast_app_group_get_count(), ast_app_group_list_head(), ast_app_group_list_rdlock(), ast_app_group_list_unlock(), ast_app_group_split_group(), ast_copy_string(), AST_LIST_NEXT, ast_log(), ast_strlen_zero(), ast_group_info::category, ast_group_info::chan, ast_group_info::group, and LOG_NOTICE.
00097 { 00098 int ret = -1; 00099 int count = -1; 00100 char group[80] = "", category[80] = ""; 00101 00102 ast_app_group_split_group(data, group, sizeof(group), category, 00103 sizeof(category)); 00104 00105 /* If no group has been provided let's find one */ 00106 if (ast_strlen_zero(group)) { 00107 struct ast_group_info *gi = NULL; 00108 00109 ast_app_group_list_rdlock(); 00110 for (gi = ast_app_group_list_head(); gi; gi = AST_LIST_NEXT(gi, group_list)) { 00111 if (gi->chan != chan) 00112 continue; 00113 if (ast_strlen_zero(category) || (!ast_strlen_zero(gi->category) && !strcasecmp(gi->category, category))) 00114 break; 00115 } 00116 if (gi) { 00117 ast_copy_string(group, gi->group, sizeof(group)); 00118 if (!ast_strlen_zero(gi->category)) 00119 ast_copy_string(category, gi->category, sizeof(category)); 00120 } 00121 ast_app_group_list_unlock(); 00122 } 00123 00124 if ((count = ast_app_group_get_count(group, category)) == -1) { 00125 ast_log(LOG_NOTICE, "No group could be found for channel '%s'\n", chan->name); 00126 } else { 00127 snprintf(buf, len, "%d", count); 00128 ret = 0; 00129 } 00130 00131 return ret; 00132 }
| static int group_function_read | ( | struct ast_channel * | chan, | |
| const char * | cmd, | |||
| char * | data, | |||
| char * | buf, | |||
| size_t | len | |||
| ) | [static] |
Definition at line 165 of file func_groupcount.c.
References ast_app_group_list_head(), ast_app_group_list_rdlock(), ast_app_group_list_unlock(), ast_copy_string(), AST_LIST_NEXT, ast_strlen_zero(), ast_group_info::category, ast_group_info::chan, and ast_group_info::group.
00167 { 00168 int ret = -1; 00169 struct ast_group_info *gi = NULL; 00170 00171 ast_app_group_list_rdlock(); 00172 00173 for (gi = ast_app_group_list_head(); gi; gi = AST_LIST_NEXT(gi, group_list)) { 00174 if (gi->chan != chan) 00175 continue; 00176 if (ast_strlen_zero(data)) 00177 break; 00178 if (!ast_strlen_zero(gi->category) && !strcasecmp(gi->category, data)) 00179 break; 00180 } 00181 00182 if (gi) { 00183 ast_copy_string(buf, gi->group, len); 00184 ret = 0; 00185 } 00186 00187 ast_app_group_list_unlock(); 00188 00189 return ret; 00190 }
| static int group_function_write | ( | struct ast_channel * | chan, | |
| const char * | cmd, | |||
| char * | data, | |||
| const char * | value | |||
| ) | [static] |
Definition at line 192 of file func_groupcount.c.
References ast_app_group_set_channel(), ast_copy_string(), ast_log(), ast_strlen_zero(), and LOG_WARNING.
00194 { 00195 char grpcat[256]; 00196 00197 if (!value) { 00198 return -1; 00199 } 00200 00201 if (!ast_strlen_zero(data)) { 00202 snprintf(grpcat, sizeof(grpcat), "%s@%s", value, data); 00203 } else { 00204 ast_copy_string(grpcat, value, sizeof(grpcat)); 00205 } 00206 00207 if (ast_app_group_set_channel(chan, grpcat)) 00208 ast_log(LOG_WARNING, 00209 "Setting a group requires an argument (group name)\n"); 00210 00211 return 0; 00212 }
| static int group_list_function_read | ( | struct ast_channel * | chan, | |
| const char * | cmd, | |||
| char * | data, | |||
| char * | buf, | |||
| size_t | len | |||
| ) | [static] |
Definition at line 220 of file func_groupcount.c.
References ast_app_group_list_head(), ast_app_group_list_rdlock(), ast_app_group_list_unlock(), ast_copy_string(), AST_LIST_NEXT, ast_strlen_zero(), ast_group_info::category, ast_group_info::chan, and ast_group_info::group.
00222 { 00223 struct ast_group_info *gi = NULL; 00224 char tmp1[1024] = ""; 00225 char tmp2[1024] = ""; 00226 00227 if (!chan) 00228 return -1; 00229 00230 ast_app_group_list_rdlock(); 00231 00232 for (gi = ast_app_group_list_head(); gi; gi = AST_LIST_NEXT(gi, group_list)) { 00233 if (gi->chan != chan) 00234 continue; 00235 if (!ast_strlen_zero(tmp1)) { 00236 ast_copy_string(tmp2, tmp1, sizeof(tmp2)); 00237 if (!ast_strlen_zero(gi->category)) 00238 snprintf(tmp1, sizeof(tmp1), "%s %s@%s", tmp2, gi->group, gi->category); 00239 else 00240 snprintf(tmp1, sizeof(tmp1), "%s %s", tmp2, gi->group); 00241 } else { 00242 if (!ast_strlen_zero(gi->category)) 00243 snprintf(tmp1, sizeof(tmp1), "%s@%s", gi->group, gi->category); 00244 else 00245 snprintf(tmp1, sizeof(tmp1), "%s", gi->group); 00246 } 00247 } 00248 00249 ast_app_group_list_unlock(); 00250 00251 ast_copy_string(buf, tmp1, len); 00252 00253 return 0; 00254 }
| static int group_match_count_function_read | ( | struct ast_channel * | chan, | |
| const char * | cmd, | |||
| char * | data, | |||
| char * | buf, | |||
| size_t | len | |||
| ) | [static] |
Definition at line 139 of file func_groupcount.c.
References ast_app_group_match_get_count(), ast_app_group_split_group(), and ast_strlen_zero().
00142 { 00143 int count; 00144 char group[80] = ""; 00145 char category[80] = ""; 00146 00147 ast_app_group_split_group(data, group, sizeof(group), category, 00148 sizeof(category)); 00149 00150 if (!ast_strlen_zero(group)) { 00151 count = ast_app_group_match_get_count(group, category); 00152 snprintf(buf, len, "%d", count); 00153 return 0; 00154 } 00155 00156 return -1; 00157 }
| static int load_module | ( | void | ) | [static] |
Definition at line 274 of file func_groupcount.c.
References ast_custom_function_register.
00275 { 00276 int res = 0; 00277 00278 res |= ast_custom_function_register(&group_count_function); 00279 res |= ast_custom_function_register(&group_match_count_function); 00280 res |= ast_custom_function_register(&group_list_function); 00281 res |= ast_custom_function_register(&group_function); 00282 00283 return res; 00284 }
| static int unload_module | ( | void | ) | [static] |
Definition at line 262 of file func_groupcount.c.
References ast_custom_function_unregister().
00263 { 00264 int res = 0; 00265 00266 res |= ast_custom_function_unregister(&group_count_function); 00267 res |= ast_custom_function_unregister(&group_match_count_function); 00268 res |= ast_custom_function_unregister(&group_list_function); 00269 res |= ast_custom_function_unregister(&group_function); 00270 00271 return res; 00272 }
struct ast_custom_function group_count_function [static] |
{
.name = "GROUP_COUNT",
.read = group_count_function_read,
}
Definition at line 134 of file func_groupcount.c.
struct ast_custom_function group_function [static] |
{
.name = "GROUP",
.read = group_function_read,
.write = group_function_write,
}
Definition at line 214 of file func_groupcount.c.
struct ast_custom_function group_list_function [static] |
{
.name = "GROUP_LIST",
.read = group_list_function_read,
.write = NULL,
}
Definition at line 256 of file func_groupcount.c.
struct ast_custom_function group_match_count_function [static] |
{
.name = "GROUP_MATCH_COUNT",
.read = group_match_count_function_read,
.write = NULL,
}
Definition at line 159 of file func_groupcount.c.
1.6.1