Initial revision
[citadel.git] / citadel / citadel.h
1 /* citadel.h
2  * main Citadel/UX header file
3  * see copyright.doc for copyright information
4  */
5
6 /* system customizations are in sysconfig.h */
7 #include "sysdep.h"
8 #include "sysconfig.h"
9 #include "ipcdef.h"
10 #define CITADEL "Citadel/UX 5.02"
11 #define REV_LEVEL 501
12 #define SERVER_TYPE 0   /* zero for stock Citadel/UX; other developers please
13                            obtain SERVER_TYPE codes for your implementations */
14
15 #undef  tolower
16 #define tolower(x)      ( ((x>='A')&&(x<='Z')) ? (x+'a'-'A') : x )
17 #define strucmp(lstr,rstr) struncmp(lstr,rstr,32767)
18 #define NEW_CONFIG
19
20 /* 
21  * The only typedef we do is an 8-bit unsigned, for screen dimensions.
22  * All other defs are done using standard C types.  The code assumes that
23  * 'int' 'unsigned' and 'short' are at least 16 bits, and that 'long' is at
24  * least 32 bits.  There are no endian dependencies in any of the Citadel
25  * programs.
26  */
27 typedef unsigned char CIT_UBYTE;
28
29 struct config {
30         char c_nodename[16];            /* UUCP and Citadel nodename        */
31         char c_fqdn[64];                /* Fully Qualified Domain Name      */
32         char c_humannode[21];           /* Long name of system              */
33         char c_phonenum[16];            /* Dialup number of system          */
34         int c_bbsuid;                   /* UID of the bbs-only user         */
35         int c_pwcrypt;                  /* password encryption seed         */
36         char c_creataide;               /* room creator = room aide  flag   */
37         int c_sleeping;                 /* watchdog timer setting           */
38         char c_initax;                  /* initial access level             */
39         char c_regiscall;               /* call number to register on       */
40         char c_twitdetect;              /* twit detect flag                 */
41         char c_twitroom[20];            /* twit detect msg move to room     */
42         int c_defent;                   /* command generated by <E> key     */
43         char c_moreprompt[80];          /* paginator prompt                 */
44         char c_restrict;                /* restrict Internet mail flag      */
45         long c_msgbase;                 /* size of message base             */
46         char c_bbs_city[32];            /* city and state you are located in*/
47         char c_sysadm[26];              /* name of system administrator     */
48         char c_bucket_dir[15];          /* bit bucket for files...          */
49         int c_setup_level;              /* what rev level we've setup to    */
50         int c_maxsessions;              /* maximum concurrent sessions      */
51         char c_net_password[20];        /* system net password              */
52         int c_port_number;              /* TCP port to run the server on    */
53         int c_ipgm_secret;              /* Internal program authentication  */
54         };
55
56 #define NODENAME                config.c_nodename
57 #define FQDN                    config.c_fqdn
58 #define HUMANNODE               config.c_humannode
59 #define PHONENUM                config.c_phonenum
60 #define BBSUID                  config.c_bbsuid
61 #define PWCRYPT                 config.c_pwcrypt
62 #define CREATAIDE               config.c_creataide
63 #define INITAX                  config.c_initax
64 #define REGISCALL               config.c_regiscall
65 #define TWITDETECT              config.c_twitdetect
66 #define TWITROOM                config.c_twitroom
67 #define MORE_PROMPT             config.c_moreprompt
68 #define RESTRICT_INTERNET       config.c_restrict
69 #define MM_FILELEN              config.c_msgbase
70
71 struct usersupp {                       /* User record                      */
72         int USuid;                      /* userid (==BBSUID for bbs only)   */
73         char password[20];              /* password (for BBS-only users)    */
74         long lastseen[MAXROOMS];        /* Last message seen in each room   */
75         char generation[MAXROOMS];      /* Generation # (for private rooms) */
76         char forget[MAXROOMS];          /* Forgotten generation number      */
77         long mailnum[MAILSLOTS];        /* Message #'s of each mail message */
78         long mailpos[MAILSLOTS];        /* Disk positions of each mail      */
79         unsigned flags;                 /* See US_ flags below              */
80         int timescalled;                /* Total number of logins           */
81         int posted;                     /* Number of messages posted (ever) */
82         char fullname[26];              /* Name for Citadel messages & mail */
83         char axlevel;                   /* Access level                     */
84         CIT_UBYTE USscreenwidth;        /* Screen width                     */
85         CIT_UBYTE USscreenheight;       /* Screen height                    */
86         char spare[1];                  /* spare bytes in the user account  */
87         long usernum;                   /* Eternal (non-recycled) user num  */
88         long lastcall;                  /* Last time the user called        */
89         char USname[30];                /* Real name (i.e. not a handle)    */
90         char USaddr[25];                /* Street address                   */
91         char UScity[15];                /* Municipality                     */
92         char USstate[3];                /* State or province                */
93         char USzip[10];                 /* ZIP code                         */
94         char USphone[11];               /* Voice telephone number           */
95         char USemail[32];               /* E-mail address (elsewhere)       */
96         int logged_time;                /* (Not yet implemented)            */
97         int time_limit;                 /* (Not yet implemented)            */
98         };
99
100
101 /* this is a mask for all of the bits the user is allowed to change */
102 #define US_USER_SET     (US_LASTOLD | US_EXPERT | US_UNLISTED | \
103                         US_NOPROMPT | US_DISAPPEAR | US_PAGINATOR | US_FLOORS)
104
105 /****************************************************************************
106  * This is the control record for the message base... 
107  */
108 struct CitControl {
109         long MMhighest;                 /* highest message number in file   */
110         unsigned MMflags;               /* Global system flags              */
111         long MMnextuser;                /* highest user number on system    */
112         };
113
114 /* Bits which may appear in CitControl.MMflags.  Note that these don't
115  * necessarily pertain to the message base -- it's just a good place to
116  * store any global flags.
117  */
118 #define MM_VALID        4               /* New users need validating        */
119
120 /****************************************************************************
121  * Information returned when a message is written to the message base
122  */
123 struct smreturn {                       /* Return from the send_message()   */
124         long smnumber;                  /* Message number (if sent)         */
125         long smpos;                     /* Position in file (if sent)       */
126         int smerror;                    /* Error code                       */
127         };
128
129 /****************************************************************************
130  * Room records
131  */
132 struct quickroom {
133         char QRname[20];                /* Max. len is 19, plus null term   */
134         char QRpasswd[10];              /* Only valid if it's a private rm  */
135         long QRroomaide;                /* User number of room aide         */
136         long QRhighest;                 /* Highest message NUMBER in room   */
137         char QRgen;                     /* Generation number of room        */
138         unsigned QRflags;               /* See flag values below            */
139         char QRdirname[15];             /* Directory name, if applicable    */
140         long QRinfo;                    /* Info file update relative to msgs*/
141         char QRfloor;                   /* Which floor this room is on      */
142         };
143
144
145 /* Private rooms are always flagged with QR_PRIVATE. If neither QR_PASSWORDED
146  * or QR_GUESSNAME is set, then it is invitation-only. Passworded rooms are
147  * flagged with both QR_PRIVATE and QR_PASSWORDED while guess-name rooms are
148  * flagged with both QR_PRIVATE and QR_GUESSNAME. DO NOT set all three flags.
149  *
150  ****************************************************************************/
151
152 struct fullroom {
153         long FRnum[MSGSPERRM];          /* Message NUMBERS                  */
154         long FRpos[MSGSPERRM];          /* Message POSITIONS in master file */
155                 };
156
157 /* This structure is not 'circular'. When scrolling, each message moves
158  * down a slot, and the oldest one falls off the bottom. A null message is 
159  * represented by the value 0L in both fields.
160  */
161
162 struct calllog {
163         char CLfullname[30];            /* Name of user                     */
164         long CLtime;                    /* Date/time of record              */
165         unsigned CLflags;               /* Info on record                   */
166         };
167
168 #define CL_CONNECT      8               /* Connect to server                */
169 #define CL_LOGIN        16              /* CLfullname logged in             */
170 #define CL_NEWUSER      32              /* CLfullname is a new user         */
171 #define CL_BADPW        64              /* Bad attempt at CLfullname's pw   */
172 #define CL_TERMINATE    128             /* Logout - proper termination      */
173 #define CL_DROPCARR     256             /* Logout - dropped carrier         */
174 #define CL_SLEEPING     512             /* Logout - sleeping                */
175 #define CL_PWCHANGE     1024            /* CLfullname changed passwords     */
176
177 /* Miscellaneous                                                            */
178
179 #define MES_NORMAL      65              /* Normal message                   */
180 #define MES_ANON        66              /* "****" header                    */
181 #define MES_AN2         67              /* "Anonymous" header               */
182
183 #define M_ERROR         (-1)    /* Can't send message due to bad address   */
184 #define M_LOCAL         0       /* Local message, do no network processing */
185 #define M_INTERNET      1       /* Convert msg and send as Internet mail   */
186 #define M_BINARY        2       /* Process recipient and send via C/UX net */
187
188 /****************************************************************************/
189
190 struct recentmsg {
191         char RMnodename[10];
192         long RMnum;                     /* Number or time of message        */
193         };
194
195
196 /****************************************************************************
197  *
198  * Floor record.  The floor number is implicit in its location in the file.
199  */
200 struct floor {
201         unsigned short f_flags;         /* flags */
202         char f_name[256];               /* name of floor */
203         int f_ref_count;                /* reference count */
204         int f_reserved;                 /* for future use */
205         };
206
207 #define F_INUSE         1               /* floor is in use */
208
209
210 /****************************************************************************
211  * Values used internally for function call returns, etc.
212  */
213
214 #define NEWREGISTER     0               /* new user to register */
215 #define REREGISTER      1               /* existing user reregistering */
216
217 #define READ_HEADER     2
218 #define READ_MSGBODY    3
219
220 /* commands we can send to the sttybbs() routine */
221 #define SB_NO_INTR      0               /* set to bbs mode, i/q disabled */
222 #define SB_YES_INTR     1               /* set to bbs mode, i/q enabled */
223 #define SB_SAVE         2               /* save settings */
224 #define SB_RESTORE      3               /* restore settings */
225
226 #define NEXT_KEY        15
227 #define STOP_KEY        3
228
229 /* server exit codes */
230 #define EXIT_NORMAL     0               /* server terminated normally */
231                                         /* 1 through 63 reserved for signals */
232 #define EXIT_NULL       64              /* EOF on server command input */
233
234 /* citadel.rc stuff */
235 #define RC_NO           0               /* always no */
236 #define RC_YES          1               /* always yes */
237 #define RC_DEFAULT      2               /* setting depends on user config */
238
239 /* keepalives */
240 #define KA_NO           0               /* no keepalives */
241 #define KA_YES          1               /* full keepalives */
242 #define KA_CHAT         2               /* half keepalives (for chat mode) */
243
244 /* for <;G>oto and <;S>kip commands */
245 #define GF_GOTO         0               /* <;G>oto floor mode */
246 #define GF_SKIP         1               /* <;S>kip floor mode */
247 #define GF_ZAP          2               /* <;Z>ap floor mode */
248
249 /* message transfer formats */
250 #define MT_CITADEL      0               /* Citadel proprietary */
251 #define MT_RFC822       2               /* RFC822 */
252 #define MT_RAW          3               /* IGnet raw format */