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 void erase_factory(int j);
00100 void erase_module(int j);
00101
00102 public:
00103 time_t startup_time;
00104
00105 bool LoadModule(const char* filename);
00106 bool UnloadModule(const char* filename);
00107 InspIRCd(int argc, char** argv);
00108 int Run();
00109
00110 };
00111
00112
00113 void force_nickchange(userrec* user,const char* newnick);
00114 void kill_link(userrec *user,const char* r);
00115 void kill_link_silent(userrec *user,const char* r);
00116 void call_handler(const char* commandname,char **parameters, int pcnt, userrec *user);
00117 bool is_valid_cmd(const char* commandname, int pcnt, userrec * user);
00118 std::string GetRevision();
00119 int loop_call(handlerfunc fn, char **parameters, int pcnt, userrec *u, int start, int end, int joins);
00120 void AddWhoWas(userrec* u);
00121 void ConnectUser(userrec *user);
00122 userrec* ReHashNick(char* Old, char* New);
00123 char* ModuleError();
00124
00125 void AddOper(userrec* user);
00126 void DeleteOper(userrec* user);
00127 void handle_version(char **parameters, int pcnt, userrec *user);
00128
00129 void AddServerName(std::string servername);
00130 const char* FindServerNamePtr(std::string servername);
00131 std::string GetVersionString();
00132 void* dns_task(void* arg);
00133 void process_buffer(const char* cmdbuf,userrec *user);
00134 void FullConnectUser(userrec* user);
00135
00136 #endif