Re: [twsocket] FTP Client - Size() Function

2005-07-31 Thread Frank Wunderlich
Angus Robertson - Magenta Systems Ltd schrieb:
 The only bullet proof way is use CWD and DIR to get a directory 
 listing, and parse it (many different formats) to get the file size.  
 These commands are supported by all FTP servers. 

is there any parsing routine available which works for windows and 
unix-servers?

Greets Frank
-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


[twsocket] [TMimeDec] Boundary detection optimization

2005-07-31 Thread Piotr Hellrayzer Dałek
Hi!

There's possible optimization. Since all MIME boundaries start with
-- (=$2D2D), we could check whether FCurrentData points to two dashes
instead of copying whole data line, switching to lowercase and then
comparing:

procedure TMimeDecode.ProcessWaitBoundary;   { ##ERIC }
var
t : Integer;
s : String;
begin
if (FCurrentData  nil) and (FCurrentData^  #0) and
   {$IFDEF DELPHI2_UP} (PWord(FCurrentData)^=$2D2D) {$ELSE}
   ((FCurrentData[1]=#$2D)and(FCurrentData[2]=#$2D)) {$ENDIF} then begin
[..]

procedure TMimeDecode.ProcessPartLine; { ##ERIC }
var
t   : Integer;
s   : String;{ ##ERIC }
begin
{ Check if end of part (boundary line found) }
if (FCurrentData  nil) and (FCurrentData^  #0) and
   {$IFDEF DELPHI2_UP} (PWord(FCurrentData)^=$2D2D) {$ELSE}
   ((FCurrentData[1]=#$2D)and(FCurrentData[2]=#$2D)) {$ENDIF} then begin

This optimization would make great difference when dealing with large
multipart MIME messages - parsing time of 9,1MB message (large Base64
attachment) was reduced by this optimization to ~20 seconds (from ~30) - on
my old Pentium 120 machine.

-- 
Piotr Hellrayzer Dalek
Author of ICS-Based Hellcore Mailer - an Outlook Express killer
http://www.hcm.prv.pl
[EMAIL PROTECTED]

--
Najlepszy serwis MOTO w Polsce!  http://link.interia.pl/f18a8

-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


[twsocket] [TMimeDec] Preamble and Epilogue

2005-07-31 Thread Piotr Hellrayzer Dałek
Hi!

TMimeDec does NOT ignore MIME preamble and epilogue, so it fails to decode
correctly complex multipart message from RFC 2049 Appendix A. Specifically,
when it sees ending boundary (--boundary--) it starts another part.

Disabling preamble parsing as text/plain is very simple, just have to
check in OnHeaderEnd if the ContentType starts with multipart/ - if so,
we have to ignore next part. With preambles and epilogues of embedded
parts is far worse. Let's see the ProcessPartLine:

procedure TMimeDecode.ProcessPartLine; { ##ERIC }
var
Len : Integer;
t   : Integer;
s   : String;{ ##ERIC }
begin
{ Check if end of part (boundary line found) }
if (FCurrentData  nil) and (FCurrentData^  #0) then begin
s := LowerCase(StrPas(FCurrentData));
if (s = FBoundary) then begin
PreparePart;
exit;
end
else if (s = (FBoundary + '--')) then begin
FEndOfMime := TRUE;
PreparePart;
exit;
end
else begin
for t := 0 to FEmbeddedBoundary.Count - 1 do begin
if (s = FEmbeddedBoundary[t]) or
   (s = (FEmbeddedBoundary[t] + '--')) then begin
{ we now have to wait for the next part }
PreparePart;
exit;
end
end;
end;
end;
[..]  

What do we see? When we hit epilogue of *the message*, we get information
about that we're done with MIME (whatever that should mean...). We don't
get *any* information if we crossed the ending boundary (--boundary--)
and start parsing epilogue. TMimeDec simply starts another part! My fix:

procedure TMimeDecode.ProcessPartLine; { ##ERIC }
var
Len : Integer;
t   : Integer;
s   : String;{ ##ERIC }
begin
{ Check if end of part (boundary line found) }
if (FCurrentData  nil) and (FCurrentData^  #0) then begin
s := LowerCase(StrPas(FCurrentData));
if (s = FBoundary) then begin
PreparePart;
exit;
end
else if (s = (FBoundary + '--')) then begin
FPartOpened := False; //phd
TriggerPartEnd;   //phd
exit;
end
else begin
for t := 0 to FEmbeddedBoundary.Count - 1 do begin
if s = FEmbeddedBoundary[t] then begin //phd
PreparePart; //phd
Exit; //phd
end else if s=(FEmbeddedBoundary[t] + '--')) then begin 
FPartOpened := False; /phd
TriggerPartEnd; //phd
exit; //phd
end
end;
end;
end;
[..]  

And I propose that we throw away that FEndOfMime. From my point of view,
it's useless, and still eats that byte or four (if compiler aligns variables
on dword boundaries).

-- 
Piotr Hellrayzer Dalek
Author of ICS-Based Hellcore Mailer - an Outlook Express killer
http://www.hcm.prv.pl
[EMAIL PROTECTED]

--
Najlepszy serwis MOTO w Polsce!  http://link.interia.pl/f18a8

-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be