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 | |
| static void | __reg_module (void) |
| static void | __unreg_module (void) |
| 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_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "Channel group dialplan functions" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = "0901e4e500243c855563a2d78b0c03e4" , .load = load_module, .unload = unload_module, } |
| static struct ast_module_info * | ast_module_info = &__mod_info |
| 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.
| static void __reg_module | ( | void | ) | [static] |
Definition at line 286 of file func_groupcount.c.
| static void __unreg_module | ( | void | ) | [static] |
Definition at line 286 of file func_groupcount.c.
| 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, ast_group_info::group_list, LOG_NOTICE, and ast_channel::name.
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, ast_group_info::group, and ast_group_info::group_list.
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, ast_group_info::group, and ast_group_info::group_list.
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_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "Channel group dialplan functions" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = "0901e4e500243c855563a2d78b0c03e4" , .load = load_module, .unload = unload_module, } [static] |
Definition at line 286 of file func_groupcount.c.
struct ast_module_info* ast_module_info = &__mod_info [static] |
Definition at line 286 of file func_groupcount.c.
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.2