00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __INSPIRCD_H__
00018 #define __INSPIRCD_H__
00019
00020 #include "inspircd_config.h"
00021 #include <string>
00022 #include <stdio.h>
00023 #include <unistd.h>
00024 #include <signal.h>
00025 #include <time.h>
00026 #include <netdb.h>
00027 #include <string.h>
00028 #include <errno.h>
00029 #include <sys/types.h>
00030
00031 #ifndef _LINUX_C_LIB_VERSION
00032 #include <sys/socket.h>
00033 #include <sys/stat.h>
00034 #include <netinet/in.h>
00035 #endif
00036
00037 #include <arpa/inet.h>
00038 #include <string>
00039 #include <deque>
00040
00041 #include "inspircd_io.h"
00042 #include "inspircd_util.h"
00043 #include "users.h"
00044 #include "channels.h"
00045 #include "socket.h"
00046
00047
00048
00049 #define ERROR -1
00050 #define TRUE 1
00051 #define FALSE 0
00052 #define MAXSOCKS 64
00053 #define MAXCOMMAND 32
00054
00055
00056
00057 #define WM_AND 1
00058 #define WM_OR 2
00059
00060
00061
00062 #define TYPE_USER 1
00063 #define TYPE_CHANNEL 2
00064 #define TYPE_SERVER 3
00065
00066 #define IS_LOCAL(x) (x->fd > -1)
00067 #define IS_REMOTE(x) (x->fd < 0)
00068 #define IS_MODULE_CREATED(x) (x->fd == FD_MAGIC_NUMBER)
00069
00070 typedef void (handlerfunc) (char**, int, userrec*);
00071
00072 class serverstats
00073 {
00074 public:
00075 int statsAccept;
00076 int statsRefused;
00077 int statsUnknown;
00078 int statsCollisions;
00079 int statsDns;
00080 int statsDnsGood;
00081 int statsDnsBad;
00082 int statsConnects;
00083 int statsSent;
00084 int statsRecv;
00085
00086 serverstats()
00087 {
00088 statsAccept = statsRefused = statsUnknown = 0;
00089 statsCollisions = statsDns = statsDnsGood = 0;
00090 statsDnsBad = statsConnects = statsSent = statsRecv = 0;
00091 }
00092 };
00093
00094
00095 class InspIRCd
00096 {
00097
00098 private:
00099 char MODERR[MAXBUF];
00100 void erase_factory(int j);
00101 void erase_module(int j);
00102
00103 public:
00104 time_t startup_time;
00105
00106 std::string GetRevision();
00107 std::string GetVersionString();
00108 char* ModuleError();
00109 bool LoadModule(const char* filename);
00110 bool UnloadModule(const char* filename);
00111 InspIRCd(int argc, char** argv);
00112 int Run();
00113
00114 };
00115
00116
00117 void force_nickchange(userrec* user,const char* newnick);
00118 void kill_link(userrec *user,const char* r);
00119 void kill_link_silent(userrec *user,const char* r);
00120 void call_handler(const char* commandname,char **parameters, int pcnt, userrec *user);
00121 bool is_valid_cmd(const char* commandname, int pcnt, userrec * user);
00122 int loop_call(handlerfunc fn, char **parameters, int pcnt, userrec *u, int start, int end, int joins);
00123 void AddWhoWas(userrec* u);
00124 void ConnectUser(userrec *user);
00125 userrec* ReHashNick(char* Old, char* New);
00126
00127 void AddOper(userrec* user);
00128 void DeleteOper(userrec* user);
00129 void handle_version(char **parameters, int pcnt, userrec *user);
00130
00131 void AddServerName(std::string servername);
00132 const char* FindServerNamePtr(std::string servername);
00133 void* dns_task(void* arg);
00134 void process_buffer(const char* cmdbuf,userrec *user);
00135 void FullConnectUser(userrec* user);
00136
00137 #endif