00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #include "asterisk.h"
00030
00031 ASTERISK_FILE_VERSION(__FILE__, "$Revision: 89521 $")
00032
00033 #include "asterisk/pbx.h"
00034 #include "asterisk/module.h"
00035 #include "asterisk/channel.h"
00036 #include "asterisk/astdb.h"
00037
00038 static int blacklist_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
00039 {
00040 char blacklist[1];
00041 int bl = 0;
00042
00043 if (chan->cid.cid_num) {
00044 if (!ast_db_get("blacklist", chan->cid.cid_num, blacklist, sizeof (blacklist)))
00045 bl = 1;
00046 }
00047 if (chan->cid.cid_name) {
00048 if (!ast_db_get("blacklist", chan->cid.cid_name, blacklist, sizeof (blacklist)))
00049 bl = 1;
00050 }
00051
00052 snprintf(buf, len, "%d", bl);
00053 return 0;
00054 }
00055
00056 static struct ast_custom_function blacklist_function = {
00057 .name = "BLACKLIST",
00058 .synopsis = "Check if the callerid is on the blacklist",
00059 .desc = "Uses astdb to check if the Caller*ID is in family 'blacklist'. Returns 1 or 0.\n",
00060 .syntax = "BLACKLIST()",
00061 .read = blacklist_read,
00062 };
00063
00064 static int unload_module(void)
00065 {
00066 return ast_custom_function_unregister(&blacklist_function);
00067 }
00068
00069 static int load_module(void)
00070 {
00071 return ast_custom_function_register(&blacklist_function);
00072 }
00073
00074 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Look up Caller*ID name/number from blacklist database");