1 |
/* |
2 |
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) |
3 |
* |
4 |
* Copyright (c) 1997-2019 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_locops.c |
23 |
* \brief Includes required functions for processing the LOCOPS command. |
24 |
* \version $Id$ |
25 |
*/ |
26 |
|
27 |
#include "stdinc.h" |
28 |
#include "client.h" |
29 |
#include "ircd.h" |
30 |
#include "irc_string.h" |
31 |
#include "numeric.h" |
32 |
#include "send.h" |
33 |
#include "conf.h" |
34 |
#include "conf_cluster.h" |
35 |
#include "conf_shared.h" |
36 |
#include "server_capab.h" |
37 |
#include "parse.h" |
38 |
#include "modules.h" |
39 |
|
40 |
|
41 |
/*! \brief LOCOPS command handler |
42 |
* |
43 |
* \param source_p Pointer to allocated Client struct from which the message |
44 |
* originally comes from. This can be a local or remote client. |
45 |
* \param parc Integer holding the number of supplied arguments. |
46 |
* \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL |
47 |
* pointers. |
48 |
* \note Valid arguments for this command are: |
49 |
* - parv[0] = command |
50 |
* - parv[1] = message text |
51 |
*/ |
52 |
static int |
53 |
mo_locops(struct Client *source_p, int parc, char *parv[]) |
54 |
{ |
55 |
const char *const message = parv[1]; |
56 |
|
57 |
if (!HasOFlag(source_p, OPER_FLAG_LOCOPS)) |
58 |
{ |
59 |
sendto_one_numeric(source_p, &me, ERR_NOPRIVS, "locops"); |
60 |
return 0; |
61 |
} |
62 |
|
63 |
if (EmptyString(message)) |
64 |
{ |
65 |
sendto_one_numeric(source_p, &me, ERR_NEEDMOREPARAMS, "LOCOPS"); |
66 |
return 0; |
67 |
} |
68 |
|
69 |
sendto_realops_flags(UMODE_LOCOPS, L_ALL, SEND_LOCOPS, "from %s: %s", |
70 |
source_p->name, message); |
71 |
cluster_distribute(source_p, "LOCOPS", 0, CLUSTER_LOCOPS, message); |
72 |
return 0; |
73 |
} |
74 |
|
75 |
/*! \brief LOCOPS command handler |
76 |
* |
77 |
* \param source_p Pointer to allocated Client struct from which the message |
78 |
* originally comes from. This can be a local or remote client. |
79 |
* \param parc Integer holding the number of supplied arguments. |
80 |
* \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL |
81 |
* pointers. |
82 |
* \note Valid arguments for this command are: |
83 |
* - parv[0] = command |
84 |
* - parv[1] = target server |
85 |
* - parv[2] = message text |
86 |
*/ |
87 |
static int |
88 |
ms_locops(struct Client *source_p, int parc, char *parv[]) |
89 |
{ |
90 |
const char *const targets = parv[1]; |
91 |
const char *const message = parv[2]; |
92 |
|
93 |
if (parc != 3 || EmptyString(message)) |
94 |
return 0; |
95 |
|
96 |
sendto_match_servs(source_p, targets, CAPAB_CLUSTER, "LOCOPS %s :%s", |
97 |
targets, message); |
98 |
|
99 |
if (match(targets, me.name)) |
100 |
return 0; |
101 |
|
102 |
if (shared_find(SHARED_LOCOPS, source_p->servptr->name, "*", "*")) |
103 |
sendto_realops_flags(UMODE_LOCOPS, L_ALL, SEND_LOCOPS, "from %s: %s", |
104 |
source_p->name, message); |
105 |
return 0; |
106 |
} |
107 |
|
108 |
static struct Message locops_msgtab = |
109 |
{ |
110 |
.cmd = "LOCOPS", |
111 |
.args_min = 2, |
112 |
.args_max = MAXPARA, |
113 |
.handlers[UNREGISTERED_HANDLER] = m_unregistered, |
114 |
.handlers[CLIENT_HANDLER] = m_not_oper, |
115 |
.handlers[SERVER_HANDLER] = ms_locops, |
116 |
.handlers[ENCAP_HANDLER] = m_ignore, |
117 |
.handlers[OPER_HANDLER] = mo_locops |
118 |
}; |
119 |
|
120 |
static void |
121 |
module_init(void) |
122 |
{ |
123 |
mod_add_cmd(&locops_msgtab); |
124 |
} |
125 |
|
126 |
static void |
127 |
module_exit(void) |
128 |
{ |
129 |
mod_del_cmd(&locops_msgtab); |
130 |
} |
131 |
|
132 |
struct module module_entry = |
133 |
{ |
134 |
.version = "$Revision$", |
135 |
.modinit = module_init, |
136 |
.modexit = module_exit, |
137 |
}; |