1 |
/** |
2 |
* kline.h: Data structures for account information. |
3 |
* |
4 |
* Copyright © 2007 Pippijn van Steenhoven / The Ermyth Team |
5 |
* Rights to this code are as documented in COPYING. |
6 |
* |
7 |
* |
8 |
* Portions of this file were derived from sources bearing the following license: |
9 |
* Copyright © 2005-2006 Atheme Development Group |
10 |
* Rights to this code are as documented in doc/pod/license.pod. |
11 |
* |
12 |
* $Id: kline.h,v 1.5 2007-09-16 18:54:42 pippijn Exp $ |
13 |
*/ |
14 |
|
15 |
#ifndef ACCOUNT_KLINE_H |
16 |
#define ACCOUNT_KLINE_H |
17 |
|
18 |
#include <util/containers.h> |
19 |
#include <object.h> |
20 |
|
21 |
/* kline list struct */ |
22 |
struct kline_t : object, zero_initialised |
23 |
{ |
24 |
unsigned index; |
25 |
|
26 |
char *user; |
27 |
char *host; |
28 |
char *reason; |
29 |
char *setby; |
30 |
|
31 |
unsigned int number; |
32 |
long duration; |
33 |
time_t settime; |
34 |
time_t expires; |
35 |
|
36 |
static kline_t *create (char const * const user, char const * const host, char const * const reason, long duration); |
37 |
static void destroy (char const * const user, char const * const host); |
38 |
static kline_t *find (char const * const user, char const * const host); |
39 |
static kline_t *find (unsigned int number); |
40 |
static kline_t *find (user_t *u); |
41 |
static void expire (void *arg); |
42 |
|
43 |
/* node.c */ |
44 |
typedef indexing_vector<kline_t> list_type; |
45 |
static list_type list; |
46 |
|
47 |
void destroy () |
48 |
{ |
49 |
list.erase (this); |
50 |
refcnt_dec (); |
51 |
cnt.kline--; |
52 |
} |
53 |
|
54 |
private: |
55 |
virtual void _destroy () |
56 |
{ |
57 |
sfree (user); |
58 |
sfree (host); |
59 |
sfree (reason); |
60 |
sfree (setby); |
61 |
|
62 |
delete this; |
63 |
} |
64 |
}; |
65 |
|
66 |
#endif |