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