]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - include/xline.h
Alter SetModeParam to take const char* to save on casts, notice a load of modules...
[user/henk/code/inspircd.git] / include / xline.h
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
6  *                       E-mail:
7  *                <brain@chatspike.net>
8  *                <Craig@chatspike.net>
9  *     
10  * Written by Craig Edwards, Craig McLure, and others.
11  * This program is free but copyrighted software; see
12  *            the file COPYING for details.
13  *
14  * ---------------------------------------------------
15  */
16
17 #ifndef __XLINE_H
18 #define __XLINE_H
19
20 // include the common header files
21
22 #include <typeinfo>
23 #include <iostream>
24 #include <string>
25 #include <deque>
26 #include <sstream>
27 #include <vector>
28 #include "users.h"
29 #include "channels.h"
30
31 const int APPLY_GLINES  = 1;
32 const int APPLY_KLINES  = 2;
33 const int APPLY_QLINES  = 4;
34 const int APPLY_ZLINES  = 8;
35 const int APPLY_ALL     = APPLY_GLINES | APPLY_KLINES | APPLY_QLINES | APPLY_ZLINES;
36
37 /** XLine is the base class for ban lines such as G lines and K lines.
38  */
39 class XLine : public classbase
40 {
41   public:
42
43         /** The time the line was added.
44          */
45         time_t set_time;
46         
47         /** The duration of the ban, or 0 if permenant
48          */
49         long duration;
50         
51         /** Source of the ban. This can be a servername or an oper nickname
52          */
53         char source[256];
54         
55         /** Reason for the ban
56          */
57         char reason[MAXBUF];
58         
59         /** Number of times the core matches the ban, for statistics
60          */
61         long n_matches;
62         
63 };
64
65 /** KLine class
66  */
67 class KLine : public XLine
68 {
69   public:
70         /** Hostmask (ident@host) to match against
71          * May contain wildcards.
72          */
73         char hostmask[200];
74 };
75
76 /** GLine class
77  */
78 class GLine : public XLine
79 {
80   public:
81         /** Hostmask (ident@host) to match against
82          * May contain wildcards.
83          */
84         char hostmask[200];
85 };
86
87 class ELine : public XLine
88 {
89   public:
90         /** Hostmask (ident@host) to match against
91          * May contain wildcards.
92          */
93         char hostmask[200];
94 };
95
96 /** ZLine class
97  */
98 class ZLine : public XLine
99 {
100   public:
101         /** IP Address (xx.yy.zz.aa) to match against
102          * May contain wildcards.
103          */
104         char ipaddr[40];
105         /** Set if this is a global Z:line
106          * (e.g. it came from another server)
107          */
108         bool is_global;
109 };
110
111 /** QLine class
112  */
113 class QLine : public XLine
114 {
115   public:
116         /** Nickname to match against.
117          * May contain wildcards.
118          */
119         char nick[64];
120         /** Set if this is a global Z:line
121          * (e.g. it came from another server)
122          */
123         bool is_global;
124 };
125
126 bool InitXLine(const char* tag);
127 bool DoneXLine(const char* tag);
128
129 bool DoZLine(const char* tag, char** entries, void** values, int* types);
130 bool DoQLine(const char* tag, char** entries, void** values, int* types);
131 bool DoKLine(const char* tag, char** entries, void** values, int* types);
132 bool DoELine(const char* tag, char** entries, void** values, int* types);
133
134 bool add_gline(long duration, const char* source, const char* reason, const char* hostmask);
135 bool add_qline(long duration, const char* source, const char* reason, const char* nickname);
136 bool add_zline(long duration, const char* source, const char* reason, const char* ipaddr);
137 bool add_kline(long duration, const char* source, const char* reason, const char* hostmask);
138 bool add_eline(long duration, const char* source, const char* reason, const char* hostmask);
139
140 bool del_gline(const char* hostmask);
141 bool del_qline(const char* nickname);
142 bool del_zline(const char* ipaddr);
143 bool del_kline(const char* hostmask);
144 bool del_eline(const char* hostmask);
145
146 char* matches_qline(const char* nick);
147 char* matches_gline(const char* host);
148 char* matches_zline(const char* ipaddr);
149 char* matches_kline(const char* host);
150 char* matches_exception(const char* host);
151
152 void expire_lines();
153 void apply_lines(const int What);
154
155 void stats_k(userrec* user);
156 void stats_g(userrec* user);
157 void stats_q(userrec* user);
158 void stats_z(userrec* user);
159 void stats_e(userrec* user);
160
161 void gline_set_creation_time(const char* host, time_t create_time);
162 void qline_set_creation_time(const char* nick, time_t create_time);
163 void zline_set_creation_time(const char* ip, time_t create_time);
164 void eline_set_creation_time(const char* host, time_t create_time);
165         
166 bool zline_make_global(const char* ipaddr);
167 bool qline_make_global(const char* nickname);
168
169 #endif