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