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; TermInfo : TermIos;
TermInRaw : Boolean; TermInRaw : Boolean;
TermOutRaw : Boolean; TermOutRaw : Boolean;
TermXSize : LongInt;
TermYSize : LongInt;
OutBuffer : Array[1..ConBufSize] of Char; OutBuffer : Array[1..ConBufSize] of Char;
FTextAttr : Byte; FTextAttr : Byte;
FWinTop : Byte; FWinTop : Byte;
@ -41,6 +43,7 @@ Type
Procedure SaveRawSettings (Var TIo: TermIos); Procedure SaveRawSettings (Var TIo: TermIos);
Procedure RestoreRawSettings (TIo: TermIos); Procedure RestoreRawSettings (TIo: TermIos);
Procedure SetRawMode (SetOn: Boolean); Procedure SetRawMode (SetOn: Boolean);
Procedure GetOriginalTermSize;
Procedure WriteXY (X, Y, A: Byte; Text: String); Procedure WriteXY (X, Y, A: Byte; Text: String);
Procedure WriteXYPipe (X, Y, Attr, Pad: Integer; Text: String); Procedure WriteXYPipe (X, Y, Attr, Pad: Integer; Text: String);
Procedure GetScreenImage (X1, Y1, X2, Y2: Byte; Var Image: TConsoleImageRec); Procedure GetScreenImage (X1, Y1, X2, Y2: Byte; Var Image: TConsoleImageRec);
@ -103,6 +106,8 @@ Begin
SetRawMode(True); SetRawMode(True);
GetOriginalTermSize;
Active := A; Active := A;
OutBufPos := 0; OutBufPos := 0;
FTextAttr := 7; FTextAttr := 7;
@ -123,7 +128,8 @@ Begin
// RestoreRawSettings(SavedTerm); // RestoreRawSettings(SavedTerm);
SetRawMode(False); SetWindow (1, 1, TermXSize, TermYSize, False);
SetRawMode (False);
Inherited Destroy; Inherited Destroy;
End; End;
@ -131,6 +137,40 @@ End;
Const Const
AnsiTable : String[8] = '04261537'; 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; Function TOutputLinux.AttrToAnsi (Attr: Byte) : String;
Var Var

View File

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

View File

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