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