/[svn]/ircd-hybrid/trunk/modules/m_svshost.c
ViewVC logotype

Contents of /ircd-hybrid/trunk/modules/m_svshost.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 7580 - (show annotations)
Tue May 31 19:12:58 2016 UTC (6 years, 1 month ago) by michael
File MIME type: text/x-chdr
File size: 3091 byte(s)
- Add m_svshost.c for later use

1 /*
2 * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3 *
4 * Copyright (c) 2016-2016 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
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 * USA
20 */
21
22 /*! \file m_svshost.c
23 * \brief Includes required functions for processing the SVSHOST command.
24 * \version $Id: m_svshost.c 7329 2016-02-18 21:07:50Z michael $
25 */
26
27 #include "stdinc.h"
28 #include "client.h"
29 #include "ircd.h"
30 #include "send.h"
31 #include "channel_mode.h"
32 #include "parse.h"
33 #include "modules.h"
34 #include "user.h"
35
36
37 /*! \brief SVSHOST command handler
38 *
39 * \param source_p Pointer to allocated Client struct from which the message
40 * originally comes from. This can be a local or remote client.
41 * \param parc Integer holding the number of supplied arguments.
42 * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
43 * pointers.
44 * \note Valid arguments for this command are:
45 * - parv[0] = command
46 * - parv[1] = nickname
47 * - parv[2] = TS
48 * - parv[3] = +|-
49 * - parv[4] = host name
50 */
51 static int
52 ms_svshost(struct Client *source_p, int parc, char *parv[])
53 {
54 struct Client *target_p = NULL;
55 int what = MODE_ADD;
56
57 if (!HasFlag(source_p, FLAGS_SERVICE))
58 return 0;
59
60 if ((target_p = find_person(source_p, parv[1])) == NULL)
61 return 0;
62
63 uintmax_t ts = strtoumax(parv[2], NULL, 10);
64 if (ts && (ts != target_p->tsinfo))
65 return 0;
66
67 switch (*parv[3])
68 {
69 case '+':
70 what = MODE_ADD;
71 break;
72 case '-':
73 what = MODE_DEL;
74 break;
75 default: return 0;
76 }
77
78 if (valid_hostname(parv[4]))
79 user_set_hostmask(target_p, parv[4], what);
80
81 sendto_server(source_p, 0, 0, ":%s SVSHOST %s %ju %s %s",
82 source_p->id,
83 target_p->id, target_p->tsinfo, parv[3], parv[4]);
84 return 0;
85 }
86
87 static struct Message svshost_msgtab =
88 {
89 .cmd = "SVSHOST",
90 .args_min = 5,
91 .args_max = MAXPARA,
92 .handlers[UNREGISTERED_HANDLER] = m_ignore,
93 .handlers[CLIENT_HANDLER] = m_ignore,
94 .handlers[SERVER_HANDLER] = ms_svshost,
95 .handlers[ENCAP_HANDLER] = m_ignore,
96 .handlers[OPER_HANDLER] = m_ignore
97 };
98
99 static void
100 module_init(void)
101 {
102 mod_add_cmd(&svshost_msgtab);
103 }
104
105 static void
106 module_exit(void)
107 {
108 mod_del_cmd(&svshost_msgtab);
109 }
110
111 struct module module_entry =
112 {
113 .version = "$Revision: 7329 $",
114 .modinit = module_init,
115 .modexit = module_exit,
116 };

svnadmin@ircd-hybrid.org
ViewVC Help
Powered by ViewVC 1.1.28