Doxyfy motd.h and motd.c.
[ircu2.10.12-pk.git] / include / motd.h
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$
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
37
38 struct Client;
39 struct TRecord;
40 struct StatDesc;
41
42 /** Entry for a single Message Of The Day (MOTD). */
43 struct Motd {
44   struct Motd*          next;     /**< Next MOTD in the linked list. */
45   int                   type;     /**< Type of MOTD (MOTD_UNIVERSAL,
46                                      MOTD_HOSTMASK or MOTD_CLASS) */
47   /* Used for classname if it is a class. */
48   char*                 hostmask; /**< Hostmask if type==MOTD_HOSTMASK,
49                                      class name if type==MOTD_CLASS. */
50   char*                 path;     /**< Pathname of MOTD file. */
51   int                   maxcount; /**< Number of lines for MOTD. */
52   struct MotdCache*     cache;    /**< MOTD cache entry. */
53 };
54
55 #define MOTD_UNIVERSAL  0         /**< MOTD selected by no criteria */
56 #define MOTD_HOSTMASK   1         /**< MOTD selected by hostmask */
57 #define MOTD_CLASS      2         /**< MOTD selected by connection class */
58
59 /** Length of one MOTD line(80 chars + '\\0'). */
60 #define MOTD_LINESIZE   81
61 /** Maximum number of lines for local MOTD */
62 #define MOTD_MAXLINES   100
63 /** Maximum number of lines for remote MOTD */
64 #define MOTD_MAXREMOTE  3
65
66 /** Cache entry for the contents of a MOTD file. */
67 struct MotdCache {
68   struct MotdCache*     next;     /**< Next MotdCache in list. */
69   struct MotdCache**    prev_p;   /**< Pointer to previous node's next pointer. */
70   int                   ref;      /**< Number of references to this entry. */
71   char*                 path;     /**< Pathname of file. */
72   int                   maxcount; /**< Number of lines allocated for message. */
73   struct tm             modtime;  /**< Last modification time from file. */
74   int                   count;    /**< Actual number of lines used in message. */
75   char                  motd[1][MOTD_LINESIZE]; /**< Message body. */
76 };
77
78 /* motd_send sends a MOTD off to a user */
79 int motd_send(struct Client* cptr);
80
81 /* motd_signon sends a MOTD off to a newly-registered user */
82 void motd_signon(struct Client* cptr);
83
84 /* motd_recache causes all the MOTD caches to be cleared */
85 void motd_recache(void);
86
87 /* motd_init initializes the MOTD routines, including reading the
88  * ircd.motd and remote.motd files into cache
89  */
90 void motd_init(void);
91
92 /* This routine adds a MOTD */
93 void motd_add(const char *hostmask, const char *path);
94
95 /* This routine clears the list of MOTDs */
96 void motd_clear(void);
97
98 /* This is called to report T-lines */
99 void motd_report(struct Client *to, const struct StatDesc *sd,
100                  char *param);
101 void motd_memory_count(struct Client *cptr);
102
103 #endif /* INCLUDED_motd_h */