/[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.2 - (show annotations) (download) (as text)
Mon Aug 14 01:47:33 2000 UTC (19 years, 2 months ago) by guppy
Branch: MAIN
Changes since 1.1: +2 -0 lines
File MIME type: text/x-chdr
added Id tags

1 /*
2 * $Id$
3 *
4 * Copyright (C) 2000 Teemu Hjelt <temex@iki.fi>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 */
20
21 static int matchattr (struct userrec *u, char *flags, char *chan) {
22 struct flag_record plus, minus, user;
23 int ok = 0, f;
24
25 Context;
26 if (u && (!chan || findchan_by_dname(chan))) {
27 Context;
28 user.match = FR_GLOBAL | (chan ? FR_CHAN : 0) | FR_BOT;
29 get_user_flagrec(u, &user, chan);
30 plus.match = user.match;
31 break_down_flags(flags, &plus, &minus);
32 f = (minus.global || minus.udef_global || minus.chan ||
33 minus.udef_chan || minus.bot);
34 if (flagrec_eq(&plus, &user)) {
35 Context;
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 Context;
46 return ok;
47 }
48
49 static int isop (char *nick, char *chname)
50 {
51 struct chanset_t *chan = NULL;
52 memberlist *m;
53
54 if ((chan = findchan_by_dname(chname)) && ((m = ismember(chan, nick)) && chan_hasop(m)))
55 return 1;
56 else
57 return 0;
58 }
59
60 static int handisop (char *handle, char *chname)
61 {
62 char s[UHOSTLEN];
63 struct chanset_t *chan = NULL;
64 struct userrec *u;
65 memberlist *m;
66
67 if (!(chan = findchan_by_dname(chname)))
68 return 0;
69 m = chan->channel.member;
70 while (m && m->nick[0]) {
71 egg_snprintf(s, sizeof s, "%s!%s", m->nick, m->userhost);
72 u = get_user_by_host(s);
73 if (u && !egg_strcasecmp(u->handle, handle)) {
74 break;
75 }
76 m = m->next;
77 }
78 return isop(m->nick, chan->dname);
79 }

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23