CHANNEL(callid): Give dialplan access to the callid.
[asterisk/asterisk.git] / funcs / func_blacklist.c
index b940b58..fdc899b 100644 (file)
  * 
  */
 
-#include "asterisk.h"
+/*** MODULEINFO
+       <support_level>core</support_level>
+ ***/
 
-ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
+#include "asterisk.h"
 
 #include "asterisk/pbx.h"
 #include "asterisk/module.h"
@@ -57,12 +59,17 @@ static int blacklist_read(struct ast_channel *chan, const char *cmd, char *data,
        char blacklist[1];
        int bl = 0;
 
-       if (chan->caller.id.number.valid && chan->caller.id.number.str) {
-               if (!ast_db_get("blacklist", chan->caller.id.number.str, blacklist, sizeof (blacklist)))
+       if (!chan) {
+               ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
+               return -1;
+       }
+
+       if (ast_channel_caller(chan)->id.number.valid && ast_channel_caller(chan)->id.number.str) {
+               if (!ast_db_get("blacklist", ast_channel_caller(chan)->id.number.str, blacklist, sizeof (blacklist)))
                        bl = 1;
        }
-       if (chan->caller.id.name.valid && chan->caller.id.name.str) {
-               if (!ast_db_get("blacklist", chan->caller.id.name.str, blacklist, sizeof (blacklist)))
+       if (ast_channel_caller(chan)->id.name.valid && ast_channel_caller(chan)->id.name.str) {
+               if (!ast_db_get("blacklist", ast_channel_caller(chan)->id.name.str, blacklist, sizeof (blacklist)))
                        bl = 1;
        }