X-Git-Url: http://git.pk910.de/?a=blobdiff_plain;f=ircd%2Fm_motd.c;h=f431df1e5a906a5a0f8db635c7df343ac7cab7d6;hb=refs%2Fheads%2Fupstream-ssl;hp=4a8354082f6fe55169dcf3d22a3c85d5b53ac094;hpb=8049d81b2a13d802a41016396781b02fad16f443;p=ircu2.10.12-pk.git diff --git a/ircd/m_motd.c b/ircd/m_motd.c index 4a83540..f431df1 100644 --- a/ircd/m_motd.c +++ b/ircd/m_motd.c @@ -79,27 +79,26 @@ * note: it is guaranteed that parv[0]..parv[parc-1] are all * non-NULL pointers. */ -#if 0 -/* - * No need to include handlers.h here the signatures must match - * and we don't need to force a rebuild of all the handlers everytime - * we add a new one to the list. --Bleep - */ -#include "handlers.h" -#endif /* 0 */ +#include "config.h" + #include "client.h" #include "ircd.h" +#include "ircd_features.h" +#include "ircd_log.h" #include "ircd_reply.h" #include "ircd_string.h" #include "match.h" +#include "motd.h" #include "msg.h" #include "numeric.h" #include "numnicks.h" #include "s_conf.h" +#include "class.h" #include "s_user.h" #include "send.h" -#include +#include +/* #include -- Now using assert in ircd_log.h */ /* * m_motd - generic message handler @@ -113,98 +112,15 @@ * stolen from comstud & Xorath. All motd files are read into * memory in read_motd() in s_conf.c * - * When NODEFAULTMOTD is defined, then it is possible that - * sptr == NULL, which means that this function is called from - * register_user. + * Now using the motd_* family of functions defined in motd.c */ int m_motd(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) { - struct tm *tm = &motd_tm; /* Default: Most general case */ - struct TRecord *ptr; - int count; - struct MotdItem *temp; - -#ifdef NODEFAULTMOTD - int no_motd; - - if (sptr) - { - no_motd = 0; -#endif - if (hunt_server_cmd(sptr, CMD_MODE, cptr, 0, "%C", 1, parc, parv) != - HUNTED_ISME) - return 0; -#ifdef NODEFAULTMOTD - } - else - { - sptr = cptr; - no_motd = 1; - } -#endif - - /* - * Find out if this is a remote query or if we have a T line for our hostname - */ - if (IsServer(cptr)) - { - tm = 0; /* Remote MOTD */ - temp = rmotd; - } - else - { - for (ptr = tdata; ptr; ptr = ptr->next) - { - if (!match(ptr->hostmask, cptr->sockhost)) - break; - } - if (ptr) - { - temp = ptr->tmotd; - tm = &ptr->tmotd_tm; - } - else - temp = motd; - } - if (temp == 0) - { - send_reply(sptr, ERR_NOMOTD); + if (hunt_server_cmd(sptr, CMD_MOTD, cptr, feature_int(FEAT_HIS_REMOTE), "%C", 1, + parc, parv) != HUNTED_ISME) return 0; - } -#ifdef NODEFAULTMOTD - if (!no_motd) - { -#endif - if (tm) /* Not remote? */ - { - send_reply(sptr, RPL_MOTDSTART, me.name); - send_reply(sptr, SND_EXPLICIT | RPL_MOTD, "- %d/%d/%d %d:%02d", - tm->tm_mday, tm->tm_mon + 1, 1900 + tm->tm_year, tm->tm_hour, - tm->tm_min); - count = 100; - } - else - count = 3; - for (; temp; temp = temp->next) - { - send_reply(sptr, RPL_MOTD, temp->line); - if (--count == 0) - break; - } -#ifdef NODEFAULTMOTD - } - else - { - send_reply(sptr, RPL_MOTDSTART, me.name); - send_reply(sptr, SND_EXPLICIT | RPL_MOTD, ":Type /MOTD to read the " - "AUP before continuing using this service."); - send_reply(sptr, SND_EXPLICIT | RPL_MOTD, ":The message of the day was " - "last changed: %d/%d/%d", tm->tm_mday, tm->tm_mon + 1, - 1900 + tm->tm_year); - } -#endif - send_reply(sptr, RPL_ENDOFMOTD); - return 0; + + return motd_send(sptr); } /* @@ -219,205 +135,13 @@ int m_motd(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) * stolen from comstud & Xorath. All motd files are read into * memory in read_motd() in s_conf.c * - * When NODEFAULTMOTD is defined, then it is possible that - * sptr == NULL, which means that this function is called from - * register_user. + * Now using the motd_* family of functions defined in motd.c */ int ms_motd(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) { - struct tm *tm = &motd_tm; /* Default: Most general case */ - struct TRecord *ptr; - int count; - struct MotdItem *temp; - -#ifdef NODEFAULTMOTD - int no_motd; - - if (sptr) - { - no_motd = 0; -#endif - if (hunt_server_cmd(sptr, CMD_MOTD, cptr, 0, "%C", 1, parc, parv) != - HUNTED_ISME) - return 0; -#ifdef NODEFAULTMOTD - } - else - { - sptr = cptr; - no_motd = 1; - } -#endif - - /* - * Find out if this is a remote query or if we have a T line for our hostname - */ - if (IsServer(cptr)) - { - tm = 0; /* Remote MOTD */ - temp = rmotd; - } - else - { - for (ptr = tdata; ptr; ptr = ptr->next) - { - if (!match(ptr->hostmask, cptr->sockhost)) - break; - } - if (ptr) - { - temp = ptr->tmotd; - tm = &ptr->tmotd_tm; - } - else - temp = motd; - } - if (temp == 0) - { - send_reply(sptr, ERR_NOMOTD); + if (hunt_server_cmd(sptr, CMD_MOTD, cptr, 0, "%C", 1, parc, parv) != + HUNTED_ISME) return 0; - } -#ifdef NODEFAULTMOTD - if (!no_motd) - { -#endif - if (tm) /* Not remote? */ - { - send_reply(sptr, RPL_MOTDSTART, me.name); - send_reply(sptr, SND_EXPLICIT | RPL_MOTD, ":- %d/%d/%d %d:%02d", - tm->tm_mday, tm->tm_mon + 1, 1900 + tm->tm_year, tm->tm_hour, - tm->tm_min); - count = 100; - } - else - count = 3; - for (; temp; temp = temp->next) - { - send_reply(sptr, RPL_MOTD, temp->line); - if (--count == 0) - break; - } -#ifdef NODEFAULTMOTD - } - else - { - send_reply(sptr, RPL_MOTDSTART, me.name); - send_reply(sptr, SND_EXPLICIT | RPL_MOTD, ":Type /MOTD to read the " - "AUP before continuing using this service."); - send_reply(sptr, SND_EXPLICIT | RPL_MOTD, ":The message of the day was " - "last changed: %d/%d/%d", tm->tm_mday, tm->tm_mon + 1, - 1900 + tm->tm_year); - } -#endif - send_reply(sptr, RPL_ENDOFMOTD); - return 0; -} -#if 0 -/* - * m_motd - * - * parv[0] - sender prefix - * parv[1] - servername - * - * modified 30 mar 1995 by flux (cmlambertus@ucdavis.edu) - * T line patch - display motd based on hostmask - * modified again 7 sep 97 by Ghostwolf with code and ideas - * stolen from comstud & Xorath. All motd files are read into - * memory in read_motd() in s_conf.c - * - * When NODEFAULTMOTD is defined, then it is possible that - * sptr == NULL, which means that this function is called from - * register_user. - */ -int m_motd(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) -{ - struct tm *tm = &motd_tm; /* Default: Most general case */ - struct TRecord *ptr; - int count; - struct MotdItem *temp; - -#ifdef NODEFAULTMOTD - int no_motd; - - if (sptr) - { - no_motd = 0; -#endif - if (hunt_server(0, cptr, sptr, "%s%s " TOK_MOTD " %s", 1, parc, /* XXX DEAD */ - parv) != HUNTED_ISME) - return 0; -#ifdef NODEFAULTMOTD - } - else - { - sptr = cptr; - no_motd = 1; - } -#endif - - /* - * Find out if this is a remote query or if we have a T line for our hostname - */ - if (IsServer(cptr)) - { - tm = 0; /* Remote MOTD */ - temp = rmotd; - } - else - { - for (ptr = tdata; ptr; ptr = ptr->next) - { - if (!match(ptr->hostmask, cptr->sockhost)) - break; - } - if (ptr) - { - temp = ptr->tmotd; - tm = &ptr->tmotd_tm; - } - else - temp = motd; - } - if (temp == 0) - { - sendto_one(sptr, err_str(ERR_NOMOTD), me.name, parv[0]); /* XXX DEAD */ - return 0; - } -#ifdef NODEFAULTMOTD - if (!no_motd) - { -#endif - if (tm) /* Not remote? */ - { - sendto_one(sptr, rpl_str(RPL_MOTDSTART), me.name, parv[0], me.name); /* XXX DEAD */ - sendto_one(sptr, ":%s %d %s :- %d/%d/%d %d:%02d", me.name, RPL_MOTD, /* XXX DEAD */ - parv[0], tm->tm_mday, tm->tm_mon + 1, 1900 + tm->tm_year, - tm->tm_hour, tm->tm_min); - count = 100; - } - else - count = 3; - for (; temp; temp = temp->next) - { - sendto_one(sptr, rpl_str(RPL_MOTD), me.name, parv[0], temp->line); /* XXX DEAD */ - if (--count == 0) - break; - } -#ifdef NODEFAULTMOTD - } - else - { - sendto_one(sptr, rpl_str(RPL_MOTDSTART), me.name, parv[0], me.name); /* XXX DEAD */ - sendto_one(sptr, ":%s %d %s :%s", me.name, RPL_MOTD, parv[0], /* XXX DEAD */ - "Type /MOTD to read the AUP before continuing using this service."); - sendto_one(sptr, /* XXX DEAD */ - ":%s %d %s :The message of the day was last changed: %d/%d/%d", me.name, - RPL_MOTD, parv[0], tm->tm_mday, tm->tm_mon + 1, 1900 + tm->tm_year); - } -#endif - sendto_one(sptr, rpl_str(RPL_ENDOFMOTD), me.name, parv[0]); /* XXX DEAD */ - return 0; + return motd_send(sptr); } -#endif /* 0 */ -