actions/action_alert_console.c

Go to the documentation of this file.
00001 #include "action_alert_console.h"
00002 #include <stdio.h>
00003 #include "../engine/message.h"
00004 
00005 //#define DEBUG
00006 
00007 extern GlobalVars       Globals;
00008 
00009 /******************************************
00010 * handle info messages
00011 ******************************************/
00012 int AlertConsoleMessage(char* Message, void* Data){
00013 #ifdef DEBUGPATH
00014         printf("In AlertConsoleMessage\n");
00015 #endif
00016 
00017         printf("%s\n",Message);
00018         
00019         return TRUE;
00020 }
00021 
00022 /******************************************
00023 * write the alert message to the console
00024 ******************************************/
00025 int AlertConsoleAction(int RuleNum, int PacketSlot, void* Data){
00026         char            Buff[1024];
00027         PacketRec*      p;
00028         
00029 #ifdef DEBUGPATH
00030         printf("In AlsertConsoleAction\n");
00031 #endif
00032 
00033 #ifdef DEBUG
00034         printf("Writing to the console\n");
00035 #endif
00036 
00037         p=&Globals.Packets[PacketSlot];
00038 
00039         if (!ApplyMessage(Globals.AlertHeader, PacketSlot, Buff, 1024)){
00040                 printf("Couldn't apply message to packet\n");
00041                 return FALSE;
00042         }
00043 
00044         printf("%s ", Buff);
00045 
00046         if (!ApplyMessage(Globals.Rules[RuleNum].MessageFormat, PacketSlot, Buff, 1024)){
00047                 printf("Couldn't apply message to packet\n");
00048                 return FALSE;
00049         }
00050 
00051         printf("%s\n",Buff);
00052         
00053         return TRUE;
00054 }
00055 
00056 /********************************
00057 * Set up the alert console stuff
00058 ********************************/
00059 int InitActionAlertConsole(){
00060         int ActionID;
00061 
00062 #ifdef DEBUGPATH
00063         printf("In InitActionAlertConsole\n");
00064 #endif
00065 
00066         ActionID=CreateAction("alert console");
00067         if (ActionID==ACTION_NONE){
00068 #ifdef DEBUG
00069                 printf("Couldn't allocation action alert console\n");
00070 #endif  
00071                 return FALSE;
00072         }
00073         
00074         Globals.ActionItems[ActionID].ActionFunc=AlertConsoleAction;
00075         Globals.ActionItems[ActionID].MessageFunc=AlertConsoleMessage;
00076 
00077         return TRUE;
00078 }

Generated on Sat Jul 7 23:33:09 2007 for HLBR by  doxygen 1.5.2