/[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.4 - (show annotations) (download) (as text)
Mon Aug 28 18:23:31 2000 UTC (18 years, 9 months ago) by sup
Branch: MAIN
Changes since 1.3: +32 -15 lines
File MIME type: text/x-chdr
Updated to 0.5.0

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

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23