* Variable names, comments, documentation, etc... removed the acronym 'BBS'
[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  */
36 #define CITADEL "Citadel 6.45"
37
38 /*
39  * REV_LEVEL is the current version number (multiplied by 100 to avoid having
40  * to fiddle with the decimal).  REV_MIN is the oldest version of Citadel
41  * whose data files are compatible with the current version.  If the data files
42  * are older than REV_MIN, none of the programs will work until the setup
43  * program is run again to bring things up to date.  EXPORT_REV_MIN is the
44  * oldest version of Citadel whose export files we can read.  The latter is
45  * usually more strict because you're not really supposed to dump/load and
46  * upgrade at the same time.
47  */
48 #define REV_LEVEL       645             /* This version */
49 #define REV_MIN         591             /* Oldest compatible database */
50 #define EXPORT_REV_MIN  626             /* Oldest compatible export files */
51
52 #define SERVER_TYPE 0   /* zero for stock Citadel; other developers please
53                            obtain SERVER_TYPE codes for your implementations */
54
55 /* Various length constants */
56
57 #define UGLISTLEN       100     /* you get a ungoto list of this size */
58 #define ROOMNAMELEN     128     /* The size of a roomname string */
59 #define NONCE_SIZE      128     /* Added by <bc> to allow for APOP auth 
60                                  * it is BIG becuase there is a hostname
61                                  * in the nonce, as per the APOP RFC.
62                                  */
63                                          
64 #define USERNAME_SIZE   64      /* The size of a username string */
65 #define MAX_EDITORS     5       /* # of external editors supported */
66                                 /* MUST be at least 1 */
67
68 /*
69  * Message expiration policy stuff
70  */
71 struct ExpirePolicy {
72         int expire_mode;
73         int expire_value;
74 };
75
76 #define EXPIRE_NEXTLEVEL        0       /* Inherit expiration policy    */
77 #define EXPIRE_MANUAL           1       /* Don't expire messages at all */
78 #define EXPIRE_NUMMSGS          2       /* Keep only latest n messages  */
79 #define EXPIRE_AGE              3       /* Expire messages after n days */
80
81
82 /* 
83  * Global system configuration.
84  * 
85  * Developers: please do NOT remove the fields labelled "not in use".  We
86  * can't simply remove them from the struct, because this gets written to
87  * disk, and if you change it then you'll break all existing systems.
88  * However, if you'd like to reclaim some of that space for another use, feel
89  * free to do so, as long as the sizes are kept identical.
90  */
91 struct config {
92         char c_nodename[16];            /* Unqualified "short" nodename     */
93         char c_fqdn[64];                /* Fully Qualified Domain Name      */
94         char c_humannode[21];           /* Long name of system              */
95         char c_phonenum[16];            /* Dialup number of system          */
96         uid_t c_ctdluid;                /* UID under which we run Citadel   */
97         char c_creataide;               /* room creator = room aide  flag   */
98         int c_sleeping;                 /* watchdog timer setting           */
99         char c_initax;                  /* initial access level             */
100         char c_regiscall;               /* call number to register on       */
101         char c_twitdetect;              /* twit detect flag                 */
102         char c_twitroom[ROOMNAMELEN];   /* twit detect msg move to room     */
103         char c_moreprompt[80];          /* paginator prompt                 */
104         char c_restrict;                /* restrict Internet mail flag      */
105         long c_niu_1;                   /* (not in use)                     */
106         char c_site_location[32];               /* physical location of server      */
107         char c_sysadm[26];              /* name of system administrator     */
108         char c_niu_2[15];               /* (not in use)                     */
109         int c_setup_level;              /* what rev level we've setup to    */
110         int c_maxsessions;              /* maximum concurrent sessions      */
111         char c_ip_addr[20];             /* IP address to listen on          */
112         int c_port_number;              /* Cit listener port (usually 504)  */
113         int c_ipgm_secret;              /* Internal program authentication  */
114         struct ExpirePolicy c_ep;       /* System default msg expire policy */
115         int c_userpurge;                /* System default user purge (days) */
116         int c_roompurge;                /* System default room purge (days) */
117         char c_logpages[ROOMNAMELEN];   /* Room to log pages to (or not)    */
118         char c_createax;                /* Axlevel required to create rooms */
119         long c_maxmsglen;               /* Maximum message length           */
120         int c_min_workers;              /* Lower limit on number of threads */
121         int c_max_workers;              /* Upper limit on number of threads */
122         int c_pop3_port;                /* POP3 listener port (usually 110) */
123         int c_smtp_port;                /* SMTP listener port (usually 25)  */
124         int c_rfc822_strict_from;       /* 1 = don't correct From: forgeries*/
125         int c_aide_zap;                 /* Are Aides allowed to zap rooms?  */
126         int c_imap_port;                /* IMAP listener port (usually 143) */
127         time_t c_net_freq;              /* how often to run the networker   */
128         char c_disable_newu;            /* disable NEWU command             */
129         char c_niu_4;                   /* (not in use)                     */
130         char c_baseroom[ROOMNAMELEN];   /* Name of baseroom (Lobby)         */
131         char c_aideroom[ROOMNAMELEN];   /* Name of aideroom (Aide)          */
132         int c_purge_hour;               /* Hour during which db purges run  */
133         struct ExpirePolicy c_mbxep;    /* Expire policy for mailbox rooms  */
134         char c_ldap_host[128];          /* Host where LDAP service lives    */
135         int c_ldap_port;                /* Port on host where LDAP lives    */
136         char c_ldap_base_dn[256];       /* LDAP base DN                     */
137         char c_ldap_bind_dn[256];       /* LDAP bind DN                     */
138         char c_ldap_bind_pw[256];       /* LDAP bind password               */
139         int c_msa_port;                 /* SMTP MSA listener port (usu 587) */
140         int c_imaps_port;               /* IMAPS listener port (usually 993)*/
141         int c_pop3s_port;               /* POP3S listener port (usually 995)*/
142         int c_smtps_port;               /* SMTPS listener port (usually 465)*/
143 };
144
145 /*
146  * This struct stores a list of rooms with new messages which the client
147  * fetches from the server.  This allows the client to "march" through
148  * relevant rooms without having to ask the server each time where to go next.
149  */
150 struct march {
151         struct march *next;
152         char march_name[ROOMNAMELEN];
153         unsigned int march_flags;
154         char march_floor;
155         char march_order;
156         unsigned int march_flags2;
157         int march_access;
158 };
159
160 #define NODENAME                config.c_nodename
161 #define FQDN                    config.c_fqdn
162 #define HUMANNODE               config.c_humannode
163 #define PHONENUM                config.c_phonenum
164 #define CTDLUID                 config.c_ctdluid
165 #define CREATAIDE               config.c_creataide
166 #define REGISCALL               config.c_regiscall
167 #define TWITDETECT              config.c_twitdetect
168 #define TWITROOM                config.c_twitroom
169 #define RESTRICT_INTERNET       config.c_restrict
170
171 /*
172  * User records.
173  */
174 struct ctdluser {                       /* User record                      */
175         int version;                    /* Cit vers. which created this rec */
176         uid_t uid;                      /* Associate with a unix account?   */
177         char password[32];              /* password (for Citadel-only users)*/
178         unsigned flags;                 /* See US_ flags below              */
179         long timescalled;               /* Total number of logins           */
180         long posted;                    /* Number of messages posted (ever) */
181         cit_uint8_t axlevel;            /* Access level                     */
182         long usernum;                   /* User number (never recycled)     */
183         time_t lastcall;                /* Last time the user called        */
184         int USuserpurge;                /* Purge time (in days) for user    */
185         char fullname[64];              /* Name for Citadel messages & mail */
186         cit_uint8_t USscreenwidth;      /* Screen width (for textmode users)*/
187         cit_uint8_t USscreenheight;     /* Screen height(for textmode users)*/
188 };
189
190
191 /*
192  * This is the control record for the message base... 
193  */
194 struct CitControl {
195         long MMhighest;                 /* highest message number in file   */
196         unsigned MMflags;               /* Global system flags              */
197         long MMnextuser;                /* highest user number on system    */
198         long MMnextroom;                /* highest room number on system    */
199         int version;                    /* Server-hosted upgrade level      */
200 };
201
202 /* Bits which may appear in CitControl.MMflags.  Note that these don't
203  * necessarily pertain to the message base -- it's just a good place to
204  * store any global flags.
205  */
206 #define MM_VALID        4               /* New users need validating        */
207
208 /*
209  * Room records.
210  */
211 struct ctdlroom {
212         char QRname[ROOMNAMELEN];       /* Name of room                     */
213         char QRpasswd[10];              /* Only valid if it's a private rm  */
214         long QRroomaide;                /* User number of room aide         */
215         long QRhighest;                 /* Highest message NUMBER in room   */
216         time_t QRgen;                   /* Generation number of room        */
217         unsigned QRflags;               /* See flag values below            */
218         char QRdirname[15];             /* Directory name, if applicable    */
219         long QRinfo;                    /* Info file update relative to msgs*/
220         char QRfloor;                   /* Which floor this room is on      */
221         time_t QRmtime;                 /* Date/time of last post           */
222         struct ExpirePolicy QRep;       /* Message expiration policy        */
223         long QRnumber;                  /* Globally unique room number      */
224         char QRorder;                   /* Sort key for room listing order  */
225         unsigned QRflags2;              /* Additional flags                 */
226         int QRdefaultview;              /* How to display the contents      */
227 };
228
229 /* Private rooms are always flagged with QR_PRIVATE.  If neither QR_PASSWORDED
230  * or QR_GUESSNAME is set, then it is invitation-only.  Passworded rooms are
231  * flagged with both QR_PRIVATE and QR_PASSWORDED while guess-name rooms are
232  * flagged with both QR_PRIVATE and QR_GUESSNAME.  NEVER set all three flags.
233  */
234
235 /*
236  * Miscellaneous
237  */
238 #define MES_NORMAL      65              /* Normal message                   */
239 #define MES_ANONONLY    66              /* "****" header                    */
240 #define MES_ANONOPT     67              /* "Anonymous" header               */
241
242 #define MES_ERROR       (-1)    /* Can't send message due to bad address   */
243 #define MES_LOCAL       0       /* Local message, do no network processing */
244 #define MES_INTERNET    1       /* Convert msg and send as Internet mail   */
245 #define MES_IGNET       2       /* Process recipient and send via Cit net  */
246
247 /****************************************************************************/
248
249 /*
250  * Floor record.  The floor number is implicit in its location in the file.
251  */
252 struct floor {
253         unsigned short f_flags;         /* flags */
254         char f_name[256];               /* name of floor */
255         int f_ref_count;                /* reference count */
256         struct ExpirePolicy f_ep;       /* default expiration policy */
257 };
258
259 #define F_INUSE         1               /* floor is in use */
260
261
262 /*
263  * Values used internally for function call returns, etc.
264  */
265
266 #define NEWREGISTER     0               /* new user to register */
267 #define REREGISTER      1               /* existing user reregistering */
268
269 #define READ_HEADER     2
270 #define READ_MSGBODY    3
271
272 /* commands we can send to the stty_ctdl() routine */
273 #define SB_NO_INTR      0               /* set to Citadel client mode, i/q disabled */
274 #define SB_YES_INTR     1               /* set to Citadel client mode, i/q enabled */
275 #define SB_SAVE         2               /* save settings */
276 #define SB_RESTORE      3               /* restore settings */
277 #define SB_LAST         4               /* redo the last command sent */
278
279 #define NEXT_KEY        15
280 #define STOP_KEY        3
281
282 /* server exit codes */
283 #define EXIT_NORMAL     0               /* server terminated normally */
284                                         /* 1 through 63 reserved for signals */
285 #define EXIT_NULL       64              /* EOF on server command input */
286
287 /* citadel.rc stuff */
288 #define RC_NO           0               /* always no */
289 #define RC_YES          1               /* always yes */
290 #define RC_DEFAULT      2               /* setting depends on user config */
291
292 /* keepalives */
293 enum {
294         KA_NO,                          /* no keepalives */
295         KA_YES,                         /* full keepalives */
296         KA_HALF                         /* half keepalives */
297 };
298
299 /* for <;G>oto and <;S>kip commands */
300 #define GF_GOTO         0               /* <;G>oto floor mode */
301 #define GF_SKIP         1               /* <;S>kip floor mode */
302 #define GF_ZAP          2               /* <;Z>ap floor mode */
303
304 /*
305  * MIME types used in Citadel for configuration stuff
306  */
307 #define SPOOLMIME       "application/x-citadel-delivery-list"
308 #define INTERNETCFG     "application/x-citadel-internet-config"
309 #define IGNETCFG        "application/x-citadel-ignet-config"
310 #define IGNETMAP        "application/x-citadel-ignet-map"
311 #define FILTERLIST      "application/x-citadel-filter-list"
312
313 #define TRACE   lprintf(CTDL_DEBUG, "Checkpoint: %s, %d\n", __FILE__, __LINE__)
314
315 #ifndef LONG_MAX
316 #define LONG_MAX 2147483647L
317 #endif
318
319
320 /*
321  * Views
322  */
323 #define VIEW_BBS                0       /* Bulletin board view */
324 #define VIEW_MAILBOX            1       /* Mailbox summary */
325 #define VIEW_ADDRESSBOOK        2       /* Address book view */
326 #define VIEW_CALENDAR           3       /* Calendar view */
327 #define VIEW_TASKS              4       /* Tasks view */
328 #define VIEW_NOTES              5       /* Notes view */
329
330 #ifdef __cplusplus
331 }
332 #endif
333
334 #endif /* CITADEL_H */