1 |
/* |
2 |
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) |
3 |
* |
4 |
* Copyright (c) 2000 Kevin L. Mitchell <klmitch@mit.edu> |
5 |
* Copyright (c) 2013-2015 ircd-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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 |
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 |
|
31 |
/** Type of MOTD. */ |
32 |
enum MotdType |
33 |
{ |
34 |
MOTD_UNIVERSAL, /**< MOTD for all users */ |
35 |
MOTD_HOSTMASK, /**< MOTD selected by hostmask */ |
36 |
MOTD_IPMASKV4, /**< MOTD selected by IPv4 mask */ |
37 |
MOTD_IPMASKV6, /**< MOTD selected by IPv6 mask */ |
38 |
MOTD_CLASS /**< MOTD selected by connection class */ |
39 |
}; |
40 |
|
41 |
/** Entry for a single Message Of The Day (MOTD). */ |
42 |
struct Motd |
43 |
{ |
44 |
dlink_node node; /**< Next MOTD in the linked list. */ |
45 |
enum MotdType type; /**< Type of MOTD. */ |
46 |
char *path; /**< Pathname of MOTD file. */ |
47 |
char *mask; /**< Hostmask if type==MOTD_HOSTMASK, |
48 |
class name if type==MOTD_CLASS, |
49 |
text IP mask if type==MOTD_IPMASK. */ |
50 |
struct irc_ssaddr address; /**< Address if type==MOTD_IPMASK. */ |
51 |
int addrbits; /**< Number of bits checked in Motd::address. */ |
52 |
unsigned int maxcount; /**< Number of lines for MOTD. */ |
53 |
struct MotdCache *cache; /**< MOTD cache entry. */ |
54 |
}; |
55 |
|
56 |
/** Length of one MOTD line(80 chars + '\\0'). */ |
57 |
enum { MOTD_LINESIZE = 81 }; |
58 |
/** Maximum number of lines for MOTD */ |
59 |
enum { MOTD_MAXLINES = 100 }; |
60 |
|
61 |
|
62 |
/** Cache entry for the contents of a MOTD file. */ |
63 |
struct MotdCache |
64 |
{ |
65 |
dlink_node node; /**< Next MotdCache in list. */ |
66 |
char *path; /**< Pathname of file. */ |
67 |
unsigned int ref; /**< Number of references to this entry. */ |
68 |
unsigned int maxcount; /**< Number of lines allocated for message. */ |
69 |
unsigned int count; /**< Actual number of lines used in message. */ |
70 |
time_t modtime; /**< Last modification time from file. */ |
71 |
char motd[][MOTD_LINESIZE]; /**< Message body. */ |
72 |
}; |
73 |
|
74 |
/* motd_send sends a MOTD off to a user */ |
75 |
extern void motd_send(struct Client *); |
76 |
|
77 |
/* motd_signon sends a MOTD off to a newly-registered user */ |
78 |
extern void motd_signon(struct Client *); |
79 |
|
80 |
/* motd_recache causes all the MOTD caches to be cleared */ |
81 |
extern void motd_recache(void); |
82 |
|
83 |
/* motd_init initializes the MOTD routines, including reading the |
84 |
* ircd.motd and remote.motd files into cache |
85 |
*/ |
86 |
extern void motd_init(void); |
87 |
|
88 |
/* This routine adds a MOTD */ |
89 |
extern void motd_add(const char *, const char *); |
90 |
|
91 |
/* This routine clears the list of MOTDs */ |
92 |
extern void motd_clear(void); |
93 |
|
94 |
/* This is called to report motd {} blocks */ |
95 |
extern void motd_report(struct Client *, int, char *[]); |
96 |
extern void motd_memory_count(struct Client *); |
97 |
#endif |