/[cvs]/botnetop.mod/misc.c
ViewVC logotype

Contents of /botnetop.mod/misc.c

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.7 - (show annotations) (download) (as text)
Sun Jul 14 09:28:45 2002 UTC (16 years, 5 months ago) by sup
Branch: MAIN
CVS Tags: HEAD
Changes since 1.6: +24 -21 lines
File MIME type: text/x-chdr
Updated to 1.1.0-gamma

1 /*
2 * misc.c -- part of botnetop.mod
3 *
4 * $Id$
5 */
6 /*
7 * Copyright (C) 2000, 2001, 2002 Teemu Hjelt <temex@iki.fi>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 */
23
24 static int matchattr(struct userrec *u, char *flags, char *chan)
25 {
26 struct flag_record plus, minus, user;
27 int ok = 0, f;
28
29 if (u && (!chan || findchan_by_dname(chan))) {
30 user.match = FR_GLOBAL | (chan ? FR_CHAN : 0) | FR_BOT;
31 get_user_flagrec(u, &user, chan);
32 plus.match = user.match;
33 break_down_flags(flags, &plus, &minus);
34 f = (minus.global || minus.udef_global || minus.chan ||
35 minus.udef_chan || minus.bot);
36 if (flagrec_eq(&plus, &user)) {
37 if (!f)
38 ok = 1;
39 else {
40 minus.match = plus.match ^ (FR_AND | FR_OR);
41 if (!flagrec_eq(&minus, &user))
42 ok = 1;
43 }
44 }
45 }
46
47 return ok;
48 }
49
50 static int isop(char *nick, struct chanset_t *chan)
51 {
52 memberlist *m = NULL;
53
54 if ((m = ismember(chan, nick)) && chan_hasop(m))
55 return 1;
56
57 return 0;
58 }
59
60 static int handisop(char *handle, struct chanset_t *chan)
61 {
62 char s[UHOSTLEN];
63 struct userrec *u = NULL;
64 memberlist *m = NULL;
65
66 for (m = chan->channel.member; m && m->nick[0]; m = m->next) {
67 egg_snprintf(s, sizeof s, "%s!%s", m->nick, m->userhost);
68 if ((u = get_user_by_host(s)) && !egg_strcasecmp(u->handle, handle) && isop(m->nick, chan))
69 return 1;
70 }
71
72 return 0;
73 }
74
75 static int lowbots(struct chanset_t *chan)
76 {
77 int bots = 1;
78 char s[UHOSTLEN];
79 struct userrec *u = NULL;
80 memberlist *m = NULL;
81
82 if (!bop_lowbotslimit)
83 return 0; /* Let's speed up things and return 0 right
84 away if bop_lowbotslimit is set to 0. */
85
86 for (m = chan->channel.member; m && m->nick[0]; m = m->next) {
87 if (rfc_casecmp(m->nick, botname) && chan_hasop(m)) {
88 egg_snprintf(s, sizeof s, "%s!%s", m->nick, m->userhost);
89 if ((u = get_user_by_host(s)) && matchattr(u, "b|-", chan->dname))
90 bots++;
91 }
92 }
93 if (bots < bop_lowbotslimit)
94 return 1;
95
96 return 0;
97 }

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23