IFDEFS added to reduce EXE size

This commit is contained in:
mysticbbs 2013-09-07 23:52:11 -04:00
parent bb924941ec
commit 3f97c8438f
2 changed files with 32 additions and 25 deletions

View File

@ -4,8 +4,12 @@ Unit m_TCP_Client;
Interface Interface
{.$DEFINE USESTRINGLIST}
Uses Uses
Classes, {$IFDEF USESTRINGLIST}
Classes,
{$ENDIF}
m_Strings, m_Strings,
m_IO_Sockets; m_IO_Sockets;
@ -14,7 +18,9 @@ Type
Client : TIOSocket; Client : TIOSocket;
ResponseType : Integer; ResponseType : Integer;
ResponseStr : String; ResponseStr : String;
ResponseData : TStringList; {$IFDEF USESTRINGLIST}
ResponseData : TStringList;
{$ENDIF}
NetInterface : String; NetInterface : String;
Constructor Create (NetI: String); Virtual; Constructor Create (NetI: String); Virtual;
@ -32,13 +38,19 @@ Begin
Client := NIL; Client := NIL;
NetInterface := NetI; NetInterface := NetI;
ResponseData := TStringList.Create;
{$IFDEF USESTRINGLIST}
ResponseData := TStringList.Create;
{$ENDIF}
End; End;
Destructor TTCPClient.Destroy; Destructor TTCPClient.Destroy;
Begin Begin
Client.Free; Client.Free;
ResponseData.Free;
{$IFDEF USESTRINGLIST}
ResponseData.Free;
{$ENDIF}
Inherited Destroy; Inherited Destroy;
End; End;
@ -80,7 +92,9 @@ Begin
Result := ResponseType; Result := ResponseType;
If ResponseStr[4] = '-' Then Begin If ResponseStr[4] = '-' Then Begin
ResponseData.Clear; {$IFDEF USESTRINGLIST}
ResponseData.Clear;
{$ENDIF}
Repeat Repeat
Res := Client.ReadLine(Str); Res := Client.ReadLine(Str);
@ -88,8 +102,10 @@ Begin
If Res < 0 Then If Res < 0 Then
Break; Break;
If Res > 0 Then {$IFDEF USESTRINGLIST}
ResponseData.Add(Str); If Res > 0 Then
ResponseData.Add(Str);
{$ENDIF}
Until Copy(Str, 1, 4) = strI2S(ResponseType) + ' '; Until Copy(Str, 1, 4) = strI2S(ResponseType) + ' ';
End; End;
End; End;

View File

@ -5,11 +5,15 @@ Unit m_Tcp_Client_FTP;
Interface Interface
Uses Uses
SysUtils, // replace wordrec and remove
m_io_Sockets, m_io_Sockets,
m_Tcp_Client; m_Tcp_Client;
Type Type
WordRec = Record
Lo : Byte;
Hi : Byte;
End;
TFTPClient = Class(TTCPClient) TFTPClient = Class(TTCPClient)
DataPort : Word; DataPort : Word;
DataIP : String; DataIP : String;
@ -56,8 +60,6 @@ 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;
@ -73,23 +75,15 @@ 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
@ -174,19 +168,13 @@ Begin
If Not FileExist(FileName) Then Exit; If Not FileExist(FileName) Then Exit;
WriteLn ('DEBUG SendFile Passive ', Passive, ' Filename ', FileName);
SetPassive(Passive); SetPassive(Passive);
WriteLn ('DEBUG SETPASSIVE()');
Client.WriteLine ('STOR ' + JustFile(FileName)); Client.WriteLine ('STOR ' + JustFile(FileName));
OK := OpenDataSession; OK := OpenDataSession;
If OK and (GetResponse = 150) Then Begin If OK and (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
@ -252,7 +240,10 @@ Begin
Result := GetResponse = 226; Result := GetResponse = 226;
End Else Begin End Else Begin
WriteLn ('DEBUG unable to open data session, receive aborted'); If IsPassive Then
WriteLn ('DEBUG unable to connect to FTP server for data session')
Else
WriteLn ('DEBUG unable to establish data session on port ', DataPort);
CloseDataSession; CloseDataSession;
End; End;