1 |
/* |
2 |
* ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). |
3 |
* m_capab.c: Negotiates capabilities with a remote server. |
4 |
* |
5 |
* Copyright (C) 2002 by the past and present ircd coders, and others. |
6 |
* |
7 |
* This program is free software; you can redistribute it and/or modify |
8 |
* it under the terms of the GNU General Public License as published by |
9 |
* the Free Software Foundation; either version 2 of the License, or |
10 |
* (at your option) any later version. |
11 |
* |
12 |
* This program is distributed in the hope that it will be useful, |
13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 |
* GNU General Public License for more details. |
16 |
* |
17 |
* You should have received a copy of the GNU General Public License |
18 |
* along with this program; if not, write to the Free Software |
19 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
20 |
* USA |
21 |
* |
22 |
* $Id$ |
23 |
*/ |
24 |
|
25 |
#include "stdinc.h" |
26 |
#include "client.h" |
27 |
#include "irc_string.h" |
28 |
#include "s_serv.h" |
29 |
#include "conf.h" |
30 |
#include "parse.h" |
31 |
#include "modules.h" |
32 |
|
33 |
|
34 |
/* |
35 |
* mr_capab - CAPAB message handler |
36 |
* parv[0] = sender prefix |
37 |
* parv[1] = space-separated list of capabilities |
38 |
* |
39 |
*/ |
40 |
static void |
41 |
mr_capab(struct Client *client_p, struct Client *source_p, |
42 |
int parc, char *parv[]) |
43 |
{ |
44 |
int i; |
45 |
int cap; |
46 |
char *p = NULL; |
47 |
char *s = NULL; |
48 |
|
49 |
if (client_p->localClient->caps && !(IsCapable(client_p, CAP_TS6))) |
50 |
{ |
51 |
exit_client(client_p, client_p, "CAPAB received twice"); |
52 |
return; |
53 |
} |
54 |
|
55 |
SetCapable(client_p, CAP_CAP); |
56 |
|
57 |
for (i = 1; i < parc; ++i) |
58 |
for (s = strtoken(&p, parv[i], " "); s; |
59 |
s = strtoken(&p, NULL, " ")) |
60 |
if ((cap = find_capability(s))) |
61 |
SetCapable(client_p, cap); |
62 |
} |
63 |
|
64 |
static struct Message capab_msgtab = { |
65 |
"CAPAB", 0, 0, 0, MAXPARA, MFLG_SLOW | MFLG_UNREG, 0, |
66 |
{ mr_capab, m_ignore, m_ignore, m_ignore, m_ignore, m_ignore } |
67 |
}; |
68 |
|
69 |
static void |
70 |
module_init(void) |
71 |
{ |
72 |
mod_add_cmd(&capab_msgtab); |
73 |
} |
74 |
|
75 |
static void |
76 |
module_exit(void) |
77 |
{ |
78 |
mod_del_cmd(&capab_msgtab); |
79 |
} |
80 |
|
81 |
struct module module_entry = { |
82 |
.node = { NULL, NULL, NULL }, |
83 |
.name = NULL, |
84 |
.version = "$Revision$", |
85 |
.handle = NULL, |
86 |
.modinit = module_init, |
87 |
.modexit = module_exit, |
88 |
.flags = 0 |
89 |
}; |