From 9576b3233f3df4529edabeb8a6bfb697bd55eb56 Mon Sep 17 00:00:00 2001 From: Michiel Broek Date: Wed, 20 Apr 2005 20:27:32 +0000 Subject: [PATCH] Fix userlist --- mbtask/taskchat.c | 5 +++-- mbtask/taskibc.c | 22 +++++++++++----------- mbtask/taskibc.h | 4 ++-- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/mbtask/taskchat.c b/mbtask/taskchat.c index 07fe48a6..2f2fe307 100644 --- a/mbtask/taskchat.c +++ b/mbtask/taskchat.c @@ -113,6 +113,7 @@ extern struct sysconfig CFG; /* System configuration */ extern int s_bbsopen; /* The BBS open status */ #ifdef USE_EXPERIMENT extern srv_list *servers; /* Connected servers */ +extern usr_list *users; /* Connected users */ #endif @@ -435,7 +436,7 @@ char *chat_connect(char *data) /* * Register with IBC */ - add_user(CFG.myfqdn, nick, realname); + add_user(&users, CFG.myfqdn, nick, realname); sprintf(buf, "USER %s@%s %s", nick, CFG.myfqdn, realname); send_all(buf); #endif @@ -486,7 +487,7 @@ char *chat_close(char *data) * Remove from IBC network */ #ifdef USE_EXPERIMENT - del_user(CFG.myfqdn, chat_users[i].realname); + del_user(&users, CFG.myfqdn, chat_users[i].realname); sprintf(buf, "QUIT %s@%s Leaving chat", chat_users[i].nick, CFG.myfqdn); send_all(buf); #endif diff --git a/mbtask/taskibc.c b/mbtask/taskibc.c index 17f1c716..76581380 100644 --- a/mbtask/taskibc.c +++ b/mbtask/taskibc.c @@ -160,10 +160,10 @@ void dump_ncslist(void) } if (usrchg) { - Syslog('+', "IBC: Server User Nick Channel Cop Connect time"); - Syslog('+', "IBC: ------------------------- ------------------------- --------- -------------------- --- --------------------"); + Syslog('+', "IBC: Server User Nick Channel Cop Connect time"); + Syslog('+', "IBC: -------------------- -------------------- --------- --------------- --- --------------------"); for (usrp = users; usrp; usrp = usrp->next) { - Syslog('+', "IBC: %-25s %-25s %-9s %-20s %s %s", usrp->server, usrp->realname, usrp->nick, usrp->channel, + Syslog('+', "IBC: %-20s %-20s %-9s %-15s %s %s", usrp->server, usrp->realname, usrp->nick, usrp->channel, usrp->chanop ? "yes":"no ", rfcdate(usrp->connected)); } } @@ -191,7 +191,7 @@ void tidy_servers(srv_list ** fdp) /* * Add one user to the userlist */ -void add_user(char *server, char *nick, char *realname) +void add_user(usr_list **fap, char *server, char *nick, char *realname) { usr_list *tmp, *ta; srv_list *sl; @@ -199,7 +199,7 @@ void add_user(char *server, char *nick, char *realname) Syslog('r', "add_user %s %s %s", server, nick, realname); - for (ta = users; ta; ta = ta->next) { + for (ta = *fap; ta; ta = ta->next) { if ((strcmp(ta->server, server) == 0) && (strcmp(ta->realname, realname) == 0)) { Syslog('r', "duplicate, ignore"); return; @@ -217,10 +217,10 @@ void add_user(char *server, char *nick, char *realname) strncpy(tmp->realname, realname, 36); tmp->connected = now; - if (users == NULL) { - users = tmp; + if (*fap == NULL) { + *fap = tmp; } else { - for (ta = users; ta; ta = ta->next) + for (ta = *fap; ta; ta = ta->next) if (ta->next == NULL) { ta->next = (usr_list *)tmp; break; @@ -245,7 +245,7 @@ void add_user(char *server, char *nick, char *realname) /* * Delete one user. */ -void del_user(char *server, char *realname) +void del_user(usr_list **fap, char *server, char *realname) { usr_list *ta, *tan; srv_list *sl; @@ -253,13 +253,13 @@ void del_user(char *server, char *realname) Syslog('r', "deluser %s %s", server, realname); - if (users == NULL) + if (*fap == NULL) return; if ((rc = pthread_mutex_lock(&b_mutex))) Syslog('!', "del_user() mutex_lock failed rc=%d", rc); - for (ta = users; ta; ta = ta->next) { + for (ta = *fap; ta; ta = ta->next) { while ((tan = ta->next) && (strcmp(tan->server, server) == 0) && (strcmp(tan->realname, realname) == 0)) { ta->next = tan->next; free(tan); diff --git a/mbtask/taskibc.h b/mbtask/taskibc.h index e7d51b3e..0244ba04 100644 --- a/mbtask/taskibc.h +++ b/mbtask/taskibc.h @@ -76,8 +76,8 @@ typedef struct _chn_list { -void add_user(char *, char *, char *); -void del_user(char *, char *); +void add_user(usr_list **, char *, char *, char *); +void del_user(usr_list **, char *, char *); void send_all(char *); void *ibc_thread(void *);