Skip to content

Commit

Permalink
Trying out removing m->user
Browse files Browse the repository at this point in the history
  • Loading branch information
vanosg committed May 15, 2024
1 parent aa93194 commit 4f7ed02
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 74 deletions.
2 changes: 1 addition & 1 deletion src/chan.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ typedef struct memstruct {
time_t split; /* in case they were just netsplit */
time_t last; /* for measuring idle time */
time_t delay; /* for delayed autoop */
struct userrec *user;
// struct userrec *user;
int tried_getuser;
struct memstruct *next;
} memberlist;
Expand Down
6 changes: 3 additions & 3 deletions src/chanprog.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ struct userrec *check_chanlist(const char *host)
for (chan = chanset; chan; chan = chan->next)
for (m = chan->channel.member; m && m->nick[0]; m = m->next)
if (!rfc_casecmp(nick, m->nick) && !strcasecmp(uhost, m->userhost))
return m->user;
//XXXXXXXX loop? Does this whole func come out?
return get_user_from_channel(m);
return NULL;
}

Expand All @@ -152,7 +153,6 @@ void clear_chanlist(void)

for (chan = chanset; chan; chan = chan->next)
for (m = chan->channel.member; m && m->nick[0]; m = m->next) {
m->user = NULL;
m->tried_getuser = 0;
}
}
Expand All @@ -170,7 +170,6 @@ void clear_chanlist_member(const char *nick)
for (chan = chanset; chan; chan = chan->next)
for (m = chan->channel.member; m && m->nick[0]; m = m->next)
if (!rfc_casecmp(m->nick, nick)) {
m->user = NULL;
m->tried_getuser = 0;
break;
}
Expand All @@ -190,6 +189,7 @@ void set_chanlist(const char *host, struct userrec *rec)
for (chan = chanset; chan; chan = chan->next)
for (m = chan->channel.member; m && m->nick[0]; m = m->next)
if (!rfc_casecmp(nick, m->nick) && !strcasecmp(uhost, m->userhost))
//XXXXXXXX Does this whole func come out?
m->user = rec;
}

Expand Down
2 changes: 1 addition & 1 deletion src/mod/channels.mod/tclchan.c
Original file line number Diff line number Diff line change
Expand Up @@ -1731,7 +1731,7 @@ static int tcl_do_masklist(maskrec *m, Tcl_Interp *irp)
list[3] = ts1;
snprintf(ts2, sizeof ts2, "%" PRId64, (int64_t) m->lastactive);
list[4] = ts2;
list[5] = m->user;
list[5] = get_user_from_channel(m);
p = Tcl_Merge(6, list);
Tcl_AppendElement(irp, p);
Tcl_Free((char *) p);
Expand Down
6 changes: 1 addition & 5 deletions src/mod/channels.mod/userchan.c
Original file line number Diff line number Diff line change
Expand Up @@ -1270,11 +1270,7 @@ static int expired_mask(struct chanset_t *chan, char *who)
* present in the channel and has op.
*/

if (m->user)
u = m->user;
else {
u = get_user_from_channel(m);
}
u = get_user_from_channel(m);
/* Do not expire masks set by bots. */
if (u && u->flags & USER_BOT)
return 0;
Expand Down
27 changes: 11 additions & 16 deletions src/mod/irc.mod/chan.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ static void setaccount(char *nick, char *account)
} else {
putlog(LOG_MODES, chan->dname, "%s!%s logged in to their account %s", nick, m->userhost, account);
}
check_tcl_account(m->nick, m->userhost, m->user, chan->dname, account);
check_tcl_account(m->nick, m->userhost, get_user_from_channel(m), chan->dname, account);
}
strlcpy(m->account, account, sizeof m->account);
}
Expand Down Expand Up @@ -426,7 +426,7 @@ static void kick_all(struct chanset_t *chan, char *hostmask, char *comment,
flushed = 0;
kicknick[0] = 0;
for (m = chan->channel.member; m && m->nick[0]; m = m->next) {
get_user_flagrec(m->user ? m->user : get_user_from_channel(m), &fr, chan->dname);
get_user_flagrec(get_user_from_channel(m), &fr, chan->dname);
if ((me_op(chan) || (me_halfop(chan) && !chan_hasop(m))) &&
match_addr(hostmask, s) && !chan_sentkick(m) &&
!match_my_nick(m->nick) && !chan_issplit(m) &&
Expand Down Expand Up @@ -474,7 +474,7 @@ static void refresh_ban_kick(struct chanset_t *chan, char *user, char *nick)
if (match_addr(b->mask, user)) {
struct flag_record fr = { FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0 };
char c[512]; /* The ban comment. */
get_user_flagrec(m->user ? m->user : get_user_from_channel(m), &fr,
get_user_flagrec(get_user_from_channel(m), &fr,
chan->dname);
if (!glob_friend(fr) && !chan_friend(fr)) {
add_mode(chan, '-', 'o', nick); /* Guess it can't hurt. */
Expand Down Expand Up @@ -866,7 +866,7 @@ static void check_this_member(struct chanset_t *chan, char *nick,
(me_op(chan) || (me_halfop(chan) && !chan_hasop(m)))) {
check_exemptlist(chan, s);
quickban(chan, m->userhost);
p = get_user(&USERENTRY_COMMENT, m->user);
p = get_user(&USERENTRY_COMMENT, get_user_from_channel(m));
dprintf(DP_SERVER, "KICK %s %s :%s\n", chan->name, m->nick,
p ? p : IRC_POLITEKICK);
m->flags |= SENTKICK;
Expand All @@ -885,7 +885,7 @@ static void check_this_user(char *hand, int delete, char *host)

for (chan = chanset; chan; chan = chan->next)
for (m = chan->channel.member; m && m->nick[0]; m = m->next) {
u = m->user ? m->user : get_user_from_channel(m);
u = get_user_from_channel(m);
if ((u && !strcasecmp(u->handle, hand) && delete < 2) ||
(!u && delete == 2 && match_addr(host, s))) {
u = delete ? NULL : u;
Expand All @@ -910,11 +910,11 @@ static void recheck_channel(struct chanset_t *chan, int dobans)
stacking++;
/* Okay, sort through who needs to be deopped. */
for (m = chan->channel.member; m && m->nick[0]; m = m->next) {
if (!m->user && !m->tried_getuser) {
if (!get_user_from_channel(m) && !m->tried_getuser) {
m->tried_getuser = 1;
m->user = get_user_from_channel(m);
u = get_user_from_channel(m);
}
get_user_flagrec(m->user, &fr, chan->dname);
get_user_flagrec(u, &fr, chan->dname);
if (glob_bot(fr) && chan_hasop(m) && !match_my_nick(m->nick))
stop_reset = 1;
/* Perhaps we were halfop and tried to halfop/kick the user earlier but
Expand Down Expand Up @@ -1078,7 +1078,6 @@ static int got352or4(struct chanset_t *chan, char *user, char *host,
simple_sprintf(m->userhost, "%s@%s", user, host);
simple_sprintf(userhost, "%s!%s", nick, m->userhost);
/* Combine n!u@h */
m->user = NULL; /* No handle match (yet) */
if (match_my_nick(nick)) /* Is it me? */
strcpy(botuserhost, m->userhost); /* Yes, save my own userhost */
m->flags |= WHO_SYNCED;
Expand Down Expand Up @@ -1109,7 +1108,6 @@ static int got352or4(struct chanset_t *chan, char *user, char *host,
if (chan->need_op[0])
do_tcl("need-op", chan->need_op);
}
m->user = get_user_from_channel(m);

/* Update accountname in channel records, 0 means logged out */
/* A 0 is not a change from "" */
Expand Down Expand Up @@ -2053,7 +2051,6 @@ static int gotjoin(char *from, char *channame)
m->last = now;
m->delay = 0L;
m->flags = (chan_hasop(m) ? WASOP : 0) | (chan_hashalfop(m) ? WASHALFOP : 0);
m->user = u;
set_handle_laston(chan->dname, u, now);
m->flags |= STOPWHO;
putlog(LOG_JOIN, chan->dname, "%s (%s) returned to %s.", nick, uhost,
Expand All @@ -2069,7 +2066,6 @@ static int gotjoin(char *from, char *channame)
m->delay = 0L;
strlcpy(m->nick, nick, sizeof m->nick);
strlcpy(m->userhost, uhost, sizeof m->userhost);
m->user = u;
m->flags |= STOPWHO;

if (extjoin) {
Expand All @@ -2091,7 +2087,6 @@ static int gotjoin(char *from, char *channame)

/* The record saved in the channel record always gets updated,
* so we can use that. */
u = m->user;

if (match_my_nick(nick)) {
/* It was me joining! Need to update the channel record with the
Expand Down Expand Up @@ -2122,9 +2117,9 @@ static int gotjoin(char *from, char *channame)
if (u) {
struct laston_info *li = 0;

cr = get_chanrec(m->user, chan->dname);
cr = get_chanrec(get_user_from_channel(m), chan->dname);
if (!cr && no_chanrec_info)
li = get_user(&USERENTRY_LASTON, m->user);
li = get_user(&USERENTRY_LASTON, get_user_from_channel(m));
if (channel_greet(chan) && use_info &&
((cr && now - cr->laston > wait_info) ||
(no_chanrec_info && (!li || now - li->laston > wait_info)))) {
Expand Down Expand Up @@ -2182,7 +2177,7 @@ static int gotjoin(char *from, char *channame)
(me_op(chan) || (me_halfop(chan) && !chan_hasop(m)))) {
check_exemptlist(chan, from);
quickban(chan, from);
p = get_user(&USERENTRY_COMMENT, m->user);
p = get_user(&USERENTRY_COMMENT, get_user_from_channel(m));
dprintf(DP_MODE, "KICK %s %s :%s\n", chname, nick,
(p && (p[0] != '@')) ? p : IRC_COMMENTKICK);
m->flags |= SENTKICK;
Expand Down
25 changes: 13 additions & 12 deletions src/mod/irc.mod/cmdsirc.c
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ static void cmd_halfop(struct userrec *u, int idx, char *par)
get_user_flagrec(dcc[idx].user, &user, chan->dname);
m = ismember(chan, nick);
if (m && !chan_op(user) && (!glob_op(user) || chan_deop(user))) {
u2 = m->user ? m->user : get_user_from_channel(m);
u2 = get_user_from_channel(m);

if (!u2 || strcasecmp(u2->handle, dcc[idx].nick) || (!chan_halfop(user) &&
(!glob_halfop(user) || chan_dehalfop(user)))) {
Expand Down Expand Up @@ -442,7 +442,7 @@ static void cmd_dehalfop(struct userrec *u, int idx, char *par)
get_user_flagrec(dcc[idx].user, &user, chan->dname);
m = ismember(chan, nick);
if (m && !chan_op(user) && (!glob_op(user) || chan_deop(user))) {
u2 = m->user ? m->user : get_user_from_channel(m);
u2 = get_user_from_channel(m);
if (!u2 || strcasecmp(u2->handle, dcc[idx].nick) || (!chan_halfop(user) &&
(!glob_halfop(user) || chan_dehalfop(user)))) {
dprintf(idx, "You are not a channel op on %s.\n", chan->dname);
Expand Down Expand Up @@ -519,7 +519,7 @@ static void cmd_voice(struct userrec *u, int idx, char *par)
* - stdarg */
if (m && !(chan_op(user) || chan_halfop(user) || (glob_op(user) &&
!chan_deop(user)) || (glob_halfop(user) && !chan_dehalfop(user)))) {
u2 = m->user ? m->user : get_user_from_channel(m);
u2 = get_user_from_channel(m);

if (!u2 || strcasecmp(u2->handle, dcc[idx].nick) || (!chan_voice(user) &&
(!glob_voice(user) || chan_quiet(user)))) {
Expand Down Expand Up @@ -570,7 +570,7 @@ static void cmd_devoice(struct userrec *u, int idx, char *par)
m = ismember(chan, nick);
if (m && !(chan_op(user) || chan_halfop(user) || (glob_op(user) &&
!chan_deop(user)) || (glob_halfop(user) && !chan_dehalfop(user)))) {
u2 = m->user ? m->user : get_user_from_channel(m);
u2 = get_user_from_channel(m);

if (!u2 || strcasecmp(u2->handle, dcc[idx].nick) || (!chan_voice(user) &&
(!glob_voice(user) || chan_quiet(user)))) {
Expand Down Expand Up @@ -706,6 +706,7 @@ static void cmd_channel(struct userrec *u, int idx, char *par)
char handle[HANDLEN + 1], s[UHOSTLEN], s1[UHOSTLEN], atrflag, chanflag;
struct chanset_t *chan;
memberlist *m;
struct userrec *u;
int maxnicklen, maxhandlen;

chan = get_channel(idx, par);
Expand All @@ -729,8 +730,9 @@ static void cmd_channel(struct userrec *u, int idx, char *par)
for (m = chan->channel.member; m && m->nick[0]; m = m->next) {
if (strlen(m->nick) > maxnicklen)
maxnicklen = strlen(m->nick);
if ((m->user) && (strlen(m->user->handle) > maxhandlen))
maxhandlen = strlen(m->user->handle);
u = get_user_from_channel(m);
if (u && (strlen(u->handle) > maxhandlen))
maxhandlen = strlen(u->handle);
}
if (maxnicklen < 9)
maxnicklen = 9;
Expand All @@ -750,14 +752,13 @@ static void cmd_channel(struct userrec *u, int idx, char *par)
} else
strlcpy(s, " --- ", sizeof s);
egg_snprintf(s, sizeof s, "%s!%s", m->nick, m->userhost);
if (m->user == NULL) {
m->user = get_user_from_channel(m);
}
if (m->user == NULL)

u = get_user_from_channel(m);
if (u == NULL)
strlcpy(handle, "*", sizeof handle);
else
strlcpy(handle, m->user->handle, sizeof handle);
get_user_flagrec(m->user, &user, chan->dname);
strlcpy(handle, u->handle, sizeof handle);
get_user_flagrec(u, &user, chan->dname);
/* Determine status char to use */
if (glob_bot(user) && (glob_op(user) || chan_op(user)))
atrflag = 'B';
Expand Down
6 changes: 2 additions & 4 deletions src/mod/irc.mod/irc.c
Original file line number Diff line number Diff line change
Expand Up @@ -669,8 +669,7 @@ static void check_expired_chanstuff()
for (m = chan->channel.member; m && m->nick[0]; m = m->next)
if (now - m->last >= chan->idle_kick * 60 &&
!match_my_nick(m->nick) && !chan_issplit(m)) {
get_user_flagrec(m->user ? m->user : get_user_from_channel(m),
&fr, chan->dname);
get_user_flagrec(get_user_from_channel(m), &fr, chan->dname);
if ((!(glob_bot(fr) || glob_friend(fr) || (glob_op(fr) &&
!chan_deop(fr)) || chan_friend(fr) || chan_op(fr))) &&
(me_op(chan) || (me_halfop(chan) && !chan_hasop(m)))) {
Expand All @@ -683,8 +682,7 @@ static void check_expired_chanstuff()
for (m = chan->channel.member; m && m->nick[0]; m = n) {
n = m->next;
if (m->split && now - m->split > wait_split) {
check_tcl_sign(m->nick, m->userhost,
m->user ? m->user : get_user_from_channel(m),
check_tcl_sign(m->nick, m->userhost, get_user_from_channel(m),
chan->dname, "lost in the netsplit");
putlog(LOG_JOIN, chan->dname,
"%s (%s) got lost in the net-split.", m->nick, m->userhost);
Expand Down
13 changes: 3 additions & 10 deletions src/mod/irc.mod/mode.c
Original file line number Diff line number Diff line change
Expand Up @@ -421,10 +421,7 @@ static void got_op(struct chanset_t *chan, char *nick, char *from,
check_chan = 1;

strcpy(ch, chan->name);
if (!m->user)
u = get_user_from_channel(m);
else
u = m->user;
u = get_user_from_channel(m);

get_user_flagrec(u, &victim, chan->dname);
/* Flags need to be set correctly right from the beginning now, so that
Expand Down Expand Up @@ -518,10 +515,7 @@ static void got_halfop(struct chanset_t *chan, char *nick, char *from,
check_chan = 1;

strcpy(ch, chan->name);
if (!m->user)
u = get_user_from_channel(m);
else
u = m->user;
u = get_user_from_channel(m);

get_user_flagrec(u, &victim, chan->dname);
/* Flags need to be set correctly right from the beginning now, so that
Expand Down Expand Up @@ -1245,8 +1239,7 @@ static int gotmode(char *from, char *origmsg)
refresh_who_chan(chan->name);
} else {
simple_sprintf(s, "%s!%s", m->nick, m->userhost);
get_user_flagrec(m->user ? m->user : get_user_from_channel(m),
&victim, chan->dname);
get_user_flagrec(get_user_from_channel, &victim, chan->dname);
if (ms2[0] == '+') {
m->flags &= ~SENTVOICE;
m->flags |= CHANVOICE;
Expand Down
Loading

0 comments on commit 4f7ed02

Please sign in to comment.