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