This commit is contained in:
mysticbbs 2013-09-07 17:25:43 -04:00
parent 59f04ee524
commit ab7218aebf
3 changed files with 71 additions and 19 deletions

View File

@ -20,6 +20,8 @@ Type
TermInfo : TermIos;
TermInRaw : Boolean;
TermOutRaw : Boolean;
TermXSize : LongInt;
TermYSize : LongInt;
OutBuffer : Array[1..ConBufSize] of Char;
FTextAttr : Byte;
FWinTop : Byte;
@ -41,6 +43,7 @@ Type
Procedure SaveRawSettings (Var TIo: TermIos);
Procedure RestoreRawSettings (TIo: TermIos);
Procedure SetRawMode (SetOn: Boolean);
Procedure GetOriginalTermSize;
Procedure WriteXY (X, Y, A: Byte; Text: String);
Procedure WriteXYPipe (X, Y, Attr, Pad: Integer; Text: String);
Procedure GetScreenImage (X1, Y1, X2, Y2: Byte; Var Image: TConsoleImageRec);
@ -103,6 +106,8 @@ Begin
SetRawMode(True);
GetOriginalTermSize;
Active := A;
OutBufPos := 0;
FTextAttr := 7;
@ -123,7 +128,8 @@ Begin
// RestoreRawSettings(SavedTerm);
SetRawMode(False);
SetWindow (1, 1, TermXSize, TermYSize, False);
SetRawMode (False);
Inherited Destroy;
End;
@ -131,6 +137,40 @@ End;
Const
AnsiTable : String[8] = '04261537';
Procedure TOutputLinux.GetOriginalTermSize;
Var
Str : String;
Ch : Char;
FDSIN : TFDSET;
Begin
RawWriteStr (#27 + '[18t');
Str := '';
Repeat
fpFD_ZERO (FDSIN);
fpFD_SET (0, FDSIN);
If fpSelect (1, @FDSIN, NIL, NIL, 250) > 0 Then Begin
fpRead (0, Ch, 1);
If Ch <> 't' Then
Str := Str + Ch;
If Length(Str) > 13 Then Break;
End Else
Break;
Until Ch = 't';
TermXSize := strS2I(strWordGet(2, Str, ';'));
TermYSize := strS2I(strWordGet(2, Str, ';'));
If (TermXSize <= 0) or (TermYSize <= 0) Then Begin
TermXSize := 80;
TermYSize := 25;
End;
End;
(*
Function TOutputLinux.AttrToAnsi (Attr: Byte) : String;
Var

View File

@ -15,8 +15,9 @@ Type
ResponseType : Integer;
ResponseStr : String;
ResponseData : TStringList;
NetInterface : String;
Constructor Create; Virtual;
Constructor Create (NetI: String); Virtual;
Destructor Destroy; Override;
Function Connect (Address: String; Port: Word) : Boolean; Virtual;
Function SendCommand (Str: String) : Integer;
@ -25,11 +26,12 @@ Type
Implementation
Constructor TTCPClient.Create;
Constructor TTCPClient.Create (NetI: String);
Begin
Inherited Create;
Client := NIL;
NetInterface := NetI;
ResponseData := TStringList.Create;
End;

View File

@ -15,20 +15,17 @@ Type
DataIP : String;
DataSocket : TIOSocket;
IsPassive : Boolean;
NetInterface : String;
Constructor Create; Override;
Function OpenDataSession : Boolean;
Procedure CloseDataSession;
Function SetPassive (IsOn: Boolean) : Boolean;
Function OpenConnection (HostName: String) : Boolean;
Function Authenticate (Login, Password: String) : Boolean;
Function ChangeDirectory (Str: String) : Boolean;
Function SendFile (Passive: Boolean; FileName: String) : Boolean;
Function GetFile (Passive: Boolean; FileName: String) : Boolean;
Procedure CloseConnection;
Constructor Create (NetI: String); Override;
Function OpenDataSession : Boolean;
Procedure CloseDataSession;
Function SetPassive (IsOn: Boolean) : Boolean;
Function OpenConnection (HostName: String) : Boolean;
Function Authenticate (Login, Password: String) : Boolean;
Function ChangeDirectory (Str: String) : Boolean;
Function SendFile (Passive: Boolean; FileName: String) : Boolean;
Function GetFile (Passive: Boolean; FileName: String) : Boolean;
Procedure CloseConnection;
End;
Implementation
@ -37,12 +34,11 @@ Uses
m_FileIO,
m_Strings;
Constructor TFTPClient.Create;
Constructor TFTPClient.Create (NetI: String);
Begin
Inherited Create;
Inherited Create(NetI);
IsPassive := False;
NetInterface := '';
DataIP := '';
DataPort := 10000;
End;
@ -53,6 +49,8 @@ Var
Begin
Result := False;
WriteLn ('DEBUG OPEN DATA 1');
If DataSocket <> NIL Then Begin
DataSocket.Free;
DataSocket := NIL;
@ -68,15 +66,23 @@ Begin
Exit;
End;
End Else Begin
WriteLn ('DEBUG OPEN DATA 2');
WaitSock := TIOSocket.Create;
WaitSock.FTelnetServer := False;
WaitSock.FTelnetClient := False;
WriteLn ('DEBUG OPEN DATA 3');
WaitSock.WaitInit(NetInterface, DataPort);
WriteLn ('DEBUG OPEN DATA 4');
DataSocket := WaitSock.WaitConnection(10000);
WriteLn ('DEBUG OPEN DATA 5');
WaitSock.Free;
If Not Assigned(DataSocket) Then
@ -164,11 +170,15 @@ Begin
SetPassive(Passive);
WriteLn ('DEBUG SETPASSIVE()');
Client.WriteLine ('STOR ' + JustFile(FileName));
OpenDataSession;
If GetResponse = 150 Then Begin
WriteLn ('DEBUG BEGIN SEND FILE');
Assign (F, FileName);
If ioReset(F, 1, fmRWDN) Then Begin