2004-05-16 14:58:40 +00:00
|
|
|
/* +------------------------------------+
|
|
|
|
* | Inspire Internet Relay Chat Daemon |
|
|
|
|
* +------------------------------------+
|
|
|
|
*
|
2006-01-15 15:59:11 +00:00
|
|
|
* InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
|
2004-05-16 14:58:40 +00:00
|
|
|
* E-mail:
|
|
|
|
* <brain@chatspike.net>
|
|
|
|
* <Craig@chatspike.net>
|
|
|
|
*
|
|
|
|
* Written by Craig Edwards, Craig McLure, and others.
|
|
|
|
* This program is free but copyrighted software; see
|
|
|
|
* the file COPYING for details.
|
|
|
|
*
|
|
|
|
* ---------------------------------------------------
|
|
|
|
*/
|
2003-01-23 19:45:57 +00:00
|
|
|
|
2005-12-14 10:51:18 +00:00
|
|
|
#ifndef __INSPIRCD_H__
|
|
|
|
#define __INSPIRCD_H__
|
|
|
|
|
2006-04-10 20:08:30 +00:00
|
|
|
#include <time.h>
|
2003-01-23 19:45:57 +00:00
|
|
|
#include <string>
|
2006-03-10 17:51:26 +00:00
|
|
|
#include <sstream>
|
2006-04-09 11:51:24 +00:00
|
|
|
#include "inspircd_config.h"
|
2003-01-23 19:45:57 +00:00
|
|
|
#include "users.h"
|
|
|
|
#include "channels.h"
|
2005-12-14 18:34:57 +00:00
|
|
|
#include "socket.h"
|
2005-12-16 11:47:07 +00:00
|
|
|
#include "mode.h"
|
2005-12-16 12:32:01 +00:00
|
|
|
#include "socketengine.h"
|
2005-12-16 11:47:07 +00:00
|
|
|
#include "command_parse.h"
|
2003-01-23 19:45:57 +00:00
|
|
|
|
2006-04-09 11:51:24 +00:00
|
|
|
/* Some misc defines */
|
2003-01-23 19:45:57 +00:00
|
|
|
#define ERROR -1
|
2004-04-03 20:35:20 +00:00
|
|
|
#define MAXCOMMAND 32
|
|
|
|
|
2006-04-09 11:51:24 +00:00
|
|
|
/* Crucial defines */
|
2006-02-24 01:02:27 +00:00
|
|
|
#define ETIREDGERBILS EAGAIN
|
|
|
|
|
2006-04-09 11:51:24 +00:00
|
|
|
/* This define is used in place of strcmp when we
|
|
|
|
* want to check if a char* string contains only one
|
|
|
|
* letter. Pretty fast, its just two compares and an
|
|
|
|
* addition.
|
|
|
|
*/
|
2006-03-02 19:34:57 +00:00
|
|
|
#define IS_SINGLE(x,y) ( (*x == y) && (*(x+1) == 0) )
|
2005-12-14 17:46:22 +00:00
|
|
|
|
2006-06-29 14:23:35 +00:00
|
|
|
#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!"); }
|
2006-04-24 13:28:07 +00:00
|
|
|
|
2006-03-10 17:51:26 +00:00
|
|
|
template<typename T> inline std::string ConvToStr(const T &in)
|
|
|
|
{
|
|
|
|
std::stringstream tmp;
|
|
|
|
if (!(tmp << in)) return std::string();
|
|
|
|
return tmp.str();
|
|
|
|
}
|
|
|
|
|
2005-12-14 10:23:14 +00:00
|
|
|
class serverstats
|
|
|
|
{
|
2005-12-14 10:51:18 +00:00
|
|
|
public:
|
2005-12-14 10:23:14 +00:00
|
|
|
int statsAccept;
|
|
|
|
int statsRefused;
|
|
|
|
int statsUnknown;
|
|
|
|
int statsCollisions;
|
|
|
|
int statsDns;
|
|
|
|
int statsDnsGood;
|
|
|
|
int statsDnsBad;
|
|
|
|
int statsConnects;
|
|
|
|
int statsSent;
|
|
|
|
int statsRecv;
|
2005-12-16 09:30:53 +00:00
|
|
|
int BoundPortCount;
|
2005-12-14 10:23:14 +00:00
|
|
|
|
|
|
|
serverstats()
|
|
|
|
{
|
|
|
|
statsAccept = statsRefused = statsUnknown = 0;
|
|
|
|
statsCollisions = statsDns = statsDnsGood = 0;
|
|
|
|
statsDnsBad = statsConnects = statsSent = statsRecv = 0;
|
2005-12-16 09:30:53 +00:00
|
|
|
BoundPortCount = 0;
|
2005-12-14 10:23:14 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2005-12-14 17:40:06 +00:00
|
|
|
|
|
|
|
class InspIRCd
|
|
|
|
{
|
2005-12-14 18:17:13 +00:00
|
|
|
private:
|
2005-12-14 20:41:07 +00:00
|
|
|
char MODERR[MAXBUF];
|
2006-04-09 11:51:24 +00:00
|
|
|
bool expire_run;
|
|
|
|
|
|
|
|
void erase_factory(int j);
|
|
|
|
void erase_module(int j);
|
2005-12-29 21:57:34 +00:00
|
|
|
void BuildISupport();
|
2006-01-09 21:59:58 +00:00
|
|
|
void MoveTo(std::string modulename,int slot);
|
2005-12-14 18:17:13 +00:00
|
|
|
|
2005-12-14 17:40:06 +00:00
|
|
|
public:
|
2005-12-14 18:22:11 +00:00
|
|
|
time_t startup_time;
|
2005-12-16 11:47:07 +00:00
|
|
|
ModeParser* ModeGrok;
|
|
|
|
CommandParser* Parser;
|
2005-12-16 12:32:01 +00:00
|
|
|
SocketEngine* SE;
|
2005-12-16 12:47:09 +00:00
|
|
|
serverstats* stats;
|
2005-12-14 18:36:06 +00:00
|
|
|
|
2005-12-16 12:56:01 +00:00
|
|
|
void MakeLowerMap();
|
2005-12-14 20:41:07 +00:00
|
|
|
std::string GetRevision();
|
|
|
|
std::string GetVersionString();
|
|
|
|
char* ModuleError();
|
2005-12-14 18:36:06 +00:00
|
|
|
bool LoadModule(const char* filename);
|
|
|
|
bool UnloadModule(const char* filename);
|
2006-01-09 21:59:58 +00:00
|
|
|
void MoveToLast(std::string modulename);
|
|
|
|
void MoveToFirst(std::string modulename);
|
2006-01-25 16:31:05 +00:00
|
|
|
void MoveAfter(std::string modulename, std::string after);
|
|
|
|
void MoveBefore(std::string modulename, std::string before);
|
2005-12-14 17:40:06 +00:00
|
|
|
InspIRCd(int argc, char** argv);
|
2006-02-26 19:53:25 +00:00
|
|
|
void DoOneIteration(bool process_module_sockets);
|
2005-12-14 17:40:06 +00:00
|
|
|
int Run();
|
2005-12-14 18:17:13 +00:00
|
|
|
|
2005-12-14 17:40:06 +00:00
|
|
|
};
|
2004-04-19 01:27:44 +00:00
|
|
|
|
2006-04-08 17:05:48 +00:00
|
|
|
/* Miscellaneous stuff here, moved from inspircd_io.h */
|
|
|
|
void Exit(int status);
|
|
|
|
void Start();
|
|
|
|
void SetSignals();
|
|
|
|
bool DaemonSeed();
|
|
|
|
void WritePID(const std::string &filename);
|
|
|
|
|
2005-12-14 17:17:22 +00:00
|
|
|
/* userrec optimization stuff */
|
2006-04-09 11:51:24 +00:00
|
|
|
void AddServerName(const std::string &servername);
|
|
|
|
const char* FindServerNamePtr(const std::string &servername);
|
|
|
|
bool FindServerName(const std::string &servername);
|
2005-12-14 10:51:18 +00:00
|
|
|
|
|
|
|
#endif
|