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