1 |
/** |
2 |
* servers.h: Data structures related to network servers. |
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 William Pitcock, et al. |
10 |
* Rights to this code are as documented in doc/pod/license.pod. |
11 |
* |
12 |
* $Id: servers.h,v 1.6 2007-09-16 18:54:42 pippijn Exp $ |
13 |
*/ |
14 |
|
15 |
#ifndef SERVERS_H |
16 |
#define SERVERS_H |
17 |
|
18 |
#include <ermyth/callback.h> |
19 |
#include <util/containers.h> |
20 |
|
21 |
/* servers struct */ |
22 |
class server_t : public zero_initialised |
23 |
{ |
24 |
struct callbacks |
25 |
{ |
26 |
functor::callback1<server_t *> eob; |
27 |
}; |
28 |
|
29 |
public: |
30 |
char *name; |
31 |
char *desc; |
32 |
char *sid; |
33 |
|
34 |
unsigned int hops; |
35 |
unsigned int users; |
36 |
unsigned int invis; |
37 |
unsigned int opers; |
38 |
unsigned int away; |
39 |
|
40 |
time_t connected_since; |
41 |
|
42 |
unsigned int flags; |
43 |
|
44 |
server_t *uplink; /* uplink server */ |
45 |
list_t children; /* children linked to me */ |
46 |
list_t userlist; /* users attached to me */ |
47 |
|
48 |
static callbacks callback; |
49 |
}; |
50 |
|
51 |
enum server_flag |
52 |
{ |
53 |
SF_HIDE = 1 << 0, |
54 |
SF_EOB = 1 << 1, /* Burst finished (we have all users/channels) -- jilles */ |
55 |
SF_EOB2 = 1 << 2, /* Is EOB but an uplink is not (for P10) */ |
56 |
SF_JUPE_PENDING = 1 << 3 /* Sent SQUIT request, will introduce jupe when it dies (unconnect semantics) */ |
57 |
}; |
58 |
|
59 |
/* tld list struct */ |
60 |
struct tld_t : zero_initialised |
61 |
{ |
62 |
unsigned index; |
63 |
|
64 |
typedef indexing_vector<tld_t> list_type; |
65 |
static list_type list; |
66 |
|
67 |
char *name; |
68 |
}; |
69 |
|
70 |
inline char const * |
71 |
SERVER_NAME (server_t *s) |
72 |
{ |
73 |
return s->sid[0] ? s->sid : s->name; |
74 |
} |
75 |
#define ME (ircd->uses_uid ? me.numeric : me.name) |
76 |
|
77 |
E void init_servers (void); |
78 |
|
79 |
E tld_t *tld_add (char const * const name); |
80 |
E void tld_delete (char const * const name); |
81 |
E tld_t *tld_find (char const * const name); |
82 |
E void tld_cleanup (); |
83 |
|
84 |
E server_t *server_add (char const * const name, unsigned int hops, char const * const uplink, char const * const id, char const * const desc); |
85 |
E void server_delete (char const * const name); |
86 |
E void server_delete (server_t *s, bool force = false); |
87 |
E server_t *server_find (char const * const name); |
88 |
|
89 |
#endif |