1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
7 * <brain@chatspike.net>
8 * <Craig@chatspike.net>
10 * Written by Craig Edwards, Craig McLure, and others.
11 * This program is free but copyrighted software; see
12 * the file COPYING for details.
14 * ---------------------------------------------------
17 #ifndef __INSPIRCD_H__
18 #define __INSPIRCD_H__
23 #include "inspircd_config.h"
28 #include "helperfuncs.h"
29 #include "socketengine.h"
30 #include "command_parse.h"
32 /* Some misc defines */
37 #define ETIREDGERBILS EAGAIN
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
44 #define IS_SINGLE(x,y) ( (*x == y) && (*(x+1) == 0) )
46 #define DELETE(x) { InspIRCd::Log(DEBUG,"%s:%d: delete()",__FILE__,__LINE__); if (x) { delete x; x = NULL; } else InspIRCd::Log(DEBUG,"Attempt to delete NULL pointer!"); }
48 template<typename T> inline std::string ConvToStr(const T &in)
50 std::stringstream tmp;
51 if (!(tmp << in)) return std::string();
55 class serverstats : public classbase
58 unsigned long statsAccept;
59 unsigned long statsRefused;
60 unsigned long statsUnknown;
61 unsigned long statsCollisions;
62 unsigned long statsDns;
63 unsigned long statsDnsGood;
64 unsigned long statsDnsBad;
65 unsigned long statsConnects;
68 unsigned long BoundPortCount;
72 statsAccept = statsRefused = statsUnknown = 0;
73 statsCollisions = statsDns = statsDnsGood = 0;
74 statsDnsBad = statsConnects = 0;
75 statsSent = statsRecv = 0.0;
81 class InspIRCd : public classbase
87 void EraseFactory(int j);
88 void EraseModule(int j);
90 void MoveTo(std::string modulename,int slot);
92 void SetSignals(bool SEGVHandler);
95 void MoveToLast(std::string modulename);
96 void MoveToFirst(std::string modulename);
97 void MoveAfter(std::string modulename, std::string after);
98 void MoveBefore(std::string modulename, std::string before);
102 ModeParser* ModeGrok;
103 CommandParser* Parser;
106 ServerConfig* Config;
107 std::vector<InspSocket*> module_sockets;
108 InspSocket* socket_ref[MAX_DESCRIPTORS];
111 std::string GetRevision();
112 std::string GetVersionString();
113 void WritePID(const std::string &filename);
115 bool LoadModule(const char* filename);
116 bool UnloadModule(const char* filename);
117 InspIRCd(int argc, char** argv);
118 void DoOneIteration(bool process_module_sockets);
119 static void Log(int level, const char* text, ...);
120 static void Log(int level, const std::string &text);
124 /* Miscellaneous stuff here, moved from inspircd_io.h */
125 void Exit(int status);
127 /* userrec optimization stuff */
128 void AddServerName(const std::string &servername);
129 const char* FindServerNamePtr(const std::string &servername);
130 bool FindServerName(const std::string &servername);