-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPROTOCOL.PAS
162 lines (146 loc) · 4.17 KB
/
PROTOCOL.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
{$R-,S-,I-,D-,F+,V-,B-,N-,L+,O+ }
Unit Protocol;
{/ protocol selection/execution routines /}
Interface
Uses GenTypes;
Function ExecProto (X:Byte; Fn:AnyStr; UploadDir:Lstr) : Integer;
Implementation
Uses Dos, Crt, GenSubs, ConfigRt, Windows, StatRet, Modem,
Subs1, Subs2, FileLock;
Function PickProto(X:Byte) : String;
Label Retry;
Const Filez : Array[1..4] Of String[6] =
('PROT_R','PROT_S','PROT_U','PROT_D');
Var P : ProtoRec;
FP: File Of ProtoRec;
K : String[15];
E : Boolean;
Begin
PickProto := '';
If Not Exist(Cfg.DataDir + Filez[x] + '.DAT') Then Begin
SendCr(^M^G^R'Protocol File '^A+Filez[x]+'.DAT'^R' not found!');
Exit;
End;
ASSiGN(FP,Cfg.DataDir + Filez[x] + '.DAT');
Reset(FP);
K[0] := #0;
E := Exist(Cfg.TextFileDir + Filez[x] + '.ANS');
Seek(FP,0);
While Not Eof(Fp) Do Begin
nRead(FP,P);
If Not E Then
SendCr(^R'['^A+P.Letter+^R'] '^S+P.Desc);
K := K + Upcase(P.Letter);
End;
Retry :
Inpt[0] := #0;
Buflen := 1;
If Not E Then
WriteStr(^M^R'Protocol Selection; ['^A'Q'^R']uit; '+
+'['^A'Cr/'+Urec.DefProto+^R']: *')
Else
InputFile(Cfg.TextFileDir+Filez[x]+'.ANS');
If Inpt = ''
THEN IF POS(Urec.DefProto,K) > 0
Then Inpt[1] := Upcase(Urec.DefProto)
Else Inpt[1] := 'Q';
If Upcase(Inpt[1]) = 'Q' Then Begin
PickProto := '';
Close(Fp);
AnsiCls;
SendCr(^M^S'Aborted...');
Exit;
End;
If Not Pos(Upcase(Inpt[1]),K) > 0 Then Begin
DefYes := True;
WriteStr(^S^R^M'Invalid Selection; Try Again? !');
If Yes Then Goto Retry;
Close(Fp);
PickProto := '';
Exit;
End;
Seek(Fp, (Pos(Upcase(Inpt[1]),K)) - 1);
nRead(Fp,P);
Close(Fp);
PickProto := P.ProgName + #32 + P.CommFmt;
End;
Function ExecProto (X:Byte; Fn:AnyStr; UploadDir:Lstr) : Integer;
Var S : String;
Result : Word;
Procedure MakeCommandLine(Tp:String);
Var Bd,Cb : Sstr;
Ct : Byte;
C : Char;
Begin
Bd := Strr(Cfg.DefBaudRate*100);
Cb := Strr(ConnectBaud);
Ct:=0;
S[0] := #0;
While Ct<>Length(Tp) do
Begin
Inc(Ct);
If Tp[Ct]<>'%' then S:=S+Tp[Ct]
Else if Ct<Length(Tp) then
Begin
Inc(Ct);
C:=Tp[Ct];
Case C of
'1' : S := S + Strr(Cfg.UseCoM);
'2' : S := S + Bd;
'5' : S := S + Cb;
'4' : S := S + Cfg.DszLog;
'3' : S := S + Fn;
'6' : S := S + UploadDir;
End;
End;
End;
End;
Procedure Execute(S : String);
Begin
SwapVectors;
Exec(GetEnv('COMSPEC'),'/C '+S);
SwapVectors;
End;
Procedure WriteStats;
Var U,D : Longint;
Const Which : Array[1..4] Of Sstr
= ('Upload','Download','Batch Upload','Batch Download');
Begin
ClrScr;
GotoXy(1,1);
TextAttr := 31;
ClrEol;
U := Urec.KUp;
D := Urec.KDown;
WriteLn(Unam + ' - '+Which[x]+'; ULs: '+Strr(Urec.Uploads)+
+' ('+Strr(U)+'K) DLs: '+Strr(Urec.Downloads)+' ('+Strr(D)+'K)');
TextAttr:=1;
Execute('TOPLINE.COM');
End;
Begin
S := PickProto(x);
If S = '' Then Begin
ExecProto := -1;
Exit;
End;
MakeCommandLine(s);
WriteStats;
StartTimer(Status.MinutesXfer);
ClosePort;
NukeInput;
NukeOutput;
Execute(S);
Result := DosEXITCode;
InstallFossil;
Result := DosEXITCode;
SetParam;
StopTimer(Status.MinutesXfer);
StartTimer(Status.MinutesUsed);
Execute('TOPLINE.COM');
AnsiReset;
ANSiCLS;
SetUpBottom;
BottomLine;
ExecProto := Result;
End;
end.