#include "asterisk.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include "asterisk/module.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/logger.h"
#include "asterisk/utils.h"
#include "asterisk/app.h"
#include "asterisk/options.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, char *cmd, char *data, char *buf, size_t len) |
static int | callerid_write (struct ast_channel *chan, 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 | AST_MODFLAG_BUILDSUM, .description = "Caller ID related dialplan function" , .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 = "361d7bb937402d51e4658efb5b4d76e4" , .load = load_module, .unload = unload_module, } |
static const struct ast_module_info * | ast_module_info = &__mod_info |
static struct ast_custom_function | callerid_function |
Definition in file func_callerid.c.
static void __reg_module | ( | void | ) | [static] |
Definition at line 193 of file func_callerid.c.
static void __unreg_module | ( | void | ) | [static] |
Definition at line 193 of file func_callerid.c.
static int callerid_read | ( | struct ast_channel * | chan, | |
char * | cmd, | |||
char * | data, | |||
char * | buf, | |||
size_t | len | |||
) | [static] |
Definition at line 41 of file func_callerid.c.
References ast_callerid_split(), ast_channel_lock, ast_channel_unlock, ast_copy_string(), ast_log(), ast_channel::cid, ast_callerid::cid_ani, ast_callerid::cid_dnid, ast_callerid::cid_name, ast_callerid::cid_num, ast_callerid::cid_rdnis, LOG_ERROR, name, and S_OR.
00043 { 00044 int res = -1; 00045 char *opt = data; 00046 00047 if (!chan) 00048 return -1; 00049 00050 if (strchr(opt, '|')) { 00051 char name[80], num[80]; 00052 00053 data = strsep(&opt, "|"); 00054 ast_callerid_split(opt, name, sizeof(name), num, sizeof(num)); 00055 00056 if (!strncasecmp("all", data, 3)) { 00057 snprintf(buf, len, "\"%s\" <%s>", name, num); 00058 res = 0; 00059 } else if (!strncasecmp("name", data, 4)) { 00060 ast_copy_string(buf, name, len); 00061 res = 0; 00062 } else if (!strncasecmp("num", data, 3) || 00063 !strncasecmp("number", data, 6)) { 00064 00065 ast_copy_string(buf, num, len); 00066 res = 0; 00067 } else { 00068 ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data); 00069 } 00070 } else { 00071 ast_channel_lock(chan); 00072 00073 if (!strncasecmp("all", data, 3)) { 00074 snprintf(buf, len, "\"%s\" <%s>", 00075 S_OR(chan->cid.cid_name, ""), 00076 S_OR(chan->cid.cid_num, "")); 00077 res = 0; 00078 } else if (!strncasecmp("name", data, 4)) { 00079 if (chan->cid.cid_name) { 00080 ast_copy_string(buf, chan->cid.cid_name, len); 00081 res = 0; 00082 } 00083 } else if (!strncasecmp("num", data, 3) 00084 || !strncasecmp("number", data, 6)) { 00085 if (chan->cid.cid_num) { 00086 ast_copy_string(buf, chan->cid.cid_num, len); 00087 res = 0; 00088 } 00089 } else if (!strncasecmp("ani", data, 3)) { 00090 if (chan->cid.cid_ani) { 00091 ast_copy_string(buf, chan->cid.cid_ani, len); 00092 res = 0; 00093 } 00094 } else if (!strncasecmp("dnid", data, 4)) { 00095 if (chan->cid.cid_dnid) { 00096 ast_copy_string(buf, chan->cid.cid_dnid, len); 00097 res = 0; 00098 } 00099 } else if (!strncasecmp("rdnis", data, 5)) { 00100 if (chan->cid.cid_rdnis) { 00101 ast_copy_string(buf, chan->cid.cid_rdnis, len); 00102 res = 0; 00103 } 00104 } else { 00105 ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data); 00106 } 00107 00108 ast_channel_unlock(chan); 00109 } 00110 00111 return res; 00112 }
static int callerid_write | ( | struct ast_channel * | chan, | |
char * | cmd, | |||
char * | data, | |||
const char * | value | |||
) | [static] |
Definition at line 114 of file func_callerid.c.
References ast_callerid_split(), ast_cdr_setcid(), ast_channel_lock, ast_channel_unlock, ast_log(), ast_set_callerid(), ast_strdup, ast_channel::cdr, ast_channel::cid, ast_callerid::cid_dnid, ast_callerid::cid_rdnis, ast_callerid::cid_tns, free, LOG_ERROR, and name.
00116 { 00117 int valid = 1; 00118 if (!value || !chan) 00119 return -1; 00120 00121 if (!strncasecmp("all", data, 3)) { 00122 char name[256]; 00123 char num[256]; 00124 00125 if (!ast_callerid_split(value, name, sizeof(name), num, sizeof(num))) { 00126 ast_set_callerid(chan, num, name, num); 00127 if (chan->cdr) 00128 ast_cdr_setcid(chan->cdr, chan); 00129 } 00130 } else if (!strncasecmp("name", data, 4)) { 00131 ast_set_callerid(chan, NULL, value, NULL); 00132 if (chan->cdr) 00133 ast_cdr_setcid(chan->cdr, chan); 00134 } else if (!strncasecmp("num", data, 3) || 00135 !strncasecmp("number", data, 6)) { 00136 ast_set_callerid(chan, value, NULL, NULL); 00137 if (chan->cdr) 00138 ast_cdr_setcid(chan->cdr, chan); 00139 } else if (!strncasecmp("ani", data, 3)) { 00140 ast_set_callerid(chan, NULL, NULL, value); 00141 if (chan->cdr) 00142 ast_cdr_setcid(chan->cdr, chan); 00143 } else if (!strncasecmp("dnid", data, 4)) { 00144 ast_channel_lock(chan); 00145 if (chan->cid.cid_dnid) 00146 free(chan->cid.cid_dnid); 00147 chan->cid.cid_dnid = ast_strdup(value); 00148 if (chan->cdr) 00149 ast_cdr_setcid(chan->cdr, chan); 00150 ast_channel_unlock(chan); 00151 } else if (!strncasecmp("rdnis", data, 5)) { 00152 ast_channel_lock(chan); 00153 if (chan->cid.cid_rdnis) 00154 free(chan->cid.cid_rdnis); 00155 chan->cid.cid_rdnis = ast_strdup(value); 00156 if (chan->cdr) 00157 ast_cdr_setcid(chan->cdr, chan); 00158 ast_channel_unlock(chan); 00159 } else { 00160 ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data); 00161 valid = 0; 00162 } 00163 00164 if (valid) { 00165 chan->cid.cid_tns = 1; 00166 } 00167 00168 return 0; 00169 }
static int load_module | ( | void | ) | [static] |
Definition at line 188 of file func_callerid.c.
References ast_custom_function_register(), and callerid_function.
00189 { 00190 return ast_custom_function_register(&callerid_function); 00191 }
static int unload_module | ( | void | ) | [static] |
Definition at line 183 of file func_callerid.c.
References ast_custom_function_unregister(), and callerid_function.
00184 { 00185 return ast_custom_function_unregister(&callerid_function); 00186 }
struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT | AST_MODFLAG_BUILDSUM, .description = "Caller ID related dialplan function" , .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 = "361d7bb937402d51e4658efb5b4d76e4" , .load = load_module, .unload = unload_module, } [static] |
Definition at line 193 of file func_callerid.c.
const struct ast_module_info* ast_module_info = &__mod_info [static] |
Definition at line 193 of file func_callerid.c.
struct ast_custom_function callerid_function [static] |