#include <stdio.h> #include <assert.h> #include "tuved.h" int tuveVerifyNick(char *nick) { int i = 0x0; int len = 0x0; assert(nick); assert(connections); len = strlen(nick); for (i = 0x0;i < len;i++) { if ((nick[i] < 48) || (nick[i] > 122) || ((nick[i] > 57) && (nick[i] < 65)) || ((nick[i] > 90) && (nick[i] < 97))) return(0x1); } if (findNick(nick) != 0x0) return(0x1); return(0x0); } // tuveVerifyNick() myConnections_t *findNick(const char *nick) { if (nick == 0x0) return(0x0); myConnections_t *tmpConnection = 0x0; for (tmpConnection = connections;tmpConnection != 0x0;tmpConnection = tmpConnection->next) { if (!strcasecmp(nick,tmpConnection->userInfo.username)) return(tmpConnection); } return(0x0); } int tuveWhois(myConnections_t *userConnection,char *nick) { myConnections_t *user = 0x0; tuveUserChans_t *chans = 0x0; char output[256]; char channel[MAX_CHAN_LEN + 1]; int len = 0; if (strlen(nick) > MAX_USER_LEN) return(0x0); user = findNick(nick); if (user == 0x0) { sprintf(output,"MSG:TUveD:STATUS:%s Not Found",nick); sSendData(userConnection,output); return(0x0); } sprintf(output,"MSG:TUveD:STATUS:%s is %s",user->userInfo.username,user->host); sSendData(userConnection,output); len = sprintf(output,"MSG:TUveD:STATUS:%s Signed On %s",user->userInfo.username,ctime(&user->signedOn)); output[len -1] = '\0'; sSendData(userConnection,output); sprintf(output,"MSG:TUveD:STATUS:%s Is running %4.2f",user->userInfo.username,user->userInfo.version); sSendData(userConnection,output); if (user->userInfo.modes[USER_OVERLORD] == 1) { sprintf(output,"MSG:TUveD:STATUS:%s Is an Evil Overlord",user->userInfo.username); sSendData(userConnection,output); } if ((time(NULL) - user->userInfo.idle) > 30) { sprintf(output,"MSG:TUveD:STATUS:%s Has been idle for %li seconds.", user->userInfo.username, time(NULL) - user->userInfo.idle); sSendData(userConnection,output); } if (user->userInfo.chans != 0x0) { memset(output,0x0,256); for (chans = user->userInfo.chans;chans != 0x0;chans = chans->next) { if (tuveFindChanLevel(chans->channel,user,1) == 0) strcpy(channel,chans->channel); else sprintf(channel,"&%s",chans->channel); if (strlen(output) == 0) sprintf(output,"MSG:TUveD:STATUS:%s Is on channel(s) %s",user->userInfo.username,channel); else sprintf(output,"%s,%s",output,channel); } sSendData(userConnection,output); } return(0x0); }