1 |
|
/* |
2 |
< |
* ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). |
3 |
< |
* m_encap.c: encapsulated command propagation and parsing |
2 |
> |
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) |
3 |
|
* |
4 |
< |
* Copyright (C) 2003 by the past and present ircd coders, and others. |
4 |
> |
* Copyright (c) 2003-2014 ircd-hybrid development team |
5 |
|
* |
6 |
|
* This program is free software; you can redistribute it and/or modify |
7 |
|
* it under the terms of the GNU General Public License as published by |
17 |
|
* along with this program; if not, write to the Free Software |
18 |
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
19 |
|
* USA |
20 |
< |
* |
21 |
< |
* $Id$ |
20 |
> |
*/ |
21 |
> |
|
22 |
> |
/*! \file m_encap.c |
23 |
> |
* \brief Includes required functions for processing the ENCAP command. |
24 |
> |
* \version $Id$ |
25 |
|
*/ |
26 |
|
|
27 |
|
#include "stdinc.h" |
28 |
|
#include "client.h" |
29 |
|
#include "parse.h" |
28 |
– |
#include "sprintf_irc.h" |
30 |
|
#include "s_serv.h" |
31 |
|
#include "send.h" |
32 |
|
#include "modules.h" |
40 |
|
* output - none |
41 |
|
* side effects - propagates subcommand to locally connected servers |
42 |
|
*/ |
43 |
< |
static void |
43 |
> |
static int |
44 |
|
ms_encap(struct Client *client_p, struct Client *source_p, |
45 |
|
int parc, char *parv[]) |
46 |
|
{ |
57 |
|
len = strlen(parv[i]) + 1; |
58 |
|
|
59 |
|
if ((cur_len + len) >= sizeof(buffer)) |
60 |
< |
return; |
60 |
> |
return 0; |
61 |
|
|
62 |
|
snprintf(ptr, sizeof(buffer) - cur_len, "%s ", parv[i]); |
63 |
|
cur_len += len; |
64 |
|
ptr += len; |
65 |
|
} |
66 |
|
|
66 |
– |
len = strlen(parv[i]); |
67 |
– |
|
67 |
|
/* |
68 |
< |
* if the final parameter crosses our buffer size, should we bail, |
68 |
> |
* If the final parameter crosses our buffer size, should we bail, |
69 |
|
* like the rest, or should we truncate? ratbox seems to think truncate, |
70 |
|
* so i'll do that for now until i can talk to lee. -bill |
71 |
|
*/ |
73 |
– |
|
72 |
|
if (parc == 3) |
73 |
|
snprintf(ptr, sizeof(buffer) - cur_len, "%s", parv[2]); |
74 |
|
else |
75 |
|
snprintf(ptr, sizeof(buffer) - cur_len, ":%s", parv[parc - 1]); |
76 |
|
|
79 |
– |
if ((cur_len + len) >= sizeof(buffer)) |
80 |
– |
buffer[sizeof(buffer) - 1] = '\0'; |
81 |
– |
|
77 |
|
sendto_match_servs(source_p, parv[1], CAP_ENCAP, |
78 |
|
"ENCAP %s", buffer); |
79 |
|
|
80 |
< |
if (!match(parv[1], me.name)) |
81 |
< |
return; |
80 |
> |
if (match(parv[1], me.name)) |
81 |
> |
return 0; |
82 |
|
|
83 |
|
if ((mptr = find_command(parv[2])) == NULL) |
84 |
< |
return; |
84 |
> |
return 0; |
85 |
|
|
86 |
|
#ifdef NOT_USED_YET |
87 |
|
paramcount = mptr->parameters; |
90 |
|
mptr->bytes += strlen(buffer); |
91 |
|
|
92 |
|
/* |
93 |
< |
* yes this is an ugly hack, but it is quicker than copying the entire array again |
94 |
< |
* note: this hack wouldnt be needed if parv[0] were set to the command name, rather |
95 |
< |
* than being derived from the prefix, as it should have been from the beginning. |
93 |
> |
* Yes this is an ugly hack, but it is quicker than copying the |
94 |
> |
* entire array again. |
95 |
> |
* |
96 |
> |
* Note: this hack wouldn't be needed if parv[0] were set to the |
97 |
> |
* command name, rather than being derived from the prefix, as |
98 |
> |
* it should have been from the beginning. |
99 |
|
*/ |
100 |
|
ptr = parv[0]; |
101 |
|
parv += 2; |
104 |
|
|
105 |
|
if ((handler = mptr->handlers[ENCAP_HANDLER])) |
106 |
|
(*handler)(client_p, source_p, parc, parv); |
107 |
+ |
return 0; |
108 |
|
} |
109 |
|
|
110 |
< |
static struct Message encap_msgtab = { |
110 |
> |
static struct Message encap_msgtab = |
111 |
> |
{ |
112 |
|
"ENCAP", 0, 0, 3, MAXPARA, MFLG_SLOW, 0, |
113 |
< |
{m_ignore, m_ignore, ms_encap, m_ignore, m_ignore, m_ignore} |
113 |
> |
{ m_ignore, m_ignore, ms_encap, m_ignore, m_ignore, m_ignore } |
114 |
|
}; |
115 |
|
|
116 |
|
static void |
127 |
|
delete_capability("ENCAP"); |
128 |
|
} |
129 |
|
|
130 |
< |
struct module module_entry = { |
130 |
> |
struct module module_entry = |
131 |
> |
{ |
132 |
|
.node = { NULL, NULL, NULL }, |
133 |
|
.name = NULL, |
134 |
|
.version = "$Revision$", |