ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/branches/8.1.x/modules/core/m_error.c
Revision: 1230
Committed: Thu Sep 22 19:41:19 2011 UTC (15 years ago) by michael
Content type: text/x-csrc
Original Path: ircd-hybrid-8/modules/core/m_error.c
File size: 3377 byte(s)
Log Message:
- cleanup module loader. Make module api more flexible

File Contents

# User Rev Content
1 michael 947 /*
2     * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3     * m_error.c: Handles error messages from the other end.
4     *
5     * Copyright (C) 2002 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 michael 953 * $Id$
23 michael 947 */
24    
25     #include "stdinc.h"
26 michael 1011 #include "list.h"
27 michael 947 #include "handlers.h"
28     #include "client.h"
29     #include "ircd.h"
30     #include "send.h"
31     #include "msg.h"
32     #include "modules.h"
33     #include "s_log.h"
34    
35    
36     /*
37     * Note: At least at protocol level ERROR has only one parameter.
38     * --msa
39     *
40     * parv[0] = sender prefix
41     * parv[*] = parameters
42     */
43     void
44     m_error(struct Client *client_p, struct Client *source_p,
45     int parc, char *parv[])
46     {
47     const char *para;
48    
49     para = (parc > 1 && *parv[1] != '\0') ? parv[1] : "<>";
50    
51     ilog(L_ERROR, "Received ERROR message from %s: %s",
52     source_p->name, para);
53    
54     if (client_p == source_p)
55     {
56     sendto_realops_flags(UMODE_ALL, L_ADMIN, "ERROR :from %s -- %s",
57     get_client_name(client_p, HIDE_IP), para);
58     sendto_realops_flags(UMODE_ALL, L_OPER, "ERROR :from %s -- %s",
59     get_client_name(client_p, MASK_IP), para);
60     }
61     else
62     {
63     sendto_realops_flags(UMODE_ALL, L_OPER, "ERROR :from %s via %s -- %s",
64     source_p->name, get_client_name(client_p, MASK_IP), para);
65     sendto_realops_flags(UMODE_ALL, L_ADMIN, "ERROR :from %s via %s -- %s",
66     source_p->name, get_client_name(client_p, HIDE_IP), para);
67     }
68    
69     if (MyClient(source_p))
70     exit_client(source_p, source_p, "ERROR");
71     }
72    
73     void
74     ms_error(struct Client *client_p, struct Client *source_p,
75     int parc, char *parv[])
76     {
77     const char *para;
78    
79     para = (parc > 1 && *parv[1] != '\0') ? parv[1] : "<>";
80    
81     ilog(L_ERROR, "Received ERROR message from %s: %s",
82     source_p->name, para);
83    
84     if (client_p == source_p)
85     sendto_realops_flags(UMODE_ALL, L_ALL, "ERROR :from %s -- %s",
86     get_client_name(client_p, MASK_IP), para);
87     else
88     sendto_realops_flags(UMODE_ALL, L_ALL, "ERROR :from %s via %s -- %s",
89     source_p->name,
90     get_client_name(client_p, MASK_IP), para);
91     }
92 michael 1230
93     static struct Message error_msgtab = {
94     "ERROR", 0, 0, 1, MAXPARA, MFLG_SLOW | MFLG_UNREG, 0,
95     { m_error, m_ignore, ms_error, m_ignore, m_ignore, m_ignore }
96     };
97    
98     static void
99     module_init(void)
100     {
101     mod_add_cmd(&error_msgtab);
102     }
103    
104     static void
105     module_exit(void)
106     {
107     mod_del_cmd(&error_msgtab);
108     }
109    
110     struct module module_entry = {
111     .node = { NULL, NULL, NULL },
112     .name = NULL,
113     .version = "$Revision$",
114     .handle = NULL,
115     .modinit = module_init,
116     .modexit = module_exit,
117     .flags = MODULE_FLAG_CORE
118     };

Properties

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