-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathBBS.C
425 lines (385 loc) · 10.8 KB
/
BBS.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
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
#include <stdio.h>
#include <ctype.h>
#include <bbs.h>
#include <mail.h>
/* Log off the system. Put logoff stuff in the log files, disconnect, and
force termination with a frc_abort() to return to the main. */
logoff(code)
int code;
{
char buff[20];
int f;
if (mode == FIDO) {
if (userflag) {
f= _xopen("user.bbs",2);
if (f == -1) {
mprintf("ERROR: No user list!\r\n");
code= 1;
} else {
user-> time+= minutes; /* accumulate time on, */
user-> msg= msgnum; /* save last selected */
user-> files= pathnum; /* directories, */
strcpy(user-> ldate,date); /* last time called, */
_xseek(f,userpos,0); /* proper place, */
_xwrite(f,user,sizeof(struct _usr)); /* update, */
_xclose(f);
}
sysnum= -1; /* ??? force reading of file */
system(0,0); /* read main system file, */
++sys-> caller; /* update caller number, */
system(1,0); /* write back out, */
}
if (cmtflag) {
lprintf("\r\nAccum DL %uK, Total DL %uK, Total UL %uK\r\n",
user-> dnldl,user-> dnld,user-> upld);
lprintf("Accum. time %u min\r\n",user-> time);
gtod(buff);
lprintf("%s off at %s.\r\n",user-> name,buff);
}
}
if (test) doscode= 1;
frc_abort();
}
/* Change the user record. */
change(s)
char *s;
{
char buf[10],ans[20],work[80];
int i,f;
do {
line= 0;
mprintf("----- Change User -----\r\n");
user_credit();
mprintf("User name : %s\r\n",user-> name);
mprintf("City, ST : %s\r\n",user-> city);
mprintf("Password : %s\r\n",user-> pwd);
mprintf("Help Level: ");
switch(user-> help) {
case 0: /* old pre v7 levels */
case 1:
user-> help= NOVICE;
case NOVICE:
mprintf("NOVICE\r\n");
break;
case REGULAR:
mprintf("REGULAR\r\n");
break;
case EXPERT:
mprintf("EXPERT\r\n");
break;
}
mprintf("----- Your Screen -----\r\n");
mprintf("Nulls : %u\r\n",user-> nulls);
mprintf("\"More?\" : %s\r\n", (user-> more ? "ON" : "OFF"));
mprintf("Width : %u columns\r\n",user-> width);
mprintf("Length : %u lines\r\n",user-> len);
mprintf("Tabs : %s\r\n",(user-> tabs ? "ON" : "OFF"));
if (user-> help > REGULAR)
mprintf("Change:\r\n");
if (user-> help > EXPERT)
mprintf("User-Name City Password Help-Level\r\n");
mprintf("Nulls More Width Length Tabs Quit ?\r\n");
getfield(buf,"U C P H N M W L T Q ?: ",0,1,10,1);
if (cmd_abort(buf)) break; /* terminate if Q or blank */
switch(*buf) {
case 'H':
i= 0;
while (i == 0) {
mprintf("----- Set Help Level -----\r\n");
mprintf("1 ... No Help. Expert.\r\n");
mprintf("2 ... Some Help. Experienced.\r\n");
mprintf("3 ... Full Help. Novice.\r\n");
getfield(buf,"Pick One: ",0,1,10,1);
switch(*buf) {
case 'N':
case '1':
i= EXPERT;
break;
case 'S':
case '2':
i= REGULAR;
break;
case 'F':
case '3':
i= NOVICE;
break;
case 'Q':
case '\0':
i= user-> help;
break;
}
}
user-> help= i;
break;
case 'U':
getfield(work,"New name, 1 or 2 words: ",0,2,36,1);
if (strlen(work) == 0) break;
if (strcmp(work,user-> name) == 0) break;
mprintf("Checking the users list, please wait ...");
i= 0; /* name not found yet, */
f= _xopen("user.bbs",0);
if (f == -1) {
mprintf("ERROR: User list is bad\r\n");
doscode= 1;
frc_abort();
}
while (_xread(f,userx,sizeof(struct _usr)) == sizeof(struct _usr)) {
if (strcmp(work,userx-> name) == 0) {
i= 1; /* found name, */
break;
}
}
_xclose(f);
if (i) mprintf("\r\nThat name already exists. Choose another.\r\n");
else {
mprintf("\r\nNew name is OK\r\n");
strcpy(user-> name,work);
}
break;
case 'P':
getfield(user-> pwd,"New password, 1 word: ",1,1,14,1);
break;
case 'C':
getfield(user-> city,"City and two letter state: ",0,3,35,1);
break;
case 'N':
getfield(ans,"Number of nulls (0 - 20): ",0,1,10,1);
if (cmd_abort(ans)) break;
i= atoi(ans);
if ((i > 20) || (i < 0))
mprintf("Must be 0 to 20.\r\n");
else
user-> nulls= i;
break;
case 'L':
getfield(ans,"Lines on Screen (16 - 66): ",0,1,10,1);
if (cmd_abort(ans)) break;
i= atoi(ans);
if ((i < 16) || (i > 66))
mprintf("Must be 16 to 66\r\n");
else
user-> len= i;
break;
case 'W':
getfield(ans,"Screen Width (20 - 80): ",0,1,10,1);
if (cmd_abort(ans)) break;
i= atoi(ans);
if ((i < 20) || (i > 80))
mprintf("Must be 20 to 80\r\n");
else
user-> width= i;
break;
case 'T':
user-> tabs^= 1; /* toggle */
break;
case 'M':
user-> more^= 1; /* toggle */
break;
case '?':
hlpmsg("c");
break;
}
} while (*buf != '\0');
}
/* List all the users on the system. */
users(p)
char *p;
{
int f;
f= _xopen("user.bbs",0);
if (f == -1) {
mprintf("ERROR: Cannot find the user file!\r\n");
doscode= 1;
frc_abort();
}
line= 0;
abort= 0;
while (!abort) {
if (line == 0)
mprintf("%-30s %-20s %s\r\n","Name","Last called","City");
if (_xread(f,userx,sizeof(struct _usr)) != sizeof(struct _usr))
break;
mprintf("%-30s %-20s %s\r\n",userx-> name,userx-> ldate,userx-> city);
}
_xclose(f);
mcrlf();
}
/* Sysop command. Test modem timeout. */
mtest(p)
char *p;
{
int i;
mprintf("Strike any key");
mconin();
mcrlf();
for (i= 0; i < 10; i++) {
modin(100);
mprintf("%d ",i + 1);
}
mprintf("\07");
}
/* System operator command. Change the path(s) in the system file. Obviously
to be used with great care. */
spath(p,path)
char *p,*path;
{
int n;
char s[80];
strcpy(s,path); /* strip off possible */
if (strlen(s) > 0) { /* trailing / from it */
s[strlen(s) - 1]= '\0';
}
if (isdigit(*p)) {
n= atoi(p);
if (n > sysfiles + 1)
mprintf("Illegal system file number!\r\n");
else {
if (n == sysfiles + 1) mprintf("New system file\r\n");
system(0,n); /* select or create system file, */
}
msgnum= n; /* force selection, */
pathnum= n;
mprintf("Wait ...\r\n");
syscount(); /* recount the system files, */
msgcount(); /* recount messages */
}
mprintf("System file #%u\r\n",sysnum); /* say which one, */
if (*p == 'm')
strcpy(sys-> msgpath,path);
else if (*p == 'f')
strcpy(sys-> filepath,path);
else if (*p == 'b')
strcpy(sys-> bbspath,path);
else if (*p == 'h')
strcpy(sys-> hlppath,path);
else if (*p == 'm')
strcpy(sys-> msgpath,path);
else if (*p == 'u')
strcpy(sys-> uppath,path);
else if (*p == 'r') /* restore original contents */
system(0,sysnum);
else if (*p == 's')
system(1,sysnum); /* write out new contents, */
else if (*p == 'v')
setpriv(s,&sys-> priv); /* set min. privelege */
else if (*p == 'a')
sys-> attrib= atoi(s); /* set attribute */
/* else if (*p == '?') {
mprintf("1 <path>\\F, B, M, H for Files, BBS, Msg, or Help paths,\r\n");
mprintf("1 <number> to change or create a new system file,\r\n");
mprintf("1 <priv>\\V to set the privelege level, where <priv> is\r\n");
mprintf("1 <number>\\A to set attributes. Current attributes are:\r\n");
mprintf(" 1 == MAIL area. Use 0 to clear.\r\n");
mprintf("1 S to Save the new contents of this system file, \r\n");
mprintf("1 R to Restore the original contents of this system file.\r\n");
mprintf(" TWIT, DISGRACE, NORMAL, PRIVEL, EXTRA, SYSOP\r\n");
mcrlf();
} */ else {
mprintf("Minimum Privelege: ");
getpriv(sys-> priv);
mprintf("\r\nBBS path: %s\r\nMSG path: %s",
sys-> bbspath,sys-> msgpath);
if (sys-> attrib & SYSMAIL) mprintf(" MAIL Section\r\n");
else mprintf(" MSG Section\r\n");
mprintf("HELP path: %s\r\nFILE path: %s\r\nUPLD path: %s\r\n",
sys-> hlppath,sys-> filepath,sys-> uppath);
}
}
/* Display and change the MAIL.SYS file. */
setmail(p,path)
char *p,*path;
{
float f;
int n;
char s[80];
switch(*p) {
case 'p':
strcpy(mail.mailpath,path);
break;
case 'f':
strcpy(mail.filepath,path);
break;
case 'n':
mail.node= atoi(path);
break;
case '?':
mprintf("FidoNet node parameters:\r\n");
mprintf("4 <number\\N sets this node number (1 - 32767)\r\n");
mprintf("4 <path>\\P sets the mail path\r\n");
mprintf("4 <path>\\F sets the mail file path\r\n");
break;
}
mprintf("\r\nFidoNet Parameters:\r\n");
mprintf("FidoNet Node : FIDO%u\r\n",mail.node);
/* sprintf(s,"Cost Fudge Factor : %f\r\n",mail.fudge);
mputs(s);
*/ mprintf("Mail Directory : %s\r\n",mail.mailpath);
mprintf("Mail File Directory: %s\r\n",mail.filepath);
strcpy(s,sys-> bbspath);
strcat(s,"mail.sys");
n= _xopen(s,2);
_xwrite(n,&mail,sizeof(mail));
_xclose(n);
}
/* List the free disk space. */
freespace()
{
unsigned i[4];
char f[80];
long n1,n2;
_free(0,i); /* get disk stuff, */
n1= i[3]; n1*= i[2]; n1*= i[0]; /* total clust * bytes/sec * secs/clust */
n2= i[1]; n2*= i[2]; n2*= i[0]; /* free clust * bytes/sec * secs/clust */
mprintf("%lu bytes total disk space, %lu free.\r\n",n1,n2);
}
/* List the users statistics. */
stats() {
char tod[20];
int kleft,dleft,tleft,lim;
gtod(tod);
mprintf("%s, on for ",tod);
min_time((minutes * 60) + seconds);
mprintf(" mins.\r\nYour "); nth(user-> times);mprintf(" call\r\n");
tleft= limit - minutes; if (tleft < 0) tleft= 0;
dleft= dlimit - user-> time; if (dleft < 0) dleft= 0;
kleft= klimit - user-> dnldl; if (kleft < 0) kleft= 0;
mprintf(" | Total Today Limit Left\r\n");
mprintf("------------+------------------------\r\n");
mprintf("Downloaded: | %4u %4u %4u %4u Kbytes\r\n",user-> dnld,user-> dnldl,klimit,kleft);
mprintf("Uploaded: | %4u Kbytes\r\n",user-> upld);
mprintf("This call: | %4u %4u %4u Min.\r\n",minutes,limit,tleft);
mprintf("Per 48 Hrs: | %4u %4u %4u Min.\r\n",user-> time,dlimit,dleft);
}
/* User logoff command. */
goodbye(p)
char *p;
{
int n;
char work[80];
p= skip_delim(p);
cpyarg(work,p);
if (! *p) {
mprintf("Leave a private message to the sysop? (y,n): ");
getstring(work);
mcrlf();
}
if (tolower(*work) == 'y') {
n= msgnum; /* save msg path, */
msgnum= 0;
system(0,msgnum); /* put in area 0, */
mprintf("Wait ...\r\n");
msgcount();
msend("Sysop",0,1); /* get a message */
msgnum= n;
system(0,msgnum); /* reselect orig. area */
}
gtod(work);
mprintf("Logging %s off at %s. Hang up now.\r\n",user-> name,work);
logoff(0);
}
/* Display the users credit and debits. */
user_credit() {
mprintf("You have ");
dollar(user-> credit); mprintf(" credit, ");
dollar(user-> debit); mprintf(" charges pending.\r\n");
}