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