--- VERSION 7.30 ---
[citadel.git] / citadel / citadel.h
1 /*
2  * $Id$
3  *
4  * Main Citadel header file
5  * See copyright.txt for copyright information.
6  */
7
8 /* system customizations are in sysconfig.h */
9
10 #ifndef CITADEL_H
11 #define CITADEL_H
12 /* #include <dmalloc.h> uncomment if using dmalloc */
13
14 /* Build Citadel with the calendar service only if the header *and*
15  * library for libical are both present.
16  */
17 #ifdef HAVE_LIBICAL
18 #ifdef HAVE_ICAL_H
19 #define CITADEL_WITH_CALENDAR_SERVICE 1
20 #endif
21 #endif
22
23 #include "sysdep.h"
24 #include <limits.h>
25 #include "sysconfig.h"
26 #include "typesize.h"
27 #include "ipcdef.h"
28
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32
33 /*
34  * Text description of this software
35  * (We used to define this ourselves, but why bother when
36  * the GNU build tools do it for us?)
37  */
38 #define CITADEL PACKAGE_STRING
39
40 /*
41  * REV_LEVEL is the current version number (multiplied by 100 to avoid having
42  * to fiddle with the decimal).  REV_MIN is the oldest version of Citadel
43  * whose data files are compatible with the current version.  If the data files
44  * are older than REV_MIN, none of the programs will work until the setup
45  * program is run again to bring things up to date.  EXPORT_REV_MIN is the
46  * oldest version of Citadel whose export files we can read.  The latter is
47  * usually more strict because you're not really supposed to dump/load and
48  * upgrade at the same time.
49  */
50 #define REV_LEVEL       730             /* This version */
51 #define REV_MIN         591             /* Oldest compatible database */
52 #define EXPORT_REV_MIN  725             /* Oldest compatible export files */
53 #define LIBCITADEL_MIN  103             /* Minimum required version of libcitadel */
54
55 #define SERVER_TYPE 0                   /* zero for stock Citadel; other developers please
56                                            obtain SERVER_TYPE codes for your implementations */
57
58 #ifdef LIBCITADEL_VERSION_NUMBER
59 #if LIBCITADEL_VERSION_NUMBER < LIBCITADEL_MIN
60 #error libcitadel is too old.  Please upgrade it before continuing.
61 #endif
62 #endif
63
64 /* Various length constants */
65
66 #define UGLISTLEN       100     /* you get a ungoto list of this size */
67 #define ROOMNAMELEN     128     /* The size of a roomname string */
68 #define NONCE_SIZE      128     /* Added by <bc> to allow for APOP auth 
69                                  * it is BIG becuase there is a hostname
70                                  * in the nonce, as per the APOP RFC.
71                                  */
72                                          
73 #define USERNAME_SIZE   64      /* The size of a username string */
74 #define MAX_EDITORS     5       /* # of external editors supported */
75                                 /* MUST be at least 1 */
76
77 /*
78  * Message expiration policy stuff
79  */
80 struct ExpirePolicy {
81 /*
82 #include "datadefinitions.h"
83 #include "dtds/expirepolicy-defs.h"
84 #include "undef_data.h"
85 */
86         int expire_mode;
87         int expire_value;
88 };
89
90 #define EXPIRE_NEXTLEVEL        0       /* Inherit expiration policy    */
91 #define EXPIRE_MANUAL           1       /* Don't expire messages at all */
92 #define EXPIRE_NUMMSGS          2       /* Keep only latest n messages  */
93 #define EXPIRE_AGE              3       /* Expire messages after n days */
94
95
96 /*
97  * This struct stores a list of rooms with new messages which the client
98  * fetches from the server.  This allows the client to "march" through
99  * relevant rooms without having to ask the server each time where to go next.
100  */
101 struct march {
102 /*
103 #include "datadefinitions.h"
104 #include "dtds/march-defs.h"
105 #include "undef_data.h"
106 */
107         struct march *next;
108         char march_name[ROOMNAMELEN];
109         unsigned int march_flags;
110         char march_floor;
111         char march_order;
112         unsigned int march_flags2;
113         int march_access;
114 };
115
116 #define NODENAME                config.c_nodename
117 #define FQDN                    config.c_fqdn
118 #define HUMANNODE               config.c_humannode
119 #define PHONENUM                config.c_phonenum
120 #define CTDLUID                 config.c_ctdluid
121 #define CREATAIDE               config.c_creataide
122 #define REGISCALL               config.c_regiscall
123 #define TWITDETECT              config.c_twitdetect
124 #define TWITROOM                config.c_twitroom
125 #define RESTRICT_INTERNET       config.c_restrict
126
127 /*
128  * User records.
129  */
130 struct ctdluser {                       /* User record                      */
131 /*
132 #include "datadefinitions.h"
133 #include "dtds/user-defs.h"
134 #include "undef_data.h"
135 */
136         int version;                    /* Cit vers. which created this rec  */
137         uid_t uid;                      /* Associate with a unix account?    */
138         char password[32];              /* password                          */
139         unsigned flags;                 /* See US_ flags below               */
140         long timescalled;               /* Total number of logins            */
141         long posted;                    /* Number of messages ever submitted */
142         cit_uint8_t axlevel;            /* Access level                      */
143         long usernum;                   /* User number (never recycled)      */
144         time_t lastcall;                /* Date/time of most recent login    */
145         int USuserpurge;                /* Purge time (in days) for user     */
146         char fullname[64];              /* Display name (primary identifier) */
147         cit_uint8_t USscreenwidth;      /* Screen width (for textmode users) */
148         cit_uint8_t USscreenheight;     /* Screen height(for textmode users) */
149 };
150
151
152 /* Bits which may appear in CitControl.MMflags.  Note that these don't
153  * necessarily pertain to the message base -- it's just a good place to
154  * store any global flags.
155  */
156 #define MM_VALID        4               /* New users need validating        */
157
158 /*
159  * Room records.
160  */
161 struct ctdlroom {
162 /*
163 #include "datadefinitions.h"
164 #include "dtds/room-defs.h"
165 #include "undef_data.h"
166 */
167         char QRname[ROOMNAMELEN];       /* Name of room                     */
168         char QRpasswd[10];              /* Only valid if it's a private rm  */
169         long QRroomaide;                /* User number of room aide         */
170         long QRhighest;                 /* Highest message NUMBER in room   */
171         time_t QRgen;                   /* Generation number of room        */
172         unsigned QRflags;               /* See flag values below            */
173         char QRdirname[15];             /* Directory name, if applicable    */
174         long QRinfo;                    /* Info file update relative to msgs*/
175         char QRfloor;                   /* Which floor this room is on      */
176         time_t QRmtime;                 /* Date/time of last post           */
177         struct ExpirePolicy QRep;       /* Message expiration policy        */
178         long QRnumber;                  /* Globally unique room number      */
179         char QRorder;                   /* Sort key for room listing order  */
180         unsigned QRflags2;              /* Additional flags                 */
181         int QRdefaultview;              /* How to display the contents      */
182 };
183
184 /* Private rooms are always flagged with QR_PRIVATE.  If neither QR_PASSWORDED
185  * or QR_GUESSNAME is set, then it is invitation-only.  Passworded rooms are
186  * flagged with both QR_PRIVATE and QR_PASSWORDED while guess-name rooms are
187  * flagged with both QR_PRIVATE and QR_GUESSNAME.  NEVER set all three flags.
188  */
189
190 /*
191  * Miscellaneous
192  */
193 #define MES_NORMAL      65              /* Normal message                   */
194 #define MES_ANONONLY    66              /* "****" header                    */
195 #define MES_ANONOPT     67              /* "Anonymous" header               */
196
197 #define MES_ERROR       (-1)    /* Can't send message due to bad address   */
198 #define MES_LOCAL       0       /* Local message, do no network processing */
199 #define MES_INTERNET    1       /* Convert msg and send as Internet mail   */
200 #define MES_IGNET       2       /* Process recipient and send via Cit net  */
201
202 /****************************************************************************/
203
204 /*
205  * Floor record.  The floor number is implicit in its location in the file.
206  */
207 struct floor {
208 /*
209 #include "datadefinitions.h"
210 #include "dtds/floor-defs.h"
211 #include "undef_data.h"
212 */
213         unsigned short f_flags;         /* flags */
214         char f_name[256];               /* name of floor */
215         int f_ref_count;                /* reference count */
216         struct ExpirePolicy f_ep;       /* default expiration policy */
217 };
218
219 #define F_INUSE         1               /* floor is in use */
220
221
222 /*
223  * Values used internally for function call returns, etc.
224  */
225
226 #define NEWREGISTER     0               /* new user to register */
227 #define REREGISTER      1               /* existing user reregistering */
228
229 #define READ_HEADER     2
230 #define READ_MSGBODY    3
231
232 /* commands we can send to the stty_ctdl() routine */
233 #define SB_NO_INTR      0               /* set to Citadel client mode, i/q disabled */
234 #define SB_YES_INTR     1               /* set to Citadel client mode, i/q enabled */
235 #define SB_SAVE         2               /* save settings */
236 #define SB_RESTORE      3               /* restore settings */
237 #define SB_LAST         4               /* redo the last command sent */
238
239 #define NEXT_KEY        15
240 #define STOP_KEY        3
241
242 /* server exit codes */
243 #define EXIT_NORMAL     0               /* server terminated normally */
244                                         /* 1 through 63 reserved for signals */
245 #define EXIT_NULL       64              /* EOF on server command input */
246
247 /* citadel.rc stuff */
248 #define RC_NO           0               /* always no */
249 #define RC_YES          1               /* always yes */
250 #define RC_DEFAULT      2               /* setting depends on user config */
251
252 /* keepalives */
253 enum {
254         KA_NO,                          /* no keepalives */
255         KA_YES,                         /* full keepalives */
256         KA_HALF                         /* half keepalives */
257 };
258
259 /* for <;G>oto and <;S>kip commands */
260 #define GF_GOTO         0               /* <;G>oto floor mode */
261 #define GF_SKIP         1               /* <;S>kip floor mode */
262 #define GF_ZAP          2               /* <;Z>ap floor mode */
263
264 /*
265  * MIME types used in Citadel for configuration stuff
266  */
267 #define SPOOLMIME       "application/x-citadel-delivery-list"
268 #define INTERNETCFG     "application/x-citadel-internet-config"
269 #define IGNETCFG        "application/x-citadel-ignet-config"
270 #define IGNETMAP        "application/x-citadel-ignet-map"
271 #define FILTERLIST      "application/x-citadel-filter-list"
272 #define SIEVECONFIG     "application/x-citadel-sieve-config"
273
274 #define TRACE   lprintf(CTDL_DEBUG, "Checkpoint: %s, %d\n", __FILE__, __LINE__)
275
276 #ifndef LONG_MAX
277 #define LONG_MAX 2147483647L
278 #endif
279
280 /*
281  * Authentication modes
282  */
283 #define AUTHMODE_NATIVE         0       /* native Citadel authentication */
284 #define AUTHMODE_HOST           1       /* host integrated */
285
286 #ifdef __cplusplus
287 }
288 #endif
289
290 #endif /* CITADEL_H */