2 * IRC - Internet Relay Chat, ircd/m_motd.c
3 * Copyright (C) 1990 Jarkko Oikarinen and
4 * University of Oulu, Computing Center
6 * See file AUTHORS in IRC package for additional names of
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 1, or (at your option)
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., 675 Mass Ave, Cambridge, MA 02139, USA.
27 * m_functions execute protocol messages on this server:
29 * cptr is always NON-NULL, pointing to a *LOCAL* client
30 * structure (with an open socket connected!). This
31 * identifies the physical socket where the message
32 * originated (or which caused the m_function to be
33 * executed--some m_functions may call others...).
35 * sptr is the source of the message, defined by the
36 * prefix part of the message if present. If not
37 * or prefix not found, then sptr==cptr.
39 * (!IsServer(cptr)) => (cptr == sptr), because
40 * prefixes are taken *only* from servers...
43 * (sptr == cptr) => the message didn't
46 * (sptr != cptr && IsServer(sptr) means
47 * the prefix specified servername. (?)
49 * (sptr != cptr && !IsServer(sptr) means
50 * that message originated from a remote
55 * (!IsServer(sptr)) means that, sptr can safely
56 * taken as defining the target structure of the
57 * message in this server.
59 * *Always* true (if 'parse' and others are working correct):
61 * 1) sptr->from == cptr (note: cptr->from == cptr)
63 * 2) MyConnect(sptr) <=> sptr == cptr (e.g. sptr
64 * *cannot* be a local connection, unless it's
65 * actually cptr!). [MyConnect(x) should probably
66 * be defined as (x == x->from) --msa ]
68 * parc number of variable parameter strings (if zero,
69 * parv is allowed to be NULL)
71 * parv a NULL terminated list of parameter pointers,
73 * parv[0], sender (prefix string), if not present
74 * this points to an empty string.
75 * parv[1]...parv[parc-1]
76 * pointers to additional parameters
77 * parv[parc] == NULL, *always*
79 * note: it is guaranteed that parv[0]..parv[parc-1] are all
84 * No need to include handlers.h here the signatures must match
85 * and we don't need to force a rebuild of all the handlers everytime
86 * we add a new one to the list. --Bleep
92 #include "ircd_reply.h"
93 #include "ircd_string.h"
105 * m_motd - generic message handler
107 * parv[0] - sender prefix
108 * parv[1] - servername
110 * modified 30 mar 1995 by flux (cmlambertus@ucdavis.edu)
111 * T line patch - display motd based on hostmask
112 * modified again 7 sep 97 by Ghostwolf with code and ideas
113 * stolen from comstud & Xorath. All motd files are read into
114 * memory in read_motd() in s_conf.c
116 * When NODEFAULTMOTD is defined, then it is possible that
117 * sptr == NULL, which means that this function is called from
120 int m_motd(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
122 struct tm *tm = &motd_tm; /* Default: Most general case */
125 struct MotdItem *temp;
134 if (hunt_server_cmd(sptr, CMD_MODE, cptr, 0, "%C", 1, parc, parv) !=
147 * Find out if this is a remote query or if we have a T line for our hostname
151 tm = 0; /* Remote MOTD */
156 for (ptr = tdata; ptr; ptr = ptr->next)
158 if (!match(ptr->hostmask, cptr->sockhost))
171 send_reply(sptr, ERR_NOMOTD);
178 if (tm) /* Not remote? */
180 send_reply(sptr, RPL_MOTDSTART, me.name);
181 send_reply(sptr, SND_EXPLICIT | RPL_MOTD, "- %d/%d/%d %d:%02d",
182 tm->tm_mday, tm->tm_mon + 1, 1900 + tm->tm_year, tm->tm_hour,
188 for (; temp; temp = temp->next)
190 send_reply(sptr, RPL_MOTD, temp->line);
198 send_reply(sptr, RPL_MOTDSTART, me.name);
199 send_reply(sptr, SND_EXPLICIT | RPL_MOTD, ":
\ 2Type /MOTD to read the "
200 "AUP before continuing using this service.
\ 2");
201 send_reply(sptr, SND_EXPLICIT | RPL_MOTD, ":The message of the day was "
202 "last changed: %d/%d/%d", tm->tm_mday, tm->tm_mon + 1,
206 send_reply(sptr, RPL_ENDOFMOTD);
211 * ms_motd - server message handler
213 * parv[0] - sender prefix
214 * parv[1] - servername
216 * modified 30 mar 1995 by flux (cmlambertus@ucdavis.edu)
217 * T line patch - display motd based on hostmask
218 * modified again 7 sep 97 by Ghostwolf with code and ideas
219 * stolen from comstud & Xorath. All motd files are read into
220 * memory in read_motd() in s_conf.c
222 * When NODEFAULTMOTD is defined, then it is possible that
223 * sptr == NULL, which means that this function is called from
226 int ms_motd(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
228 struct tm *tm = &motd_tm; /* Default: Most general case */
231 struct MotdItem *temp;
240 if (hunt_server_cmd(sptr, CMD_MOTD, cptr, 0, "%C", 1, parc, parv) !=
253 * Find out if this is a remote query or if we have a T line for our hostname
257 tm = 0; /* Remote MOTD */
262 for (ptr = tdata; ptr; ptr = ptr->next)
264 if (!match(ptr->hostmask, cptr->sockhost))
277 send_reply(sptr, ERR_NOMOTD);
284 if (tm) /* Not remote? */
286 send_reply(sptr, RPL_MOTDSTART, me.name);
287 send_reply(sptr, SND_EXPLICIT | RPL_MOTD, ":- %d/%d/%d %d:%02d",
288 tm->tm_mday, tm->tm_mon + 1, 1900 + tm->tm_year, tm->tm_hour,
294 for (; temp; temp = temp->next)
296 send_reply(sptr, RPL_MOTD, temp->line);
304 send_reply(sptr, RPL_MOTDSTART, me.name);
305 send_reply(sptr, SND_EXPLICIT | RPL_MOTD, ":
\ 2Type /MOTD to read the "
306 "AUP before continuing using this service.
\ 2");
307 send_reply(sptr, SND_EXPLICIT | RPL_MOTD, ":The message of the day was "
308 "last changed: %d/%d/%d", tm->tm_mday, tm->tm_mon + 1,
312 send_reply(sptr, RPL_ENDOFMOTD);
320 * parv[0] - sender prefix
321 * parv[1] - servername
323 * modified 30 mar 1995 by flux (cmlambertus@ucdavis.edu)
324 * T line patch - display motd based on hostmask
325 * modified again 7 sep 97 by Ghostwolf with code and ideas
326 * stolen from comstud & Xorath. All motd files are read into
327 * memory in read_motd() in s_conf.c
329 * When NODEFAULTMOTD is defined, then it is possible that
330 * sptr == NULL, which means that this function is called from
333 int m_motd(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
335 struct tm *tm = &motd_tm; /* Default: Most general case */
338 struct MotdItem *temp;
347 if (hunt_server(0, cptr, sptr, "%s%s " TOK_MOTD " %s", 1, parc, /* XXX DEAD */
348 parv) != HUNTED_ISME)
360 * Find out if this is a remote query or if we have a T line for our hostname
364 tm = 0; /* Remote MOTD */
369 for (ptr = tdata; ptr; ptr = ptr->next)
371 if (!match(ptr->hostmask, cptr->sockhost))
384 sendto_one(sptr, err_str(ERR_NOMOTD), me.name, parv[0]); /* XXX DEAD */
391 if (tm) /* Not remote? */
393 sendto_one(sptr, rpl_str(RPL_MOTDSTART), me.name, parv[0], me.name); /* XXX DEAD */
394 sendto_one(sptr, ":%s %d %s :- %d/%d/%d %d:%02d", me.name, RPL_MOTD, /* XXX DEAD */
395 parv[0], tm->tm_mday, tm->tm_mon + 1, 1900 + tm->tm_year,
396 tm->tm_hour, tm->tm_min);
401 for (; temp; temp = temp->next)
403 sendto_one(sptr, rpl_str(RPL_MOTD), me.name, parv[0], temp->line); /* XXX DEAD */
411 sendto_one(sptr, rpl_str(RPL_MOTDSTART), me.name, parv[0], me.name); /* XXX DEAD */
412 sendto_one(sptr, ":%s %d %s :%s", me.name, RPL_MOTD, parv[0], /* XXX DEAD */
413 "
\ 2Type /MOTD to read the AUP before continuing using this service.
\ 2");
414 sendto_one(sptr, /* XXX DEAD */
415 ":%s %d %s :The message of the day was last changed: %d/%d/%d", me.name,
416 RPL_MOTD, parv[0], tm->tm_mday, tm->tm_mon + 1, 1900 + tm->tm_year);
419 sendto_one(sptr, rpl_str(RPL_ENDOFMOTD), me.name, parv[0]); /* XXX DEAD */