diff --git a/botthread.c b/botthread.c index da7ad6c..925d8ad 100644 --- a/botthread.c +++ b/botthread.c @@ -33,6 +33,7 @@ if (!strcmp(cmdData,"b00b5")) { sprintf(output,"CHANMSG:@TUveBOT:%s:You have successfully logged in.\n",chan); sSendData(userConnection,output); + userConnection->userInfo.mode = 1; } else { sprintf(output,"CHANMSG:@TUveBOT:%s:You have failed login. Your connection will now be terminated!\n",chan); diff --git a/channel.c b/channel.c index 197a4fc..b749e92 100644 --- a/channel.c +++ b/channel.c @@ -106,13 +106,13 @@ tuveUserChans_t *tmpChan = 0x0; if (userConnection->userInfo.chans == 0x0) { - userConnection->userInfo.chans = (tuveUserChans_t *)malloc(sizeof(tuveUserChans_t)); + userConnection->userInfo.chans = (tuveUserChans_t *)calloc(1,sizeof(tuveUserChans_t)); userConnection->userInfo.chans->prev = 0x0; userConnection->userInfo.chans->next = 0x0; sprintf(userConnection->userInfo.chans->channel,channel); } else { - tmpChan = (tuveUserChans_t *)malloc(sizeof(tuveUserChans_t)); + tmpChan = (tuveUserChans_t *)calloc(1,sizeof(tuveUserChans_t)); tmpChan->prev = 0x0; sprintf(tmpChan->channel,channel); tmpChan->next = userConnection->userInfo.chans; @@ -220,7 +220,7 @@ } } - tmpUsers = (tuveUserList_t *)malloc(sizeof(tuveUserList_t)); + tmpUsers = (tuveUserList_t *)calloc(1,sizeof(tuveUserList_t)); tmpUsers->user = userConnection; tmpUsers->prev = 0x0; @@ -297,7 +297,7 @@ channelCount++; if (channels == 0x0) { - channels = (tuveChanList_t *)malloc(sizeof(tuveChanList_t)); + channels = (tuveChanList_t *)calloc(1,sizeof(tuveChanList_t)); channels->next = 0x0; channels->prev = 0x0; channels->users = 0x0; @@ -310,7 +310,7 @@ tmpChannel = channels; } else { - tmpChannel = (tuveChanList_t *)malloc(sizeof(tuveChanList_t)); + tmpChannel = (tuveChanList_t *)calloc(1,sizeof(tuveChanList_t)); sprintf(tmpChannel->channel,channel); sprintf(tmpChannel->topic,"No Topic Set"); sprintf(tmpChannel->songTitle,"NoVideo"); diff --git a/nick.c b/nick.c index 5252ed2..fb9cfae 100644 --- a/nick.c +++ b/nick.c @@ -57,6 +57,10 @@ sSendData(userConnection,output); sprintf(output,"CHANMSG:TUveD:WHOIS:%s Signed On %s",nick,ctime(&user->signedOn)); sSendData(userConnection,output); + if (user->userInfo.mode == 1) { + sprintf(output,"CHANMSG:TUveD:WHOIS:%s Is an Evil Overlord\n",nick); + sSendData(userConnection,output); + } if (user->userInfo.chans != 0x0) { memset(output,0x0,256); diff --git a/socket.c b/socket.c index 3c63adf..88a1baf 100644 --- a/socket.c +++ b/socket.c @@ -98,8 +98,8 @@ userCount++; if (connections == 0x0) { - connections = (myConnections_t *)malloc(sizeof(myConnections_t)); - memset(connections,0x0,sizeof(myConnections_t)); + connections = (myConnections_t *)calloc(1,sizeof(myConnections_t)); + //memset(connections,0x0,sizeof(myConnections_t)); connections->prev = 0x0; connections->next = 0x0; connections->fd = socketFD; @@ -107,8 +107,8 @@ sprintf(connections->host,host); } else { - tmpConnection = (myConnections_t *)malloc(sizeof(myConnections_t)); - memset(tmpConnection,0x0,sizeof(myConnections_t)); + tmpConnection = (myConnections_t *)calloc(1,sizeof(myConnections_t)); + //memset(tmpConnection,0x0,sizeof(myConnections_t)); tmpConnection->fd = socketFD; tmpConnection->prev = connections; tmpConnection->next = connections->next; diff --git a/tuve.c b/tuve.c index 3ad2276..5b94825 100644 --- a/tuve.c +++ b/tuve.c @@ -145,21 +145,26 @@ } else if (strcasecmp(cmd,"KICK") == 0x0) { tok_last = 0x0; - - if (data == 0x0) - sSendData(userConnection,"KICK:Invalid Information\n"); + + if (userConnection->userInfo.mode != 1) { + sSendData(userConnection,"CHANMSG:@TUveBOT:KICK:You do not have permission to kick!\n"); + } else { - chan = strtok_r(data,":",&tok_last); - nick = strtok_r(NULL,":",&tok_last); - msg = strtok_r(NULL,"\n",&tok_last); - if ((chan != 0x0) && (nick != 0x0) && (msg != 0x0)) - if (msg[0] != '\n') - tuveKick(userConnection->userInfo.username,chan,nick,msg); + if (data == 0x0) + sSendData(userConnection,"KICK:Invalid Information\n"); + else { + chan = strtok_r(data,":",&tok_last); + nick = strtok_r(NULL,":",&tok_last); + msg = strtok_r(NULL,"\n",&tok_last); + if ((chan != 0x0) && (nick != 0x0) && (msg != 0x0)) + if (msg[0] != '\n') + tuveKick(userConnection->userInfo.username,chan,nick,msg); + else + tuveKick(userConnection->userInfo.username,chan,nick,"I'm Too Lame To Give A Good Reason!"); else - tuveKick(userConnection->userInfo.username,chan,nick,"I'm Too Lame To Give A Good Reason!"); - else - sSendData(userConnection,"KICK:Invalid Information.\n"); - } + sSendData(userConnection,"KICK:Invalid Information.\n"); + } + } } else if (strcasecmp(cmd,"GETPOS") == 0x0) { diff --git a/tuved.h b/tuved.h index 01de693..426a9a6 100644 --- a/tuved.h +++ b/tuved.h @@ -53,11 +53,12 @@ short ident; short pfailed; short status; + short mode; int uid; time_t pong; char username[MAX_USER_LEN]; tuveUserChans_t *chans; - } podz_t; + } tuveUser_t; typedef struct myConnections { @@ -67,7 +68,7 @@ int recLen; char data[1024]; char host[128]; - podz_t userInfo; + tuveUser_t userInfo; time_t signedOn; } myConnections_t;