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-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-19 14:59:41 +00:00
|
|
|
#include "servers.h"
|
2003-01-23 19:45:57 +00:00
|
|
|
|
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 log()
|
|
|
|
|
2003-02-07 21:15:27 +00:00
|
|
|
#define DEBUG 10
|
|
|
|
#define VERBOSE 20
|
|
|
|
#define DEFAULT 30
|
|
|
|
#define SPARSE 40
|
|
|
|
#define NONE 50
|
|
|
|
|
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
|
|
|
|
|
2003-07-22 21:56:38 +00:00
|
|
|
typedef std::deque<std::string> file_cache;
|
2003-01-23 19:45:57 +00:00
|
|
|
|
2004-04-19 01:27:44 +00:00
|
|
|
typedef void (handlerfunc) (char**, int, userrec*);
|
|
|
|
|
2003-01-23 19:45:57 +00:00
|
|
|
/* prototypes */
|
2005-05-03 12:50:52 +00:00
|
|
|
int InspIRCd(char** argv, int argc);
|
2003-01-23 19:45:57 +00:00
|
|
|
int InitConfig(void);
|
2005-03-25 02:52:43 +00:00
|
|
|
void ReadConfig(bool bail,userrec* user);
|
2005-05-15 03:03:23 +00:00
|
|
|
|
2003-07-22 21:56:38 +00:00
|
|
|
std::string getservername();
|
|
|
|
std::string getserverdesc();
|
|
|
|
std::string getnetworkname();
|
|
|
|
std::string getadminname();
|
|
|
|
std::string getadminemail();
|
|
|
|
std::string getadminnick();
|
2003-01-23 19:45:57 +00:00
|
|
|
void readfile(file_cache &F, const char* fname);
|
2003-07-22 21:56:38 +00:00
|
|
|
bool ModeDefined(char c, int i);
|
2004-04-04 21:30:41 +00:00
|
|
|
bool ModeDefinedOper(char c, int i);
|
2004-04-03 15:46:53 +00:00
|
|
|
int ModeDefinedOn(char c, int i);
|
|
|
|
int ModeDefinedOff(char c, int i);
|
2004-05-01 12:44:07 +00:00
|
|
|
void ModeMakeList(char modechar);
|
|
|
|
bool ModeIsListMode(char modechar, int type);
|
2004-04-10 01:12:53 +00:00
|
|
|
chanrec* add_channel(userrec *user, const char* cn, const char* key, bool override);
|
2004-04-10 15:51:17 +00:00
|
|
|
chanrec* del_channel(userrec *user, const char* cname, const char* reason, bool local);
|
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-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 kick_channel(userrec *src,userrec *user, chanrec *Ptr, char* reason);
|
|
|
|
void AddWhoWas(userrec* u);
|
|
|
|
void update_stats_l(int fd,int data_out);
|
|
|
|
void ConnectUser(userrec *user);
|
|
|
|
void DoSplitEveryone();
|
|
|
|
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-04-29 15:01:13 +00:00
|
|
|
void NoticeAll(userrec *source, bool local_only, char* text, ...);
|
2005-04-30 20:56:20 +00:00
|
|
|
void NoticeAllOpers(userrec *source, bool local_only, char* text, ...);
|
2004-04-04 21:30:41 +00:00
|
|
|
|
2004-04-16 13:12:32 +00:00
|
|
|
void NetSendMyRoutingTable();
|
2004-04-16 15:23:47 +00:00
|
|
|
void DoSplit(const char* params);
|
2004-04-18 22:12:45 +00:00
|
|
|
void RemoveServer(const char* name);
|
2004-04-19 14:49:20 +00:00
|
|
|
void DoSync(serverrec* serv, char* tcp_host);
|
2005-04-27 02:30:30 +00:00
|
|
|
|
|
|
|
// optimization tricks to save us walking the user hash
|
|
|
|
|
|
|
|
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);
|