]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - include/inspircd.h
Added:
[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 #include <string>
18 #include <stdio.h>
19 #include <syslog.h>
20 #include <stdlib.h>
21 #include <unistd.h>
22 #include <signal.h>
23 #include <time.h>
24 #include <netdb.h>
25 #include <string.h>
26 #include <ctype.h>
27 #include <errno.h>
28 #include <stdarg.h>
29 #include <assert.h>
30 #include <sys/param.h>
31 #include <sys/types.h>
32
33 #ifndef _LINUX_C_LIB_VERSION
34 #include <sys/socket.h>
35 #include <sys/stat.h>
36 #include <netinet/in.h>
37 #endif
38
39 #include <arpa/inet.h>
40 #include <string>
41 #include <deque>
42
43 #include "inspircd_config.h"
44 #include "inspircd_io.h"
45 #include "inspircd_util.h"
46 #include "users.h"
47 #include "channels.h"
48 #include "servers.h"
49
50 // some misc defines
51
52 #define ERROR -1
53 #define TRUE 1
54 #define FALSE 0
55 #define IDENTMAX 12
56 #define MAXSOCKS 64
57
58 // maximum lengths of items
59
60 #define MAXQUIT 255
61 #define MAXCOMMAND 32
62 #define MAXTOPIC 307
63 #define MAXKICK 255
64
65 // flags for use with log()
66
67 #define DEBUG 10
68 #define VERBOSE 20
69 #define DEFAULT 30
70 #define SPARSE 40
71 #define NONE 50
72
73 // flags for use with WriteMode
74
75 #define WM_AND 1
76 #define WM_OR 2
77
78 // flags for use with OnUserPreMessage and OnUserPreNotice
79
80 #define TYPE_USER 1
81 #define TYPE_CHANNEL 2
82
83 typedef std::deque<std::string> file_cache;
84
85 typedef void (handlerfunc) (char**, int, userrec*);
86
87 /* prototypes */
88 int InspIRCd(void);
89 int InitConfig(void);
90 void Error(int status);
91 void send_error(char *s);
92 void ReadConfig(bool bail,userrec* user);
93 void strlower(char *n);
94
95 void WriteOpers(char* text, ...);
96 void WriteMode(const char* modes, int flags, const char* text, ...);
97 void log(int level, char *text, ...);
98 void Write(int sock,char *text, ...);
99 void WriteServ(int sock, char* text, ...);
100 void WriteFrom(int sock, userrec *user,char* text, ...);
101 void WriteTo(userrec *source, userrec *dest,char *data, ...);
102 void WriteChannel(chanrec* Ptr, userrec* user, char* text, ...);
103 void ChanExceptSender(chanrec* Ptr, userrec* user, char* text, ...);
104 void WriteCommon(userrec *u, char* text, ...);
105 void WriteCommonExcept(userrec *u, char* text, ...);
106 void WriteWallOps(userrec *source, bool local_only, char* text, ...);
107 void WriteChannelLocal(chanrec* Ptr, userrec* user, char* text, ...);
108 void WriteChannelWithServ(char* ServerName, chanrec* Ptr, userrec* user, char* text, ...);
109 char* chanmodes(chanrec *chan);
110 userrec* Find(std::string nick);
111 chanrec* FindChan(const char* chan);
112 std::string getservername();
113 std::string getserverdesc();
114 std::string getnetworkname();
115 std::string getadminname();
116 std::string getadminemail();
117 std::string getadminnick();
118 void readfile(file_cache &F, const char* fname);
119 bool ModeDefined(char c, int i);
120 bool ModeDefinedOper(char c, int i);
121 int ModeDefinedOn(char c, int i);
122 int ModeDefinedOff(char c, int i);
123 void ModeMakeList(char modechar);
124 bool ModeIsListMode(char modechar, int type);
125 chanrec* add_channel(userrec *user, const char* cn, const char* key, bool override);
126 chanrec* del_channel(userrec *user, const char* cname, const char* reason, bool local);
127 void force_nickchange(userrec* user,const char* newnick);
128 void kill_link(userrec *user,const char* r);
129 void kill_link_silent(userrec *user,const char* r);
130 int usercount(chanrec *c);
131 void call_handler(const char* commandname,char **parameters, int pcnt, userrec *user);
132 long GetRevision();
133 int loop_call(handlerfunc fn, char **parameters, int pcnt, userrec *u, int start, int end, int joins);
134 void kick_channel(userrec *src,userrec *user, chanrec *Ptr, char* reason);
135 void purge_empty_chans(void);
136 char* Passwd(userrec *user);
137 bool IsDenied(userrec *user);
138 void AddWhoWas(userrec* u);
139 void userlist(userrec *user,chanrec *c);
140 std::string GetServerDescription(char* servername);
141 int usercnt(void);
142 int registered_usercount(void);
143 int usercount_invisible(void);
144 int usercount_opers(void);
145 int usercount_unknown(void);
146 long chancount(void);
147 long count_servs(void);
148 long servercount(void);
149 long local_count();
150 void ShowMOTD(userrec *user);
151 void ShowRULES(userrec *user);
152 int usercount(chanrec *c);
153 int usercount_i(chanrec *c);
154 void update_stats_l(int fd,int data_out);
155 void ConnectUser(userrec *user);
156 void DoSplitEveryone();
157 char islast(const char* s);
158 long map_count(const char* s);
159 userrec* ReHashNick(char* Old, char* New);
160 long GetMaxBans(char* name);
161 bool LoadModule(const char* filename);
162 bool UnloadModule(const char* filename);
163 char* ModuleError();
164
165 // mesh network functions
166
167 void NetSendToCommon(userrec* u, char* s);
168 void NetSendToAll(char* s);
169 void NetSendToAllAlive(char* s);
170 void NetSendToOne(char* target,char* s);
171 void NetSendToAllExcept(const char* target,char* s);
172 void NetSendMyRoutingTable();
173 bool ChanAnyOnThisServer(chanrec *c,char* servername);
174 bool CommonOnThisServer(userrec* u,const char* servername);
175 void DoSplit(const char* params);
176 void RemoveServer(const char* name);
177 void DoSync(serverrec* serv, char* tcp_host);