]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - include/inspircd.h
1eece0532ad347875ee90019fa97dcf8524685fc
[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
46 // some misc defines
47
48 #define ERROR -1
49 #define TRUE 1
50 #define FALSE 0
51 #define MAXSOCKS 64
52 #define MAXCOMMAND 32
53
54 // flags for use with WriteMode
55
56 #define WM_AND 1
57 #define WM_OR 2
58
59 // flags for use with OnUserPreMessage and OnUserPreNotice
60
61 #define TYPE_USER 1
62 #define TYPE_CHANNEL 2
63 #define TYPE_SERVER 3
64
65 #define IS_LOCAL(x) (x->fd > -1)
66 #define IS_REMOTE(x) (x->fd < 0)
67 #define IS_MODULE_CREATED(x) (x->fd == FD_MAGIC_NUMBER)
68
69 typedef void (handlerfunc) (char**, int, userrec*);
70
71 class serverstats
72 {
73   public:
74         int statsAccept;
75         int statsRefused;
76         int statsUnknown;
77         int statsCollisions;
78         int statsDns;
79         int statsDnsGood;
80         int statsDnsBad;
81         int statsConnects;
82         int statsSent;
83         int statsRecv;
84
85         serverstats()
86         {
87                 statsAccept = statsRefused = statsUnknown = 0;
88                 statsCollisions = statsDns = statsDnsGood = 0;
89                 statsDnsBad = statsConnects = statsSent = statsRecv = 0;
90         }
91 };
92
93
94 class InspIRCd
95 {
96  public:
97         InspIRCd(int argc, char** argv);
98         int Run();
99 };
100
101 /* prototypes */
102 void force_nickchange(userrec* user,const char* newnick);
103 void kill_link(userrec *user,const char* r);
104 void kill_link_silent(userrec *user,const char* r);
105 void call_handler(const char* commandname,char **parameters, int pcnt, userrec *user);
106 bool is_valid_cmd(const char* commandname, int pcnt, userrec * user);
107 std::string GetRevision();
108 int loop_call(handlerfunc fn, char **parameters, int pcnt, userrec *u, int start, int end, int joins);
109 void AddWhoWas(userrec* u);
110 void ConnectUser(userrec *user);
111 userrec* ReHashNick(char* Old, char* New);
112 bool LoadModule(const char* filename);
113 bool UnloadModule(const char* filename);
114 char* ModuleError();
115 /* optimization tricks to save us walking the user hash */
116 void AddOper(userrec* user);
117 void DeleteOper(userrec* user);
118 void handle_version(char **parameters, int pcnt, userrec *user);
119 /* userrec optimization stuff */
120 void AddServerName(std::string servername);
121 const char* FindServerNamePtr(std::string servername);
122 std::string GetVersionString();
123 void* dns_task(void* arg);
124 void process_buffer(const char* cmdbuf,userrec *user);
125 void FullConnectUser(userrec* user);
126
127 #endif