void user_command(int connfd, char* user_name, char* real_name){ /* get user struct by connfd */ user* u = user_table[connfd]; int length = 0; char msg[MAX_MSG_LEN]; if(u->real_name && u->user_name) length += snprintf(msg,MAX_MSG_LEN,":You may not reregister\n"); else{ /* set username and realname for u*/ u->user_name = strdup(user_name); u->real_name = strdup(real_name); show_motd(connfd); } if(length > 0) send_msg_back(connfd,msg); }
void dcc_chatter(int idx) { int i, j; struct flag_record fr = { FR_GLOBAL | FR_CHAN | FR_ANYWH, 0, 0, 0, 0, 0 }; get_user_flagrec(dcc[idx].user, &fr, NULL); show_motd(idx); i = dcc[idx].u.chat->channel; dcc[idx].u.chat->channel = 234567; j = dcc[idx].sock; strcpy(dcc[idx].u.chat->con_chan, "***"); check_tcl_chon(dcc[idx].nick, dcc[idx].sock); /* Still there? */ if ((idx >= dcc_total) || (dcc[idx].sock != j)) return; /* Nope */ /* Tcl script may have taken control */ if (dcc[idx].type == &DCC_CHAT) { if (!strcmp(dcc[idx].u.chat->con_chan, "***")) strcpy(dcc[idx].u.chat->con_chan, "*"); if (dcc[idx].u.chat->channel == 234567) { /* If the chat channel has already been altered it's *highly* * probably join/part messages have been broadcast everywhere, * so dont bother sending them */ if (i == -2) i = 0; dcc[idx].u.chat->channel = i; if ((dcc[idx].u.chat->channel >= 0) && (dcc[idx].u.chat->channel < GLOBAL_CHANS)) botnet_send_join_idx(idx, -1); check_tcl_chjn(botnetnick, dcc[idx].nick, dcc[idx].u.chat->channel, geticon(idx), dcc[idx].sock, dcc[idx].host); } /* But *do* bother with sending it locally */ if (!dcc[idx].u.chat->channel) { chanout_but(-1, 0, "*** %s joined the party line.\n", dcc[idx].nick); } else if (dcc[idx].u.chat->channel > 0) { chanout_but(-1, dcc[idx].u.chat->channel, "*** %s joined the channel.\n", dcc[idx].nick); } } }
void nick_command(int connfd,char* nick_name){ int length = 0; char msg[MAX_MSG_LEN]; if(!nick_valid(nick_name)) length += snprintf(msg,MAX_MSG_LEN,"%s:Erroneus nickname\n",nick_name); else{ /* if nick name has not been used, give it to current user */ if(find_user(nick_name,connfd) < 0){ user* u = user_table[connfd]; /* USER without NICK*/ u->nick_name = strdup(nick_name); show_motd(connfd); } else length += snprintf(msg,MAX_MSG_LEN,"%s:Nickname is already in use\n",nick_name); } if(length > 0) send_msg_back(connfd,msg); }