Restore stats_spy hook that was removed in commit 401f2454671ca233e35b0e6e4f3fa4c43cd...
[seven-1.x.git] / src / extban.c
blobb0da6096922117ea5088d86554a9b4ff24807a20
1 /*
2 * charybdis: A slightly useful ircd.
3 * extban.c: extended ban types ($type:data)
5 * Copyright (C) 2006 charybdis development team
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.
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.
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
23 #include "stdinc.h"
24 #include "tools.h"
25 #include "channel.h"
26 #include "client.h"
27 #include "common.h"
29 ExtbanFunc extban_table[256] = { NULL };
31 int
32 match_extban(const char *banstr, struct Client *client_p, struct Channel *chptr, long mode_type)
34 const char *p;
35 int invert = 0, result = EXTBAN_INVALID;
36 ExtbanFunc f;
38 if (*banstr != '$')
39 return 0;
40 p = banstr + 1;
41 if (*p == '~')
43 invert = 1;
44 p++;
46 f = extban_table[(unsigned char) ToLower(*p)];
47 if (*p != '\0')
49 p++;
50 if (*p == ':')
51 p++;
52 else
53 p = NULL;
55 if (f != NULL)
56 result = f(p, client_p, chptr, mode_type);
57 else
58 result = EXTBAN_INVALID;
60 if (invert)
61 return result == EXTBAN_NOMATCH;
62 else
63 return result == EXTBAN_MATCH;
66 int
67 valid_extban(const char *banstr, struct Client *client_p, struct Channel *chptr, long mode_type)
69 const char *p;
70 int invert = 0, result = EXTBAN_INVALID;
71 ExtbanFunc f;
73 if (*banstr != '$')
74 return 0;
75 p = banstr + 1;
76 if (*p == '~')
78 invert = 1;
79 p++;
81 f = extban_table[(unsigned char) ToLower(*p)];
82 if (*p != '\0')
84 p++;
85 if (*p == ':')
86 p++;
87 else
88 p = NULL;
90 if (f != NULL)
91 result = f(p, client_p, chptr, mode_type);
92 else
93 result = EXTBAN_INVALID;
95 return result != EXTBAN_INVALID;
98 const char *
99 get_extban_string(void)
101 static char e[256];
102 int i, j;
104 j = 0;
105 for (i = 1; i < 256; i++)
106 if (i == ToLower(i) && extban_table[i])
107 e[j++] = i;
108 e[j] = 0;
109 return e;