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, 8 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

# User Rev Content
1 pippijn 1.6 /**
2     * global.C: global objects
3 pippijn 1.1 *
4 pippijn 1.6 * Copyright © 2007 Pippijn van Steenhoven / The Ermyth Team
5     * Rights to this code are as documented in COPYING.
6 pippijn 1.1 */
7    
8 pippijn 1.7 static char const rcsid[] = "$Id: global.C,v 1.6 2007-09-16 18:54:45 pippijn Exp $";
9 pippijn 1.1
10     #include "atheme.h"
11 pippijn 1.4 #include <ermyth/crypto.h>
12     #include <ermyth/database.h>
13 pippijn 1.7 #include <ermyth/system.h>
14 pippijn 1.1 #include "uplink.h"
15     #include "internal.h"
16     #include "datastream.h"
17     #include "authcookie.h"
18    
19 pippijn 1.4 protocol::handler *phandler;
20     database::handler *backend;
21     crypto::handler *crypter;
22    
23 pippijn 1.5 garbage_collector gc;
24    
25 pippijn 1.1 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 pippijn 1.4 cnt_t cnt;
35 pippijn 1.1
36     /* XXX */
37 pippijn 1.4 conf_option_t config_options;
38     database_t database_options;
39     system_state_t system_state;
40 pippijn 1.1 int runflags;
41    
42     char *config_file;
43     char *log_path;
44     bool cold_start = false;
45 pippijn 1.4 bool database::handler::loaded = false;
46 pippijn 1.1
47 pippijn 1.4 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 pippijn 1.1
79 pippijn 1.4 void
80 pippijn 1.7 me_t::cleanup ()
81 pippijn 1.4 {
82     sfree (netname);
83     sfree (hidehostsuffix);
84     sfree (adminname);
85     sfree (adminemail);
86 pippijn 1.7 sfree (desc);
87     sfree (name);
88     sfree (numeric);
89 pippijn 1.4 if (mta != NULL)
90     sfree (mta);
91 pippijn 1.7
92     netname = hidehostsuffix = adminemail = adminname = desc = name = numeric = mta = 0;
93 pippijn 1.4 }
94 pippijn 1.1
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 pippijn 1.7 desc = sstrdup (rhs.desc);
105     name = sstrdup (rhs.name);
106     numeric = sstrdup (rhs.numeric);
107 pippijn 1.1 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 pippijn 1.4 static void noop_delete (void *) throw (balloc_exception) __attribute__ ((__noreturn__));
120     static void
121     noop_delete (void *)
122     throw (balloc_exception)
123 pippijn 1.1 {
124 pippijn 1.4 // We should never reach here
125     throw balloc_exception (SRCINF, "Balloc has no deallocator");
126 pippijn 1.1 }
127    
128 pippijn 1.4 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 pippijn 1.1 {
133 pippijn 1.4 // We should never reach here
134     throw balloc_exception (SRCINF, "Balloc has no deallocator");
135 pippijn 1.1 }
136 pippijn 1.4
137     void (*NullDealloc) (void *) = &noop_delete;
138     void (*NullNDealloc) (void *, size_t) = &noop_delete;