… | |
… | |
3 | * Rights to this code are documented in doc/pod/license.pod. |
3 | * Rights to this code are documented in doc/pod/license.pod. |
4 | * |
4 | * |
5 | * Global objects. |
5 | * Global objects. |
6 | */ |
6 | */ |
7 | |
7 | |
8 | static char const rcsid[] = "$Id: global.C,v 1.3 2007/07/21 13:23:21 pippijn Exp $"; |
8 | static char const rcsid[] = "$Id: global.C,v 1.4 2007/08/28 17:08:12 pippijn Exp $"; |
9 | |
9 | |
10 | #include "atheme.h" |
10 | #include "atheme.h" |
|
|
11 | #include <ermyth/crypto.h> |
|
|
12 | #include <ermyth/database.h> |
11 | #include "uplink.h" |
13 | #include "uplink.h" |
12 | #include "pmodule.h" /* pcommand_init */ |
|
|
13 | #include "internal.h" |
14 | #include "internal.h" |
14 | #include "datastream.h" |
15 | #include "datastream.h" |
15 | #include "authcookie.h" |
16 | #include "authcookie.h" |
|
|
17 | |
|
|
18 | protocol::handler *phandler; |
|
|
19 | database::handler *backend; |
|
|
20 | crypto::handler *crypter; |
16 | |
21 | |
17 | chansvs_t chansvs; |
22 | chansvs_t chansvs; |
18 | globsvs_t globsvs; |
23 | globsvs_t globsvs; |
19 | opersvs_t opersvs; |
24 | opersvs_t opersvs; |
20 | memosvs_t memosvs; |
25 | memosvs_t memosvs; |
21 | nicksvs_t nicksvs; |
26 | nicksvs_t nicksvs; |
22 | saslsvs_t saslsvs; |
27 | saslsvs_t saslsvs; |
23 | gamesvs_t gamesvs; |
28 | gamesvs_t gamesvs; |
24 | |
29 | |
25 | me_t me; |
30 | me_t me; |
26 | struct cnt cnt; |
31 | cnt_t cnt; |
27 | |
32 | |
28 | /* XXX */ |
33 | /* XXX */ |
29 | ConfOption config_options; |
34 | conf_option_t config_options; |
30 | Database database_options; |
35 | database_t database_options; |
31 | claro_state_t claro_state; |
36 | system_state_t system_state; |
32 | int runflags; |
37 | int runflags; |
33 | |
38 | |
34 | char *config_file; |
39 | char *config_file; |
35 | char *log_path; |
40 | char *log_path; |
36 | bool cold_start = false; |
41 | bool cold_start = false; |
|
|
42 | bool database::handler::loaded = false; |
37 | |
43 | |
38 | extern char **environ; |
44 | void |
|
|
45 | me_t::init () |
|
|
46 | { |
|
|
47 | if (netname) |
|
|
48 | sfree (netname); |
|
|
49 | if (hidehostsuffix) |
|
|
50 | sfree (hidehostsuffix); |
|
|
51 | if (adminname) |
|
|
52 | sfree (adminname); |
|
|
53 | if (adminemail) |
|
|
54 | sfree (adminemail); |
|
|
55 | if (mta) |
|
|
56 | sfree (mta); |
39 | |
57 | |
40 | void (*db_save) (void *arg) = NULL; |
58 | netname |
41 | void (*db_load) (void) = NULL; |
59 | = hidehostsuffix |
|
|
60 | = adminname |
|
|
61 | = adminemail |
|
|
62 | = mta |
|
|
63 | = NULL; |
|
|
64 | |
|
|
65 | recontime |
|
|
66 | = restarttime |
|
|
67 | = maxlogins |
|
|
68 | = maxusers |
|
|
69 | = maxnicks |
|
|
70 | = maxchans |
|
|
71 | = emaillimit |
|
|
72 | = emailtime |
|
|
73 | = 0; |
|
|
74 | } |
|
|
75 | |
|
|
76 | void |
|
|
77 | me_t::fini () |
|
|
78 | { |
|
|
79 | sfree (netname); |
|
|
80 | sfree (hidehostsuffix); |
|
|
81 | sfree (adminname); |
|
|
82 | sfree (adminemail); |
|
|
83 | if (mta != NULL) |
|
|
84 | sfree (mta); |
|
|
85 | } |
42 | |
86 | |
43 | me_t & |
87 | me_t & |
44 | me_t::operator = (const me_t &rhs) |
88 | me_t::operator = (const me_t &rhs) |
45 | { |
89 | { |
46 | recontime = rhs.recontime; |
90 | recontime = rhs.recontime; |
… | |
… | |
59 | auth = rhs.auth; |
103 | auth = rhs.auth; |
60 | |
104 | |
61 | return *this; |
105 | return *this; |
62 | } |
106 | } |
63 | |
107 | |
64 | me_t::~me_t () |
108 | static void noop_delete (void *) throw (balloc_exception) __attribute__ ((__noreturn__)); |
|
|
109 | static void |
|
|
110 | noop_delete (void *) |
|
|
111 | throw (balloc_exception) |
65 | { |
112 | { |
66 | destroy (); |
113 | // We should never reach here |
|
|
114 | throw balloc_exception (SRCINF, "Balloc has no deallocator"); |
67 | } |
115 | } |
68 | |
116 | |
69 | void |
117 | static void noop_delete (void *, size_t) throw (balloc_exception) __attribute__ ((__noreturn__)); |
70 | me_t::destroy () |
118 | static void |
|
|
119 | noop_delete (void *, size_t) |
|
|
120 | throw (balloc_exception) |
71 | { |
121 | { |
72 | free (netname); |
122 | // We should never reach here |
73 | free (hidehostsuffix); |
123 | throw balloc_exception (SRCINF, "Balloc has no deallocator"); |
74 | free (adminname); |
|
|
75 | free (adminemail); |
|
|
76 | if (mta != NULL) |
|
|
77 | free (mta); |
|
|
78 | } |
124 | } |
|
|
125 | |
|
|
126 | void (*NullDealloc) (void *) = &noop_delete; |
|
|
127 | void (*NullNDealloc) (void *, size_t) = &noop_delete; |