-
Notifications
You must be signed in to change notification settings - Fork 0
/
net.pas
336 lines (288 loc) · 6.39 KB
/
net.pas
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
Unit Net;
INTERFACE
Const
Chating : Boolean = FALSE;
Procedure Register (who: String);
Procedure SetWhere (where: String);
Procedure Who (s: String);
Procedure SignOff;
Procedure SendTo (ToWho,what: String);
Procedure ReadSend;
Procedure Mesg (s: String);
Procedure ReadChat;
Procedure SetChat (make: Boolean);
Procedure Chat (what: String);
IMPLEMENTATION
Uses
BFiles,
DOS,
Misc,
Modem,
Red;
Var
NetPath,
LegalName: String;
Procedure DefineName(Var who: String;setiraj: Boolean);
Var
Len,
Count : Byte;
Begin
NetPath:=GetEnv('SONIC_BBS')+'\NET\';
Len:=Ord(who[0]);
If (Len>8) Then Begin
who:=Copy(who,1,8);
Len:=8;
End;
Count:=1;
While Count<=Len do
Case who[Count] Of
'.' : who[Count]:='-';
Else Inc(Count);
End;
If Setiraj Then LegalName:=NetPath+who;
End; {DefineUserAutoExec}
Procedure Register (who: String);
Var
F: Text;
Begin
DefineName (who,TRUE);
Assign (F,NetPath+who+'.ON'); (* za online i who *)
Rewrite (F);
WriteLn (F,Misc.Username);
WriteLn (F,Misc.Stat ('TI'));
Close (F);
Assign (F,NetPath+who+'.SND'); (* za send *)
ReWrite (F);
Close (F);
End;
Procedure SetWhere (where: String);
Var
F: Text;
Begin
Assign (F,LegalName+'.WHR'); (* gdje je gospodin *)
ReWrite (F);
WriteLn (F,where);
Close (F);
End;
Function ShowWhere (ko: String): String;
Var
F: Text;
Line: String;
Begin
ko:=Copy (ko,1,Pos ('.',ko)-1)+'.WHR';
Assign (F,ko);
Reset (F);
ReadLn (F,Line);
ShowWhere:=Line;
Close (F);
End;
Function IsOnLine (who: String):Boolean;
Begin
IsOnLine:=BFiles.FileExists (NetPath+who+'.ON');
End;
Procedure Who (s: String);
Var
DirInfo: SearchRec;
line: String;
ch : Char;
F : Text;
Begin
If Not(Red.CheckRed(s,'WHO.LOG')) Then Exit;
Modem.OutLn (#13+#13+'Username Logged Where');
Modem.OutLn ('========================================');
FindFirst (NetPath+'*.ON',Archive,DirInfo);
While DosError=0 do Begin
Assign (F,NetPath+DirInfo.Name);
Reset (F);
ReadLn (F,line);
Modem.Out (Misc.MakeBlanks(line));
ReadLn (F,line);
Modem.Out (line+' ');
Modem.OutLn (ShowWhere(NetPath+DirInfo.Name));
Close (F);
FindNext (DirInfo);
End;
(*
Podrska za Linux, ko je na Hostu
Sa linuxa cron startuje update_for_dos_bbs
koji , opet:), startuje w.bassman > /dos/disk/e/bbs/net/who.unx
svakih 10minuta, treba vidjeti zasto sporo dolazi do dolazenja
podataka iz linuxa do dos-a...(tj. zasto uopste ne dolazi do
dos-a, ako sam u dosu cijelo vrijeme cron odradi svoje i sve
ok zapise ali ovaj supak od dosemu-a ne konta da su pristigli
novi podaci ... i tako sve dok ne predjem u neki linux tty pa
ga tek dosemu registruje
*)
If Not(FileExists(NetPath+'WHO.UNX')) Then Begin
Modem.OutLn (#10+'Sonic linux host is inactive.');
Red.HandleRedirect;
Exit;
End;
Modem.OutLn (#10+'Sonic linux host is active.');
Assign (F,NetPath+'WHO.UNX');
Reset(F);
While Not(EOF(F)) do Begin
Read (F,ch);
If ch=#10 Then Modem.OutLn ('')
Else Modem.Out (ch);
End;
Close (F);
Red.HandleRedirect;
End;
Procedure SignOff;
Var
F: Text;
Begin
Assign (F,LegalName+'.ON');
{$I-}
Reset (F);
Close (F);
Erase (F);
{$I+}
Assign (F,LegalName+'.SND');
{$I-}
Reset (F);
Close (F);
Erase (F);
{$I+}
Assign (F,LegalName+'.WHR');
{$I-}
Reset (F);
Close (F);
Erase (F);
{$I+}
End;
Procedure SendTo (ToWho,what: String);
Var
orig: String;
F: Text;
Begin
If (ToWho='') Or (what='') Then Exit;
orig:=ToWho;
DefineName (ToWho,FALSE);
If Not(IsOnLine (ToWho)) Then Begin
Modem.OutLn ('User '+Misc.Lower(orig)+' is not on bbs.');
Exit;
End;
Assign (F,NetPath+ToWho+'.SND');
Append (F);
WriteLn (F,Misc.Username+' -> '+what);
Close (F);
End;
Procedure ReadSend;
Var
F: Text;
Line: String;
DirInfo: SearchRec;
Begin
FindFirst (LegalName+'.SND',Archive,DirInfo);
If DirInfo.Size=0 Then Exit;
Assign (F,LegalName+'.SND');
Reset (F);
While Not(Eof(F)) Do Begin
ReadLn (F,line);
If Line<>'' Then Modem.OutLn (Line);
Misc.Prompt;
End;
Reset (F);
ReWrite(F);
Close (F);
End;
Procedure Mesg (s: String);
Begin
If s='' Then Begin
Case Misc.MesgOff Of
TRUE : Modem.OutLn ('Message off');
FALSE : Modem.OutLn ('Message on');
End;
Exit;
End;
If (s='ON') Or (s='YES') Or (s='Y') Or (s='1') Then
Begin
Misc.MesgOff:=FALSE;
Net.SetWhere ('Sonic');
End
Else If (s='OFF') Or (s='NO') Or (s='N') Or (s='0') Then
Begin
Misc.MesgOff:=TRUE;
Net.SetWhere ('Message Off');
End
Else Modem.OutLn ('mesg: Unknown option');
End;
(*
CHAT procedure
*)
Procedure ReadChat;
Var
F: Text;
Line: String;
DirInfo: SearchRec;
Begin
FindFirst (LegalName+'.CHT',Archive,DirInfo);
If DirInfo.Size=0 Then Exit;
Assign (F,LegalName+'.CHT');
Reset (F);
While Not(Eof(F)) Do Begin
ReadLn (F,line);
If Line<>'' Then Modem.OutLn (Line);
End;
Reset (F);
ReWrite(F);
Close (F);
End;
Procedure SetChat (make: Boolean);
Var
F: Text;
Begin
Case make of
TRUE : Begin
Assign (F,LegalName+'.CHT');
ReWrite (F);
Close (F);
Chating:=TRUE;
Misc.ChatPrompt:=TRUE;
Net.Chat ('[User '+Misc.Username+' entering the chat]');
End;
FALSE : Begin
Assign (F,LegalName+'.CHT');
Erase (F);
Chating:=FALSE;
Misc.ChatPrompt:=FALSE;
Modem.OutLn ('[Leaving the chat]');
End;
End;
End;
Procedure Chat (what: String);
Procedure ChatSend (towho,what: String);
Var
F: Text;
Begin
Assign (F,NetPath+ToWho+'.CHT');
Append (F);
WriteLn (F,what);
Close (F);
End;
Const
first : Boolean = TRUE;
Var
DirInfo : SearchRec;
temp : String;
Begin
temp:=Upper(what);
If Not(Chating) Or (what='') Then Exit;
If (temp='.EX') Or (temp='..') Or (temp='.EX') Or (temp='.EXIT') Then Begin
Misc.ChatPrompt:=FALSE;
Net.SetChat (FALSE);
Net.SetWhere ('Sonic');
End;
FindFirst (NetPath+'*.CHT',Archive,DirInfo);
While DosError=0 do Begin
temp:=Copy (DirInfo.Name,1,Pos('.CHT',DirInfo.Name)-1);
If Not(Chating) Then ChatSend (temp,'[User '+Misc.Username+' leaving chat]')
Else If Not(temp=LegalName) Then ChatSend (temp,Misc.Username+' - '+what);
FindNext (DirInfo);
End;
First:=FALSE;
End;
Begin
End.