19 |
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
20 |
|
* USA |
21 |
|
* |
22 |
< |
* $Id: m_capab.c,v 1.39 2005/07/30 20:44:14 adx Exp $ |
22 |
> |
* $Id$ |
23 |
|
*/ |
24 |
|
|
25 |
|
#include "stdinc.h" |
32 |
|
#include "parse.h" |
33 |
|
#include "modules.h" |
34 |
|
|
35 |
< |
static void mr_capab(struct Client *, struct Client *, int, char **); |
35 |
> |
static void mr_capab(struct Client *, struct Client *, int, char *[]); |
36 |
|
|
37 |
|
struct Message capab_msgtab = { |
38 |
|
"CAPAB", 0, 0, 0, 0, MFLG_SLOW | MFLG_UNREG, 0, |
39 |
< |
{mr_capab, m_ignore, m_ignore, m_ignore, m_ignore, m_ignore} |
39 |
> |
{ mr_capab, m_ignore, m_ignore, m_ignore, m_ignore, m_ignore } |
40 |
|
}; |
41 |
|
|
42 |
|
#ifndef STATIC_MODULES |
52 |
|
mod_del_cmd(&capab_msgtab); |
53 |
|
} |
54 |
|
|
55 |
< |
const char *_version = "$Revision: 1.39 $"; |
55 |
> |
const char *_version = "$Revision$"; |
56 |
|
#endif |
57 |
|
|
58 |
|
/* |
67 |
|
{ |
68 |
|
int i; |
69 |
|
int cap; |
70 |
< |
char *p; |
71 |
< |
char *s; |
70 |
> |
char *p = NULL; |
71 |
> |
char *s = NULL; |
72 |
|
#ifdef HAVE_LIBCRYPTO |
73 |
< |
struct EncCapability *ecap; |
73 |
> |
const struct EncCapability *ecap; |
74 |
|
unsigned int cipher = 0; |
75 |
|
#endif |
76 |
|
|
77 |
– |
/* ummm, this shouldn't happen. Could argue this should be logged etc. */ |
78 |
– |
if (client_p->localClient == NULL) |
79 |
– |
return; |
80 |
– |
|
77 |
|
if (client_p->localClient->caps && !(IsCapable(client_p, CAP_TS6))) |
78 |
|
{ |
79 |
|
exit_client(client_p, client_p, "CAPAB received twice"); |
80 |
|
return; |
81 |
|
} |
86 |
– |
else |
87 |
– |
SetCapable(client_p, CAP_CAP); |
82 |
|
|
83 |
< |
for (i = 1; i < parc; i++) |
83 |
> |
SetCapable(client_p, CAP_CAP); |
84 |
> |
|
85 |
> |
for (i = 1; i < parc; ++i) |
86 |
|
{ |
87 |
< |
for (s = strtoken(&p, parv[i], " "); s; s = strtoken(&p, NULL, " ")) |
87 |
> |
for (s = strtoken(&p, parv[i], " "); s; |
88 |
> |
s = strtoken(&p, NULL, " ")) |
89 |
|
{ |
90 |
|
#ifdef HAVE_LIBCRYPTO |
91 |
< |
if ((strncmp(s, "ENC:", 4) == 0)) |
91 |
> |
if (!strncmp(s, "ENC:", 4)) |
92 |
|
{ |
93 |
|
/* Skip the "ENC:" portion */ |
94 |
|
s += 4; |
96 |
|
/* Check the remaining portion against the list of ciphers we |
97 |
|
* have available (CipherTable). |
98 |
|
*/ |
99 |
< |
for (ecap = CipherTable; ecap->name; ecap++) |
99 |
> |
for (ecap = CipherTable; ecap->name; ++ecap) |
100 |
|
{ |
101 |
< |
if ((irccmp(ecap->name, s) == 0) && (ecap->cap & CAP_ENC_MASK)) |
101 |
> |
if (!irccmp(ecap->name, s) && (ecap->cap & CAP_ENC_MASK)) |
102 |
|
{ |
103 |
|
cipher = ecap->cap; |
104 |
|
break; |
105 |
|
} |
106 |
|
} |
107 |
+ |
|
108 |
|
/* Since the name and capabilities matched, use it. */ |
109 |
|
if (cipher != 0) |
110 |
|
{ |