]> jfr.im git - irc/evilnet/x3.git/blame - src/proto.h
Removing config-built file from cvs
[irc/evilnet/x3.git] / src / proto.h
CommitLineData
d76ed9a9 1/* proto.h - IRC protocol output
2 * Copyright 2000-2004 srvx Development Team
3 *
4 * This file is part of srvx.
5 *
6 * srvx is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with srvx; if not, write to the Free Software Foundation,
18 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
19 */
20
21#if !defined(PROTO_H)
22#define PROTO_H
23
24/* Warning for those looking at how this code does multi-protocol
25 * support: It's an awful, nasty hack job. It is intended for short
26 * term use, not long term, since we are already developing srvx2,
27 * which has much nicer interfaces that hide most of the ugly
28 * differences between protocol dialects. */
29
30#define COMBO_NUMERIC_LEN 5 /* 1/2, 1/3 or 2/3 digits for server/client parts */
31#define MAXLEN 512 /* Maximum IRC line length */
32#define MAXNUMPARAMS 200
33#define ALLCHANMSG_FUNCS_MAX 4 /* +1 == 5 potential 'allchanmsg' funcs */
34
35#ifdef HAVE_NETINET_IN_H
36#include <netinet/in.h>
37#endif
38
39struct gline;
40struct server;
41struct userNode;
42struct chanNode;
43
44/* connection manager state */
45
46enum cState
47{
48 DISCONNECTED,
49 AUTHENTICATING,
50 BURSTING,
51 CONNECTED
52};
53
54#define UPLINK_UNAVAILABLE 0x001
55
56struct uplinkNode
57{
58 char *name;
59
60 char *host;
61 int port;
62
63 struct sockaddr_in *bind_addr;
64 int bind_addr_len;
65
66 char *password;
67 char *their_password;
68
69 enum cState state;
70 int tries;
71 int max_tries;
72 long flags;
73
74 struct uplinkNode *prev;
75 struct uplinkNode *next;
76};
77
78struct cManagerNode
79{
80 struct uplinkNode *uplinks;
81 struct uplinkNode *uplink;
82
83 int cycles;
84 int enabled;
85};
86
87#ifdef WITH_PROTOCOL_P10
88struct server* GetServerN(const char *numeric);
89struct userNode* GetUserN(const char *numeric);
90#endif
91
92/* Basic protocol parsing support. */
93void init_parse(void);
94int parse_line(char *line, int recursive);
95
96/* Callback notifications for protocol support. */
97typedef void (*chanmsg_func_t) (struct userNode *user, struct chanNode *chan, char *text, struct userNode *bot);
98void reg_chanmsg_func(unsigned char prefix, struct userNode *service, chanmsg_func_t handler);
99void reg_allchanmsg_func(struct userNode *service, chanmsg_func_t handler);
100struct userNode *get_chanmsg_bot(unsigned char prefix);
101
102typedef void (*privmsg_func_t) (struct userNode *user, struct userNode *target, char *text, int server_qualified);
103void reg_privmsg_func(struct userNode *user, privmsg_func_t handler);
104void reg_notice_func(struct userNode *user, privmsg_func_t handler);
105void unreg_privmsg_func(struct userNode *user, privmsg_func_t handler);
106void unreg_notice_func(struct userNode *user, privmsg_func_t handler);
107
108typedef void (*oper_func_t) (struct userNode *user);
109void reg_oper_func(oper_func_t handler);
110
111extern struct userList dead_users;
112
113/* replay silliness */
114void replay_read_line(void);
115void replay_event_loop(void);
116
117/* connection maintenance */
118void irc_server(struct server *srv);
119void irc_user(struct userNode *user);
120void irc_nick(struct userNode *user, const char *old_nick);
121void irc_introduce(const char *passwd);
122void irc_ping(const char *something);
123void irc_pong(const char *who, const char *data);
124void irc_quit(struct userNode *user, const char *message);
125void irc_squit(struct server *srv, const char *message, const char *service_message);
126
127/* messages */
128void irc_privmsg(struct userNode *from, const char *to, const char *message);
129void irc_notice(struct userNode *from, const char *to, const char *message);
130void irc_notice_user(struct userNode *from, struct userNode *to, const char *message);
131void irc_wallchops(struct userNode *from, const char *to, const char *message);
132
133/* channel maintenance */
134void irc_join(struct userNode *who, struct chanNode *what);
135void irc_invite(struct userNode *from, struct userNode *who, struct chanNode *to);
136void irc_mode(struct userNode *who, struct chanNode *target, const char *modes);
137void irc_kick(struct userNode *who, struct userNode *target, struct chanNode *from, const char *msg);
138void irc_part(struct userNode *who, struct chanNode *what, const char *reason);
139void irc_topic(struct userNode *who, struct chanNode *what, const char *topic);
140void irc_fetchtopic(struct userNode *from, const char *to);
141
142/* network maintenance */
143void irc_gline(struct server *srv, struct gline *gline);
144void irc_settime(const char *srv_name_mask, time_t new_time);
145void irc_ungline(const char *mask);
146void irc_error(const char *to, const char *message);
147void irc_kill(struct userNode *from, struct userNode *target, const char *message);
148void irc_raw(const char *what);
149void irc_stats(struct userNode *from, struct server *target, char type);
150void irc_svsnick(struct userNode *from, struct userNode *target, const char *newnick);
151
152/* account maintenance */
153void irc_account(struct userNode *user, const char *stamp);
154void irc_regnick(struct userNode *user);
155void irc_fakehost(struct userNode *user, const char *host);
156
157/* numeric messages */
158void irc_numeric(struct userNode *user, unsigned int num, const char *format, ...);
159/* RFC1459-compliant numeric responses */
160#define RPL_ENDOFSTATS 219
161#define RPL_STATSUPTIME 242
162#define RPL_MAXCONNECTIONS 250
163#define RPL_WHOISUSER 311
164#define RPL_WHOISSERVER 312
165#define RPL_WHOISOPERATOR 313
166#define RPL_ENDOFWHOIS 318
167#define ERR_NOSUCHNICK 401
168
169/* stuff originally from other headers that is really protocol-specific */
170int IsChannelName(const char *name);
171int is_valid_nick(const char *nick);
172struct userNode *AddService(const char *nick, const char *desc, const char *hostname);
173struct userNode *AddClone(const char *nick, const char *ident, const char *hostname, const char *desc);
174struct server* AddServer(struct server* uplink, const char *name, int hops, time_t boot, time_t link, const char *numeric, const char *description);
175void DelServer(struct server* serv, int announce, const char *message);
176void DelUser(struct userNode* user, struct userNode *killer, int announce, const char *why);
177/* Most protocols will want to make an AddUser helper function. */
178
179/* User modes */
180void mod_usermode(struct userNode *user, const char *modes);
181
182/* Channel mode manipulation */
183#define KEYLEN 23
184typedef unsigned long chan_mode_t;
185/* Rules for struct mod_chanmode:
186 * For a membership mode change, args[n].mode can contain more than
187 * one mode bit (e.g. MODE_CHANOP|MODE_VOICE). Hostmask strings are
188 * "owned" by the caller and are not freed by mod_chanmode_free().
189 */
190struct mod_chanmode {
191 chan_mode_t modes_set, modes_clear;
192 unsigned int new_limit, argc;
193#ifndef NDEBUG
194 unsigned int alloc_argc;
195#endif
196 char new_key[KEYLEN + 1];
197 struct {
198 unsigned int mode;
199 union {
200 struct modeNode *member;
201 const char *hostmask;
202 };
203 } args[1];
204};
205#define MCP_ALLOW_OVB 0x0001 /* allow op, voice, ban manipulation */
206#define MCP_FROM_SERVER 0x0002 /* parse as from a server */
207#define MCP_KEY_FREE 0x0004 /* -k without a key argument */
208#define MC_ANNOUNCE 0x0100 /* send a mod_chanmode() change out */
209#define MC_NOTIFY 0x0200 /* make local callbacks to announce */
210#ifdef NDEBUG
211#define mod_chanmode_init(CHANMODE) do { memset((CHANMODE), 0, sizeof(*CHANMODE)); } while (0)
212#else
213#define mod_chanmode_init(CHANMODE) do { memset((CHANMODE), 0, sizeof(*CHANMODE)); (CHANMODE)->alloc_argc = ArrayLength((CHANMODE)->args); } while (0)
214#endif
215
216struct mod_chanmode *mod_chanmode_alloc(unsigned int argc);
217struct mod_chanmode *mod_chanmode_dup(struct mod_chanmode *orig, unsigned int extra);
218struct mod_chanmode *mod_chanmode_parse(struct chanNode *channel, char **modes, unsigned int argc, unsigned int flags);
219void mod_chanmode_apply(struct userNode *who, struct chanNode *channel, struct mod_chanmode *change);
220void mod_chanmode_announce(struct userNode *who, struct chanNode *channel, struct mod_chanmode *change);
221char *mod_chanmode_format(struct mod_chanmode *desc, char *buffer);
222void mod_chanmode_free(struct mod_chanmode *change);
223int mod_chanmode(struct userNode *who, struct chanNode *channel, char **modes, unsigned int argc, unsigned int flags);
224typedef void (*mode_change_func_t) (struct chanNode *channel, struct userNode *user, const struct mod_chanmode *change);
225void reg_mode_change_func(mode_change_func_t handler);
226int irc_make_chanmode(struct chanNode *chan, char *out);
227
228/* The "default" for generate_hostmask is to have all of these options off. */
229#define GENMASK_STRICT_HOST 1
230#define GENMASK_STRICT_IDENT 32
231#define GENMASK_ANY_IDENT 64
232#define GENMASK_STRICT (GENMASK_STRICT_IDENT|GENMASK_STRICT_HOST)
233#define GENMASK_USENICK 2
234#define GENMASK_OMITNICK 4 /* Hurray for Kevin! */
235#define GENMASK_BYIP 8
236#define GENMASK_SRVXMASK 16
237#define GENMASK_NO_HIDING 128
238char *generate_hostmask(struct userNode *user, int options);
239
240#endif /* !defined(PROTO_H) */