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