* Bug fixes: Fix numerous char array size mismatches, signed/unsigned
[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 "typesize.h"
17 #include "ipcdef.h"
18
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22
23 /*
24  * Text description of this software
25  */
26 #define CITADEL "Citadel/UX 6.01"
27
28 /*
29  * REV_LEVEL is the current version number (multiplied by 100 to avoid having
30  * to fiddle with the decimal).  REV_MIN is the oldest version of Citadel
31  * whose data files are compatible with the current version.  If the data files
32  * are older than REV_MIN, none of the programs will work until the setup
33  * program is run again to bring things up to date.
34  */
35 #define REV_LEVEL       601             /* This version */
36 #define REV_MIN         591             /* Oldest compatible version */
37
38 #define SERVER_TYPE 0   /* zero for stock Citadel/UX; other developers please
39                            obtain SERVER_TYPE codes for your implementations */
40
41 /*
42  * This is a better implementation of tolower() than that found on some
43  * systems (there are operating systems out there on which tolower() will
44  * screw up if you give it a character that is already lower case).
45  */
46 #ifdef  tolower
47 #undef  tolower
48 #endif
49 #define tolower(x)      ( ((x>='A')&&(x<='Z')) ? (x+'a'-'A') : x )
50 #define NEW_CONFIG
51
52 /* Various length constants */
53
54 #define UGLISTLEN   100   /* you get a ungoto list of this size */
55 #define ROOMNAMELEN     128             /* The size of a roomname string */
56 #define NONCE_SIZE      128             /* Added by <bc> to allow for APOP auth 
57                                          * it is BIG becuase there is a hostname
58                                          * in the nonce, as per the APOP RFC.
59                                          */
60                                          
61 #define USERNAME_SIZE   64              /* The size of a username string */
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_unused_1;                 /* Nothin' here anymore...          */
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 };
130
131 #define NODENAME                config.c_nodename
132 #define FQDN                    config.c_fqdn
133 #define HUMANNODE               config.c_humannode
134 #define PHONENUM                config.c_phonenum
135 #define BBSUID                  config.c_bbsuid
136 #define CREATAIDE               config.c_creataide
137 #define REGISCALL               config.c_regiscall
138 #define TWITDETECT              config.c_twitdetect
139 #define TWITROOM                config.c_twitroom
140 #define RESTRICT_INTERNET       config.c_restrict
141
142 /* Defines the actual user record */
143  
144 struct usersupp {                       /* User record                      */
145         int version;                    /* Cit vers. which created this rec */
146         uid_t uid;                      /* Associate with a unix account?   */
147         char password[32];              /* password (for BBS-only users)    */
148         unsigned flags;                 /* See US_ flags below              */
149         long timescalled;               /* Total number of logins           */
150         long posted;                    /* Number of messages posted (ever) */
151         cit_uint8_t axlevel;            /* Access level                     */
152         long usernum;                   /* User number (never recycled)     */
153         time_t lastcall;                /* Last time the user called        */
154         int USuserpurge;                /* Purge time (in days) for user    */
155         char fullname[64];              /* Name for Citadel messages & mail */
156         cit_uint8_t USscreenwidth;      /* Screen width (for textmode users)*/
157         cit_uint8_t USscreenheight;     /* Screen height(for textmode users)*/
158 };
159
160
161 /*
162  * This is the control record for the message base... 
163  */
164 struct CitControl {
165         long MMhighest;                 /* highest message number in file   */
166         unsigned MMflags;               /* Global system flags              */
167         long MMnextuser;                /* highest user number on system    */
168         long MMnextroom;                /* highest room number on system    */
169         int version;                    /* Server-hosted upgrade level      */
170 };
171
172 /* Bits which may appear in CitControl.MMflags.  Note that these don't
173  * necessarily pertain to the message base -- it's just a good place to
174  * store any global flags.
175  */
176 #define MM_VALID        4               /* New users need validating        */
177
178 /*
179  * Room records
180  */
181 struct quickroom {
182         char QRname[ROOMNAMELEN];       /* Name of room                     */
183         char QRpasswd[10];              /* Only valid if it's a private rm  */
184         long QRroomaide;                /* User number of room aide         */
185         long QRhighest;                 /* Highest message NUMBER in room   */
186         time_t QRgen;                   /* Generation number of room        */
187         unsigned QRflags;               /* See flag values below            */
188         char QRdirname[15];             /* Directory name, if applicable    */
189         long QRinfo;                    /* Info file update relative to msgs*/
190         char QRfloor;                   /* Which floor this room is on      */
191         time_t QRmtime;                 /* Date/time of last post           */
192         struct ExpirePolicy QRep;       /* Message expiration policy        */
193         long QRnumber;                  /* Globally unique room number      */
194         char QRorder;                   /* Sort key for room listing order  */
195         unsigned QRflags2;              /* Additional flags                 */
196         int QRdefaultview;              /* How to display the contents      */
197 };
198
199 /* Private rooms are always flagged with QR_PRIVATE.  If neither QR_PASSWORDED
200  * or QR_GUESSNAME is set, then it is invitation-only.  Passworded rooms are
201  * flagged with both QR_PRIVATE and QR_PASSWORDED while guess-name rooms are
202  * flagged with both QR_PRIVATE and QR_GUESSNAME.  NEVER set all three flags.
203  */
204
205 /*
206  * Events which might show up in the Citadel Log
207  */
208 #define CL_CONNECT      8               /* Connect to server                */
209 #define CL_LOGIN        16              /* CLfullname logged in             */
210 #define CL_NEWUSER      32              /* CLfullname is a new user         */
211 #define CL_BADPW        64              /* Bad attempt at CLfullname's pw   */
212 #define CL_TERMINATE    128             /* Logout - proper termination      */
213 #define CL_DROPCARR     256             /* Logout - dropped carrier         */
214 #define CL_SLEEPING     512             /* Logout - sleeping                */
215 #define CL_PWCHANGE     1024            /* CLfullname changed passwords     */
216
217 /* Miscellaneous                                                            */
218
219 #define MES_NORMAL      65              /* Normal message                   */
220 #define MES_ANONONLY    66              /* "****" header                    */
221 #define MES_ANONOPT     67              /* "Anonymous" header               */
222
223 #define MES_ERROR       (-1)    /* Can't send message due to bad address   */
224 #define MES_LOCAL       0       /* Local message, do no network processing */
225 #define MES_INTERNET    1       /* Convert msg and send as Internet mail   */
226 #define MES_IGNET       2       /* Process recipient and send via Cit net  */
227
228 /****************************************************************************/
229
230 /*
231  * Floor record.  The floor number is implicit in its location in the file.
232  */
233 struct floor {
234         unsigned short f_flags;         /* flags */
235         char f_name[256];               /* name of floor */
236         int f_ref_count;                /* reference count */
237         struct ExpirePolicy f_ep;       /* default expiration policy */
238         };
239
240 #define F_INUSE         1               /* floor is in use */
241
242
243 /*
244  * Values used internally for function call returns, etc.
245  */
246
247 #define NEWREGISTER     0               /* new user to register */
248 #define REREGISTER      1               /* existing user reregistering */
249
250 #define READ_HEADER     2
251 #define READ_MSGBODY    3
252
253 /* commands we can send to the sttybbs() routine */
254 #define SB_NO_INTR      0               /* set to bbs mode, i/q disabled */
255 #define SB_YES_INTR     1               /* set to bbs mode, i/q enabled */
256 #define SB_SAVE         2               /* save settings */
257 #define SB_RESTORE      3               /* restore settings */
258 #define SB_LAST         4               /* redo the last command sent */
259
260 #define NEXT_KEY        15
261 #define STOP_KEY        3
262
263 /* server exit codes */
264 #define EXIT_NORMAL     0               /* server terminated normally */
265                                         /* 1 through 63 reserved for signals */
266 #define EXIT_NULL       64              /* EOF on server command input */
267
268 /* citadel.rc stuff */
269 #define RC_NO           0               /* always no */
270 #define RC_YES          1               /* always yes */
271 #define RC_DEFAULT      2               /* setting depends on user config */
272
273 /* keepalives */
274 enum {
275         KA_NO,                          /* no keepalives */
276         KA_YES,                         /* full keepalives */
277         KA_HALF                         /* half keepalives */
278 };
279
280 /* for <;G>oto and <;S>kip commands */
281 #define GF_GOTO         0               /* <;G>oto floor mode */
282 #define GF_SKIP         1               /* <;S>kip floor mode */
283 #define GF_ZAP          2               /* <;Z>ap floor mode */
284
285 /*
286  * MIME types used in Citadel for configuration stuff
287  */
288 #define SPOOLMIME       "application/x-citadel-delivery-list"
289 #define INTERNETCFG     "application/x-citadel-internet-config"
290 #define IGNETCFG        "application/x-citadel-ignet-config"
291 #define IGNETMAP        "application/x-citadel-ignet-map"
292 #define FILTERLIST      "application/x-citadel-filter-list"
293 #define SPAMSTRINGS     "application/x-citadel-spam-strings"
294
295 #define TRACE   lprintf(9, "Checkpoint: %s, %d\n", __FILE__, __LINE__)
296
297 #ifndef LONG_MAX
298 #define LONG_MAX 2147483647L
299 #endif
300
301
302 /*
303  * Views
304  */
305 #define VIEW_BBS                0       /* Traditional Citadel BBS view */
306 #define VIEW_MAILBOX            1       /* Mailbox summary */
307 #define VIEW_ADDRESSBOOK        2       /* Address book view */
308
309 #ifdef __cplusplus
310 }
311 #endif
312
313 #ifdef tmpnam
314 #undef tmpnam
315 #endif
316 #define tmpnam(x)       CtdlTempFileName(__FILE__, __LINE__)
317
318 #ifdef tmpfile
319 #undef tmpfile
320 #endif
321 #define tmpfile()       CtdlTempFile()
322
323 #endif /* CITADEL_H */