2004-05-16 14:58:40 +00:00
|
|
|
/* +------------------------------------+
|
|
|
|
* | Inspire Internet Relay Chat Daemon |
|
|
|
|
* +------------------------------------+
|
|
|
|
*
|
|
|
|
* Inspire is copyright (C) 2002-2004 ChatSpike-Dev.
|
|
|
|
* 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__
|
|
|
|
|
2005-05-28 20:30:06 +00:00
|
|
|
#include "inspircd_config.h"
|
2003-01-23 19:45:57 +00:00
|
|
|
#include <string>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <signal.h>
|
|
|
|
#include <time.h>
|
|
|
|
#include <netdb.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <sys/types.h>
|
2004-04-05 16:06:32 +00:00
|
|
|
|
2003-01-23 19:45:57 +00:00
|
|
|
#ifndef _LINUX_C_LIB_VERSION
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <netinet/in.h>
|
|
|
|
#endif
|
2004-04-05 16:06:32 +00:00
|
|
|
|
2003-01-23 19:45:57 +00:00
|
|
|
#include <arpa/inet.h>
|
|
|
|
#include <string>
|
|
|
|
#include <deque>
|
|
|
|
|
|
|
|
#include "inspircd_io.h"
|
|
|
|
#include "inspircd_util.h"
|
|
|
|
#include "users.h"
|
|
|
|
#include "channels.h"
|
|
|
|
|
2004-04-05 16:06:32 +00:00
|
|
|
// some misc defines
|
|
|
|
|
2003-01-23 19:45:57 +00:00
|
|
|
#define ERROR -1
|
|
|
|
#define TRUE 1
|
|
|
|
#define FALSE 0
|
|
|
|
#define MAXSOCKS 64
|
2004-04-03 20:35:20 +00:00
|
|
|
#define MAXCOMMAND 32
|
|
|
|
|
2004-04-05 16:06:32 +00:00
|
|
|
// flags for use with WriteMode
|
|
|
|
|
|
|
|
#define WM_AND 1
|
|
|
|
#define WM_OR 2
|
|
|
|
|
2004-04-06 19:22:11 +00:00
|
|
|
// flags for use with OnUserPreMessage and OnUserPreNotice
|
|
|
|
|
|
|
|
#define TYPE_USER 1
|
|
|
|
#define TYPE_CHANNEL 2
|
2005-11-30 22:00:34 +00:00
|
|
|
#define TYPE_SERVER 3
|
2004-04-06 19:22:11 +00:00
|
|
|
|
2005-12-13 23:17:22 +00:00
|
|
|
#define IS_LOCAL(x) (x->fd > -1)
|
|
|
|
#define IS_REMOTE(x) (x->fd < 0)
|
|
|
|
#define IS_MODULE_CREATED(x) (x->fd == FD_MAGIC_NUMBER)
|
|
|
|
|
2005-12-14 17:46:22 +00:00
|
|
|
typedef void (handlerfunc) (char**, int, userrec*);
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
serverstats()
|
|
|
|
{
|
|
|
|
statsAccept = statsRefused = statsUnknown = 0;
|
|
|
|
statsCollisions = statsDns = statsDnsGood = 0;
|
|
|
|
statsDnsBad = statsConnects = statsSent = statsRecv = 0;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2005-12-14 17:40:06 +00:00
|
|
|
|
|
|
|
class InspIRCd
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
InspIRCd(int argc, char** argv);
|
|
|
|
int Run();
|
|
|
|
};
|
2004-04-19 01:27:44 +00:00
|
|
|
|
2003-01-23 19:45:57 +00:00
|
|
|
/* prototypes */
|
2004-04-06 10:43:34 +00:00
|
|
|
void force_nickchange(userrec* user,const char* newnick);
|
|
|
|
void kill_link(userrec *user,const char* r);
|
2004-04-24 21:36:35 +00:00
|
|
|
void kill_link_silent(userrec *user,const char* r);
|
2004-04-11 13:08:31 +00:00
|
|
|
void call_handler(const char* commandname,char **parameters, int pcnt, userrec *user);
|
2005-12-01 19:24:53 +00:00
|
|
|
bool is_valid_cmd(const char* commandname, int pcnt, userrec * user);
|
2005-05-22 02:26:54 +00:00
|
|
|
std::string GetRevision();
|
2004-04-19 01:27:44 +00:00
|
|
|
int loop_call(handlerfunc fn, char **parameters, int pcnt, userrec *u, int start, int end, int joins);
|
2004-04-19 10:46:38 +00:00
|
|
|
void AddWhoWas(userrec* u);
|
|
|
|
void ConnectUser(userrec *user);
|
|
|
|
userrec* ReHashNick(char* Old, char* New);
|
2005-04-07 16:05:08 +00:00
|
|
|
bool LoadModule(const char* filename);
|
2005-04-07 17:04:04 +00:00
|
|
|
bool UnloadModule(const char* filename);
|
2005-04-07 16:05:08 +00:00
|
|
|
char* ModuleError();
|
2005-12-14 16:48:12 +00:00
|
|
|
/* optimization tricks to save us walking the user hash */
|
2005-04-27 02:30:30 +00:00
|
|
|
void AddOper(userrec* user);
|
|
|
|
void DeleteOper(userrec* user);
|
2005-05-15 03:03:23 +00:00
|
|
|
void handle_version(char **parameters, int pcnt, userrec *user);
|
2005-12-14 17:17:22 +00:00
|
|
|
/* userrec optimization stuff */
|
2005-05-29 05:41:03 +00:00
|
|
|
void AddServerName(std::string servername);
|
|
|
|
const char* FindServerNamePtr(std::string servername);
|
2005-06-01 15:23:25 +00:00
|
|
|
std::string GetVersionString();
|
2005-12-01 23:59:40 +00:00
|
|
|
void* dns_task(void* arg);
|
2005-12-13 00:00:18 +00:00
|
|
|
void process_buffer(const char* cmdbuf,userrec *user);
|
|
|
|
void FullConnectUser(userrec* user);
|
2005-12-14 10:51:18 +00:00
|
|
|
|
|
|
|
#endif
|