forked from oldprogs/simplex
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNodeList.pas
More file actions
264 lines (241 loc) · 6.43 KB
/
NodeList.pas
File metadata and controls
264 lines (241 loc) · 6.43 KB
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
unit NodeList;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, JvExStdCtrls, JvListBox, JvExControls, JvComponent,
JvSpecialProgress, ExtCtrls, JvExExtCtrls, JvPanel, ComCtrls,
JvExComCtrls, JvComCtrls, JvLabel, Main, JvStaticText, JvEdit;
type PNodelist = ^RNodelist;
RNodelist = record
data: TNodelistRec;
next: PNodelist;
end;
var LnkNodelist,EndNodelist: PNodelist;
procedure NdlClear;
procedure NdlAdd(entry: TNodelistRec);
function NdlFindAddr(zone,net,node:word;point:word=0):PNodelist;
function NdlInsert(entry:TNodelistRec;after:PNodelist):PNodelist;
type
TNodelistForm = class(TForm)
JvPanel1: TJvPanel;
JvPanel2: TJvPanel;
Tree: TJvTreeView;
NdlInfo: TJvLabel;
NdlAInfo: TJvLabel;
ESearch: TJvEdit;
LSearch: TJvStaticText;
procedure FormCreate(Sender: TObject);
procedure TreeChange(Sender: TObject; Node: TTreeNode);
procedure ESearchChange(Sender: TObject);
procedure TreeKeyPress(Sender: TObject; var Key: Char);
procedure ESearchKeyPress(Sender: TObject; var Key: Char);
private
{ Private declarations }
public
{ Public declarations }
end;
var
NodelistForm: TNodelistForm;
implementation
{$R *.dfm}
uses StrUtils,JclStrings, Language, MkGlobT, Setup;
procedure NdlClear;
var t: PNodelist;
begin
while LnkNodelist<>nil do begin
t:=LnkNodelist.next;
Dispose(LnkNodelist);
LnkNodelist:=t;
end;
EndNodelist:=nil;
end;
procedure NdlAdd(entry: TNodelistRec);
var t,t1:PNodelist;
begin
t:=EndNodelist;
System.New(t1);
if t<>nil then t.next:=t1 else LnkNodelist:=t1;
t1.data:=entry;
t1.next:=nil;
EndNodelist:=t1;
end;
function NdlFindAddr(zone,net,node:word;point:word=0):PNodelist;
var t:PNodelist;
begin
Result:=nil;
t:=LnkNodelist;
if t<>nil then repeat
if (t.data.zone=zone) and (t.data.net=net) and (t.data.node=node)
and (t.data.point=point)
then begin
Result:=t;
break;
end;
t:=t.next;
until t=nil
end;
function NdlInsert(entry:TNodelistRec;after:PNodelist):PNodelist;
var t,t1:PNodelist;
begin
Result:=nil;
if after=nil then Exit;
t:=after;
System.New(t1);
t1.data:=entry;
t1.next:=t.next;
t.next:=t1;
Result:=t1;
end;
procedure TNodelistForm.FormCreate(Sender: TObject);
var PrevRec:TNodelistRec;
czone,cregion,cnet,cnode: TTreeNode;
s:string;
worknodelistbin: file of TNodelistRec;
t:PNodelist;
begin
Caption:=lang.lnodelist;
NdlClear;
if not FileExists(ExtractFilePath(Application.ExeName)+'nodelist.bin') then Exit;
AssignFile(worknodelistbin,ExtractFilePath(Application.ExeName)+'nodelist.bin');
Reset(worknodelistbin);
if not eof(worknodelistbin) then repeat
Read(worknodelistbin,NdlRec);
NdlAdd(NdlRec);
until eof(worknodelistbin);
closefile(worknodelistbin);
t:=LnkNodelist;
Tree.Items.Clear;
if not FileExists(ExtractFilePath(Application.ExeName)+'nodelist.bin') then Exit;
PrevRec.zone:=0;
if t<>nil then repeat
NdlRec:=t.data;
if length(NdlRec.prefix)=0 then s:='' else s:=NdlRec.prefix+', ';
s:=s+inttostr(NdlRec.zone)+':'+inttostr(NdlRec.net)+'/'+inttostr(NdlRec.node);
if NdlRec.point>0 then s:=s+'.'+inttostr(NdlRec.Point);
s:=s+', '+NdlRec.system+', '+ndlRec.sysop;
if PrevRec.zone<>NdlRec.zone then begin
czone:=Tree.Items.AddChildObject(nil,s,t);
cregion:=czone;
cnet:=cregion;
cnode:=cnet;
end
else begin
if NdlRec.Point>0 then NdlRec.region:=PrevRec.region;
if PrevRec.region<>NdlRec.region then begin
cregion:=Tree.Items.AddChildObject(czone,s,t);
cnet:=cregion;
cnode:=cnet;
end
else begin
if PrevRec.net<>NdlRec.net then begin
cnet:=Tree.Items.AddChildObject(cregion,s,t);
cnode:=cnet;
end
else begin
if PrevRec.node<>NdlRec.node then begin
cnode:=Tree.Items.AddChildObject(cnet,s,t);
end
else Tree.Items.AddChildObject(cnode,s,t);
end;
end;
end;
PrevRec:=NdlRec;
t:=t.next;
until t=nil;
end;
procedure TNodelistForm.TreeChange(Sender: TObject; Node: TTreeNode);
var s:string;
at:AddrType;
t:PNodelist;
begin
if Tree.Selected=nil then Exit;
s:=Tree.Selected.Text;
if pos(':',s)<pos(',',s) then
s:=copy(s,1,pos(',',s)-1)
else begin
s:=copy(s,pos(',',s)+2,length(s)-pos(',',s)-1);
s:=copy(s,1,pos(',',s)-1);
end;
NdlInfo.Caption:=s+', ';
NdlAInfo.Caption:='';
ParseAddr(s,at,at);
t:=LnkNodelist;
repeat
NdlRec:=t.data;
if (NdlRec.zone=at.zone) and (NdlRec.net=at.net) and (NdlRec.node=at.node)
and (NdlRec.point=at.point) then break;
t:=t.next;
until t=nil;
if (NdlRec.zone=at.zone) and (NdlRec.net=at.net) and (NdlRec.node=at.node)
and (NdlRec.point=at.point)
then begin
NdlInfo.Caption:=NdlInfo.Caption+NdlRec.system+', '+NdlRec.sysop;
if NdlRec.Prefix<>'' then NdlInfo.Caption:=NdlInfo.Caption+' <'+NdlRec.prefix+'>';
NdlAInfo.Caption:=lang.llocation+': '+NdlRec.location+#13+lang.lphone+': '+NdlRec.phone+
#13+lang.lflags+': '+NdlRec.flags;
end
else begin
NdlInfo.Caption:=NdlInfo.Caption+lang.noinfo;
end;
end;
procedure TNodelistForm.ESearchChange(Sender: TObject);
var at:AddrType;
t:PNodelist;
i:longint;
found:boolean;
begin
found:=false;
if (Pos(':',ESearch.Text)>0) then
if (Pos('/',ESearch.Text)>Pos(':',ESearch.Text)) then begin
ParseAddr(ESearch.Text,at,at);
t:=NdlFindAddr(at.Zone,at.Net,at.Node,at.Point);
if t<>nil then for i:=0 to Tree.Items.Count-1
do if Tree.Items[i].Data=t then begin
Tree.Items[i].Focused:=true;
Tree.Items[i].Selected:=true;
if NodeListForm.Visible then Tree.SetFocus;
found:=true;
break;
end;
if (not found) and (at.Point>0) then begin
t:=NdlFindAddr(at.Zone,at.Net,at.Node,0);
if t<>nil then for i:=0 to Tree.Items.Count-1
do if Tree.Items[i].Data=t
then begin
Tree.Items[i].Focused:=true;
Tree.Items[i].Selected:=true;
if NodeListForm.Visible then Tree.SetFocus;
found:=true;
break;
end;
end;
end;
end;
procedure TNodelistForm.TreeKeyPress(Sender: TObject; var Key: Char);
begin
if key=#27 then begin
NodelistForm.Close;
key:=#0;
end
else begin
if (ord(key)>=32) and (key<>'-') and (key<>'+') then begin
ESearch.Text:=ESearch.Text+key;
ESearch.SetFocus;
SendMessage(ESearch.Handle,WM_KEYDOWN,VK_END,0);
end;
if key=#8 then begin
ESearch.Text:=Copy(ESearch.Text,1,length(ESearch.Text)-1);
ESearch.SetFocus;
SendMessage(ESearch.Handle,WM_KEYDOWN,VK_END,0);
end;
end;
end;
procedure TNodelistForm.ESearchKeyPress(Sender: TObject; var Key: Char);
begin
if key=#27 then begin
NodelistForm.Close;
key:=#0;
end;
if key='+' then Tree.SetFocus;
end;
end.