| 1 |
/* |
| 2 |
* ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). |
| 3 |
* |
| 4 |
* Copyright (C) 2000 Kevin L. Mitchell <klmitch@mit.edu> |
| 5 |
* Copyright (C) 2013 by the Hybrid Development Team. |
| 6 |
* |
| 7 |
* This program is free software; you can redistribute it and/or modify |
| 8 |
* it under the terms of the GNU General Public License as published by |
| 9 |
* the Free Software Foundation; either version 2 of the License, or |
| 10 |
* (at your option) any later version. |
| 11 |
* |
| 12 |
* This program is distributed in the hope that it will be useful, |
| 13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 |
* GNU General Public License for more details. |
| 16 |
* |
| 17 |
* You should have received a copy of the GNU General Public License |
| 18 |
* along with this program; if not, write to the Free Software |
| 19 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
| 20 |
* USA |
| 21 |
*/ |
| 22 |
|
| 23 |
/*! \file motd.h |
| 24 |
* \brief Message-of-the-day manipulation implementation. |
| 25 |
* \version $Id$ |
| 26 |
*/ |
| 27 |
|
| 28 |
#ifndef INCLUDED_motd_h |
| 29 |
#define INCLUDED_motd_h |
| 30 |
struct Client; |
| 31 |
|
| 32 |
/** Type of MOTD. */ |
| 33 |
enum MotdType |
| 34 |
{ |
| 35 |
MOTD_UNIVERSAL, /**< MOTD for all users */ |
| 36 |
MOTD_HOSTMASK, /**< MOTD selected by hostmask */ |
| 37 |
MOTD_IPMASKV4, /**< MOTD selected by IP mask */ |
| 38 |
MOTD_IPMASKV6, /**< MOTD selected by IP mask */ |
| 39 |
MOTD_CLASS /**< MOTD selected by connection class */ |
| 40 |
}; |
| 41 |
|
| 42 |
/** Entry for a single Message Of The Day (MOTD). */ |
| 43 |
struct Motd |
| 44 |
{ |
| 45 |
dlink_node node; /**< Next MOTD in the linked list. */ |
| 46 |
enum MotdType type; /**< Type of MOTD. */ |
| 47 |
char *path; /**< Pathname of MOTD file. */ |
| 48 |
char *hostmask; /**< Hostmask if type==MOTD_HOSTMASK, |
| 49 |
class name if type==MOTD_CLASS, |
| 50 |
text IP mask if type==MOTD_IPMASK. */ |
| 51 |
struct irc_ssaddr address; /**< Address if type==MOTD_IPMASK. */ |
| 52 |
int addrbits; /**< Number of bits checked in Motd::address. */ |
| 53 |
unsigned int maxcount; /**< Number of lines for MOTD. */ |
| 54 |
struct MotdCache *cache; /**< MOTD cache entry. */ |
| 55 |
}; |
| 56 |
|
| 57 |
/** Length of one MOTD line(80 chars + '\\0'). */ |
| 58 |
#define MOTD_LINESIZE 81 |
| 59 |
/** Maximum number of lines for MOTD */ |
| 60 |
#define MOTD_MAXLINES 100 |
| 61 |
|
| 62 |
|
| 63 |
/** Cache entry for the contents of a MOTD file. */ |
| 64 |
struct MotdCache |
| 65 |
{ |
| 66 |
dlink_node node; /**< Next MotdCache in list. */ |
| 67 |
char *path; /**< Pathname of file. */ |
| 68 |
unsigned int ref; /**< Number of references to this entry. */ |
| 69 |
unsigned int maxcount; /**< Number of lines allocated for message. */ |
| 70 |
unsigned int count; /**< Actual number of lines used in message. */ |
| 71 |
struct tm modtime; /**< Last modification time from file. */ |
| 72 |
char motd[][MOTD_LINESIZE]; /**< Message body. */ |
| 73 |
}; |
| 74 |
|
| 75 |
/* motd_send sends a MOTD off to a user */ |
| 76 |
extern void motd_send(struct Client *); |
| 77 |
|
| 78 |
/* motd_signon sends a MOTD off to a newly-registered user */ |
| 79 |
extern void motd_signon(struct Client *); |
| 80 |
|
| 81 |
/* motd_recache causes all the MOTD caches to be cleared */ |
| 82 |
extern void motd_recache(void); |
| 83 |
|
| 84 |
/* motd_init initializes the MOTD routines, including reading the |
| 85 |
* ircd.motd and remote.motd files into cache |
| 86 |
*/ |
| 87 |
extern void motd_init(void); |
| 88 |
|
| 89 |
/* This routine adds a MOTD */ |
| 90 |
extern void motd_add(const char *, const char *); |
| 91 |
|
| 92 |
/* This routine clears the list of MOTDs */ |
| 93 |
extern void motd_clear(void); |
| 94 |
|
| 95 |
/* This is called to report T-lines */ |
| 96 |
extern void motd_report(struct Client *); |
| 97 |
extern void motd_memory_count(struct Client *); |
| 98 |
|
| 99 |
#endif |