ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid-8/modules/m_encap.c
Revision: 1243
Committed: Fri Sep 30 10:47:53 2011 UTC (12 years, 6 months ago) by michael
Content type: text/x-csrc
File size: 3582 byte(s)
Log Message:
- move content of msg.h, ircd_handler.h and handlers.h into parse.h and
  remove headers accordingly
- killed common.h
- remove m_killhost.c and m_flags.c from contrib/
- sort out unused header includes here and there

File Contents

# Content
1 /*
2 * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3 * m_encap.c: encapsulated command propagation and parsing
4 *
5 * Copyright (C) 2003 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 "parse.h"
28 #include "sprintf_irc.h"
29 #include "s_serv.h"
30 #include "send.h"
31 #include "modules.h"
32 #include "irc_string.h"
33
34
35 /*
36 * ms_encap()
37 *
38 * inputs - destination server, subcommand, parameters
39 * output - none
40 * side effects - propagates subcommand to locally connected servers
41 */
42 static void
43 ms_encap(struct Client *client_p, struct Client *source_p,
44 int parc, char *parv[])
45 {
46 char buffer[IRCD_BUFSIZE], *ptr = buffer;
47 unsigned int cur_len = 0, len, i;
48 int paramcount, mpara = 0;
49 struct Message *mptr = NULL;
50 MessageHandler handler = 0;
51
52 for (i = 1; i < (unsigned int)parc - 1; i++)
53 {
54 len = strlen(parv[i]) + 1;
55
56 if ((cur_len + len) >= sizeof(buffer))
57 return;
58
59 snprintf(ptr, sizeof(buffer) - cur_len, "%s ", parv[i]);
60 cur_len += len;
61 ptr += len;
62 }
63
64 len = strlen(parv[i]);
65
66 /*
67 * if the final parameter crosses our buffer size, should we bail,
68 * like the rest, or should we truncate? ratbox seems to think truncate,
69 * so i'll do that for now until i can talk to lee. -bill
70 */
71
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
77 if ((cur_len + len) >= sizeof(buffer))
78 buffer[sizeof(buffer) - 1] = '\0';
79
80 sendto_match_servs(source_p, parv[1], CAP_ENCAP,
81 "ENCAP %s", buffer);
82
83 if (!match(parv[1], me.name))
84 return;
85
86 if ((mptr = find_command(parv[2])) == NULL)
87 return;
88
89 #ifdef NOT_USED_YET
90 paramcount = mptr->parameters;
91 mpara = mptr->maxpara;
92 #endif
93 mptr->bytes += strlen(buffer);
94
95 /*
96 * yes this is an ugly hack, but it is quicker than copying the entire array again
97 * note: this hack wouldnt be needed if parv[0] were set to the command name, rather
98 * than being derived from the prefix, as it should have been from the beginning.
99 */
100 ptr = parv[0];
101 parv += 2;
102 parc -= 2;
103 parv[0] = ptr;
104
105 if ((handler = mptr->handlers[ENCAP_HANDLER]))
106 (*handler)(client_p, source_p, parc, parv);
107 }
108
109 static struct Message encap_msgtab = {
110 "ENCAP", 0, 0, 3, MAXPARA, MFLG_SLOW, 0,
111 {m_ignore, m_ignore, ms_encap, m_ignore, m_ignore, m_ignore}
112 };
113
114 static void
115 module_init(void)
116 {
117 mod_add_cmd(&encap_msgtab);
118 add_capability("ENCAP", CAP_ENCAP, 1);
119 }
120
121 static void
122 module_exit(void)
123 {
124 mod_del_cmd(&encap_msgtab);
125 delete_capability("ENCAP");
126 }
127
128 struct module module_entry = {
129 .node = { NULL, NULL, NULL },
130 .name = NULL,
131 .version = "$Revision$",
132 .handle = NULL,
133 .modinit = module_init,
134 .modexit = module_exit,
135 .flags = 0
136 };

Properties

Name Value
svn:eol-style native
svn:keywords Id Revision