]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - include/inspircd.h
Made LoadModule and UnloadModule public
[user/henk/code/inspircd.git] / include / inspircd.h
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  Inspire is copyright (C) 2002-2004 ChatSpike-Dev.
6  *                       E-mail:
7  *                <brain@chatspike.net>
8  *                <Craig@chatspike.net>
9  *     
10  * Written by Craig Edwards, Craig McLure, and others.
11  * This program is free but copyrighted software; see
12  *            the file COPYING for details.
13  *
14  * ---------------------------------------------------
15  */
16
17 #ifndef __INSPIRCD_H__
18 #define __INSPIRCD_H__
19
20 #include "inspircd_config.h"
21 #include <string>
22 #include <stdio.h>
23 #include <unistd.h>
24 #include <signal.h>
25 #include <time.h>
26 #include <netdb.h>
27 #include <string.h>
28 #include <errno.h>
29 #include <sys/types.h>
30
31 #ifndef _LINUX_C_LIB_VERSION
32 #include <sys/socket.h>
33 #include <sys/stat.h>
34 #include <netinet/in.h>
35 #endif
36
37 #include <arpa/inet.h>
38 #include <string>
39 #include <deque>
40
41 #include "inspircd_io.h"
42 #include "inspircd_util.h"
43 #include "users.h"
44 #include "channels.h"
45 #include "socket.h"
46
47 // some misc defines
48
49 #define ERROR -1
50 #define TRUE 1
51 #define FALSE 0
52 #define MAXSOCKS 64
53 #define MAXCOMMAND 32
54
55 // flags for use with WriteMode
56
57 #define WM_AND 1
58 #define WM_OR 2
59
60 // flags for use with OnUserPreMessage and OnUserPreNotice
61
62 #define TYPE_USER 1
63 #define TYPE_CHANNEL 2
64 #define TYPE_SERVER 3
65
66 #define IS_LOCAL(x) (x->fd > -1)
67 #define IS_REMOTE(x) (x->fd < 0)
68 #define IS_MODULE_CREATED(x) (x->fd == FD_MAGIC_NUMBER)
69
70 typedef void (handlerfunc) (char**, int, userrec*);
71
72 class serverstats
73 {
74   public:
75         int statsAccept;
76         int statsRefused;
77         int statsUnknown;
78         int statsCollisions;
79         int statsDns;
80         int statsDnsGood;
81         int statsDnsBad;
82         int statsConnects;
83         int statsSent;
84         int statsRecv;
85
86         serverstats()
87         {
88                 statsAccept = statsRefused = statsUnknown = 0;
89                 statsCollisions = statsDns = statsDnsGood = 0;
90                 statsDnsBad = statsConnects = statsSent = statsRecv = 0;
91         }
92 };
93
94
95 class InspIRCd
96 {
97
98  private:
99         void erase_factory(int j);
100         void erase_module(int j);
101
102  public:
103         time_t startup_time;
104         std::vector<InspSocket*> module_sockets;
105
106         bool LoadModule(const char* filename);
107         bool UnloadModule(const char* filename);
108         InspIRCd(int argc, char** argv);
109         int Run();
110
111 };
112
113 /* prototypes */
114 void force_nickchange(userrec* user,const char* newnick);
115 void kill_link(userrec *user,const char* r);
116 void kill_link_silent(userrec *user,const char* r);
117 void call_handler(const char* commandname,char **parameters, int pcnt, userrec *user);
118 bool is_valid_cmd(const char* commandname, int pcnt, userrec * user);
119 std::string GetRevision();
120 int loop_call(handlerfunc fn, char **parameters, int pcnt, userrec *u, int start, int end, int joins);
121 void AddWhoWas(userrec* u);
122 void ConnectUser(userrec *user);
123 userrec* ReHashNick(char* Old, char* New);
124 char* ModuleError();
125 /* optimization tricks to save us walking the user hash */
126 void AddOper(userrec* user);
127 void DeleteOper(userrec* user);
128 void handle_version(char **parameters, int pcnt, userrec *user);
129 /* userrec optimization stuff */
130 void AddServerName(std::string servername);
131 const char* FindServerNamePtr(std::string servername);
132 std::string GetVersionString();
133 void* dns_task(void* arg);
134 void process_buffer(const char* cmdbuf,userrec *user);
135 void FullConnectUser(userrec* user);
136
137 #endif