29a2e3290c7790148e927eeac4ad1822fd39301b
[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.52"
12 #define REV_LEVEL 551
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  * System configuration 
49  */
50 struct config {
51         char c_nodename[16];            /* UUCP and Citadel 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         };
78
79 #define NODENAME                config.c_nodename
80 #define FQDN                    config.c_fqdn
81 #define HUMANNODE               config.c_humannode
82 #define PHONENUM                config.c_phonenum
83 #define BBSUID                  config.c_bbsuid
84 #define CREATAIDE               config.c_creataide
85 #define REGISCALL               config.c_regiscall
86 #define TWITDETECT              config.c_twitdetect
87 #define TWITROOM                config.c_twitroom
88 #define RESTRICT_INTERNET       config.c_restrict
89
90 /* Defines the actual user record */
91 struct usersupp {                       /* User record                      */
92         int USuid;                      /* userid (==BBSUID for bbs only)   */
93         char password[20];              /* password (for BBS-only users)    */
94         unsigned flags;                 /* See US_ flags below              */
95         int timescalled;                /* Total number of logins           */
96         int posted;                     /* Number of messages posted (ever) */
97         char fullname[26];              /* Name for Citadel messages & mail */
98         char axlevel;                   /* Access level                     */
99         CIT_UBYTE USscreenwidth;        /* Screen width (for textmode users)*/
100         CIT_UBYTE USscreenheight;       /* Screen height(for textmode users)*/
101         long usernum;                   /* User number (never recycled)     */
102         time_t lastcall;                /* Last time the user called        */
103         char USname[30];                /* Real name (i.e. not a handle)    */
104         char USaddr[25];                /* Street address                   */
105         char UScity[15];                /* Municipality                     */
106         char USstate[3];                /* State or province                */
107         char USzip[10];                 /* ZIP code                         */
108         char USphone[11];               /* Voice telephone number           */
109         char USemail[32];               /* E-mail address (elsewhere)       */
110         int USuserpurge;                /* Purge time (in days) for user    */
111         };
112
113
114 /****************************************************************************
115  * This is the control record for the message base... 
116  */
117 struct CitControl {
118         long MMhighest;                 /* highest message number in file   */
119         unsigned MMflags;               /* Global system flags              */
120         long MMnextuser;                /* highest user number on system    */
121         long MMnextroom;                /* highest room number on system    */
122         };
123
124 /* Bits which may appear in CitControl.MMflags.  Note that these don't
125  * necessarily pertain to the message base -- it's just a good place to
126  * store any global flags.
127  */
128 #define MM_VALID        4               /* New users need validating        */
129
130 /****************************************************************************
131  * Room records
132  */
133 struct quickroom {
134         char QRname[ROOMNAMELEN];       /* Name of room                     */
135         char QRpasswd[10];              /* Only valid if it's a private rm  */
136         long QRroomaide;                /* User number of room aide         */
137         long QRhighest;                 /* Highest message NUMBER in room   */
138         time_t QRgen;                   /* Generation number of room        */
139         unsigned QRflags;               /* See flag values below            */
140         char QRdirname[15];             /* Directory name, if applicable    */
141         long QRinfo;                    /* Info file update relative to msgs*/
142         char QRfloor;                   /* Which floor this room is on      */
143         time_t QRmtime;                 /* Date/time of last post           */
144         struct ExpirePolicy QRep;       /* Message expiration policy        */
145         long QRnumber;                  /* Globally unique room number      */
146         char QRorder;                   /* Sort key for room listing order  */
147         };
148
149
150 /* Private rooms are always flagged with QR_PRIVATE. If neither QR_PASSWORDED
151  * or QR_GUESSNAME is set, then it is invitation-only. Passworded rooms are
152  * flagged with both QR_PRIVATE and QR_PASSWORDED while guess-name rooms are
153  * flagged with both QR_PRIVATE and QR_GUESSNAME. DO NOT set all three flags.
154  *
155  ****************************************************************************/
156
157 /*
158  * Events which might show up in the Citadel Log
159  */
160 #define CL_CONNECT      8               /* Connect to server                */
161 #define CL_LOGIN        16              /* CLfullname logged in             */
162 #define CL_NEWUSER      32              /* CLfullname is a new user         */
163 #define CL_BADPW        64              /* Bad attempt at CLfullname's pw   */
164 #define CL_TERMINATE    128             /* Logout - proper termination      */
165 #define CL_DROPCARR     256             /* Logout - dropped carrier         */
166 #define CL_SLEEPING     512             /* Logout - sleeping                */
167 #define CL_PWCHANGE     1024            /* CLfullname changed passwords     */
168
169 /* Miscellaneous                                                            */
170
171 #define MES_NORMAL      65              /* Normal message                   */
172 #define MES_ANON        66              /* "****" header                    */
173 #define MES_AN2         67              /* "Anonymous" header               */
174
175 #define M_ERROR         (-1)    /* Can't send message due to bad address   */
176 #define M_LOCAL         0       /* Local message, do no network processing */
177 #define M_INTERNET      1       /* Convert msg and send as Internet mail   */
178 #define M_BINARY        2       /* Process recipient and send via C/UX net */
179
180 /****************************************************************************/
181
182 struct recentmsg {
183         char RMnodename[10];
184         long RMnum;                     /* Number or time of message        */
185         };
186
187
188 /****************************************************************************
189  *
190  * Floor record.  The floor number is implicit in its location in the file.
191  */
192 struct floor {
193         unsigned short f_flags;         /* flags */
194         char f_name[256];               /* name of floor */
195         int f_ref_count;                /* reference count */
196         struct ExpirePolicy f_ep;       /* default expiration policy */
197         };
198
199 #define F_INUSE         1               /* floor is in use */
200
201
202 /****************************************************************************
203  * Values used internally for function call returns, etc.
204  */
205
206 #define NEWREGISTER     0               /* new user to register */
207 #define REREGISTER      1               /* existing user reregistering */
208
209 #define READ_HEADER     2
210 #define READ_MSGBODY    3
211
212 /* commands we can send to the sttybbs() routine */
213 #define SB_NO_INTR      0               /* set to bbs mode, i/q disabled */
214 #define SB_YES_INTR     1               /* set to bbs mode, i/q enabled */
215 #define SB_SAVE         2               /* save settings */
216 #define SB_RESTORE      3               /* restore settings */
217 #define SB_LAST         4               /* redo the last command sent */
218
219 #define NEXT_KEY        15
220 #define STOP_KEY        3
221
222 /* server exit codes */
223 #define EXIT_NORMAL     0               /* server terminated normally */
224                                         /* 1 through 63 reserved for signals */
225 #define EXIT_NULL       64              /* EOF on server command input */
226
227 /* citadel.rc stuff */
228 #define RC_NO           0               /* always no */
229 #define RC_YES          1               /* always yes */
230 #define RC_DEFAULT      2               /* setting depends on user config */
231
232 /* keepalives */
233 #define KA_NO           0               /* no keepalives */
234 #define KA_YES          1               /* full keepalives */
235 #define KA_CHAT         2               /* half keepalives (for chat mode) */
236
237 /* for <;G>oto and <;S>kip commands */
238 #define GF_GOTO         0               /* <;G>oto floor mode */
239 #define GF_SKIP         1               /* <;S>kip floor mode */
240 #define GF_ZAP          2               /* <;Z>ap floor mode */
241
242
243 #define BASEROOM        "Lobby"
244 #define MAILROOM        "Mail"
245 #define AIDEROOM        "Aide"
246
247
248 /*
249  * This structure is used to hold all of the fields of a message
250  * during conversion, processing, or whatever.
251  */
252 struct minfo {
253         char A[512];
254         char B[512];
255         char C[512];
256         char D[512];
257         char E[512];
258         char G[512];
259         char H[512];
260         long I;
261         char N[512];
262         char O[512];
263         char P[512];
264         char R[512];
265         char S[512];
266         long T;
267         char U[512];
268         char nexthop[512];
269         };
270