/[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.3 - (show annotations) (download) (as text)
Fri Aug 25 20:19:17 2000 UTC (19 years, 3 months ago) by sup
Branch: MAIN
Changes since 1.2: +24 -11 lines
File MIME type: text/x-chdr
Updated to 0.4.0

1 /*
2 * misc.c -- part of botnetop.mod
3 *
4 * $Id: misc.c,v 1.2 2000/08/14 01:47:33 guppy 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, char *chname)
53 {
54 struct chanset_t *chan = NULL;
55 memberlist *m;
56
57 if ((chan = findchan_by_dname(chname)) && ((m = ismember(chan, nick)) && chan_hasop(m)))
58 return 1;
59 else
60 return 0;
61 }
62
63 static int handisop(char *handle, char *chname)
64 {
65 char s[UHOSTLEN];
66 struct chanset_t *chan = NULL;
67 struct userrec *u;
68 memberlist *m;
69
70 if (!(chan = findchan_by_dname(chname)))
71 return 0;
72 for (m = chan->channel.member; m && m->nick[0]; m = m->next) {
73 egg_snprintf(s, sizeof s, "%s!%s", m->nick, m->userhost);
74 u = get_user_by_host(s);
75 if (u && !egg_strcasecmp(u->handle, handle))
76 break;
77 }
78 return isop(m->nick, chan->dname);
79 }
80
81 static int hasops(char *chname)
82 {
83 struct chanset_t *chan = NULL;
84 memberlist *m;
85
86 if (!(chan = findchan_by_dname(chname)))
87 return 0;
88 for (m = chan->channel.member; m && m->nick[0] && chan_hasop(m); m = m->next)
89 return 1;
90 return 0;
91 }
92

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23