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