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