Skip to content

Commit 2cb7e93

Browse files
authored
Merge branch 'eggheads:develop' into develop
2 parents a1f7e51 + d58f563 commit 2cb7e93

26 files changed

+281
-330
lines changed

Diff for: doc/sphinx_source/using/tcl-commands.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1136,7 +1136,7 @@ nick2hand <nickname> [channel]
11361136
Module: irc
11371137

11381138
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1139-
account2nicks <handle> [channel]
1139+
account2nicks <account> [channel]
11401140
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
11411141

11421142
Returns: a de-duplicated Tcl list of the nickname(s) on the specified channel (if one is specified) whose nickname matches the given account; "" is returned if no match is found. This command will only work if a server supports (and Eggdrop has enabled) the account-notify and extended-join capabilities, and the server understands WHOX requests (also known as raw 354 responses). If no channel is specified, all channels are checked.

Diff for: src/chan.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ typedef struct memstruct {
5050
time_t split; /* in case they were just netsplit */
5151
time_t last; /* for measuring idle time */
5252
time_t delay; /* for delayed autoop */
53-
struct userrec *user;
54-
int tried_getuser;
53+
struct userrec *user; /* cached user lookup */
54+
int tried_getuser; /* negative user lookup cache */
5555
struct memstruct *next;
5656
} memberlist;
5757

Diff for: src/chanprog.c

+8-45
Original file line numberDiff line numberDiff line change
@@ -116,34 +116,13 @@ struct chanset_t *findchan_by_dname(const char *name)
116116
return NULL;
117117
}
118118

119-
120-
/*
121-
* "caching" functions
122-
*/
123-
124-
/* Shortcut for get_user_by_host -- might have user record in one
125-
* of the channel caches.
126-
*/
127-
struct userrec *check_chanlist(const char *host)
128-
{
129-
char *nick, *uhost, buf[UHOSTLEN];
130-
memberlist *m;
131-
struct chanset_t *chan;
132-
133-
strlcpy(buf, host, sizeof buf);
134-
uhost = buf;
135-
nick = splitnick(&uhost);
136-
for (chan = chanset; chan; chan = chan->next)
137-
for (m = chan->channel.member; m && m->nick[0]; m = m->next)
138-
if (!rfc_casecmp(nick, m->nick) && !strcasecmp(uhost, m->userhost))
139-
return m->user;
140-
return NULL;
141-
}
142-
143119
/* Clear the user pointers in the chanlists.
144120
*
145-
* Necessary when a hostmask is added/removed, a user is added or a new
146-
* userfile is loaded.
121+
* Necessary when:
122+
* - a hostmask is added/removed
123+
* - an account is added/removed
124+
* - a user is added
125+
* - new userfile is loaded
147126
*/
148127
void clear_chanlist(void)
149128
{
@@ -159,8 +138,9 @@ void clear_chanlist(void)
159138

160139
/* Clear the user pointer of a specific nick in the chanlists.
161140
*
162-
* Necessary when a hostmask is added/removed, a nick changes, etc.
163-
* Does not completely invalidate the channel cache like clear_chanlist().
141+
* Necessary when:
142+
* - their hostmask changed (chghost)
143+
* - their account changed
164144
*/
165145
void clear_chanlist_member(const char *nick)
166146
{
@@ -176,23 +156,6 @@ void clear_chanlist_member(const char *nick)
176156
}
177157
}
178158

179-
/* If this user@host is in a channel, set it (it was null)
180-
*/
181-
void set_chanlist(const char *host, struct userrec *rec)
182-
{
183-
char *nick, *uhost, buf[UHOSTLEN];
184-
memberlist *m;
185-
struct chanset_t *chan;
186-
187-
strlcpy(buf, host, sizeof buf);
188-
uhost = buf;
189-
nick = splitnick(&uhost);
190-
for (chan = chanset; chan; chan = chan->next)
191-
for (m = chan->channel.member; m && m->nick[0]; m = m->next)
192-
if (!rfc_casecmp(nick, m->nick) && !strcasecmp(uhost, m->userhost))
193-
m->user = rec;
194-
}
195-
196159
/* Calculate the memory we should be using
197160
*/
198161
int expmem_chanprog()

Diff for: src/main.c

+5-3
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,8 @@ int init_userent();
722722
int init_misc();
723723
int init_bots();
724724
int init_modules();
725-
void init_tcl(int, char **);
725+
void init_tcl0(int, char **);
726+
void init_tcl1(int, char **);
726727
void init_language(int);
727728
#ifdef TLS
728729
int ssl_init();
@@ -893,7 +894,7 @@ static void mainloop(int toplevel)
893894
}
894895

895896
kill_tcl();
896-
init_tcl(argc, argv);
897+
init_tcl1(argc, argv);
897898
init_language(0);
898899

899900
/* this resets our modules which we didn't unload (encryption and uptime) */
@@ -1041,6 +1042,7 @@ int main(int arg_c, char **arg_v)
10411042
init_mem();
10421043
if (argc > 1)
10431044
do_arg();
1045+
init_tcl0(argc, argv);
10441046
init_language(1);
10451047

10461048
printf("\n%s\n", version);
@@ -1060,7 +1062,7 @@ int main(int arg_c, char **arg_v)
10601062
init_modules();
10611063
if (backgrd)
10621064
bg_prepare_split();
1063-
init_tcl(argc, argv);
1065+
init_tcl1(argc, argv);
10641066
init_language(0);
10651067
#ifdef STATIC
10661068
link_statics();

Diff for: src/main.h

+8-5
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,18 @@
4141
#include "eggint.h"
4242
#include "lush.h"
4343

44+
#ifndef TCL_SIZE_MAX
45+
typedef int Tcl_Size;
46+
# define Tcl_GetSizeIntFromObj Tcl_GetIntFromObj
47+
# define TCL_SIZE_MAX INT_MAX
48+
# define TCL_SIZE_MODIFIER ""
49+
#endif
50+
4451
#ifndef TCL_PATCH_LEVEL
4552
# define TCL_PATCH_LEVEL "*unknown*"
4653
#endif
4754

48-
#ifdef CONST
49-
# define EGG_CONST CONST
50-
#else
51-
# define EGG_CONST
52-
#endif
55+
#define EGG_CONST const
5356

5457
#ifdef CONST86
5558
# define TCL_CONST86 CONST86

Diff for: src/mod/channels.mod/channels.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,7 @@ static char *traced_globchanset(ClientData cdata, Tcl_Interp *irp,
737737
EGG_CONST char *name1,
738738
EGG_CONST char *name2, int flags)
739739
{
740-
int i, items;
740+
Tcl_Size i, items;
741741
char *t, *s;
742742
EGG_CONST char **item, *s2;
743743

Diff for: src/mod/channels.mod/cmdschan.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1191,7 +1191,7 @@ static void cmd_mns_chrec(struct userrec *u, int idx, char *par)
11911191

11921192
static void cmd_pls_chan(struct userrec *u, int idx, char *par)
11931193
{
1194-
int i, argc;
1194+
Tcl_Size i, argc;
11951195
EGG_CONST char **argv;
11961196
char *chname;
11971197
struct chanset_t *chan;

Diff for: src/mod/channels.mod/tclchan.c

+7-7
Original file line numberDiff line numberDiff line change
@@ -1013,7 +1013,7 @@ static int tcl_channel_getlist(Tcl_Interp *irp, struct chanset_t *chan)
10131013
{
10141014
char s[121], *str;
10151015
EGG_CONST char **argv = NULL;
1016-
int argc = 0;
1016+
Tcl_Size argc = 0;
10171017
struct udef_struct *ul;
10181018

10191019
/* String values first */
@@ -1133,7 +1133,7 @@ static int tcl_channel_get(Tcl_Interp *irp, struct chanset_t *chan,
11331133
{
11341134
char s[121], *str = NULL;
11351135
EGG_CONST char **argv = NULL;
1136-
int argc = 0;
1136+
Tcl_Size argc = 0;
11371137
struct udef_struct *ul;
11381138

11391139
if (!strcmp(setting, "chanmode"))
@@ -1998,17 +1998,17 @@ static void init_masklist(masklist *m)
19981998
static void init_channel(struct chanset_t *chan, int reset)
19991999
{
20002000
int flags = reset ? reset : CHAN_RESETALL;
2001+
memberlist *m, *m1;
20012002

20022003
if (flags & CHAN_RESETWHO) {
2003-
if (chan->channel.member) {
2004-
nfree(chan->channel.member);
2004+
for (m = chan->channel.member; m; m = m1) {
2005+
m1 = m->next;
2006+
nfree(m);
20052007
}
20062008
chan->channel.members = 0;
20072009
chan->channel.member = nmalloc(sizeof *chan->channel.member);
20082010
/* Since we don't have channel_malloc, manually bzero */
20092011
egg_bzero(chan->channel.member, sizeof *chan->channel.member);
2010-
chan->channel.member->nick[0] = 0;
2011-
chan->channel.member->next = NULL;
20122012
}
20132013

20142014
if (flags & CHAN_RESETMODES) {
@@ -2089,7 +2089,7 @@ static void clear_channel(struct chanset_t *chan, int reset)
20892089
*/
20902090
static int tcl_channel_add(Tcl_Interp *irp, char *newname, char *options)
20912091
{
2092-
int items;
2092+
Tcl_Size items;
20932093
int ret = TCL_OK;
20942094
int join = 0;
20952095
char buf[2048], buf2[256];

Diff for: src/mod/channels.mod/userchan.c

+1-6
Original file line numberDiff line numberDiff line change
@@ -1270,12 +1270,7 @@ static int expired_mask(struct chanset_t *chan, char *who)
12701270
* present in the channel and has op.
12711271
*/
12721272

1273-
if (m->user)
1274-
u = m->user;
1275-
else {
1276-
simple_sprintf(buf, "%s!%s", m->nick, m->userhost);
1277-
u = get_user_by_host(buf);
1278-
}
1273+
u = get_user_from_member(m);
12791274
/* Do not expire masks set by bots. */
12801275
if (u && u->flags & USER_BOT)
12811276
return 0;

0 commit comments

Comments
 (0)