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