]>
Commit | Line | Data |
---|---|---|
189935b1 | 1 | #ifndef INCLUDED_motd_h |
2 | #define INCLUDED_motd_h | |
3 | /* | |
4 | * IRC - Internet Relay Chat, include/motd.h | |
5 | * Copyright (C) 1990 Jarkko Oikarinen and | |
6 | * University of Oulu, Computing Center | |
7 | * Copyright (C) 2000 Kevin L. Mitchell <klmitch@mit.edu> | |
8 | * | |
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 2, or (at your option) | |
12 | * any later version. | |
13 | * | |
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. | |
18 | * | |
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. | |
22 | */ | |
23 | /** @file | |
24 | * @brief Message-of-the-day manipulation interface and declarations. | |
25 | * @version $Id: motd.h,v 1.8 2004/10/17 01:58:16 entrope Exp $ | |
26 | */ | |
27 | ||
28 | #ifndef INCLUDED_time_h | |
29 | #include <time.h> /* struct tm */ | |
30 | #define INCLUDED_time_h | |
31 | #endif | |
32 | #ifndef INCLUDED_sys_types_h | |
33 | #include <sys/types.h> | |
34 | #define INCLUDED_sys_types_h | |
35 | #endif | |
36 | #ifndef INCLUDED_res_H | |
37 | #include "res.h" | |
38 | #endif | |
39 | ||
40 | struct Client; | |
41 | struct TRecord; | |
42 | struct StatDesc; | |
43 | ||
44 | /** Type of MOTD. */ | |
45 | enum MotdType { | |
46 | MOTD_UNIVERSAL, /**< MOTD for all users */ | |
47 | MOTD_HOSTMASK, /**< MOTD selected by hostmask */ | |
48 | MOTD_IPMASK, /**< MOTD selected by IP mask */ | |
49 | MOTD_CLASS /**< MOTD selected by connection class */ | |
50 | }; | |
51 | ||
52 | /** Entry for a single Message Of The Day (MOTD). */ | |
53 | struct Motd { | |
54 | struct Motd* next; /**< Next MOTD in the linked list. */ | |
55 | enum MotdType type; /**< Type of MOTD. */ | |
56 | char* hostmask; /**< Hostmask if type==MOTD_HOSTMASK, | |
57 | class name if type==MOTD_CLASS, | |
58 | text IP mask if type==MOTD_IPMASK. */ | |
59 | struct irc_in_addr address; /**< Address if type==MOTD_IPMASK. */ | |
60 | unsigned char addrbits; /**< Number of bits checked in Motd::address. */ | |
61 | char* path; /**< Pathname of MOTD file. */ | |
62 | int maxcount; /**< Number of lines for MOTD. */ | |
63 | struct MotdCache* cache; /**< MOTD cache entry. */ | |
64 | }; | |
65 | ||
66 | /** Length of one MOTD line(80 chars + '\\0'). */ | |
67 | #define MOTD_LINESIZE 81 | |
68 | /** Maximum number of lines for local MOTD */ | |
69 | #define MOTD_MAXLINES 100 | |
70 | /** Maximum number of lines for remote MOTD */ | |
71 | #define MOTD_MAXREMOTE 3 | |
72 | ||
73 | /** Cache entry for the contents of a MOTD file. */ | |
74 | struct MotdCache { | |
75 | struct MotdCache* next; /**< Next MotdCache in list. */ | |
76 | struct MotdCache** prev_p; /**< Pointer to previous node's next pointer. */ | |
77 | int ref; /**< Number of references to this entry. */ | |
78 | char* path; /**< Pathname of file. */ | |
79 | int maxcount; /**< Number of lines allocated for message. */ | |
80 | struct tm modtime; /**< Last modification time from file. */ | |
81 | int count; /**< Actual number of lines used in message. */ | |
82 | char motd[1][MOTD_LINESIZE]; /**< Message body. */ | |
83 | }; | |
84 | ||
85 | /* motd_send sends a MOTD off to a user */ | |
86 | int motd_send(struct Client* cptr); | |
87 | ||
88 | /* motd_signon sends a MOTD off to a newly-registered user */ | |
89 | void motd_signon(struct Client* cptr); | |
90 | ||
91 | /* motd_recache causes all the MOTD caches to be cleared */ | |
92 | void motd_recache(void); | |
93 | ||
94 | /* motd_init initializes the MOTD routines, including reading the | |
95 | * ircd.motd and remote.motd files into cache | |
96 | */ | |
97 | void motd_init(void); | |
98 | ||
99 | /* This routine adds a MOTD */ | |
100 | void motd_add(const char *hostmask, const char *path); | |
101 | ||
102 | /* This routine clears the list of MOTDs */ | |
103 | void motd_clear(void); | |
104 | ||
105 | /* This is called to report T-lines */ | |
106 | void motd_report(struct Client *to, const struct StatDesc *sd, | |
107 | char *param); | |
108 | void motd_memory_count(struct Client *cptr); | |
109 | ||
110 | #endif /* INCLUDED_motd_h */ |