NodeSpy telnet client
This commit is contained in:
parent
af6df73fa5
commit
d06397195c
|
@ -4838,3 +4838,7 @@
|
||||||
+ NodeSpy in Windows now uses OS named pipes instead of Disk I/O.
|
+ NodeSpy in Windows now uses OS named pipes instead of Disk I/O.
|
||||||
|
|
||||||
+ NodeSpy in Unix now uses OS named pipes instead of Disk I/O.
|
+ NodeSpy in Unix now uses OS named pipes instead of Disk I/O.
|
||||||
|
|
||||||
|
+ NodeSpy now has a full blown telnet client, which replaces the "local
|
||||||
|
login" feature. Instead, my default the phone book will contain an entry
|
||||||
|
for "local login" which just telnets to localhost.
|
||||||
|
|
|
@ -29,6 +29,10 @@ Program NodeSpy;
|
||||||
{$I M_OPS.PAS}
|
{$I M_OPS.PAS}
|
||||||
|
|
||||||
Uses
|
Uses
|
||||||
|
{$IFDEF DEBUG}
|
||||||
|
HeapTrc,
|
||||||
|
LineInfo,
|
||||||
|
{$ENDIF}
|
||||||
{$IFDEF UNIX}
|
{$IFDEF UNIX}
|
||||||
BaseUnix,
|
BaseUnix,
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
@ -39,10 +43,10 @@ Uses
|
||||||
m_Pipe,
|
m_Pipe,
|
||||||
m_Input,
|
m_Input,
|
||||||
m_Output,
|
m_Output,
|
||||||
m_io_Base,
|
|
||||||
m_io_Sockets,
|
|
||||||
m_Term_Ansi,
|
m_Term_Ansi,
|
||||||
NodeSpy_Common;
|
m_IniReader,
|
||||||
|
NodeSpy_Common,
|
||||||
|
NodeSpy_Term;
|
||||||
|
|
||||||
Const
|
Const
|
||||||
HiddenNode = 255;
|
HiddenNode = 255;
|
||||||
|
@ -109,6 +113,7 @@ Var
|
||||||
Info : Stat;
|
Info : Stat;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
Count : Byte;
|
Count : Byte;
|
||||||
|
INI : TIniReader;
|
||||||
Begin
|
Begin
|
||||||
{$IFDEF UNIX}
|
{$IFDEF UNIX}
|
||||||
If fpStat('nodespy', Info) = 0 Then Begin
|
If fpStat('nodespy', Info) = 0 Then Begin
|
||||||
|
@ -460,107 +465,6 @@ Begin
|
||||||
AutoSnoopID := NodeInfo[Node]^.ID;
|
AutoSnoopID := NodeInfo[Node]^.ID;
|
||||||
End;
|
End;
|
||||||
|
|
||||||
Procedure LocalLogin;
|
|
||||||
Const
|
|
||||||
BufferSize = 1024 * 4;
|
|
||||||
Var
|
|
||||||
Client : TIOSocket;
|
|
||||||
Res : LongInt;
|
|
||||||
Buffer : Array[1..BufferSize] of Char;
|
|
||||||
Done : Boolean;
|
|
||||||
Ch : Char;
|
|
||||||
Begin
|
|
||||||
Screen.SetWindowTitle('NodeSpy/Terminal');
|
|
||||||
|
|
||||||
Screen.TextAttr := 7;
|
|
||||||
Screen.ClearScreen;
|
|
||||||
|
|
||||||
Screen.WriteStr ('Connecting to 127.0.0.1... ');
|
|
||||||
|
|
||||||
Client := TIOSocket.Create;
|
|
||||||
|
|
||||||
Client.FTelnetClient := True;
|
|
||||||
|
|
||||||
If Not Client.Connect('127.0.0.1', Config.INetTNPort) Then
|
|
||||||
ShowMsgBox (0, 'Unable to connect')
|
|
||||||
Else Begin
|
|
||||||
Done := False;
|
|
||||||
Term := TTermAnsi.Create(Screen);
|
|
||||||
|
|
||||||
If Config.UseStatusBar Then Begin
|
|
||||||
Screen.SetWindow (1, 1, 80, 24, True);
|
|
||||||
Screen.WriteXY (1, 25, Config.StatusColor3, strPadC('Local TELNET: ALT-X to Quit', 80, ' '));
|
|
||||||
End;
|
|
||||||
|
|
||||||
Term.SetReplyClient(TIOBase(Client));
|
|
||||||
|
|
||||||
Repeat
|
|
||||||
If Client.WaitForData(0) > 0 Then Begin
|
|
||||||
Repeat
|
|
||||||
Res := Client.ReadBuf (Buffer, BufferSize);
|
|
||||||
|
|
||||||
If Res < 0 Then Begin
|
|
||||||
Done := True;
|
|
||||||
Break;
|
|
||||||
End;
|
|
||||||
|
|
||||||
Term.ProcessBuf(Buffer, Res);
|
|
||||||
Until Res <> BufferSize;
|
|
||||||
End Else
|
|
||||||
If Keyboard.KeyPressed Then Begin
|
|
||||||
Ch := Keyboard.ReadKey;
|
|
||||||
Case Ch of
|
|
||||||
#00 : Case Keyboard.ReadKey of
|
|
||||||
#45 : Break;
|
|
||||||
#71 : Client.WriteStr(#27 + '[H');
|
|
||||||
#72 : Client.WriteStr(#27 + '[A');
|
|
||||||
#73 : Client.WriteStr(#27 + '[V');
|
|
||||||
#75 : Client.WriteStr(#27 + '[D');
|
|
||||||
#77 : Client.WriteStr(#27 + '[C');
|
|
||||||
#79 : Client.WriteStr(#27 + '[K');
|
|
||||||
#80 : Client.WriteStr(#27 + '[B');
|
|
||||||
#81 : Client.WriteStr(#27 + '[U');
|
|
||||||
#83 : Client.WriteStr(#127);
|
|
||||||
End;
|
|
||||||
Else
|
|
||||||
Client.WriteBuf(Ch, 1);
|
|
||||||
If Client.FTelnetEcho Then Term.Process(Ch);
|
|
||||||
End;
|
|
||||||
End Else
|
|
||||||
WaitMS(5);
|
|
||||||
Until Done;
|
|
||||||
|
|
||||||
Term.Free;
|
|
||||||
End;
|
|
||||||
|
|
||||||
Client.Free;
|
|
||||||
|
|
||||||
Screen.TextAttr := 7;
|
|
||||||
Screen.SetWindow (1, 1, 80, 25, True);
|
|
||||||
End;
|
|
||||||
|
|
||||||
Procedure Terminal;
|
|
||||||
Type
|
|
||||||
PhoneRec = Record
|
|
||||||
Name : String[40];
|
|
||||||
Address : String[60];
|
|
||||||
User : String[30];
|
|
||||||
Password : String[20];
|
|
||||||
StatusBar : Boolean;
|
|
||||||
End;
|
|
||||||
|
|
||||||
Var
|
|
||||||
Book : Array[1..200] of PhoneRec;
|
|
||||||
|
|
||||||
Begin
|
|
||||||
// create phonebook
|
|
||||||
// write phonebook
|
|
||||||
// load phonebook
|
|
||||||
// do directory
|
|
||||||
|
|
||||||
// name, address, user, password, statusbar, sysop, software
|
|
||||||
End;
|
|
||||||
|
|
||||||
Procedure UpdateOnlineStatus;
|
Procedure UpdateOnlineStatus;
|
||||||
Var
|
Var
|
||||||
Count : LongInt;
|
Count : LongInt;
|
||||||
|
@ -809,7 +713,7 @@ Begin
|
||||||
FullReDraw;
|
FullReDraw;
|
||||||
End;
|
End;
|
||||||
#32 : Begin
|
#32 : Begin
|
||||||
LocalLogin;
|
Terminal;
|
||||||
FullReDraw;
|
FullReDraw;
|
||||||
End;
|
End;
|
||||||
#27 : Break;
|
#27 : Break;
|
||||||
|
@ -845,6 +749,10 @@ Begin
|
||||||
End;
|
End;
|
||||||
|
|
||||||
Begin
|
Begin
|
||||||
|
{$IFDEF DEBUG}
|
||||||
|
SetHeapTraceOutput('nodespy.mem');
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
ApplicationInit;
|
ApplicationInit;
|
||||||
|
|
||||||
MainMenu;
|
MainMenu;
|
||||||
|
|
|
@ -7,5 +7,5 @@
|
||||||
[0;34m°°²ÛÛÛÛ [1;30;44m²[40mÜÜÜܲ [0;34mÛÛÛÛÛ [1;30m±Ü [0;34mßßßßÛÛÛÛ²ÛÛÛÛÛÛÛÛÛÛ²± ßÛÛÛÛÜÜÛÛÛÛÛ[1m±[44m°°°°°[1C[0;34mßÛÛÛÛÜÜÜÜÜ [1;30mÜÜÛ
|
[0;34m°°²ÛÛÛÛ [1;30;44m²[40mÜÜÜܲ [0;34mÛÛÛÛÛ [1;30m±Ü [0;34mßßßßÛÛÛÛ²ÛÛÛÛÛÛÛÛÛÛ²± ßÛÛÛÛÜÜÛÛÛÛÛ[1m±[44m°°°°°[1C[0;34mßÛÛÛÛÜÜÜÜÜ [1;30mÜÜÛ
|
||||||
ÜÜþ [0;34mßß² [1;30m± °°²ÜÜÜÜÜÜܲßßßßß [0;34m²ÛÛÛ ²²²ÛÛÛ²ßßßß [1;30mÞÜÜ [0;34mßßßßßßßß ßßßßß ßßßßßßß [1;30mÝ°°
|
ÜÜþ [0;34mßß² [1;30m± °°²ÜÜÜÜÜÜܲßßßßß [0;34m²ÛÛÛ ²²²ÛÛÛ²ßßßß [1;30mÞÜÜ [0;34mßßßßßßßß ßßßßß ßßßßßßß [1;30mÝ°°
|
||||||
[8C°[12CÝ[6C[0;34m°°[11C[1;30mþ Þßßßßßßßßßßßßß ß [37mN[0mode [1mS[0mpy [1;30mßÜ
|
[8C°[12CÝ[6C[0;34m°°[11C[1;30mþ Þßßßßßßßßßßßßß ß [37mN[0mode [1mS[0mpy [1;30mßÜ
|
||||||
[0mワ[1mワワワワワワワワワワワワワワワワワワワワワワワワワワ[0mワ ワ[1mワワワワワワワワワワワワワワワワワワワワワワワワワワ[0mワ ワ[1mワワワワワワワワワワ[0mワ ワ[1mワワワワワワワ[0mワ[11;1H[1;30;47mイ [0;30;47mSystem Name [37;40mイ[1mウ[30;47mイ [0;30;47mAddress [37;40mイ[1mウ[30;47mイ [0;30;47mLastCall [1;40mイ[37mウ[30;47mイ [0;30;47mCalls [1mイ[12;1H[40mロ゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚[34mウ[30m゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚[34mウ[30m゚゚゚゚゚゚゚゚゚゚゚゚[34mウ[30m゚゚゚゚゚゚゚゚ロ[13;1Hン[78C゙[14;1Hン[78C゙[15;1H[0mン[78C゙[16;1Hン[78C゙[17;1Hン[78C゙[18;1H[1mン[78C゙[19;1H[0mン[78C゙[20;1H[1mン[78C゙[21;1Hン[78C゙[22;1Hイワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワイ[23;1H[0mー[47m [30mDefault NodeSpy Phone Book % [1;40mーーーーーーーーーー[47m [0;30;47m( /200) [37;40mー[24;1H [1;30m゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚
|
[0mワ[1mワワワワワワワワワワワワワワワワワワワワワワワワワワ[0mワ ワ[1mワワワワワワワワワワワワワワワワワワワワワワワワワワ[0mワ ワ[1mワワワワワワワワワワ[0mワ ワ[1mワワワワワワワ[0mワ[11;1H[1;30;47mイ [0;30;47mSystem Name [37;40mイ[1mウ[30;47mイ [0;30;47mAddress [37;40mイ[1mウ[30;47mイ [0;30;47mLastCall [1;40mイ[37mウ[30;47mイ [0;30;47mCalls [1mイ[12;1H[40mロ゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚[34mウ[30m゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚[34mウ[30m゚゚゚゚゚゚゚゚゚゚゚゚[34mウ[30m゚゚゚゚゚゚゚゚ロ[13;1Hン[78C゙[14;1Hン[78C゙[15;1H[0mン[78C゙[16;1Hン[78C゙[17;1Hン[78C゙[18;1H[1mン[78C゙[19;1H[0mン[78C゙[20;1H[1mン[78C゙[21;1Hン[78C゙[22;1Hイワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワワイ[23;1H[0mー[47m [30mDefault NodeSpy PhoneBook [37;40mー[24;1H [1;30m゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚゚
|
||||||
[37mENTER[30m: [0mCall [1mALT+E[30m: [0mEdit [1mALT+S[30m: [0mSort [1mINSERT[30m: [0mNew [1mDELETE[30m: [0mRemove[0m[255D
|
[37mENTER[30m: [0mCall [1mALT+E[30m: [0mEdit [1mALT+S[30m: [0mSort [1mDELETE[30m: [0mClear [1mESCAPE[30m: [0mQuit[0m[255D
|
|
@ -2,8 +2,8 @@ Procedure DrawTerminalAnsi;
|
||||||
Const
|
Const
|
||||||
IMAGEDATA_WIDTH=80;
|
IMAGEDATA_WIDTH=80;
|
||||||
IMAGEDATA_DEPTH=25;
|
IMAGEDATA_DEPTH=25;
|
||||||
IMAGEDATA_LENGTH=1134;
|
IMAGEDATA_LENGTH=1115;
|
||||||
IMAGEDATA : array [1..1134] of Char = (
|
IMAGEDATA : array [1..1115] of Char = (
|
||||||
#1,#16,'Ü','Ü',#25,#10, #8,'Ü','Ü',#25, #3, #7,'°', #0,#23,'²',#16,
|
#1,#16,'Ü','Ü',#25,#10, #8,'Ü','Ü',#25, #3, #7,'°', #0,#23,'²',#16,
|
||||||
#25,#23, #9,#26, #4,'Ü',#25, #9,#14,'±','Û','±', #7,'°', #0,#23,'²',
|
#25,#23, #9,#26, #4,'Ü',#25, #9,#14,'±','Û','±', #7,'°', #0,#23,'²',
|
||||||
#16,#25, #8, #7,'°', #0,#23,'²', #8,#16,'g','j','!',#24,' ', #9,#17,
|
#16,#25, #8, #7,'°', #0,#23,'²', #8,#16,'g','j','!',#24,' ', #9,#17,
|
||||||
|
@ -62,15 +62,14 @@ Const
|
||||||
'M','Þ',#24,'Ý',#25,'M','Þ',#24, #7,'Ý',#25,'M','Þ',#24,'Ý',#25,'M',
|
'M','Þ',#24,'Ý',#25,'M','Þ',#24, #7,'Ý',#25,'M','Þ',#24,'Ý',#25,'M',
|
||||||
'Þ',#24,'Ý',#25,'M','Þ',#24,#15,'Ý',#25,'M','Þ',#24, #7,'Ý',#25,'M',
|
'Þ',#24,'Ý',#25,'M','Þ',#24,#15,'Ý',#25,'M','Þ',#24, #7,'Ý',#25,'M',
|
||||||
'Þ',#24,#15,'Ý',#25,'M','Þ',#24,'Ý',#25,'M','Þ',#24,'²',#26,'M','Ü',
|
'Þ',#24,#15,'Ý',#25,'M','Þ',#24,'Ý',#25,'M','Þ',#24,'²',#26,'M','Ü',
|
||||||
'²',#24, #7,'°',#23,' ', #0,'D','e','f','a','u','l','t',' ','N','o',
|
'²',#24, #7,'°',#23,#25,#26, #0,'D','e','f','a','u','l','t',' ','N',
|
||||||
'd','e','S','p','y',' ','P','h','o','n','e',' ','B','o','o','k',#25,
|
'o','d','e','S','p','y',' ','P','h','o','n','e','B','o','o','k',#25,
|
||||||
#27,'%',' ', #8,#16,#26, #9,'°',#23,' ', #0,'(',#25, #2,'/','2','0',
|
#25, #7,#16,'°',#24,' ', #8,#26,'M','ß',#24,#25, #2,#15,'E','N','T',
|
||||||
'0',')',' ', #7,#16,'°',#24,' ', #8,#26,'M','ß',#24,#25, #2,#15,'E',
|
'E','R', #8,':',' ', #7,'C','a','l','l',#25, #3,#15,'A','L','T','+',
|
||||||
'N','T','E','R', #8,':',' ', #7,'C','a','l','l',#25, #3,#15,'A','L',
|
'E', #8,':',' ', #7,'E','d','i','t',#25, #3,#15,'A','L','T','+','S',
|
||||||
'T','+','E', #8,':',' ', #7,'E','d','i','t',#25, #3,#15,'A','L','T',
|
#8,':',' ', #7,'S','o','r','t',#25, #3,#15,'D','E','L','E','T','E',
|
||||||
'+','S', #8,':',' ', #7,'S','o','r','t',#25, #3,#15,'I','N','S','E',
|
#8,':',' ', #7,'C','l','e','a','r',#25, #3,#15,'E','S','C','A','P',
|
||||||
'R','T', #8,':',' ', #7,'N','e','w',#25, #3,#15,'D','E','L','E','T',
|
'E', #8,':',' ', #7,'Q','u','i','t',#24);
|
||||||
'E', #8,':',' ', #7,'R','e','m','o','v','e',#24);
|
|
||||||
Begin
|
Begin
|
||||||
Screen.LoadScreenImage(ImageData, ImageData_Length, ImageData_Width, 1, 1);
|
Screen.LoadScreenImage(ImageData, ImageData_Length, ImageData_Width, 1, 1);
|
||||||
End;
|
End;
|
|
@ -105,8 +105,7 @@ Begin
|
||||||
Until False;
|
Until False;
|
||||||
End;
|
End;
|
||||||
|
|
||||||
If BoxType < 2 Then MsgBox.Close;
|
MsgBox.Close;
|
||||||
|
|
||||||
MsgBox.Free;
|
MsgBox.Free;
|
||||||
|
|
||||||
Screen.CursorXY (SavedX, SavedY);
|
Screen.CursorXY (SavedX, SavedY);
|
||||||
|
|
|
@ -4,65 +4,108 @@ Unit NodeSpy_Term;
|
||||||
|
|
||||||
Interface
|
Interface
|
||||||
|
|
||||||
|
Procedure Terminal;
|
||||||
|
|
||||||
Implementation
|
Implementation
|
||||||
|
|
||||||
Uses
|
Uses
|
||||||
|
m_DateTime,
|
||||||
m_Strings,
|
m_Strings,
|
||||||
m_FileIO,
|
m_FileIO,
|
||||||
m_IniReader,
|
m_IniReader,
|
||||||
|
m_io_Base,
|
||||||
|
m_io_Sockets,
|
||||||
|
m_Term_Ansi,
|
||||||
|
m_MenuBox,
|
||||||
|
m_MenuForm,
|
||||||
NodeSpy_Common;
|
NodeSpy_Common;
|
||||||
|
|
||||||
{$I NODESPY_ANSITERM.PAS}
|
{$I NODESPY_ANSITERM.PAS}
|
||||||
|
|
||||||
Type
|
Type
|
||||||
PhoneRec = Record
|
PhoneRec = Record
|
||||||
Name : String[40];
|
Name : String[26];
|
||||||
Address : String[60];
|
Address : String[60];
|
||||||
User : String[30];
|
User : String[30];
|
||||||
Password : String[20];
|
Password : String[20];
|
||||||
StatusBar : Boolean;
|
StatusBar : Boolean;
|
||||||
|
LastCall : String[8];
|
||||||
|
Calls : String[5];
|
||||||
End;
|
End;
|
||||||
|
|
||||||
Var
|
PhoneBookRec = Array[1..100] of PhoneRec;
|
||||||
Book : Array[1..200] of PhoneRec;
|
|
||||||
|
|
||||||
Procedure InitializeBook;
|
|
||||||
Var
|
Var
|
||||||
Count : Byte;
|
IsBookLoaded : Boolean;
|
||||||
|
|
||||||
|
Function StripAddressPort (Str : String) : String;
|
||||||
|
Var
|
||||||
|
A : Byte;
|
||||||
|
Begin
|
||||||
|
A := Pos(':', Str);
|
||||||
|
|
||||||
|
If A > 0 Then
|
||||||
|
StripAddressPort := Copy(Str, 1, A - 1)
|
||||||
|
Else
|
||||||
|
StripAddressPort := Str;
|
||||||
|
End;
|
||||||
|
|
||||||
|
Function GetAddressPort (Addr : String) : Word;
|
||||||
|
Var
|
||||||
|
A : Byte;
|
||||||
|
Begin
|
||||||
|
A := Pos(':', Addr);
|
||||||
|
|
||||||
|
If A > 0 Then
|
||||||
|
GetAddressPort := strS2I(Copy(Addr, A+1, Length(Addr)))
|
||||||
|
Else
|
||||||
|
GetAddressPort := 23;
|
||||||
|
End;
|
||||||
|
|
||||||
|
Procedure InitializeBook (Var Book: PhoneBookRec);
|
||||||
|
Var
|
||||||
|
Count : SmallInt;
|
||||||
Begin
|
Begin
|
||||||
FillChar (Book, SizeOf(Book), 0);
|
FillChar (Book, SizeOf(Book), 0);
|
||||||
|
|
||||||
For Count := 1 to 200 Do
|
For Count := 1 to 100 Do Begin
|
||||||
Book[Count].StatusBar := True;
|
Book[Count].StatusBar := True;
|
||||||
|
Book[Count].LastCall := '00/00/00';
|
||||||
|
Book[Count].Calls := '0';
|
||||||
|
End;
|
||||||
|
|
||||||
Book[1].Name := 'Mystic BBS Local Login';
|
Book[1].Name := 'Local Login';
|
||||||
Book[1].Address := 'localhost:' + strI2S(Config.INetTNPort);
|
Book[1].Address := 'localhost:' + strI2S(Config.INetTNPort);
|
||||||
End;
|
End;
|
||||||
|
|
||||||
Procedure WriteBook;
|
Procedure WriteBook (Var Book: PhoneBookRec);
|
||||||
Var
|
Var
|
||||||
OutFile : Text;
|
OutFile : Text;
|
||||||
Buffer : Array[1..4096] of Char;
|
Buffer : Array[1..4096] of Char;
|
||||||
Count : SmallInt;
|
Count : SmallInt;
|
||||||
Begin
|
Begin
|
||||||
|
ShowMsgBox (2, 'Saving phonebook');
|
||||||
|
|
||||||
Assign (OutFile, 'nodespy.phn');
|
Assign (OutFile, 'nodespy.phn');
|
||||||
SetTextBuf (OutFile, Buffer);
|
SetTextBuf (OutFile, Buffer);
|
||||||
ReWrite (OutFile);
|
ReWrite (OutFile);
|
||||||
|
|
||||||
For Count := 1 to 200 Do Begin
|
For Count := 1 to 100 Do Begin
|
||||||
WriteLn(OutFile, '[' + strI2S(Count) + ']');
|
WriteLn (OutFile, '[' + strI2S(Count) + ']');
|
||||||
WriteLn(OutFile, #9 + 'name=' + Book[Count].Name);
|
WriteLn (OutFile, #9 + 'name=' + Book[Count].Name);
|
||||||
WriteLn(OutFile, #9 + 'address=' + Book[Count].Address);
|
WriteLn (OutFile, #9 + 'address=' + Book[Count].Address);
|
||||||
WriteLn(OutFile, #9 + 'user=' + Book[Count].User);
|
WriteLn (OutFile, #9 + 'user=' + Book[Count].User);
|
||||||
WriteLn(OutFile, #9 + 'pass=' + Book[Count].Password);
|
WriteLn (OutFile, #9 + 'pass=' + Book[Count].Password);
|
||||||
WriteLn(OutFile, #9 + 'statusbar=', Ord(Book[Count].StatusBar));
|
WriteLn (OutFile, #9 + 'statusbar=', Ord(Book[Count].StatusBar));
|
||||||
WriteLn(OutFile, '');
|
WriteLn (OutFile, #9 + 'last=' + Book[Count].LastCall);
|
||||||
|
WriteLn (OutFile, #9 + 'calls=' + Book[Count].Calls);
|
||||||
|
WriteLn (OutFile, '');
|
||||||
End;
|
End;
|
||||||
|
|
||||||
Close (OutFile);
|
Close (OutFile);
|
||||||
End;
|
End;
|
||||||
|
|
||||||
Procedure LoadBook;
|
Procedure LoadBook (Var Book: PhoneBookRec);
|
||||||
Var
|
Var
|
||||||
INI : TIniReader;
|
INI : TIniReader;
|
||||||
Count : SmallInt;
|
Count : SmallInt;
|
||||||
|
@ -71,28 +114,208 @@ Begin
|
||||||
|
|
||||||
INI := TIniReader.Create('nodespy.phn');
|
INI := TIniReader.Create('nodespy.phn');
|
||||||
|
|
||||||
For Count := 1 to 200 Do Begin
|
INI.Sequential := True;
|
||||||
|
|
||||||
|
For Count := 1 to 100 Do Begin
|
||||||
Book[Count].Name := INI.ReadString(strI2S(Count), 'name', '');
|
Book[Count].Name := INI.ReadString(strI2S(Count), 'name', '');
|
||||||
Book[Count].Address := INI.ReadString(strI2S(Count), 'address', '');
|
Book[Count].Address := INI.ReadString(strI2S(Count), 'address', '');
|
||||||
Book[Count].User := INI.ReadString(strI2S(Count), 'user', '');
|
Book[Count].User := INI.ReadString(strI2S(Count), 'user', '');
|
||||||
Book[Count].Password := INI.ReadString(strI2S(Count), 'pass', '');
|
Book[Count].Password := INI.ReadString(strI2S(Count), 'pass', '');
|
||||||
Book[Count].StatusBar := INI.ReadString(strI2S(Count), 'statusbar', '1') = '1';
|
Book[Count].StatusBar := INI.ReadString(strI2S(Count), 'statusbar', '1') = '1';
|
||||||
|
Book[Count].LastCall := INI.ReadString(strI2S(Count), 'last', '');
|
||||||
|
Book[Count].Calls := INI.ReadString(strI2S(Count), 'calls', '');
|
||||||
End;
|
End;
|
||||||
|
|
||||||
INI.Free;
|
INI.Free;
|
||||||
End;
|
End;
|
||||||
|
|
||||||
Procedure Terminal;
|
Procedure TelnetClient (Dial: PhoneRec);
|
||||||
|
Const
|
||||||
|
BufferSize = 1024 * 4;
|
||||||
|
Var
|
||||||
|
Client : TIOSocket;
|
||||||
|
Res : LongInt;
|
||||||
|
Buffer : Array[1..BufferSize] of Char;
|
||||||
|
Done : Boolean;
|
||||||
|
Ch : Char;
|
||||||
Begin
|
Begin
|
||||||
If Not FileExist('nodespy.phn') Then Begin
|
ShowMsgBox (2, 'Connecting to ' + Dial.Address);
|
||||||
ShowMsgBox(2, 'Creating phone book');
|
|
||||||
|
|
||||||
InitializeBook;
|
Client := TIOSocket.Create;
|
||||||
WriteBook;
|
|
||||||
|
Client.FTelnetClient := True;
|
||||||
|
|
||||||
|
If Not Client.Connect(StripAddressPort(Dial.Address), GetAddressPort(Dial.Address)) Then
|
||||||
|
ShowMsgBox (0, 'Unable to connect')
|
||||||
|
Else Begin
|
||||||
|
Screen.TextAttr := 7;
|
||||||
|
Screen.ClearScreen;
|
||||||
|
|
||||||
|
Done := False;
|
||||||
|
Term := TTermAnsi.Create(Screen);
|
||||||
|
|
||||||
|
If Dial.StatusBar Then Begin
|
||||||
|
Screen.SetWindow (1, 1, 80, 24, True);
|
||||||
|
Screen.WriteXY (1, 25, Config.StatusColor3, strPadC('ALT-X/Quit', 80, ' '));
|
||||||
|
End;
|
||||||
|
|
||||||
|
Term.SetReplyClient(TIOBase(Client));
|
||||||
|
|
||||||
|
Repeat
|
||||||
|
If Client.DataWaiting Then Begin
|
||||||
|
Res := Client.ReadBuf (Buffer, BufferSize);
|
||||||
|
|
||||||
|
If Res < 0 Then Begin
|
||||||
|
Done := True;
|
||||||
|
Break;
|
||||||
|
End;
|
||||||
|
|
||||||
|
Term.ProcessBuf(Buffer, Res);
|
||||||
|
End Else
|
||||||
|
If Keyboard.KeyPressed Then Begin
|
||||||
|
Ch := Keyboard.ReadKey;
|
||||||
|
|
||||||
|
Case Ch of
|
||||||
|
#00 : Case Keyboard.ReadKey of
|
||||||
|
#45 : Break;
|
||||||
|
#71 : Client.WriteStr(#27 + '[H');
|
||||||
|
#72 : Client.WriteStr(#27 + '[A');
|
||||||
|
#73 : Client.WriteStr(#27 + '[V');
|
||||||
|
#75 : Client.WriteStr(#27 + '[D');
|
||||||
|
#77 : Client.WriteStr(#27 + '[C');
|
||||||
|
#79 : Client.WriteStr(#27 + '[K');
|
||||||
|
#80 : Client.WriteStr(#27 + '[B');
|
||||||
|
#81 : Client.WriteStr(#27 + '[U');
|
||||||
|
#83 : Client.WriteStr(#127);
|
||||||
|
End;
|
||||||
|
Else
|
||||||
|
Client.WriteBuf(Ch, 1);
|
||||||
|
|
||||||
|
If Client.FTelnetEcho Then Term.Process(Ch);
|
||||||
|
End;
|
||||||
|
End Else
|
||||||
|
WaitMS(10);
|
||||||
|
Until Done;
|
||||||
|
|
||||||
|
Term.Free;
|
||||||
|
End;
|
||||||
|
|
||||||
|
Client.Free;
|
||||||
|
|
||||||
|
Screen.TextAttr := 7;
|
||||||
|
Screen.SetWindow (1, 1, 80, 25, True);
|
||||||
|
End;
|
||||||
|
|
||||||
|
Procedure EditEntry (Var Book: PhoneBookRec; Num: SmallInt);
|
||||||
|
Var
|
||||||
|
Box : TMenuBox;
|
||||||
|
Form : TMenuForm;
|
||||||
|
NewRec : PhoneRec;
|
||||||
|
Begin
|
||||||
|
NewRec := Book[Num];
|
||||||
|
Box := TMenuBox.Create(Screen);
|
||||||
|
Form := TMenuForm.Create(Screen);
|
||||||
|
|
||||||
|
Box.Header := ' Book Editor ';
|
||||||
|
|
||||||
|
Box.Open (18, 8, 63, 16);
|
||||||
|
|
||||||
|
Form.AddStr ('N', ' Name' , 24, 10, 32, 10, 6, 26, 26, @NewRec.Name, '');
|
||||||
|
Form.AddStr ('A', ' Address', 21, 11, 32, 11, 9, 30, 60, @NewRec.Address, '');
|
||||||
|
|
||||||
|
Form.Execute;
|
||||||
|
|
||||||
|
If Form.Changed Then
|
||||||
|
If ShowMsgBox(1, 'Save changes?') Then Begin
|
||||||
|
Book[Num] := NewRec;
|
||||||
|
WriteBook(Book);
|
||||||
|
End;
|
||||||
|
|
||||||
|
Form.Free;
|
||||||
|
|
||||||
|
Box.Close;
|
||||||
|
Box.Free;
|
||||||
|
End;
|
||||||
|
|
||||||
|
Function GetTerminalEntry (Var Book: PhoneBookRec; Var Dial: PhoneRec) : Boolean;
|
||||||
|
Var
|
||||||
|
Count : SmallInt;
|
||||||
|
List : TMenuList;
|
||||||
|
Begin
|
||||||
|
Result := False;
|
||||||
|
|
||||||
|
If Not FileExist('nodespy.phn') Then Begin
|
||||||
|
ShowMsgBox (2, 'Creating phone book');
|
||||||
|
WriteBook (Book);
|
||||||
|
|
||||||
|
IsBookLoaded := True;
|
||||||
End Else
|
End Else
|
||||||
LoadBook;
|
If Not IsBookLoaded Then Begin
|
||||||
|
LoadBook(Book);
|
||||||
|
IsBookLoaded := True;
|
||||||
|
End;
|
||||||
|
|
||||||
DrawTerminalAnsi;
|
DrawTerminalAnsi;
|
||||||
|
|
||||||
|
Repeat
|
||||||
|
List := TMenuList.Create(Screen);
|
||||||
|
|
||||||
|
List.NoWindow := True;
|
||||||
|
List.AllowTag := False;
|
||||||
|
List.LoAttr := 7;
|
||||||
|
List.HiAttr := 9 + 1 * 16;
|
||||||
|
List.LoChars := #13#27;
|
||||||
|
List.HiChars := #18;
|
||||||
|
|
||||||
|
For Count := 1 to 100 Do
|
||||||
|
List.Add(strPadR(Book[Count].Name, 26, ' ') + ' ' +
|
||||||
|
strPadR(Book[Count].Address, 26, ' ') + ' ' +
|
||||||
|
Book[Count].LastCall + ' ' +
|
||||||
|
strPadL(Book[Count].Calls, 6, ' '),
|
||||||
|
2);
|
||||||
|
|
||||||
|
List.Open(1, 12, 80, 22);
|
||||||
|
|
||||||
|
Case List.ExitCode of
|
||||||
|
#13 : If Book[List.Picked].Address = '' Then
|
||||||
|
ShowMsgBox(0, 'Address is empty')
|
||||||
|
Else Begin
|
||||||
|
With Book[List.Picked] Do Begin
|
||||||
|
LastCall := DateDos2Str(CurDateDos, 1);
|
||||||
|
Calls := strI2S(strS2I(Calls) + 1);
|
||||||
|
End;
|
||||||
|
|
||||||
|
WriteBook(Book);
|
||||||
|
|
||||||
|
Dial := Book[List.Picked];
|
||||||
|
Result := True;
|
||||||
|
|
||||||
|
Break;
|
||||||
|
End;
|
||||||
|
#18 : EditEntry(Book, List.Picked);
|
||||||
|
#27 : Break;
|
||||||
|
End;
|
||||||
|
|
||||||
|
List.Free;
|
||||||
|
Until False;
|
||||||
|
End;
|
||||||
|
|
||||||
|
Procedure Terminal;
|
||||||
|
Var
|
||||||
|
Dial : PhoneRec;
|
||||||
|
Book : PhoneBookRec;
|
||||||
|
Begin
|
||||||
|
Screen.SetWindowTitle('NodeSpy/Terminal');
|
||||||
|
|
||||||
|
InitializeBook(Book);
|
||||||
|
|
||||||
|
IsBookLoaded := False;
|
||||||
|
|
||||||
|
Repeat
|
||||||
|
If Not GetTerminalEntry(Book, Dial) Then Break;
|
||||||
|
|
||||||
|
TelnetClient(Dial);
|
||||||
|
Until False;
|
||||||
End;
|
End;
|
||||||
|
|
||||||
End.
|
End.
|
Loading…
Reference in New Issue