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