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

Annotation of /botnetop.mod/misc.c

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


Revision 1.7 - (hide annotations) (download) (as text)
Sun Jul 14 09:28:45 2002 UTC (17 years, 7 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 sup 1.3 /*
2     * misc.c -- part of botnetop.mod
3     *
4 sup 1.7 * $Id$
5 sup 1.3 */
6     /*
7 sup 1.7 * Copyright (C) 2000, 2001, 2002 Teemu Hjelt <temex@iki.fi>
8 guppy 1.1 *
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 sup 1.7 static int matchattr(struct userrec *u, char *flags, char *chan)
25     {
26 guppy 1.1 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 sup 1.7
47 guppy 1.1 return ok;
48     }
49    
50 sup 1.4 static int isop(char *nick, struct chanset_t *chan)
51 guppy 1.1 {
52 sup 1.7 memberlist *m = NULL;
53 guppy 1.1
54 sup 1.7 if ((m = ismember(chan, nick)) && chan_hasop(m))
55 guppy 1.1 return 1;
56 sup 1.7
57     return 0;
58 guppy 1.1 }
59    
60 sup 1.4 static int handisop(char *handle, struct chanset_t *chan)
61 guppy 1.1 {
62     char s[UHOSTLEN];
63 sup 1.7 struct userrec *u = NULL;
64     memberlist *m = NULL;
65 guppy 1.1
66 sup 1.3 for (m = chan->channel.member; m && m->nick[0]; m = m->next) {
67 guppy 1.1 egg_snprintf(s, sizeof s, "%s!%s", m->nick, m->userhost);
68 sup 1.7 if ((u = get_user_by_host(s)) && !egg_strcasecmp(u->handle, handle) && isop(m->nick, chan))
69 sup 1.5 return 1;
70 sup 1.4 }
71 sup 1.7
72 sup 1.4 return 0;
73 guppy 1.1 }
74 sup 1.3
75 sup 1.4 static int lowbots(struct chanset_t *chan)
76 sup 1.3 {
77 sup 1.4 int bots = 1;
78     char s[UHOSTLEN];
79 sup 1.7 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 sup 1.3
86 sup 1.5 for (m = chan->channel.member; m && m->nick[0]; m = m->next) {
87 sup 1.7 if (rfc_casecmp(m->nick, botname) && chan_hasop(m)) {
88 sup 1.4 egg_snprintf(s, sizeof s, "%s!%s", m->nick, m->userhost);
89 sup 1.7 if ((u = get_user_by_host(s)) && matchattr(u, "b|-", chan->dname))
90 sup 1.4 bots++;
91     }
92     }
93 sup 1.7 if (bots < bop_lowbotslimit)
94 sup 1.3 return 1;
95 sup 1.7
96     return 0;
97 sup 1.3 }

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23