Caller ID 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"#include "asterisk/callerid.h"
Go to the source code of this file.
Functions | |
| static void | __reg_module (void) |
| static void | __unreg_module (void) |
| static int | callerid_read (struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len) |
| static int | callerid_write (struct ast_channel *chan, const char *cmd, char *data, const char *value) |
| static int | callerpres_read (struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len) |
| static int | callerpres_write (struct ast_channel *chan, const char *cmd, char *data, const char *value) |
| 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 = "Caller ID related 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 | callerid_function |
| static struct ast_custom_function | callerpres_function |
Caller ID related dialplan functions.
Definition in file func_callerid.c.
| static void __reg_module | ( | void | ) | [static] |
Definition at line 301 of file func_callerid.c.
| static void __unreg_module | ( | void | ) | [static] |
Definition at line 301 of file func_callerid.c.
| static int callerid_read | ( | struct ast_channel * | chan, | |
| const char * | cmd, | |||
| char * | data, | |||
| char * | buf, | |||
| size_t | len | |||
| ) | [static] |
Definition at line 120 of file func_callerid.c.
References ast_callerid_split(), ast_channel_lock, ast_channel_unlock, ast_copy_string(), ast_log(), ast_named_caller_presentation(), ast_channel::cid, ast_callerid::cid_ani, ast_callerid::cid_ani2, ast_callerid::cid_dnid, ast_callerid::cid_name, ast_callerid::cid_num, ast_callerid::cid_pres, ast_callerid::cid_rdnis, ast_callerid::cid_ton, LOG_ERROR, name, num, and S_OR.
00122 { 00123 char *opt = data; 00124 00125 /* Ensure that the buffer is empty */ 00126 *buf = 0; 00127 00128 if (!chan) 00129 return -1; 00130 00131 if (strchr(opt, ',')) { 00132 char name[80], num[80]; 00133 00134 data = strsep(&opt, ","); 00135 ast_callerid_split(opt, name, sizeof(name), num, sizeof(num)); 00136 00137 if (!strncasecmp("all", data, 3)) { 00138 snprintf(buf, len, "\"%s\" <%s>", name, num); 00139 } else if (!strncasecmp("name", data, 4)) { 00140 ast_copy_string(buf, name, len); 00141 } else if (!strncasecmp("num", data, 3)) { 00142 /* also matches "number" */ 00143 ast_copy_string(buf, num, len); 00144 } else { 00145 ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data); 00146 } 00147 } else { 00148 ast_channel_lock(chan); 00149 00150 if (!strncasecmp("all", data, 3)) { 00151 snprintf(buf, len, "\"%s\" <%s>", 00152 S_OR(chan->cid.cid_name, ""), 00153 S_OR(chan->cid.cid_num, "")); 00154 } else if (!strncasecmp("name", data, 4)) { 00155 if (chan->cid.cid_name) { 00156 ast_copy_string(buf, chan->cid.cid_name, len); 00157 } 00158 } else if (!strncasecmp("num", data, 3)) { 00159 /* also matches "number" */ 00160 if (chan->cid.cid_num) { 00161 ast_copy_string(buf, chan->cid.cid_num, len); 00162 } 00163 } else if (!strncasecmp("ani", data, 3)) { 00164 if (!strncasecmp(data + 3, "2", 1)) { 00165 snprintf(buf, len, "%d", chan->cid.cid_ani2); 00166 } else if (chan->cid.cid_ani) { 00167 ast_copy_string(buf, chan->cid.cid_ani, len); 00168 } 00169 } else if (!strncasecmp("dnid", data, 4)) { 00170 if (chan->cid.cid_dnid) { 00171 ast_copy_string(buf, chan->cid.cid_dnid, len); 00172 } 00173 } else if (!strncasecmp("rdnis", data, 5)) { 00174 if (chan->cid.cid_rdnis) { 00175 ast_copy_string(buf, chan->cid.cid_rdnis, len); 00176 } 00177 } else if (!strncasecmp("pres", data, 4)) { 00178 ast_copy_string(buf, ast_named_caller_presentation(chan->cid.cid_pres), len); 00179 } else if (!strncasecmp("ton", data, 3)) { 00180 snprintf(buf, len, "%d", chan->cid.cid_ton); 00181 } else { 00182 ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data); 00183 } 00184 00185 ast_channel_unlock(chan); 00186 } 00187 00188 return 0; 00189 }
| static int callerid_write | ( | struct ast_channel * | chan, | |
| const char * | cmd, | |||
| char * | data, | |||
| const char * | value | |||
| ) | [static] |
Definition at line 191 of file func_callerid.c.
References ast_callerid_split(), ast_cdr_setcid(), ast_channel_lock, ast_channel_unlock, ast_free, ast_log(), ast_parse_caller_presentation(), ast_set_callerid(), ast_skip_blanks(), ast_strdup, ast_trim_blanks(), ast_channel::cdr, ast_channel::cid, ast_callerid::cid_ani2, ast_callerid::cid_dnid, ast_callerid::cid_pres, ast_callerid::cid_rdnis, ast_callerid::cid_ton, LOG_ERROR, name, and num.
00193 { 00194 if (!value || !chan) 00195 return -1; 00196 00197 value = ast_skip_blanks(value); 00198 00199 if (!strncasecmp("all", data, 3)) { 00200 char name[256]; 00201 char num[256]; 00202 00203 ast_callerid_split(value, name, sizeof(name), num, sizeof(num)); 00204 ast_set_callerid(chan, num, name, num); 00205 if (chan->cdr) { 00206 ast_cdr_setcid(chan->cdr, chan); 00207 } 00208 } else if (!strncasecmp("name", data, 4)) { 00209 ast_set_callerid(chan, NULL, value, NULL); 00210 if (chan->cdr) { 00211 ast_cdr_setcid(chan->cdr, chan); 00212 } 00213 } else if (!strncasecmp("num", data, 3)) { 00214 /* also matches "number" */ 00215 ast_set_callerid(chan, value, NULL, NULL); 00216 if (chan->cdr) { 00217 ast_cdr_setcid(chan->cdr, chan); 00218 } 00219 } else if (!strncasecmp("ani", data, 3)) { 00220 if (!strncasecmp(data + 3, "2", 1)) { 00221 chan->cid.cid_ani2 = atoi(value); 00222 } else { 00223 ast_set_callerid(chan, NULL, NULL, value); 00224 } 00225 if (chan->cdr) { 00226 ast_cdr_setcid(chan->cdr, chan); 00227 } 00228 } else if (!strncasecmp("dnid", data, 4)) { 00229 ast_channel_lock(chan); 00230 if (chan->cid.cid_dnid) { 00231 ast_free(chan->cid.cid_dnid); 00232 } 00233 chan->cid.cid_dnid = ast_strdup(value); 00234 if (chan->cdr) { 00235 ast_cdr_setcid(chan->cdr, chan); 00236 } 00237 ast_channel_unlock(chan); 00238 } else if (!strncasecmp("rdnis", data, 5)) { 00239 ast_channel_lock(chan); 00240 if (chan->cid.cid_rdnis) { 00241 ast_free(chan->cid.cid_rdnis); 00242 } 00243 chan->cid.cid_rdnis = ast_strdup(value); 00244 if (chan->cdr) { 00245 ast_cdr_setcid(chan->cdr, chan); 00246 } 00247 ast_channel_unlock(chan); 00248 } else if (!strncasecmp("pres", data, 4)) { 00249 int i; 00250 char *val; 00251 00252 val = ast_strdupa(value); 00253 ast_trim_blanks(val); 00254 00255 if ((val[0] >= '0') && (val[0] <= '9')) { 00256 i = atoi(val); 00257 } else { 00258 i = ast_parse_caller_presentation(val); 00259 } 00260 00261 if (i < 0) { 00262 ast_log(LOG_ERROR, "Unknown calling number presentation '%s', value unchanged\n", val); 00263 } else { 00264 chan->cid.cid_pres = i; 00265 } 00266 } else if (!strncasecmp("ton", data, 3)) { 00267 chan->cid.cid_ton = atoi(value); 00268 } else { 00269 ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data); 00270 } 00271 00272 return 0; 00273 }
| static int callerpres_read | ( | struct ast_channel * | chan, | |
| const char * | cmd, | |||
| char * | data, | |||
| char * | buf, | |||
| size_t | len | |||
| ) | [static] |
Definition at line 104 of file func_callerid.c.
References ast_copy_string(), ast_named_caller_presentation(), ast_channel::cid, and ast_callerid::cid_pres.
00105 { 00106 ast_copy_string(buf, ast_named_caller_presentation(chan->cid.cid_pres), len); 00107 return 0; 00108 }
| static int callerpres_write | ( | struct ast_channel * | chan, | |
| const char * | cmd, | |||
| char * | data, | |||
| const char * | value | |||
| ) | [static] |
Definition at line 110 of file func_callerid.c.
References ast_log(), ast_parse_caller_presentation(), ast_channel::cid, ast_callerid::cid_pres, and LOG_WARNING.
00111 { 00112 int pres = ast_parse_caller_presentation(value); 00113 if (pres < 0) 00114 ast_log(LOG_WARNING, "'%s' is not a valid presentation (see 'show function CALLERPRES')\n", value); 00115 else 00116 chan->cid.cid_pres = pres; 00117 return 0; 00118 }
| static int load_module | ( | void | ) | [static] |
Definition at line 294 of file func_callerid.c.
References ast_custom_function_register.
00295 { 00296 int res = ast_custom_function_register(&callerpres_function); 00297 res |= ast_custom_function_register(&callerid_function); 00298 return res; 00299 }
| static int unload_module | ( | void | ) | [static] |
Definition at line 287 of file func_callerid.c.
References ast_custom_function_unregister().
00288 { 00289 int res = ast_custom_function_unregister(&callerpres_function); 00290 res |= ast_custom_function_unregister(&callerid_function); 00291 return res; 00292 }
struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "Caller ID related 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 301 of file func_callerid.c.
struct ast_module_info* ast_module_info = &__mod_info [static] |
Definition at line 301 of file func_callerid.c.
struct ast_custom_function callerid_function [static] |
{
.name = "CALLERID",
.read = callerid_read,
.write = callerid_write,
}
Definition at line 275 of file func_callerid.c.
struct ast_custom_function callerpres_function [static] |
{
.name = "CALLERPRES",
.read = callerpres_read,
.write = callerpres_write,
}
Definition at line 281 of file func_callerid.c.
1.6.2