diff --git a/Makefile b/Makefile index e684b22..3a2d48f 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,7 @@ OBJS = nick.o botthread.o main.o socket.o tuve.o channel.o LIBRARIES = -lthr -CFLAGS = -Wall -O2 +CFLAGS = -Wall -W -O2 -g # Link The Binary $(BINARY) : $(OBJS) diff --git a/channel.c b/channel.c index 6775572..850a8a8 100644 --- a/channel.c +++ b/channel.c @@ -8,6 +8,7 @@ #include #include #include +#include #include "tuved.h" @@ -34,11 +35,15 @@ /* * Joins A User To A Channel */ -int tuveChanJoin(char *channel,myConnections_t *userConnection) { +int +tuveChanJoin(char *channel,myConnections_t *userConnection) { char output[256]; tuveChanList_t *tmpChan = 0x0; int min, sec; + assert(channel); + assert(userConnection); + if (tuveAddChan(channel,userConnection) != 0x0) return(0x1); /* Send JOIN to all users in the channel */ @@ -46,6 +51,7 @@ tuveSendAllInChan(channel,userConnection,output); tmpChan = findChan(channel); + assert(tmpChan); sprintf(output,"CURPOS:%i:%s:%s\n",tmpChan->songTime - (tmpChan->songEnd - (time(NULL) + 2)),tmpChan->curSong,tmpChan->songTitle); sSendData(userConnection,output); @@ -176,13 +182,17 @@ return(0x1); } -int tuveAddToChanList(char *channel,myConnections_t *userConnection) { +int +tuveAddToChanList(char *channel,myConnections_t *userConnection) { tuveChanList_t *tmpChannel = 0x0; tuveUserList_t *tmpUsers = 0x0; char output[1024]; tmpChannel = findChan(channel); + + // tmpChannel is okay to be null here + if (tmpChannel == 0x0) { writeLog(2,"Channel %s Does Not Exist Adding To List\n",channel); tmpChannel = addChan(channel); diff --git a/nick.c b/nick.c index 33db88f..2d7fd68 100644 --- a/nick.c +++ b/nick.c @@ -1,14 +1,19 @@ #include +#include #include "tuved.h" -int tuveVerifyNick(char *nick) { +int +tuveVerifyNick(char *nick) { myConnections_t *tmpConnection = 0x0; + assert(nick); + assert(connections); + for (tmpConnection = connections;tmpConnection != 0x0;tmpConnection = tmpConnection->next) { if (!strcasecmp(nick,tmpConnection->userInfo.username)) return(0x1); } return(0x0); - } +} // tuveVerifyNick() diff --git a/tuve.c b/tuve.c index f15cee2..ea4cc47 100644 --- a/tuve.c +++ b/tuve.c @@ -52,6 +52,8 @@ memset(&output,0x0,1024); memset(&buffer,0x0,1024); + assert(userConnection); + cmd = userConnection->data; assert(userConnection->recLen > 2);