| 1 |
adx |
30 |
/* |
| 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 |
knight |
31 |
* $Id$ |
| 23 |
adx |
30 |
*/ |
| 24 |
|
|
|
| 25 |
|
|
#include "stdinc.h" |
| 26 |
|
|
#include "client.h" |
| 27 |
|
|
#include "irc_string.h" |
| 28 |
|
|
#include "s_serv.h" |
| 29 |
michael |
1309 |
#include "conf.h" |
| 30 |
adx |
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 |
michael |
1877 |
int i = 0; |
| 45 |
|
|
unsigned int cap = 0; |
| 46 |
michael |
875 |
char *p = NULL; |
| 47 |
|
|
char *s = NULL; |
| 48 |
adx |
30 |
|
| 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 |
michael |
969 |
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 |
michael |
2525 |
if ((cap = find_capability(s))) |
| 61 |
|
|
SetCapable(client_p, cap); |
| 62 |
adx |
30 |
} |
| 63 |
michael |
1230 |
|
| 64 |
|
|
static struct Message capab_msgtab = { |
| 65 |
michael |
1728 |
"CAPAB", 0, 0, 2, MAXPARA, MFLG_SLOW, 0, |
| 66 |
michael |
1230 |
{ 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 |
|
|
}; |