/[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.5 - (hide annotations) (download) (as text)
Fri Oct 13 20:22:48 2000 UTC (19 years, 1 month ago) by sup
Branch: MAIN
Changes since 1.4: +12 -27 lines
File MIME type: text/x-chdr
Updated to 1.0.0pre5

1 sup 1.3 /*
2     * misc.c -- part of botnetop.mod
3     *
4 sup 1.4 * $Id: misc.c,v 1.3 2000/08/25 20:19:17 sup Exp $
5 sup 1.3 */
6     /*
7 guppy 1.1 * Copyright (C) 2000 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 sup 1.3 static int matchattr(struct userrec *u, char *flags, char *chan) {
25 guppy 1.1 struct flag_record plus, minus, user;
26     int ok = 0, f;
27    
28     if (u && (!chan || findchan_by_dname(chan))) {
29     user.match = FR_GLOBAL | (chan ? FR_CHAN : 0) | FR_BOT;
30     get_user_flagrec(u, &user, chan);
31     plus.match = user.match;
32     break_down_flags(flags, &plus, &minus);
33     f = (minus.global || minus.udef_global || minus.chan ||
34     minus.udef_chan || minus.bot);
35     if (flagrec_eq(&plus, &user)) {
36     if (!f)
37     ok = 1;
38     else {
39     minus.match = plus.match ^ (FR_AND | FR_OR);
40     if (!flagrec_eq(&minus, &user))
41     ok = 1;
42     }
43     }
44     }
45     return ok;
46     }
47    
48 sup 1.4 static int isop(char *nick, struct chanset_t *chan)
49 guppy 1.1 {
50     memberlist *m;
51    
52 sup 1.5 if ((m = ismember(chan, nick)) && (chan_hasop(m)))
53 guppy 1.1 return 1;
54     else
55     return 0;
56     }
57    
58 sup 1.4 static int handisop(char *handle, struct chanset_t *chan)
59 guppy 1.1 {
60     char s[UHOSTLEN];
61     struct userrec *u;
62     memberlist *m;
63    
64 sup 1.3 for (m = chan->channel.member; m && m->nick[0]; m = m->next) {
65 guppy 1.1 egg_snprintf(s, sizeof s, "%s!%s", m->nick, m->userhost);
66 sup 1.5 if ((u = get_user_by_host(s)) && (!egg_strcasecmp(u->handle, handle))) {
67     if (isop(m->nick, chan))
68     return 1;
69     else
70     return 0;
71     }
72 sup 1.4 }
73     return 0;
74 guppy 1.1 }
75 sup 1.3
76 sup 1.4 static int lowbots(struct chanset_t *chan)
77 sup 1.3 {
78 sup 1.4 int bots = 1;
79     char s[UHOSTLEN];
80     struct userrec *u;
81 sup 1.5 memberlist *m;
82 sup 1.3
83 sup 1.5 for (m = chan->channel.member; m && m->nick[0]; m = m->next) {
84 sup 1.4 if ((egg_strcasecmp(m->nick, botname)) && (chan_hasop(m))) {
85     egg_snprintf(s, sizeof s, "%s!%s", m->nick, m->userhost);
86 sup 1.5 if ((u = get_user_by_host(s)) && (matchattr(u, "b|-", chan->dname)))
87 sup 1.4 bots++;
88     }
89     }
90     if (bots < 3)
91 sup 1.3 return 1;
92 sup 1.5 else
93     return 0;
94 sup 1.3 }

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23