74f088a06aff2b39945e804ec846b20000a9a422
[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 };
109
110 #define NODENAME                config.c_nodename
111 #define FQDN                    config.c_fqdn
112 #define HUMANNODE               config.c_humannode
113 #define PHONENUM                config.c_phonenum
114 #define BBSUID                  config.c_bbsuid
115 #define CREATAIDE               config.c_creataide
116 #define REGISCALL               config.c_regiscall
117 #define TWITDETECT              config.c_twitdetect
118 #define TWITROOM                config.c_twitroom
119 #define RESTRICT_INTERNET       config.c_restrict
120
121 /* Defines the actual user record */
122  
123 struct usersupp {                       /* User record                      */
124         int version;                    /* Cit vers. which created this rec */
125         uid_t uid;                      /* Associate with a unix account?   */
126         char password[32];              /* password (for BBS-only users)    */
127         unsigned flags;                 /* See US_ flags below              */
128         long timescalled;               /* Total number of logins           */
129         long posted;                    /* Number of messages posted (ever) */
130         CIT_UBYTE axlevel;              /* Access level                     */
131         long usernum;                   /* User number (never recycled)     */
132         time_t lastcall;                /* Last time the user called        */
133         int USuserpurge;                /* Purge time (in days) for user    */
134         char fullname[64];              /* Name for Citadel messages & mail */
135         CIT_UBYTE USscreenwidth;        /* Screen width (for textmode users)*/
136         CIT_UBYTE USscreenheight;       /* Screen height(for textmode users)*/
137         char moderation_filter;         /* Moderation filter level          */
138 };
139
140
141 /*
142  * This is the control record for the message base... 
143  */
144 struct CitControl {
145         long MMhighest;                 /* highest message number in file   */
146         unsigned MMflags;               /* Global system flags              */
147         long MMnextuser;                /* highest user number on system    */
148         long MMnextroom;                /* highest room number on system    */
149         int version;                    /* Server-hosted upgrade level      */
150 };
151
152 /* Bits which may appear in CitControl.MMflags.  Note that these don't
153  * necessarily pertain to the message base -- it's just a good place to
154  * store any global flags.
155  */
156 #define MM_VALID        4               /* New users need validating        */
157
158 /*
159  * Room records
160  */
161 struct quickroom {
162         char QRname[ROOMNAMELEN];       /* Name of room                     */
163         char QRpasswd[10];              /* Only valid if it's a private rm  */
164         long QRroomaide;                /* User number of room aide         */
165         long QRhighest;                 /* Highest message NUMBER in room   */
166         time_t QRgen;                   /* Generation number of room        */
167         unsigned QRflags;               /* See flag values below            */
168         char QRdirname[15];             /* Directory name, if applicable    */
169         long QRinfo;                    /* Info file update relative to msgs*/
170         char QRfloor;                   /* Which floor this room is on      */
171         time_t QRmtime;                 /* Date/time of last post           */
172         struct ExpirePolicy QRep;       /* Message expiration policy        */
173         long QRnumber;                  /* Globally unique room number      */
174         char QRorder;                   /* Sort key for room listing order  */
175 };
176
177 /* Private rooms are always flagged with QR_PRIVATE.  If neither QR_PASSWORDED
178  * or QR_GUESSNAME is set, then it is invitation-only.  Passworded rooms are
179  * flagged with both QR_PRIVATE and QR_PASSWORDED while guess-name rooms are
180  * flagged with both QR_PRIVATE and QR_GUESSNAME.  NEVER set all three flags.
181  */
182
183 /*
184  * Events which might show up in the Citadel Log
185  */
186 #define CL_CONNECT      8               /* Connect to server                */
187 #define CL_LOGIN        16              /* CLfullname logged in             */
188 #define CL_NEWUSER      32              /* CLfullname is a new user         */
189 #define CL_BADPW        64              /* Bad attempt at CLfullname's pw   */
190 #define CL_TERMINATE    128             /* Logout - proper termination      */
191 #define CL_DROPCARR     256             /* Logout - dropped carrier         */
192 #define CL_SLEEPING     512             /* Logout - sleeping                */
193 #define CL_PWCHANGE     1024            /* CLfullname changed passwords     */
194
195 /* Miscellaneous                                                            */
196
197 #define MES_NORMAL      65              /* Normal message                   */
198 #define MES_ANON        66              /* "****" header                    */
199 #define MES_AN2         67              /* "Anonymous" header               */
200
201 #define MES_ERROR       (-1)    /* Can't send message due to bad address   */
202 #define MES_LOCAL       0       /* Local message, do no network processing */
203 #define MES_INTERNET    1       /* Convert msg and send as Internet mail   */
204 #define MES_BINARY      2       /* Process recipient and send via Cit net  */
205
206 /****************************************************************************/
207
208 /*
209  * Floor record.  The floor number is implicit in its location in the file.
210  */
211 struct floor {
212         unsigned short f_flags;         /* flags */
213         char f_name[256];               /* name of floor */
214         int f_ref_count;                /* reference count */
215         struct ExpirePolicy f_ep;       /* default expiration policy */
216         };
217
218 #define F_INUSE         1               /* floor is in use */
219
220
221 /*
222  * Values used internally for function call returns, etc.
223  */
224
225 #define NEWREGISTER     0               /* new user to register */
226 #define REREGISTER      1               /* existing user reregistering */
227
228 #define READ_HEADER     2
229 #define READ_MSGBODY    3
230
231 /* commands we can send to the sttybbs() routine */
232 #define SB_NO_INTR      0               /* set to bbs mode, i/q disabled */
233 #define SB_YES_INTR     1               /* set to bbs mode, i/q enabled */
234 #define SB_SAVE         2               /* save settings */
235 #define SB_RESTORE      3               /* restore settings */
236 #define SB_LAST         4               /* redo the last command sent */
237
238 #define NEXT_KEY        15
239 #define STOP_KEY        3
240
241 /* server exit codes */
242 #define EXIT_NORMAL     0               /* server terminated normally */
243                                         /* 1 through 63 reserved for signals */
244 #define EXIT_NULL       64              /* EOF on server command input */
245
246 /* citadel.rc stuff */
247 #define RC_NO           0               /* always no */
248 #define RC_YES          1               /* always yes */
249 #define RC_DEFAULT      2               /* setting depends on user config */
250
251 /* keepalives */
252 #define KA_NO           0               /* no keepalives */
253 #define KA_YES          1               /* full keepalives */
254
255 /* for <;G>oto and <;S>kip commands */
256 #define GF_GOTO         0               /* <;G>oto floor mode */
257 #define GF_SKIP         1               /* <;S>kip floor mode */
258 #define GF_ZAP          2               /* <;Z>ap floor mode */
259
260 /*
261  * MIME types used in Citadel for configuration stuff
262  */
263 #define SPOOLMIME       "application/x-citadel-delivery-list"
264 #define INTERNETCFG     "application/x-citadel-internet-config"
265 #define IGNETCFG        "application/x-citadel-ignet-config"
266 #define IGNETMAP        "application/x-citadel-ignet-map"
267 #define USETABLE        "application/x-citadel-usetable"
268
269 #define TRACE   lprintf(9, "Checkpoint: %s, %d\n", __FILE__, __LINE__)
270
271 #ifndef LONG_MAX
272 #define LONG_MAX 2147483647L
273 #endif
274
275 #endif /* CITADEL_H */