ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/ermyth/src/global.C
Revision: 1.5
Committed: Wed Aug 29 21:01:18 2007 UTC (16 years, 9 months ago) by pippijn
Content type: text/plain
Branch: MAIN
Changes since 1.4: +3 -1 lines
Log Message:
- reduced ifdefs by moving __GNUC__ and friends to svsconfig.h
- #define to enum { } in tools.h
- corrected log levels a bit
- made timersub an inline function instead of a macro
- added a simple garbage collection mechanism for postponed freeing of lost
  memory chunks
- enhanced type_traits
- merged inspircd1.2 support with upstream
- reformatting
- renamed TTP to a more "standard" PRItime and STP to PRIsize

File Contents

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