]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - include/inspircd.h
delete operator tracking in debug mode (using a macro -- live with it.)
[user/henk/code/inspircd.git] / include / inspircd.h
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
6  *                       E-mail:
7  *                <brain@chatspike.net>
8  *                <Craig@chatspike.net>
9  *     
10  * Written by Craig Edwards, Craig McLure, and others.
11  * This program is free but copyrighted software; see
12  *            the file COPYING for details.
13  *
14  * ---------------------------------------------------
15  */
16
17 #ifndef __INSPIRCD_H__
18 #define __INSPIRCD_H__
19
20 #include <time.h>
21 #include <string>
22 #include <sstream>
23 #include "inspircd_config.h"
24 #include "users.h"
25 #include "channels.h"
26 #include "socket.h"
27 #include "mode.h"
28 #include "socketengine.h"
29 #include "command_parse.h"
30
31 /* Some misc defines */
32 #define ERROR -1
33 #define MAXCOMMAND 32
34
35 /* Crucial defines */
36 #define ETIREDGERBILS EAGAIN
37
38 /* This define is used in place of strcmp when we 
39  * want to check if a char* string contains only one
40  * letter. Pretty fast, its just two compares and an
41  * addition.
42  */
43 #define IS_SINGLE(x,y) ( (*x == y) && (*(x+1) == 0) )
44
45 #define DELETE(x) { log(DEBUG,__FILE__" ("__LINE__"): delete()"); delete x; }
46
47 template<typename T> inline std::string ConvToStr(const T &in)
48 {
49         std::stringstream tmp;
50         if (!(tmp << in)) return std::string();
51         return tmp.str();
52 }
53
54 class serverstats
55 {
56   public:
57         int statsAccept;
58         int statsRefused;
59         int statsUnknown;
60         int statsCollisions;
61         int statsDns;
62         int statsDnsGood;
63         int statsDnsBad;
64         int statsConnects;
65         int statsSent;
66         int statsRecv;
67         int BoundPortCount;
68
69         serverstats()
70         {
71                 statsAccept = statsRefused = statsUnknown = 0;
72                 statsCollisions = statsDns = statsDnsGood = 0;
73                 statsDnsBad = statsConnects = statsSent = statsRecv = 0;
74                 BoundPortCount = 0;
75         }
76 };
77
78
79 class InspIRCd
80 {
81  private:
82         char MODERR[MAXBUF];
83         bool expire_run;
84  
85         void erase_factory(int j);
86         void erase_module(int j);
87         void BuildISupport();
88         void MoveTo(std::string modulename,int slot);
89
90  public:
91         time_t startup_time;
92         ModeParser* ModeGrok;
93         CommandParser* Parser;
94         SocketEngine* SE;
95         serverstats* stats;
96
97         void MakeLowerMap();
98         std::string GetRevision();
99         std::string GetVersionString();
100         char* ModuleError();
101         bool LoadModule(const char* filename);
102         bool UnloadModule(const char* filename);
103         void MoveToLast(std::string modulename);
104         void MoveToFirst(std::string modulename);
105         void MoveAfter(std::string modulename, std::string after);
106         void MoveBefore(std::string modulename, std::string before);
107         InspIRCd(int argc, char** argv);
108         void DoOneIteration(bool process_module_sockets);
109         int Run();
110
111 };
112
113 /* Miscellaneous stuff here, moved from inspircd_io.h */
114 void Exit(int status); 
115 void Start(); 
116 void SetSignals();
117 bool DaemonSeed();
118 void WritePID(const std::string &filename);
119
120 /* userrec optimization stuff */
121 void AddServerName(const std::string &servername);
122 const char* FindServerNamePtr(const std::string &servername);
123 bool FindServerName(const std::string &servername);
124
125 #endif