/[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.1 - (show annotations) (download) (as text)
Mon Aug 14 01:41:03 2000 UTC (19 years, 3 months ago) by guppy
Branch: MAIN
Branch point for: botnetop
File MIME type: text/x-chdr
Initial revision

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

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23