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