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