updated setting nick

This commit is contained in:
Michiel Broek 2005-04-22 20:01:21 +00:00
parent 251e87c139
commit 43ebecc091
2 changed files with 11 additions and 10 deletions

View File

@ -49,6 +49,7 @@ typedef enum {CH_FREE, CH_PRIVATE, CH_PUBLIC} CHANNELTYPE;
typedef struct _ch_user_rec { typedef struct _ch_user_rec {
pid_t pid; /* User's pid */ pid_t pid; /* User's pid */
char realname[36]; /* Real name */ char realname[36]; /* Real name */
char name[10]; /* Unix name */
char nick[10]; /* Nickname */ char nick[10]; /* Nickname */
time_t connected; /* Time connected */ time_t connected; /* Time connected */
int channel; /* Connected channel or -1 */ int channel; /* Connected channel or -1 */
@ -425,6 +426,7 @@ char *chat_connect(char *data)
chat_users[i].pid = atoi(pid); chat_users[i].pid = atoi(pid);
strncpy(chat_users[i].realname, realname, 36); strncpy(chat_users[i].realname, realname, 36);
strncpy(chat_users[i].nick, nick, 9); strncpy(chat_users[i].nick, nick, 9);
strncpy(chat_users[i].name, nick, 9);
chat_users[i].connected = time(NULL); chat_users[i].connected = time(NULL);
chat_users[i].pointer = buffer_head; chat_users[i].pointer = buffer_head;
chat_users[i].channel = -1; chat_users[i].channel = -1;
@ -486,8 +488,8 @@ char *chat_close(char *data)
* Remove from IBC network * Remove from IBC network
*/ */
#ifdef USE_EXPERIMENT #ifdef USE_EXPERIMENT
del_user(&users, CFG.myfqdn, chat_users[i].nick); del_user(&users, CFG.myfqdn, chat_users[i].name);
send_all("QUIT %s@%s Leaving chat\r\n", chat_users[i].nick, CFG.myfqdn); send_all("QUIT %s@%s Leaving chat\r\n", chat_users[i].name, CFG.myfqdn);
#endif #endif
Syslog('-', "Closing chat for pid %s, slot %d", pid, i); Syslog('-', "Closing chat for pid %s, slot %d", pid, i);
memset(&chat_users[i], 0, sizeof(_chat_users)); memset(&chat_users[i], 0, sizeof(_chat_users));
@ -631,6 +633,8 @@ char *chat_put(char *data)
strncpy(chat_users[i].nick, cmd, 9); strncpy(chat_users[i].nick, cmd, 9);
sprintf(buf, "Nick set to \"%s\"", cmd); sprintf(buf, "Nick set to \"%s\"", cmd);
system_msg(chat_users[i].pid, buf); system_msg(chat_users[i].pid, buf);
send_all("NICK %s %s %s %s\r\n", chat_users[i].nick, chat_users[i].name,
CFG.myfqdn, chat_users[i].realname);
chat_dump(); chat_dump();
goto ack; goto ack;
} }

View File

@ -165,12 +165,8 @@ void dump_ncslist(void)
Syslog('+', "IBC: Server User Name/Nick Channel Cop Connect time"); Syslog('+', "IBC: Server User Name/Nick Channel Cop Connect time");
Syslog('+', "IBC: -------------------- -------------------- --------- ------------- --- --------------------"); Syslog('+', "IBC: -------------------- -------------------- --------- ------------- --- --------------------");
for (usrp = users; usrp; usrp = usrp->next) { for (usrp = users; usrp; usrp = usrp->next) {
if (strlen(usrp->nick)) Syslog('+', "IBC: %-20s %-20s %-9s %-13s %s %s", usrp->server, usrp->realname, usrp->nick, usrp->channel,
Syslog('+', "IBC: %-20s %-20s %-9s %-13s %s %s", usrp->server, usrp->realname, usrp->nick, usrp->channel, usrp->chanop ? "yes":"no ", rfcdate(usrp->connected));
usrp->chanop ? "yes":"no ", rfcdate(usrp->connected));
else
Syslog('+', "IBC: %-20s %-20s %-9s %-13s %s %s", usrp->server, usrp->realname, usrp->name, usrp->channel,
usrp->chanop ? "yes":"no ", rfcdate(usrp->connected));
} }
} }
@ -222,6 +218,7 @@ int add_user(usr_list **fap, char *server, char *name, char *realname)
tmp->next = NULL; tmp->next = NULL;
strncpy(tmp->server, server, 63); strncpy(tmp->server, server, 63);
strncpy(tmp->name, name, 9); strncpy(tmp->name, name, 9);
strncpy(tmp->nick, name, 9);
strncpy(tmp->realname, realname, 36); strncpy(tmp->realname, realname, 36);
tmp->connected = now; tmp->connected = now;
@ -950,7 +947,7 @@ int command_nick(char *hostname, char *parameters)
found = FALSE; found = FALSE;
for (tmp = users; tmp; tmp = tmp->next) { for (tmp = users; tmp; tmp = tmp->next) {
if (strcmp(tmp->nick, nick) == 0) { if ((strcmp(tmp->name, nick) == 0) || (strcmp(tmp->nick, nick) == 0)) {
found = TRUE; found = TRUE;
break; break;
} }
@ -963,7 +960,7 @@ int command_nick(char *hostname, char *parameters)
for (tmp = users; tmp; tmp = tmp->next) { for (tmp = users; tmp; tmp = tmp->next) {
if ((strcmp(tmp->server, server) == 0) && (strcmp(tmp->realname, realname) == 0) && (strcmp(tmp->name, name) == 0)) { if ((strcmp(tmp->server, server) == 0) && (strcmp(tmp->realname, realname) == 0) && (strcmp(tmp->name, name) == 0)) {
pthread_mutex_lock(&b_mutex); pthread_mutex_lock(&b_mutex);
sprintf(tmp->nick, "%s", nick); strncpy(tmp->nick, nick, 9);
pthread_mutex_unlock(&b_mutex); pthread_mutex_unlock(&b_mutex);
found = TRUE; found = TRUE;
Syslog('+', "IBC: user %s set nick to %s", name, nick); Syslog('+', "IBC: user %s set nick to %s", name, nick);