Initial import
[ratbox-ambernet.git] / modules / core / m_error.c
blob65d998274da8dd6e9597e3cd8384feffa4d289d9
1 /*
2 * ircd-ratbox: A slightly useful ircd.
3 * m_error.c: Handles error messages from the other end.
5 * Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center
6 * Copyright (C) 1996-2002 Hybrid Development Team
7 * Copyright (C) 2002-2005 ircd-ratbox development team
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
22 * USA
24 * $Id: m_error.c 21510 2005-12-19 18:57:37Z leeh $
27 #include "stdinc.h"
28 #include "client.h"
29 #include "common.h" /* FALSE */
30 #include "ircd.h"
31 #include "numeric.h"
32 #include "send.h"
33 #include "msg.h"
34 #include "memory.h"
35 #include "modules.h"
36 #include "s_log.h"
37 #include "s_conf.h"
39 static int m_error(struct Client *, struct Client *, int, const char **);
40 static int ms_error(struct Client *, struct Client *, int, const char **);
42 struct Message error_msgtab = {
43 "ERROR", 0, 0, 0, MFLG_SLOW | MFLG_UNREG,
44 {{m_error, 0}, mg_ignore, mg_ignore, {ms_error, 0}, mg_ignore, mg_ignore}
47 mapi_clist_av1 error_clist[] = {
48 &error_msgtab, NULL
51 DECLARE_MODULE_AV1(error, NULL, NULL, error_clist, NULL, NULL, "$Revision: 21510 $");
55 * Note: At least at protocol level ERROR has only one parameter,
56 * although this is called internally from other functions
57 * --msa
59 * parv[0] = sender prefix
60 * parv[*] = parameters
62 int
63 m_error(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
65 const char *para;
67 para = (parc > 1 && *parv[1] != '\0') ? parv[1] : "<>";
69 ilog(L_SERVER, "Received ERROR message from %s: %s",
70 source_p->sockhost, para);
72 if(IsAnyServer(client_p) && ConfigFileEntry.hide_error_messages < 2)
74 sendto_realops_flags(UMODE_ALL, L_ADMIN,
75 "ERROR :from %s[@255.255.255.255] -- %s",
76 EmptyString(client_p->name) ? "" : client_p->name, para);
78 if(!ConfigFileEntry.hide_error_messages)
79 sendto_realops_flags(UMODE_ALL, L_OPER,
80 "ERROR :from %s[@255.255.255.255] -- %s",
81 EmptyString(client_p->name) ? "" : client_p->name, para);
84 exit_client(client_p, source_p, source_p, "ERROR");
86 return 0;
89 static int
90 ms_error(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
92 const char *para;
94 para = (parc > 1 && *parv[1] != '\0') ? parv[1] : "<>";
96 ilog(L_SERVER, "Received ERROR message from %s: %s",
97 log_client_name(source_p, SHOW_IP), para);
99 if(ConfigFileEntry.hide_error_messages == 2)
100 return 0;
102 if(client_p == source_p)
104 sendto_realops_flags(UMODE_ALL, L_ADMIN, "ERROR :from %s -- %s",
105 client_p->name, para);
107 if(!ConfigFileEntry.hide_error_messages)
108 sendto_realops_flags(UMODE_ALL, L_OPER,
109 "ERROR :from %s -- %s",
110 client_p->name, para);
112 else
114 sendto_realops_flags(UMODE_ALL, L_ADMIN, "ERROR :from %s via %s -- %s",
115 source_p->name, client_p->name, para);
117 if(!ConfigFileEntry.hide_error_messages)
118 sendto_realops_flags(UMODE_ALL, L_OPER,
119 "ERROR :from %s via %s -- %s",
120 source_p->name, client_p->name, para);
123 return 0;