diff --git a/main.c b/main.c index a3acffd..81b4c1b 100644 --- a/main.c +++ b/main.c @@ -78,6 +78,7 @@ if (dbInit() == 0x1) exit(0x1); + /* Reset Server Sessions */ dbQuery("DELETE FROM active",0); srandom(time(NULL)); @@ -90,15 +91,17 @@ sStartListener(); while (1) { - if (sGetConnections(&readset) == 0x0) { - writeLog(0,"Error: sGetConnections Failed\nShuttown Down\n"); - exit(0x0); + /* Get Socket Set For Readable Connections */ + if (sGetConnections(&readset) == 0x0) { + writeLog(0,"Error: sGetConnections Failed\nShutting Down\n"); + exit(0x1); } readSocks = select(highSock+1,&readset,0x0,0x0,&timeout); if (readSocks < 0) { + writeLog(0,"Error: select Failed\nShutting Down\n") perror("select failed"); exit(0x1); } diff --git a/tuve.c b/tuve.c index 8e14e8f..dbfc7c3 100644 --- a/tuve.c +++ b/tuve.c @@ -40,16 +40,16 @@ } /* End int tuveSendAll(const char *data,int fd); */ int tuveProcessData(myConnections_t *userConnection) { - char *chan = 0x0; - char *nick = 0x0; - char *cmd = 0x0; - char *msg = 0x0; - char *data = 0x0; - char *data2 = 0x0; - char *data_tok = 0x0; - char *tok_last = 0x0; - char output[1280]; - char buffer[1024]; + char *chan = 0x0; + char *nick = 0x0; + char *cmd = 0x0; + char *msg = 0x0; + char *data = 0x0; + char *data2 = 0x0; + char *data_tok = 0x0; + char *tok_last = 0x0; + char output[1280]; + char buffer[1024]; myConnections_t *tmpConnection = 0x0; memset(&output,0x0,1024); @@ -190,6 +190,19 @@ } } } + else if (strcasecmp(cmd,"MODE") == 0x0) { + if (data == 0x0) { + sSendData(userConnection,"MODE:FAILED"); + goto Tail; + } + + chan = strtok_r(data,":",&tok_last); + msg = strtok_r(NULL,"\n",&tok_last); + + if (msg == 0x0) + goto Tail; + tuveCMD_CMD(userConnection,chan,msg); + } else if (strcasecmp(cmd,"EMOTE") == 0x0) { if (data != 0x0) { chan = strtok_r(data,":",&tok_last);