ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/ermyth/src/global.C
Revision: 1.7
Committed: Sat Sep 22 14:27:30 2007 UTC (16 years, 7 months ago) by pippijn
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 1.6: +11 -2 lines
Log Message:
split up ermyth into ermyth-modules, libermyth (currently just ermyth-util) and ermyth-core

File Contents

# Content
1 /**
2 * global.C: global objects
3 *
4 * Copyright © 2007 Pippijn van Steenhoven / The Ermyth Team
5 * Rights to this code are as documented in COPYING.
6 */
7
8 static char const rcsid[] = "$Id: global.C,v 1.6 2007-09-16 18:54:45 pippijn Exp $";
9
10 #include "atheme.h"
11 #include <ermyth/crypto.h>
12 #include <ermyth/database.h>
13 #include <ermyth/system.h>
14 #include "uplink.h"
15 #include "internal.h"
16 #include "datastream.h"
17 #include "authcookie.h"
18
19 protocol::handler *phandler;
20 database::handler *backend;
21 crypto::handler *crypter;
22
23 garbage_collector gc;
24
25 chansvs_t chansvs;
26 globsvs_t globsvs;
27 opersvs_t opersvs;
28 memosvs_t memosvs;
29 nicksvs_t nicksvs;
30 saslsvs_t saslsvs;
31 gamesvs_t gamesvs;
32
33 me_t me;
34 cnt_t cnt;
35
36 /* XXX */
37 conf_option_t config_options;
38 database_t database_options;
39 system_state_t system_state;
40 int runflags;
41
42 char *config_file;
43 char *log_path;
44 bool cold_start = false;
45 bool database::handler::loaded = false;
46
47 void
48 me_t::init ()
49 {
50 if (netname)
51 sfree (netname);
52 if (hidehostsuffix)
53 sfree (hidehostsuffix);
54 if (adminname)
55 sfree (adminname);
56 if (adminemail)
57 sfree (adminemail);
58 if (mta)
59 sfree (mta);
60
61 netname
62 = hidehostsuffix
63 = adminname
64 = adminemail
65 = mta
66 = NULL;
67
68 recontime
69 = restarttime
70 = maxlogins
71 = maxusers
72 = maxnicks
73 = maxchans
74 = emaillimit
75 = emailtime
76 = 0;
77 }
78
79 void
80 me_t::cleanup ()
81 {
82 sfree (netname);
83 sfree (hidehostsuffix);
84 sfree (adminname);
85 sfree (adminemail);
86 sfree (desc);
87 sfree (name);
88 sfree (numeric);
89 if (mta != NULL)
90 sfree (mta);
91
92 netname = hidehostsuffix = adminemail = adminname = desc = name = numeric = mta = 0;
93 }
94
95 me_t &
96 me_t::operator = (const me_t &rhs)
97 {
98 recontime = rhs.recontime;
99 restarttime = rhs.restarttime;
100 netname = sstrdup (rhs.netname);
101 hidehostsuffix = sstrdup (rhs.hidehostsuffix);
102 adminname = sstrdup (rhs.adminname);
103 adminemail = sstrdup (rhs.adminemail);
104 desc = sstrdup (rhs.desc);
105 name = sstrdup (rhs.name);
106 numeric = sstrdup (rhs.numeric);
107 mta = rhs.mta ? sstrdup (rhs.mta) : NULL;
108 maxlogins = rhs.maxlogins;
109 maxusers = rhs.maxusers;
110 maxnicks = rhs.maxnicks;
111 maxchans = rhs.maxchans;
112 emaillimit = rhs.emaillimit;
113 emailtime = rhs.emailtime;
114 auth = rhs.auth;
115
116 return *this;
117 }
118
119 static void noop_delete (void *) throw (balloc_exception) __attribute__ ((__noreturn__));
120 static void
121 noop_delete (void *)
122 throw (balloc_exception)
123 {
124 // We should never reach here
125 throw balloc_exception (SRCINF, "Balloc has no deallocator");
126 }
127
128 static void noop_delete (void *, size_t) throw (balloc_exception) __attribute__ ((__noreturn__));
129 static void
130 noop_delete (void *, size_t)
131 throw (balloc_exception)
132 {
133 // We should never reach here
134 throw balloc_exception (SRCINF, "Balloc has no deallocator");
135 }
136
137 void (*NullDealloc) (void *) = &noop_delete;
138 void (*NullNDealloc) (void *, size_t) = &noop_delete;