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