From 3f97c8438f2197071dbdac41798ab5eeda954ad9 Mon Sep 17 00:00:00 2001 From: mysticbbs Date: Sat, 7 Sep 2013 23:52:11 -0400 Subject: [PATCH] IFDEFS added to reduce EXE size --- mdl/m_tcp_client.pas | 30 +++++++++++++++++++++++------- mdl/m_tcp_client_ftp.pas | 27 +++++++++------------------ 2 files changed, 32 insertions(+), 25 deletions(-) diff --git a/mdl/m_tcp_client.pas b/mdl/m_tcp_client.pas index a780a45..e40193d 100644 --- a/mdl/m_tcp_client.pas +++ b/mdl/m_tcp_client.pas @@ -4,8 +4,12 @@ Unit m_TCP_Client; Interface +{.$DEFINE USESTRINGLIST} + Uses - Classes, + {$IFDEF USESTRINGLIST} + Classes, + {$ENDIF} m_Strings, m_IO_Sockets; @@ -14,7 +18,9 @@ Type Client : TIOSocket; ResponseType : Integer; ResponseStr : String; - ResponseData : TStringList; + {$IFDEF USESTRINGLIST} + ResponseData : TStringList; + {$ENDIF} NetInterface : String; Constructor Create (NetI: String); Virtual; @@ -32,13 +38,19 @@ Begin Client := NIL; NetInterface := NetI; - ResponseData := TStringList.Create; + + {$IFDEF USESTRINGLIST} + ResponseData := TStringList.Create; + {$ENDIF} End; Destructor TTCPClient.Destroy; Begin Client.Free; - ResponseData.Free; + + {$IFDEF USESTRINGLIST} + ResponseData.Free; + {$ENDIF} Inherited Destroy; End; @@ -80,7 +92,9 @@ Begin Result := ResponseType; If ResponseStr[4] = '-' Then Begin - ResponseData.Clear; + {$IFDEF USESTRINGLIST} + ResponseData.Clear; + {$ENDIF} Repeat Res := Client.ReadLine(Str); @@ -88,8 +102,10 @@ Begin If Res < 0 Then Break; - If Res > 0 Then - ResponseData.Add(Str); + {$IFDEF USESTRINGLIST} + If Res > 0 Then + ResponseData.Add(Str); + {$ENDIF} Until Copy(Str, 1, 4) = strI2S(ResponseType) + ' '; End; End; diff --git a/mdl/m_tcp_client_ftp.pas b/mdl/m_tcp_client_ftp.pas index 1e6ea51..26bbbbe 100644 --- a/mdl/m_tcp_client_ftp.pas +++ b/mdl/m_tcp_client_ftp.pas @@ -5,11 +5,15 @@ Unit m_Tcp_Client_FTP; Interface Uses - SysUtils, // replace wordrec and remove m_io_Sockets, m_Tcp_Client; Type + WordRec = Record + Lo : Byte; + Hi : Byte; + End; + TFTPClient = Class(TTCPClient) DataPort : Word; DataIP : String; @@ -56,8 +60,6 @@ Var Begin Result := False; - WriteLn ('DEBUG OPEN DATA 1'); - If DataSocket <> NIL Then Begin DataSocket.Free; DataSocket := NIL; @@ -73,23 +75,15 @@ 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 @@ -174,19 +168,13 @@ Begin If Not FileExist(FileName) Then Exit; - WriteLn ('DEBUG SendFile Passive ', Passive, ' Filename ', FileName); - SetPassive(Passive); - WriteLn ('DEBUG SETPASSIVE()'); - Client.WriteLine ('STOR ' + JustFile(FileName)); OK := OpenDataSession; If OK and (GetResponse = 150) Then Begin - WriteLn ('DEBUG BEGIN SEND FILE'); - Assign (F, FileName); If ioReset(F, 1, fmRWDN) Then Begin @@ -252,7 +240,10 @@ Begin Result := GetResponse = 226; 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; End;