2 * IRC - Internet Relay Chat, ircd/m_jupe.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
85 * No need to include handlers.h here the signatures must match
86 * and we don't need to force a rebuild of all the handlers everytime
87 * we add a new one to the list. --Bleep
95 #include "ircd_reply.h"
96 #include "ircd_string.h"
100 #include "numnicks.h"
111 * ms_jupe - server message handler
113 * parv[0] = Send prefix
117 * parv[1] = Target: server numeric or *
118 * parv[2] = (+|-)<server name>
119 * parv[3] = Expiration offset
120 * parv[4] = Last modification time
124 int ms_jupe(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
126 struct Client *acptr = 0;
128 int local = 0, active = 1;
129 time_t expire_off, lastmod;
130 char *server = parv[2], *target = parv[1], *reason = parv[5];
133 return need_more_params(sptr, "JUPE");
135 if (!(target[0] == '*' && target[1] == '\0')) {
136 if (!(acptr = FindNServer(target)))
137 return 0; /* no such server */
139 if (!IsMe(acptr)) { /* manually propagate, since we don't set it */
140 sendcmdto_one(acptr, CMD_JUPE, sptr, "%s %s %s %s :%s", target, server,
141 parv[3], parv[4], reason);
148 if (*server == '-') {
151 } else if (*server == '+') {
156 expire_off = atoi(parv[3]);
157 lastmod = atoi(parv[4]);
159 ajupe = jupe_find(server);
162 if (JupeIsLocal(ajupe) && !local) /* global jupes override local ones */
164 else if (JupeLastMod(ajupe) < lastmod) { /* new modification */
166 return jupe_activate(cptr, sptr, ajupe, lastmod);
168 return jupe_deactivate(cptr, sptr, ajupe, lastmod);
169 } else if (JupeLastMod(ajupe) == lastmod) /* no changes */
172 return jupe_resend(cptr, ajupe); /* other server desynched WRT jupes */
175 return jupe_add(cptr, sptr, server, reason, expire_off, lastmod, local,
180 * mo_jupe - oper message handler
182 * parv[0] = Send prefix
186 * parv[1] = [[+|-]<server name>]
188 * parv[3] = [Expiration offset]
189 * parv[4] = [Comment]
192 #ifdef CONFIG_OPERCMDS
193 int mo_jupe(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
195 struct Client *acptr = 0;
197 int local = 0, active = 1;
199 char *server = parv[1], *target = parv[2], *reason = parv[4];
202 return jupe_list(sptr, 0);
204 if (*server == '+') {
207 } else if (*server == '-') {
211 return jupe_list(sptr, server);
214 return need_more_params(sptr, "JUPE");
216 if (!(target[0] == '*' && target[1] == '\0')) {
217 if (!(acptr = find_match_server(target)))
218 return send_error_to_client(sptr, ERR_NOSUCHSERVER, target);
220 if (!IsMe(acptr)) { /* manually propagate, since we don't set it */
222 return send_error_to_client(sptr, ERR_NOPRIVILEGES);
224 sendcmdto_one(acptr, CMD_JUPE, sptr, "%C %c%s %s %Tu :%s", acptr,
225 active ? '+' : '-', server, parv[3], TStime(), reason);
230 } else if (!IsOper(sptr))
231 return send_error_to_client(sptr, ERR_NOPRIVILEGES);
233 expire_off = atoi(parv[3]);
235 ajupe = jupe_find(server);
238 if (JupeIsLocal(ajupe) && !local) /* global jupes override local ones */
242 return jupe_activate(cptr, sptr, ajupe, TStime());
244 return jupe_deactivate(cptr, sptr, ajupe, TStime());
248 return jupe_add(cptr, sptr, server, reason, expire_off, TStime(), local,
251 #endif /* CONFIG_OPERCMDS */
254 * m_jupe - user message handler
256 * parv[0] = Send prefix
260 * parv[1] = [<server name>]
263 int m_jupe(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
266 return jupe_list(sptr, 0);
268 return jupe_list(sptr, parv[1]);