-
Notifications
You must be signed in to change notification settings - Fork 0
/
CTDL.C
376 lines (331 loc) · 11.2 KB
/
CTDL.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
/************************************************************************
* ctdl.c
* Command-interpreter code for Citadel
************************************************************************/
#define MAIN
#include <string.h>
#include <time.h>
#include "ctdl.h"
#ifndef ATARI_ST
#include <dos.h>
#include <conio.h>
#endif
#include "keywords.h"
#include "proto.h"
#include "global.h"
unsigned int _stklen = 1024 * 18;
/* unsigned int _ovrbuffer = 0x800; */
void interrupt ( *oldhandler)(void);
extern void interrupt criterr(unsigned bp,unsigned si,unsigned ds,unsigned es,unsigned dx,
unsigned cx,unsigned bx,unsigned ax);
/************************************************************************
* Contents
*
* main() has the central menu code
*
************************************************************************/
/* --------------------------------------------------------------------
* Version control log:
* $Log: D:/VCS/FCIT/CTDL.C_V $
*
* Rev 1.51 01 Nov 1991 11:19:50 FJM
* Added gl_ structures
*
* Rev 1.50 21 Sep 1991 10:18:34 FJM
* FredCit release
*
* Rev 1.49 08 Jul 1991 16:18:12 FJM
* Changed cron looping.
*
* Rev 1.48 15 Jun 1991 8:37:06 FJM
*
* Rev 1.47 06 Jun 1991 9:18:38 FJM
*
* Rev 1.46 27 May 1991 11:41:42 FJM
*
* Rev 1.45 22 May 1991 2:15:14 FJM
* Made memory check optional.
*
* Rev 1.44 06 May 1991 17:28:26 FJM
* Added new prompt code.
*
* Rev 1.42 19 Apr 1991 23:26:22 FJM
* Rev 1.41 17 Apr 1991 12:55:06 FJM
* Rev 1.35 10 Feb 1991 17:32:50 FJM
* Changes to shell mode carrier detect.
*
* Rev 1.33 05 Feb 1991 14:31:04 FJM
* Rev 1.32 28 Jan 1991 13:10:42 FJM
* Rev 1.30 19 Jan 1991 14:14:48 FJM
* Added time display, and properly init parm struct.
*
* Rev 1.25 13 Jan 1991 0:30:46 FJM
* Name overflow fixes.
*
* Rev 1.23 11 Jan 1991 12:42:52 FJM
* Rev 1.22 06 Jan 1991 16:49:46 FJM
* Added -l parameter. Made -d work.
*
* Rev 1.19 06 Jan 1991 12:45:02 FJM
* Porting, formating, fixes and misc changes.
*
* Rev 1.18 27 Dec 1990 20:16:30 FJM
* Changes for porting.
*
* Rev 1.15 22 Dec 1990 13:38:58 FJM
* Rev 1.10 16 Dec 1990 18:12:52 FJM
* Rev 1.8 07 Dec 1990 23:10:08 FJM
* Rev 1.6 24 Nov 1990 3:07:24 FJM
* Changes for shell/door mode.
*
* Rev 1.5 23 Nov 1990 18:24:06 FJM
* Changes to login for shell mode.
*
* Rev 1.4 23 Nov 1990 13:22:38 FJM
* Rev 1.2 17 Nov 1990 16:11:38 FJM
* Added version control log header
*
* --------------------------------------------------------------------
*
* Early History:
*
* 03/08/90 {zm} Add 'softname' as the name of the software.
* 03/15/90 {zm} Add [title] name [surname], 30 characters long.
* 03/19/90 FJM Linted & partial cleanup
* 05/15/90 FJM Changed Next/previous room/hall prompts
* 05/17/90 FJM Added external commands
* 05/18/90 FJM Made = an alias for + at room prompt
* 05/20/90 FJM Improved external commands. Message if can't enter
* surname. Made NOCHAT.BLB,NOCHAT1.BLB... cycle
* 06/06/90 FJM Changed strftime to cit_strftime
* 06/15/90 FJM Added option for modem output pacing, -p.
* Added help display if incorrect option.
* Mods for running from another BBS as a door.
* 06/16/90 FJM Made IBM Graphics characters a seperate option.
* 06/20/90 FJM Moved most functions to COMMAND.C
* 07/22/90 FJM Added -b (baud) option.
* 07/23/90 FJM Added -v (events) option.
* 07/24/90 FJM Increased overlay buffer size from 22k to 32k.
* -------------------------------------------------------------------- */
/************************************************************************
* Local function definitions for CTDL.C
************************************************************************/
static void command_loop(void);
/************************************************************************
* command_loop() contains the central menu code
************************************************************************/
static void command_loop(void)
{
char c, more = FALSE, help = FALSE;
int i;
while (!ExitToMsdos) {
if (sysReq && !loggedIn && !haveCarrier) {
sysReq = FALSE;
if (cfg.offhook) {
offhook();
} else {
drop_dtr();
}
ringSystemREQ();
}
if (parm.door) {
if (!loggedIn && cfg.forcelogin) {
for (i = 0; !loggedIn && i < 4; ++i)
doLogin(2);
if (!loggedIn) {
ExitToMsdos = 1;
break;
}
}
}
more = getCommand(&c);
outFlag = IMPERVIOUS;
if (chatkey)
chat();
if (eventkey && !haveCarrier) {
do_cron(CRON_TIMEOUT);
eventkey = FALSE;
}
if (sysopkey)
help = doSysop();
else
help = doRegular(more, c);
if (help) {
if (!gl_user.expert)
mPrintf("\n '?' for menu, 'H' for help.\n \n");
else
mPrintf(" ?\n \n");
}
}
}
/************************************************************************
* main() Initialize & start citadel
************************************************************************/
void main(int argc, char *argv[])
{
int i, cfg_ctdl = FALSE;
long b;
char init_baud;
static char prompt[92];
char *envprompt;
cfg.bios = 1;
cit_init_timer(); /* initialize cit_time() and cit_timer() */
cfg.attr = 7; /* logo gets white letters */
setscreen(); /* initialize screen system */
memset(&parm,0,sizeof(parm));
for (i = 1; i < argc; i++) {
if (argv[i][0] == '/'
|| argv[i][0] == '-') {
switch (tolower(argv[i][1])) {
#ifndef ATARI_ST
case 'd': /* DesqView/TopView */
parm.dv = 1;
cPrintf("DesqView/TopView mode\n");
break;
case 'b': /* baud rate (for shell) */
if (argv[i + 1]) {
b = atol(argv[++i]);
for (init_baud = 0; bauds[init_baud]; ++init_baud)
if (bauds[init_baud] == b) {
parm.baud = init_baud;
cPrintf("Initial baud rate fixed at %ld\n", b);
break;
}
}
break;
case 'm':
parm.memcheck = !parm.memcheck;
break;
#endif
case 'c': /* Configure system */
cfg_ctdl = TRUE;
break;
case 'p': /* pace output */
if (argv[i + 1]) {
parm.pace = atoi(argv[++i]);
cPrintf("Output pacing %d\n", parm.pace);
}
break;
case 's': /* run in shell from another BBS (door). */
cPrintf("Shell mode\n");
parm.door = TRUE;
break;
/*#ifndef ATARI_ST*/
#ifndef FLOPPY
case 'e': /* use EMS */
if (_OvrInitEms(0, 0, 0)) {
cPrintf("EMS memory initialization failed!\n");
parm.ems = 1;
}
break;
#endif
/*#endif*/
case 'v': /* just do events */
parm.events = 1;
break;
/*#ifndef ATARI_ST*/
#ifndef FLOPPY
case 'x': /* use exteneded memory */
if (_OvrInitExt(0, 0))
cPrintf("Extended memory initialization failed!\n");
parm.ext = 1;
break;
#endif
/*#endif*/
case 'l': /* log in user */
if (argv[i + 1]) {
parm.login = argv[++i];
cPrintf("Auto-login\n");
}
break;
case 'u': /* log in user */
if (argv[i + 1]) {
parm.user = argv[++i];
cPrintf("Auto-login %s\n", parm.user);
}
break;
default:
cPrintf("\nUnknown commandline switch '%s'.\n", argv[i]);
cPrintf("Valid DOS command line switches:\n");
cPrintf(" -b baud Starting baud rate (300-19200)\n");
cPrintf(" -c Read configuration files\n");
cPrintf(" -d DesqView/TopView\n");
#ifndef FLOPPY
cPrintf(" -e Use EMS memory for overlays\n");
#endif
cPrintf(" -l str Log in using initials;password in str\n");
cPrintf(" -m Memory check during idle time, start\n");
cPrintf(" -p num Set output pacing to num\n");
cPrintf(" -s Run as a shell from another BBS\n");
cPrintf(" -u 'name' Log in using specifed user name");
cPrintf(" -v Just run cron events\n");
#ifndef FLOPPY
cPrintf(" -x Use extended memory for overlays (386/486 only!)\n");
#endif
exit(1);
}
}
}
if (cfg_ctdl) /* force reconfigure? */
unlink("etc.tab");
logo(); /* prints out system logo */
if (cit_time() < 607415813L) {
cPrintf("\n\nPlease set your time and date!\n");
exit(1);
}
/* set prompt for shells */
envprompt = getenv("PROMPT");
if (!envprompt)
envprompt = "$p$g";
sprintf(prompt, "PROMPT=\r\nType EXIT to return to FredCit\r\n%s", envprompt);
if (putenv(prompt)) {
cPrintf("\n\nCan not set DOS prompt!\n");
delay (5000);
}
/* initialize citadel */
initCitadel();
if (parm.baud) {
cfg.initbaud = parm.baud;
baud(cfg.initbaud);
}
if (parm.door) {
detectflag = 1;
// carrier();
// if (haveCarrier) {
// carrdetect();
// newCarrier = 1; /* make hello blurb show up */
// }
}
greeting();
sysReq = FALSE;
if (cfg.f6pass[0])
ConLock = TRUE;
if (parm.dv) {
cfg.bios = 1;
directvideo = 0;
}
if (parm.login) {
normalizeString(parm.login); /* normalize string in environment */
login(parm.login,NULL);
} else if (parm.user && !loggedIn) {
normalizeString(parm.user); /* normalize string in environment */
if (findPerson(parm.user, &lBuf) != ERROR)
login(lBuf.lbin,lBuf.lbpw);
}
/* read in door interface files */
if (parm.door) {
readDoorFiles(0);
}
/* update25(); */
do_idle(0);
/* install critical error handler */
harderr(cit_herror_handler);
/* execute main command loop */
if (!parm.events)
command_loop();
else {
do_cron_loop();
}
exitcitadel();
}
/* EOF */