]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - include/inspircd.h
Routing more socket includes through socket.h
[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 template<typename T> inline std::string ConvToStr(const T &in)
46 {
47         std::stringstream tmp;
48         if (!(tmp << in)) return std::string();
49         return tmp.str();
50 }
51
52 class serverstats
53 {
54   public:
55         int statsAccept;
56         int statsRefused;
57         int statsUnknown;
58         int statsCollisions;
59         int statsDns;
60         int statsDnsGood;
61         int statsDnsBad;
62         int statsConnects;
63         int statsSent;
64         int statsRecv;
65         int BoundPortCount;
66
67         serverstats()
68         {
69                 statsAccept = statsRefused = statsUnknown = 0;
70                 statsCollisions = statsDns = statsDnsGood = 0;
71                 statsDnsBad = statsConnects = statsSent = statsRecv = 0;
72                 BoundPortCount = 0;
73         }
74 };
75
76
77 class InspIRCd
78 {
79  private:
80         char MODERR[MAXBUF];
81         bool expire_run;
82  
83         void erase_factory(int j);
84         void erase_module(int j);
85         void BuildISupport();
86         void MoveTo(std::string modulename,int slot);
87
88  public:
89         time_t startup_time;
90         ModeParser* ModeGrok;
91         CommandParser* Parser;
92         SocketEngine* SE;
93         serverstats* stats;
94
95         void MakeLowerMap();
96         std::string GetRevision();
97         std::string GetVersionString();
98         char* ModuleError();
99         bool LoadModule(const char* filename);
100         bool UnloadModule(const char* filename);
101         void MoveToLast(std::string modulename);
102         void MoveToFirst(std::string modulename);
103         void MoveAfter(std::string modulename, std::string after);
104         void MoveBefore(std::string modulename, std::string before);
105         InspIRCd(int argc, char** argv);
106         void DoOneIteration(bool process_module_sockets);
107         int Run();
108
109 };
110
111 /* Miscellaneous stuff here, moved from inspircd_io.h */
112 void Exit(int status); 
113 void Start(); 
114 void SetSignals();
115 bool DaemonSeed();
116 void WritePID(const std::string &filename);
117
118 /* userrec optimization stuff */
119 void AddServerName(const std::string &servername);
120 const char* FindServerNamePtr(const std::string &servername);
121 bool FindServerName(const std::string &servername);
122
123 #endif