/[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.6 - (show annotations) (download) (as text)
Tue Feb 13 18:23:24 2001 UTC (18 years, 4 months ago) by sup
Branch: MAIN
Changes since 1.5: +2 -2 lines
File MIME type: text/x-chdr
Updated to 1.0.1

1 /*
2 * misc.c -- part of botnetop.mod
3 *
4 * $Id: misc.c,v 1.5 2000/10/13 20:22:48 sup Exp $
5 */
6 /*
7 * Copyright (C) 2000, 2001 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 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 static int isop(char *nick, struct chanset_t *chan)
49 {
50 memberlist *m;
51
52 if ((m = ismember(chan, nick)) && (chan_hasop(m)))
53 return 1;
54 else
55 return 0;
56 }
57
58 static int handisop(char *handle, struct chanset_t *chan)
59 {
60 char s[UHOSTLEN];
61 struct userrec *u;
62 memberlist *m;
63
64 for (m = chan->channel.member; m && m->nick[0]; m = m->next) {
65 egg_snprintf(s, sizeof s, "%s!%s", m->nick, m->userhost);
66 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 }
73 return 0;
74 }
75
76 static int lowbots(struct chanset_t *chan)
77 {
78 int bots = 1;
79 char s[UHOSTLEN];
80 struct userrec *u;
81 memberlist *m;
82
83 for (m = chan->channel.member; m && m->nick[0]; m = m->next) {
84 if ((egg_strcasecmp(m->nick, botname)) && (chan_hasop(m))) {
85 egg_snprintf(s, sizeof s, "%s!%s", m->nick, m->userhost);
86 if ((u = get_user_by_host(s)) && (matchattr(u, "b|-", chan->dname)))
87 bots++;
88 }
89 }
90 if (bots < 3)
91 return 1;
92 else
93 return 0;
94 }

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23