/[svn]/ircd-hybrid/branches/8.2.x/modules/core/m_error.c
ViewVC logotype

Contents of /ircd-hybrid/branches/8.2.x/modules/core/m_error.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 8280 - (show annotations)
Tue Feb 20 19:30:33 2018 UTC (4 years, 9 months ago) by michael
File MIME type: text/x-chdr
File size: 4115 byte(s)
- Update copyright years

1 /*
2 * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3 *
4 * Copyright (c) 1997-2018 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_error.c
23 * \brief Includes required functions for processing the ERROR command.
24 * \version $Id$
25 */
26
27 #include "stdinc.h"
28 #include "client.h"
29 #include "ircd.h"
30 #include "send.h"
31 #include "modules.h"
32 #include "log.h"
33 #include "parse.h"
34 #include "irc_string.h"
35
36
37 /*! \brief ERROR 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] = error message
47 */
48 static int
49 mr_error(struct Client *source_p, int parc, char *parv[])
50 {
51 const char *message = (parc > 1 && !EmptyString(parv[1])) ? parv[1] : "<>";
52
53 assert(MyConnect(source_p));
54
55 if (!IsHandshake(source_p) && !IsConnecting(source_p))
56 return 0;
57
58 ilog(LOG_TYPE_IRCD, "Received ERROR message from %s: %s",
59 source_p->name, message);
60
61 sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE,
62 "ERROR :from %s -- %s",
63 client_get_name(source_p, HIDE_IP), message);
64 sendto_realops_flags(UMODE_SERVNOTICE, L_OPER, SEND_NOTICE,
65 "ERROR :from %s -- %s",
66 client_get_name(source_p, MASK_IP), message);
67 return 0;
68 }
69
70 /*! \brief ERROR command handler
71 *
72 * \param source_p Pointer to allocated Client struct from which the message
73 * originally comes from. This can be a local or remote client.
74 * \param parc Integer holding the number of supplied arguments.
75 * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
76 * pointers.
77 * \note Valid arguments for this command are:
78 * - parv[0] = command
79 * - parv[1] = error message
80 */
81 static int
82 ms_error(struct Client *source_p, int parc, char *parv[])
83 {
84 const char *message = (parc > 1 && !EmptyString(parv[1])) ? parv[1] : "<>";
85
86 ilog(LOG_TYPE_IRCD, "Received ERROR message from %s: %s",
87 source_p->name, message);
88
89 if (MyConnect(source_p))
90 sendto_realops_flags(UMODE_SERVNOTICE, L_ALL, SEND_NOTICE,
91 "ERROR :from %s -- %s",
92 client_get_name(source_p->from, MASK_IP), message);
93 else
94 sendto_realops_flags(UMODE_SERVNOTICE, L_ALL, SEND_NOTICE,
95 "ERROR :from %s via %s -- %s",
96 source_p->name,
97 client_get_name(source_p->from, MASK_IP), message);
98 return 0;
99 }
100
101 static struct Message error_msgtab =
102 {
103 .cmd = "ERROR",
104 .args_max = MAXPARA,
105 .handlers[UNREGISTERED_HANDLER] = mr_error,
106 .handlers[CLIENT_HANDLER] = m_ignore,
107 .handlers[SERVER_HANDLER] = ms_error,
108 .handlers[ENCAP_HANDLER] = m_ignore,
109 .handlers[OPER_HANDLER] = m_ignore
110 };
111
112 static void
113 module_init(void)
114 {
115 mod_add_cmd(&error_msgtab);
116 }
117
118 static void
119 module_exit(void)
120 {
121 mod_del_cmd(&error_msgtab);
122 }
123
124 struct module module_entry =
125 {
126 .version = "$Revision$",
127 .modinit = module_init,
128 .modexit = module_exit,
129 .flags = MODULE_FLAG_CORE
130 };

Properties

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

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