2 * IRC - Internet Relay Chat, ircd/m_tmpl.c
3 * Copyright (C) 1990 Jarkko Oikarinen and
4 * University of Oulu, Computing Center
5 * Copyright (C) 2000 Kevin L. Mitchell <klmitch@mit.edu>
7 * See file AUTHORS in IRC package for additional names of
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 1, or (at your option)
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 * m_functions execute protocol messages on this server:
30 * cptr is always NON-NULL, pointing to a *LOCAL* client
31 * structure (with an open socket connected!). This
32 * identifies the physical socket where the message
33 * originated (or which caused the m_function to be
34 * executed--some m_functions may call others...).
36 * sptr is the source of the message, defined by the
37 * prefix part of the message if present. If not
38 * or prefix not found, then sptr==cptr.
40 * (!IsServer(cptr)) => (cptr == sptr), because
41 * prefixes are taken *only* from servers...
44 * (sptr == cptr) => the message didn't
47 * (sptr != cptr && IsServer(sptr) means
48 * the prefix specified servername. (?)
50 * (sptr != cptr && !IsServer(sptr) means
51 * that message originated from a remote
56 * (!IsServer(sptr)) means that, sptr can safely
57 * taken as defining the target structure of the
58 * message in this server.
60 * *Always* true (if 'parse' and others are working correct):
62 * 1) sptr->from == cptr (note: cptr->from == cptr)
64 * 2) MyConnect(sptr) <=> sptr == cptr (e.g. sptr
65 * *cannot* be a local connection, unless it's
66 * actually cptr!). [MyConnect(x) should probably
67 * be defined as (x == x->from) --msa ]
69 * parc number of variable parameter strings (if zero,
70 * parv is allowed to be NULL)
72 * parv a NULL terminated list of parameter pointers,
74 * parv[0], sender (prefix string), if not present
75 * this points to an empty string.
76 * parv[1]...parv[parc-1]
77 * pointers to additional parameters
78 * parv[parc] == NULL, *always*
80 * note: it is guaranteed that parv[0]..parv[parc-1] are all
89 #include "ircd_features.h"
90 #include "ircd_reply.h"
91 #include "ircd_string.h"
100 * ms_opmode - server message handler
102 int ms_opmode(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
104 struct Channel *chptr = 0;
108 return need_more_params(sptr, "OPMODE");
110 if (IsLocalChannel(parv[1]))
113 if ('#' != *parv[1] || !(chptr = FindChannel(parv[1])))
114 return send_reply(sptr, ERR_NOSUCHCHANNEL, parv[1]);
116 modebuf_init(&mbuf, sptr, cptr, chptr,
117 (MODEBUF_DEST_CHANNEL | /* Send MODE to channel */
118 MODEBUF_DEST_SERVER | /* And to server */
119 MODEBUF_DEST_OPMODE | /* Use OPMODE */
120 MODEBUF_DEST_HACK4 | /* Generate a HACK(4) notice */
121 MODEBUF_DEST_LOG)); /* Log the mode changes to OPATH */
123 mode_parse(&mbuf, cptr, sptr, chptr, parc - 2, parv + 2,
124 (MODE_PARSE_SET | /* Set the modes on the channel */
125 MODE_PARSE_STRICT | /* Be strict about it */
126 MODE_PARSE_FORCE)); /* And force them to be accepted */
128 modebuf_flush(&mbuf); /* flush the modes */
134 * mo_opmode - oper message handler
136 int mo_opmode(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
138 struct Channel *chptr = 0;
140 struct Membership *member;
142 if (!feature_bool(FEAT_CONFIG_OPERCMDS))
143 return send_reply(sptr, ERR_DISABLED, "OPMODE");
146 return need_more_params(sptr, "OPMODE");
148 clean_channelname(parv[1]);
151 IsLocalChannel(parv[1]) ? PRIV_LOCAL_OPMODE : PRIV_OPMODE))
152 return send_reply(sptr, ERR_NOPRIVILEGES);
154 if (('#' != *parv[1] && '&' != *parv[1]) || !(chptr = FindChannel(parv[1])))
155 return send_reply(sptr, ERR_NOSUCHCHANNEL, parv[1]);
157 if (!(member = find_member_link(chptr, sptr)))
158 return send_reply(sptr, ERR_NOTONCHANNEL, chptr->chname);
160 modebuf_init(&mbuf, sptr, cptr, chptr,
161 (MODEBUF_DEST_CHANNEL | /* Send MODE to channel */
162 MODEBUF_DEST_SERVER | /* And to server */
163 MODEBUF_DEST_OPMODE | /* Use OPMODE */
164 MODEBUF_DEST_HACK4 | /* Generate a HACK(4) notice */
165 MODEBUF_DEST_LOG)); /* Log the mode changes to OPATH */
167 mode_parse(&mbuf, cptr, sptr, chptr, parc - 2, parv + 2,
168 (MODE_PARSE_SET | /* set the modes on the channel */
169 MODE_PARSE_FORCE)); /* And force them to be accepted */
171 modebuf_flush(&mbuf); /* flush the modes */