diff options
Diffstat (limited to 'include/motd.h')
-rw-r--r-- | include/motd.h | 95 |
1 files changed, 64 insertions, 31 deletions
diff --git a/include/motd.h b/include/motd.h index 4490b17..e78b64a 100644 --- a/include/motd.h +++ b/include/motd.h @@ -1,8 +1,8 @@ /* * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). - * motd.h: A header for the MOTD functions. * - * Copyright (C) 2002 by the past and present ircd coders, and others. + * Copyright (C) 2000 Kevin L. Mitchell <klmitch@mit.edu> + * Copyright (C) 2013 by the Hybrid Development Team. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,48 +18,81 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * USA - * - * $Id$ + */ + +/*! \file motd.h + * \brief Message-of-the-day manipulation implementation. + * \version $Id$ */ #ifndef INCLUDED_motd_h #define INCLUDED_motd_h -#include "ircd_defs.h" - +struct Client; -#define MESSAGELINELEN 256 +/** Type of MOTD. */ +enum MotdType +{ + MOTD_UNIVERSAL, /**< MOTD for all users */ + MOTD_HOSTMASK, /**< MOTD selected by hostmask */ + MOTD_IPMASK, /**< MOTD selected by IP mask */ + MOTD_CLASS /**< MOTD selected by connection class */ +}; -struct MessageFileLine +/** Entry for a single Message Of The Day (MOTD). */ +struct Motd { - struct MessageFileLine *next; - char line[MESSAGELINELEN + 1]; + dlink_node node; /**< Next MOTD in the linked list. */ + enum MotdType type; /**< Type of MOTD. */ + char *hostmask; /**< Hostmask if type==MOTD_HOSTMASK, + class name if type==MOTD_CLASS, + text IP mask if type==MOTD_IPMASK. */ + struct irc_ssaddr address; /**< Address if type==MOTD_IPMASK. */ + int addrbits; /**< Number of bits checked in Motd::address. */ + char *path; /**< Pathname of MOTD file. */ + int maxcount; /**< Number of lines for MOTD. */ + struct MotdCache *cache; /**< MOTD cache entry. */ }; -typedef struct MessageFileLine MessageFileLine; +/** Length of one MOTD line(80 chars + '\\0'). */ +#define MOTD_LINESIZE 81 +/** Maximum number of lines for MOTD */ +#define MOTD_MAXLINES 100 -typedef enum { - USER_MOTD, - USER_LINKS, - ISSUPPORT -} MotdType; - -struct MessageFile + +/** Cache entry for the contents of a MOTD file. */ +struct MotdCache { - MessageFileLine *contentsOfFile; - MotdType motdType; - char fileName[HYB_PATH_MAX + 1]; - char lastChangedDate[MAX_DATE_STRING + 1]; + dlink_node node; /**< Next MotdCache in list. */ + int ref; /**< Number of references to this entry. */ + char *path; /**< Pathname of file. */ + int maxcount; /**< Number of lines allocated for message. */ + struct tm modtime; /**< Last modification time from file. */ + int count; /**< Actual number of lines used in message. */ + char motd[1][MOTD_LINESIZE]; /**< Message body. */ }; -typedef struct MessageFile MessageFile; +/* motd_send sends a MOTD off to a user */ +extern void motd_send(struct Client *); -struct Client; +/* motd_signon sends a MOTD off to a newly-registered user */ +extern void motd_signon(struct Client *); + +/* motd_recache causes all the MOTD caches to be cleared */ +extern void motd_recache(void); + +/* motd_init initializes the MOTD routines, including reading the + * ircd.motd and remote.motd files into cache + */ +extern void motd_init(void); + +/* This routine adds a MOTD */ +extern void motd_add(const char *, const char *); + +/* This routine clears the list of MOTDs */ +extern void motd_clear(void); -extern void init_message_file(MotdType, const char *, struct MessageFile *); -extern int send_message_file(struct Client *, struct MessageFile *); -extern int read_message_file(MessageFile *); -extern MessageFile *init_MessageLine(void); -extern void addto_MessageLine(MessageFile *, const char *); -extern void destroy_MessageLine(MessageFile *); +/* This is called to report T-lines */ +extern void motd_report(struct Client *); +extern void motd_memory_count(struct Client *); -#endif /* INCLUDED_motd_h */ +#endif |