Removed a lot of legacy cruft out of the setup utility. Eventually I want to remove...
[citadel.git] / citadel / citadel.h
1 /*
2  * Main Citadel header file
3  *
4  * Copyright (c) 1987-2019 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       927             // This version
39 #define REV_MIN         591             // Oldest compatible database
40 #define EXPORT_REV_MIN  760             // Oldest compatible export files
41 #define LIBCITADEL_MIN  922             // 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 /* Various length constants */
51
52 #define ROOMNAMELEN     128             /* The size of a roomname string */
53 #define USERNAME_SIZE   64              /* The size of a username string */
54 #define MAX_EDITORS     5               /* number of external editors supported ; must be at least 1 */
55
56 /*
57  * Message expiration policy stuff
58  */
59 typedef struct ExpirePolicy ExpirePolicy;
60 struct ExpirePolicy {
61         int expire_mode;
62         int expire_value;
63 };
64
65 #define EXPIRE_NEXTLEVEL        0       // Inherit expiration policy
66 #define EXPIRE_MANUAL           1       // Don't expire messages at all
67 #define EXPIRE_NUMMSGS          2       // Keep only latest n messages
68 #define EXPIRE_AGE              3       // Expire messages after n days
69
70
71 /*
72  * This struct stores a list of rooms with new messages which the client
73  * fetches from the server.  This allows the client to "march" through
74  * relevant rooms without having to ask the server each time where to go next.
75  */
76 typedef struct march march;
77 struct march {
78         struct march *next;
79         char march_name[ROOMNAMELEN];
80         unsigned int march_flags;
81         char march_floor;
82         char march_order;
83         unsigned int march_flags2;
84         int march_access;
85 };
86
87
88 /*
89  * User records.
90  */
91 typedef struct ctdluser ctdluser;
92 struct ctdluser {                       // User record
93         int version;                    // Cit vers. which created this rec
94         uid_t uid;                      // Associate with a unix account?
95         char password[32];              // password
96         unsigned flags;                 // See US_ flags below
97         long timescalled;               // Total number of logins
98         long posted;                    // Number of messages ever submitted
99         cit_uint8_t axlevel;            // Access level
100         long usernum;                   // User number (never recycled)
101         time_t lastcall;                // Date/time of most recent login
102         int USuserpurge;                // Purge time (in days) for user
103         char fullname[64];              // Display name (primary identifier)
104         long msgnum_bio;                // msgnum of user's profile (bio)
105         long msgnum_pic;                // msgnum of user's avatar (photo)
106         char emailaddrs[512];           // Internet email addresses
107 };
108
109
110 /* Bits which may appear in MMflags.
111  */
112 #define MM_VALID        4               // New users need validating
113
114 /*
115  * Room records.
116  */
117 typedef struct ctdlroom ctdlroom;
118 struct ctdlroom {
119         char QRname[ROOMNAMELEN];       // Name of room
120         char QRpasswd[10];              // Only valid if it's a private rm
121         long QRroomaide;                // User number of room aide
122         long QRhighest;                 // Highest message NUMBER in room
123         time_t QRgen;                   // Generation number of room
124         unsigned QRflags;               // See flag values below
125         char QRdirname[15];             // Directory name, if applicable
126         long msgnum_info;               // msgnum of room banner (info file)
127         char QRfloor;                   // Which floor this room is on
128         time_t QRmtime;                 // Date/time of last post
129         struct ExpirePolicy QRep;       // Message expiration policy
130         long QRnumber;                  // Globally unique room number
131         char QRorder;                   // Sort key for room listing order
132         unsigned QRflags2;              // Additional flags
133         int QRdefaultview;              // How to display the contents
134         long msgnum_pic;                // msgnum of room picture or icon
135 };
136
137 /* Private rooms are always flagged with QR_PRIVATE.  If neither QR_PASSWORDED
138  * or QR_GUESSNAME is set, then it is invitation-only.  Passworded rooms are
139  * flagged with both QR_PRIVATE and QR_PASSWORDED while guess-name rooms are
140  * flagged with both QR_PRIVATE and QR_GUESSNAME.  NEVER set all three flags.
141  */
142
143 /*
144  * Miscellaneous
145  */
146 #define MES_NORMAL      65              // Normal message
147 #define MES_ANONONLY    66              // "****" header
148 #define MES_ANONOPT     67              // "Anonymous" header
149
150 #define MES_ERROR       (-1)            // Can't send message due to bad address
151 #define MES_LOCAL       0               // Local message, do no network processing
152 #define MES_INTERNET    1               // Convert msg and send as Internet mail
153
154 /****************************************************************************/
155
156 /*
157  * Floor record.  The floor number is implicit in its location in the file.
158  */
159 typedef struct floor floor;
160 struct floor {
161         unsigned short f_flags;         // flags
162         char f_name[256];               // name of floor
163         int f_ref_count;                // reference count
164         struct ExpirePolicy f_ep;       // default expiration policy
165 };
166
167 #define F_INUSE         1               // floor is in use
168
169
170 /*
171  * Values used internally for function call returns, etc.
172  */
173 #define NEWREGISTER     0               // new user to register
174 #define REREGISTER      1               // existing user reregistering
175
176 /* number of items which may be handled by the CONF command */
177 #define NUM_CONFIGS 71
178
179 #define TRACE   syslog(LOG_DEBUG, "\033[31mCheckpoint: %s : %d\033[0m", __FILE__, __LINE__)
180
181 #ifndef LONG_MAX
182 #define LONG_MAX 2147483647L
183 #endif
184
185 /*
186  * Authentication modes
187  */
188 #define AUTHMODE_NATIVE         0       // Native (self-contained or "black box")
189 #define AUTHMODE_HOST           1       // Authenticate against the host OS user database
190 #define AUTHMODE_LDAP           2       // Authenticate against an LDAP server with RFC 2307 schema
191 #define AUTHMODE_LDAP_AD        3       // Authenticate against non-standard MS Active Directory LDAP
192
193 #ifdef __cplusplus
194 }
195 #endif
196
197 #if __GNUC__ >= 8
198 #pragma GCC diagnostic push
199 #pragma GCC diagnostic ignored "-Wformat-truncation"
200 #endif
201
202 #endif /* CITADEL_H */