Release version 932 generated by do-release.sh
[citadel.git] / citadel / citadel.h
1 /*
2  * Main Citadel header file
3  *
4  * Copyright (c) 1987-2020 by the citadel.org team
5  *
6  * This program is open source software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 3.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  */
14
15 /* system customizations are in sysconfig.h */
16
17 #ifndef CITADEL_H
18 #define CITADEL_H
19 /* #include <dmalloc.h> uncomment if using dmalloc */
20
21 #include "sysdep.h"
22 #include <limits.h>
23 #include "sysconfig.h"
24 #include "typesize.h"
25 #include "ipcdef.h"
26
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30
31 /*
32  * Text description of this software
33  * (We used to define this ourselves, but why bother when
34  * the GNU build tools do it for us?)
35  */
36 #define CITADEL PACKAGE_STRING
37
38 #define REV_LEVEL 932           // This version
39 #define REV_MIN         591             // Oldest compatible database
40 #define EXPORT_REV_MIN  931             // Oldest compatible export files
41 #define LIBCITADEL_MIN  931             // Minimum required version of libcitadel
42 #define SERVER_TYPE     0               // zero for stock Citadel; other developers please obtain SERVER_TYPE codes for your implementations
43
44 #ifdef LIBCITADEL_VERSION_NUMBER
45 #if LIBCITADEL_VERSION_NUMBER < LIBCITADEL_MIN
46 #error libcitadel is too old.  Please upgrade it before continuing.
47 #endif
48 #endif
49
50 /*
51  * This is the user name and password for the default administrator account
52  * that is created when Citadel Server is started with an empty database.
53  */
54 #define DEFAULT_ADMIN_USERNAME  "admin"
55 #define DEFAULT_ADMIN_PASSWORD  "citadel"
56
57 /* Various length constants */
58
59 #define ROOMNAMELEN     128             /* The size of a roomname string */
60 #define USERNAME_SIZE   64              /* The size of a username string */
61 #define MAX_EDITORS     5               /* number of external editors supported ; must be at least 1 */
62
63 /*
64  * Message expiration policy stuff
65  */
66 typedef struct ExpirePolicy ExpirePolicy;
67 struct ExpirePolicy {
68         int expire_mode;
69         int expire_value;
70 };
71
72 #define EXPIRE_NEXTLEVEL        0       // Inherit expiration policy
73 #define EXPIRE_MANUAL           1       // Don't expire messages at all
74 #define EXPIRE_NUMMSGS          2       // Keep only latest n messages
75 #define EXPIRE_AGE              3       // Expire messages after n days
76
77
78 /*
79  * This struct stores a list of rooms with new messages which the client
80  * fetches from the server.  This allows the client to "march" through
81  * relevant rooms without having to ask the server each time where to go next.
82  */
83 typedef struct march march;
84 struct march {
85         struct march *next;
86         char march_name[ROOMNAMELEN];
87         unsigned int march_flags;
88         char march_floor;
89         char march_order;
90         unsigned int march_flags2;
91         int march_access;
92 };
93
94
95 /*
96  * User records.
97  */
98 typedef struct ctdluser ctdluser;
99 struct ctdluser {                       // User record
100         int version;                    // Citadel version which created this record
101         uid_t uid;                      // Associate with a unix account?
102         char password[32];              // password
103         unsigned flags;                 // See US_ flags below
104         long timescalled;               // Total number of logins
105         long posted;                    // Number of messages ever submitted
106         cit_uint8_t axlevel;            // Access level
107         long usernum;                   // User number (never recycled)
108         time_t lastcall;                // Date/time of most recent login
109         int USuserpurge;                // Purge time (in days) for user
110         char fullname[64];              // Display name (primary identifier)
111         long msgnum_bio;                // msgnum of user's profile (bio)
112         long msgnum_pic;                // msgnum of user's avatar (photo)
113         char emailaddrs[512];           // Internet email addresses
114         long msgnum_inboxrules;         // msgnum of user's inbox filtering rules
115         long lastproc_inboxrules;       // msgnum of last message filtered
116 };
117
118
119 /* Bits which may appear in MMflags.
120  */
121 #define MM_VALID        4               // New users need validating
122
123 /*
124  * Room records.
125  */
126 typedef struct ctdlroom ctdlroom;
127 struct ctdlroom {
128         char QRname[ROOMNAMELEN];       // Name of room
129         char QRpasswd[10];              // Only valid if it's a private rm
130         long QRroomaide;                // User number of room aide
131         long QRhighest;                 // Highest message NUMBER in room
132         time_t QRgen;                   // Generation number of room
133         unsigned QRflags;               // See flag values below
134         char QRdirname[15];             // Directory name, if applicable
135         long msgnum_info;               // msgnum of room banner (info file)
136         char QRfloor;                   // Which floor this room is on
137         time_t QRmtime;                 // Date/time of last post
138         struct ExpirePolicy QRep;       // Message expiration policy
139         long QRnumber;                  // Globally unique room number
140         char QRorder;                   // Sort key for room listing order
141         unsigned QRflags2;              // Additional flags
142         int QRdefaultview;              // How to display the contents
143         long msgnum_pic;                // msgnum of room picture or icon
144 };
145
146 /* Private rooms are always flagged with QR_PRIVATE.  If neither QR_PASSWORDED
147  * or QR_GUESSNAME is set, then it is invitation-only.  Passworded rooms are
148  * flagged with both QR_PRIVATE and QR_PASSWORDED while guess-name rooms are
149  * flagged with both QR_PRIVATE and QR_GUESSNAME.  NEVER set all three flags.
150  */
151
152 /*
153  * Miscellaneous
154  */
155 #define MES_NORMAL      65              // Normal message
156 #define MES_ANONONLY    66              // "****" header
157 #define MES_ANONOPT     67              // "Anonymous" header
158
159 #define MES_ERROR       (-1)            // Can't send message due to bad address
160 #define MES_LOCAL       0               // Local message, do no network processing
161 #define MES_INTERNET    1               // Convert msg and send as Internet mail
162
163 /****************************************************************************/
164
165 /*
166  * Floor record.  The floor number is implicit in its location in the file.
167  */
168 typedef struct floor floor;
169 struct floor {
170         unsigned short f_flags;         // flags
171         char f_name[256];               // name of floor
172         int f_ref_count;                // reference count
173         struct ExpirePolicy f_ep;       // default expiration policy
174 };
175
176 #define F_INUSE         1               // floor is in use
177
178
179 /*
180  * Values used internally for function call returns, etc.
181  */
182 #define NEWREGISTER     0               // new user to register
183 #define REREGISTER      1               // existing user reregistering
184
185 /* number of items which may be handled by the CONF command */
186 #define NUM_CONFIGS 71
187
188 #define TRACE   syslog(LOG_DEBUG, "\033[7m  Checkpoint: %s : %d  \033[0m", __FILE__, __LINE__)
189
190 #ifndef LONG_MAX
191 #define LONG_MAX 2147483647L
192 #endif
193
194 /*
195  * Authentication modes
196  */
197 #define AUTHMODE_NATIVE         0       // Native (self-contained or "black box")
198 #define AUTHMODE_HOST           1       // Authenticate against the host OS user database
199 #define AUTHMODE_LDAP           2       // Authenticate against an LDAP server with RFC 2307 schema
200 #define AUTHMODE_LDAP_AD        3       // Authenticate against non-standard MS Active Directory LDAP
201
202 #ifdef __cplusplus
203 }
204 #endif
205
206 #if __GNUC__ >= 8
207 #pragma GCC diagnostic push
208 #pragma GCC diagnostic ignored "-Wformat-truncation"
209 #endif
210
211 #endif /* CITADEL_H */