Remove cruft left behind by removed stats_p_hook.
[seven-1.x.git] / modules / m_capab.c
blob82266ef7baeb022654e706038cef040d8322e9b7
1 /* {{{ irc-seven: Cows like it.
3 * Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center.
4 * Copyright (C) 1996-2002 Hybrid Development Team.
5 * Copyright (C) 2002-2005 ircd-ratbox development team.
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.
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.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to:
20 * Free Software Foundation, Inc.
21 * 51 Franklin St - Fifth Floor
22 * Boston, MA 02110-1301
23 * USA
25 * }}} */
27 /* {{{ Includes. */
28 #include "stdinc.h"
29 #include "client.h"
30 #include "irc_string.h"
31 #include "s_serv.h"
32 #include "s_conf.h"
33 #include "msg.h"
34 #include "parse.h"
35 #include "modules.h"
36 /* }}} */
38 static int mr_capab (struct Client *, struct Client *, int, const char **);
39 static int me_gcap (struct Client *, struct Client *, int, const char **);
41 /* {{{ static struct Message capab_msgtab = { ... } */
42 static struct Message capab_msgtab =
44 "CAPAB", 0, 0, 0, MFLG_SLOW | MFLG_UNREG,
46 {mr_capab, 0}, mg_ignore, mg_ignore,
47 mg_ignore, mg_ignore, mg_ignore,
50 /* }}} */
52 /* {{{ static struct Message gcap_msgtab = { ... } */
53 static struct Message gcap_msgtab =
55 "GCAP", 0, 0, 0, MFLG_SLOW,
57 mg_ignore, mg_ignore, mg_ignore,
58 mg_ignore, {me_gcap, 2}, mg_ignore,
61 /* }}} */
63 /* {{{ static mapi_clist_av1 capab_clist[] = { ... } */
64 static mapi_clist_av1 capab_clist[] =
66 &capab_msgtab,
67 &gcap_msgtab,
68 NULL
70 /* }}} */
72 /* {{{ DECLARE_MODULE_AV1(...) */
73 DECLARE_MODULE_AV1
75 capab,
76 NULL,
77 NULL,
78 capab_clist,
79 NULL,
80 NULL,
81 "1.1"
83 /* }}} */
85 /* {{{ static int mr_capab()
87 * CAPAB message handler.
89 * Usage:
90 * CAPAB <capabs>
92 * parv[0] - prefix
93 * parv[1] - capabs
95 static int
96 mr_capab (struct Client *client_p, struct Client *source_p, int parc, const char **parv)
98 struct Capability *cap = NULL;
99 int i;
100 char *p = NULL;
101 char *s = NULL;
103 if (!client_p->localClient || client_p->user)
104 return 0;
106 if ((client_p->localClient->caps & ~CAP_TS6) != 0)
108 exit_client(client_p, client_p, client_p,
109 "CAPAB TS6 is specified via PASS not CAPAB");
110 return 0;
113 client_p->localClient->caps |= CAP_CAP;
114 MyFree(client_p->localClient->fullcaps);
115 DupString(client_p->localClient->fullcaps, parv[1]);
117 for (i = 1; i < parc; ++i)
119 char *t = LOCAL_COPY(parv[i]);
120 for (s = strtoken(&p, t, " "); s; s = strtoken(&p, NULL, " "))
122 for (cap = captab; cap->name; cap++)
124 if (!irccmp(cap->name, s))
126 client_p->localClient->caps |= cap->cap;
127 break;
133 return 0;
135 /* }}} */
137 /* {{{ static int me_gcap()
139 * GCAP ENCAP message handler.
141 * Usage:
142 * GCAP <capabs>
144 * parv[0] - prefix
145 * parv[1] - capabs
147 static int
148 me_gcap (struct Client *client_p, struct Client *source_p, int parc, const char **parv)
150 struct Capability *cap = NULL;
151 char *t = LOCAL_COPY(parv[1]);
152 char *s = NULL;
153 char *p = NULL;
155 if (!IsServer(source_p) || !EmptyString(source_p->serv->fullcaps))
156 return 0;
158 DupString(source_p->serv->fullcaps, parv[1]);
159 for (s = strtoken(&p, t, " "); s; s = strtoken(&p, NULL, " "))
161 for (cap = captab; cap->name; cap++)
163 if (!irccmp(cap->name, s))
165 source_p->serv->caps |= cap->cap;
166 break;
171 return 0;
173 /* }}} */
176 * vim: ts=8 sw=8 noet fdm=marker tw=80