Go to the documentation of this file.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: 154542 $")
00032
00033 #include "asterisk/pbx.h"
00034 #include "asterisk/module.h"
00035 #include "asterisk/channel.h"
00036 #include "asterisk/astdb.h"
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055 static int blacklist_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
00056 {
00057 char blacklist[1];
00058 int bl = 0;
00059
00060 if (chan->cid.cid_num) {
00061 if (!ast_db_get("blacklist", chan->cid.cid_num, blacklist, sizeof (blacklist)))
00062 bl = 1;
00063 }
00064 if (chan->cid.cid_name) {
00065 if (!ast_db_get("blacklist", chan->cid.cid_name, blacklist, sizeof (blacklist)))
00066 bl = 1;
00067 }
00068
00069 snprintf(buf, len, "%d", bl);
00070 return 0;
00071 }
00072
00073 static struct ast_custom_function blacklist_function = {
00074 .name = "BLACKLIST",
00075 .read = blacklist_read,
00076 };
00077
00078 static int unload_module(void)
00079 {
00080 return ast_custom_function_unregister(&blacklist_function);
00081 }
00082
00083 static int load_module(void)
00084 {
00085 return ast_custom_function_register(&blacklist_function);
00086 }
00087
00088 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Look up Caller*ID name/number from blacklist database");