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