ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_encap.c
Revision: 4545
Committed: Fri Aug 22 08:46:13 2014 UTC (11 years ago) by michael
Content type: text/x-csrc
File size: 3032 byte(s)
Log Message:
- Implemented pseudo {} blocks (service aliases)
- Fixed compile warnings with -Wmissing-field-initializers

File Contents

# User Rev Content
1 adx 30 /*
2 michael 2816 * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3 adx 30 *
4 michael 2816 * Copyright (c) 2003-2014 ircd-hybrid development team
5 adx 30 *
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
8     * the Free Software Foundation; either version 2 of the License, or
9     * (at your option) any later version.
10     *
11     * This program is distributed in the hope that it will be useful,
12     * but WITHOUT ANY WARRANTY; without even the implied warranty of
13     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14     * GNU General Public License for more details.
15     *
16     * You should have received a copy of the GNU General Public License
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    
22 michael 2816 /*! \file m_encap.c
23     * \brief Includes required functions for processing the ENCAP command.
24     * \version $Id$
25     */
26    
27 adx 30 #include "stdinc.h"
28     #include "client.h"
29     #include "parse.h"
30 michael 3347 #include "server.h"
31 adx 30 #include "send.h"
32     #include "modules.h"
33     #include "irc_string.h"
34    
35    
36     /*
37     * ms_encap()
38     *
39     * inputs - destination server, subcommand, parameters
40     * output - none
41     * side effects - propagates subcommand to locally connected servers
42     */
43 michael 2820 static int
44 michael 3156 ms_encap(struct Client *source_p, int parc, char *parv[])
45 adx 30 {
46 michael 3215 char buffer[IRCD_BUFSIZE] = "", *ptr = buffer;
47 adx 30 unsigned int cur_len = 0, len, i;
48 michael 1321 #ifdef NOT_USED_YET
49 adx 30 int paramcount, mpara = 0;
50 michael 1321 #endif
51 adx 30 struct Message *mptr = NULL;
52    
53 michael 3215 for (i = 1; i < (unsigned int)parc - 1; ++i)
54 adx 30 {
55     len = strlen(parv[i]) + 1;
56    
57     if ((cur_len + len) >= sizeof(buffer))
58 michael 2820 return 0;
59 adx 30
60 michael 1233 snprintf(ptr, sizeof(buffer) - cur_len, "%s ", parv[i]);
61 adx 30 cur_len += len;
62     ptr += len;
63     }
64    
65 michael 3037 /* If it's a command without parameters, don't prepend a ':' */
66 adx 30 if (parc == 3)
67 michael 1233 snprintf(ptr, sizeof(buffer) - cur_len, "%s", parv[2]);
68 adx 30 else
69 michael 1233 snprintf(ptr, sizeof(buffer) - cur_len, ":%s", parv[parc - 1]);
70 adx 30
71     sendto_match_servs(source_p, parv[1], CAP_ENCAP,
72     "ENCAP %s", buffer);
73    
74 michael 1652 if (match(parv[1], me.name))
75 michael 2820 return 0;
76 adx 30
77     if ((mptr = find_command(parv[2])) == NULL)
78 michael 2820 return 0;
79 adx 30
80 michael 1178 #ifdef NOT_USED_YET
81 adx 30 paramcount = mptr->parameters;
82     mpara = mptr->maxpara;
83 michael 1178 #endif
84 adx 30 mptr->bytes += strlen(buffer);
85    
86     parv += 2;
87     parc -= 2;
88    
89 michael 4155 if ((unsigned int)parc >= mptr->args_min)
90     mptr->handlers[ENCAP_HANDLER](source_p, parc, parv);
91 michael 2820 return 0;
92 adx 30 }
93 michael 1230
94 michael 2816 static struct Message encap_msgtab =
95     {
96 michael 4545 "ENCAP", NULL, 0, 0, 3, MAXPARA, MFLG_SLOW, 0,
97 michael 2816 { m_ignore, m_ignore, ms_encap, m_ignore, m_ignore, m_ignore }
98 michael 1230 };
99    
100     static void
101     module_init(void)
102     {
103     mod_add_cmd(&encap_msgtab);
104     add_capability("ENCAP", CAP_ENCAP, 1);
105     }
106    
107     static void
108     module_exit(void)
109     {
110     mod_del_cmd(&encap_msgtab);
111     delete_capability("ENCAP");
112     }
113    
114 michael 2816 struct module module_entry =
115     {
116 michael 1230 .node = { NULL, NULL, NULL },
117     .name = NULL,
118     .version = "$Revision$",
119     .handle = NULL,
120     .modinit = module_init,
121     .modexit = module_exit,
122     .flags = 0
123     };

Properties

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