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