]> jfr.im git - solanum.git/blame - ircd/extban.c
ircd/authproc.c: avoid crash on lack of any configured DNSBLs
[solanum.git] / ircd / extban.c
CommitLineData
212380e3 1/*
a6f63a82 2 * Solanum: a slightly advanced ircd
212380e3
AC
3 * extban.c: extended ban types ($type:data)
4 *
5 * Copyright (C) 2006 charybdis development team
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 * USA
212380e3
AC
21 */
22
23#include "stdinc.h"
212380e3
AC
24#include "channel.h"
25#include "client.h"
212380e3
AC
26
27ExtbanFunc extban_table[256] = { NULL };
28
29int
30match_extban(const char *banstr, struct Client *client_p, struct Channel *chptr, long mode_type)
31{
32 const char *p;
33 int invert = 0, result = EXTBAN_INVALID;
34 ExtbanFunc f;
35
36 if (*banstr != '$')
37 return 0;
38 p = banstr + 1;
39 if (*p == '~')
40 {
41 invert = 1;
42 p++;
43 }
7e6b5384 44 f = extban_table[(unsigned char) irctolower(*p)];
212380e3
AC
45 if (*p != '\0')
46 {
47 p++;
48 if (*p == ':')
49 p++;
50 else
51 p = NULL;
52 }
53 if (f != NULL)
54 result = f(p, client_p, chptr, mode_type);
55 else
56 result = EXTBAN_INVALID;
57
58 if (invert)
59 return result == EXTBAN_NOMATCH;
60 else
61 return result == EXTBAN_MATCH;
62}
63
64int
65valid_extban(const char *banstr, struct Client *client_p, struct Channel *chptr, long mode_type)
66{
67 const char *p;
d7dc7ae6 68 int result = EXTBAN_INVALID;
212380e3
AC
69 ExtbanFunc f;
70
71 if (*banstr != '$')
72 return 0;
73 p = banstr + 1;
74 if (*p == '~')
212380e3 75 p++;
7e6b5384 76 f = extban_table[(unsigned char) irctolower(*p)];
212380e3
AC
77 if (*p != '\0')
78 {
79 p++;
80 if (*p == ':')
81 p++;
82 else
83 p = NULL;
84 }
85 if (f != NULL)
86 result = f(p, client_p, chptr, mode_type);
87 else
88 result = EXTBAN_INVALID;
89
90 return result != EXTBAN_INVALID;
91}
92
93const char *
94get_extban_string(void)
95{
96 static char e[256];
97 int i, j;
98
99 j = 0;
100 for (i = 1; i < 256; i++)
7e6b5384 101 if (i == irctolower(i) && extban_table[i])
212380e3
AC
102 e[j++] = i;
103 e[j] = 0;
104 return e;
105}