]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - include/inspircd.h
More fixes
[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 <string>
21 #include <sstream>
22 #include "inspircd_config.h"
23 #include "users.h"
24 #include "channels.h"
25 #include "socket.h"
26 #include "mode.h"
27 #include "socketengine.h"
28 #include "command_parse.h"
29
30 /* Some misc defines */
31 #define ERROR -1
32 #define MAXCOMMAND 32
33
34 /* Crucial defines */
35 #define ETIREDGERBILS EAGAIN
36
37 /* This define is used in place of strcmp when we 
38  * want to check if a char* string contains only one
39  * letter. Pretty fast, its just two compares and an
40  * addition.
41  */
42 #define IS_SINGLE(x,y) ( (*x == y) && (*(x+1) == 0) )
43
44 template<typename T> inline std::string ConvToStr(const T &in)
45 {
46         std::stringstream tmp;
47         if (!(tmp << in)) return std::string();
48         return tmp.str();
49 }
50
51 class serverstats
52 {
53   public:
54         int statsAccept;
55         int statsRefused;
56         int statsUnknown;
57         int statsCollisions;
58         int statsDns;
59         int statsDnsGood;
60         int statsDnsBad;
61         int statsConnects;
62         int statsSent;
63         int statsRecv;
64         int BoundPortCount;
65
66         serverstats()
67         {
68                 statsAccept = statsRefused = statsUnknown = 0;
69                 statsCollisions = statsDns = statsDnsGood = 0;
70                 statsDnsBad = statsConnects = statsSent = statsRecv = 0;
71                 BoundPortCount = 0;
72         }
73 };
74
75
76 class InspIRCd
77 {
78  private:
79         char MODERR[MAXBUF];
80         bool expire_run;
81  
82         void erase_factory(int j);
83         void erase_module(int j);
84         void BuildISupport();
85         void MoveTo(std::string modulename,int slot);
86
87  public:
88         time_t startup_time;
89         ModeParser* ModeGrok;
90         CommandParser* Parser;
91         SocketEngine* SE;
92         serverstats* stats;
93
94         void MakeLowerMap();
95         std::string GetRevision();
96         std::string GetVersionString();
97         char* ModuleError();
98         bool LoadModule(const char* filename);
99         bool UnloadModule(const char* filename);
100         void MoveToLast(std::string modulename);
101         void MoveToFirst(std::string modulename);
102         void MoveAfter(std::string modulename, std::string after);
103         void MoveBefore(std::string modulename, std::string before);
104         InspIRCd(int argc, char** argv);
105         void DoOneIteration(bool process_module_sockets);
106         int Run();
107
108 };
109
110 /* Miscellaneous stuff here, moved from inspircd_io.h */
111 void Exit(int status); 
112 void Start(); 
113 void SetSignals();
114 bool DaemonSeed();
115 void WritePID(const std::string &filename);
116
117 /* userrec optimization stuff */
118 void AddServerName(const std::string &servername);
119 const char* FindServerNamePtr(const std::string &servername);
120 bool FindServerName(const std::string &servername);
121
122 #endif