BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

XPAT search in TIdNNTP

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Internet Winsock
View previous topic :: View next topic  
Author Message
Gummy
Guest





PostPosted: Thu Sep 08, 2005 1:42 pm    Post subject: XPAT search in TIdNNTP Reply with quote



Hello guys,

In need of XPAT search for my nntp client, I quickly wrote the following
method to add to IdNntp; probably contains a couple bugs, doesn't
respect rules, bla bla bla, but if it can save you 5 minutes or so :)

You will notice it is heavily based on XHDR method, and it calls
OnXhdrEntry, as the results returned are in the same format.

Hope it can help Smile
Gummy
----------------------------------------------------------------------
procedure TIdNNTP.XPAT(AHeader : string; startArticle,endArticle :
integer;AParam: String);
var LLine : String;
LMsg, LHeaderData : String;
LCanContinue : Boolean;
SearchPattern : string;
c:char;
i:integer;
begin
if Assigned(FOnXHDREntry) then
begin
// make the search pattern
SearchPattern := 'subject '+inttostr(startArticle)+'-';

// searching the whole group is done by specifying 0 both for
startArticle and endArticle
if endArticle>0 then SearchPattern :=
SearchPattern+inttostr(endArticle);

if AParam<>'' then begin
SearchPattern := SearchPattern+' *';
// make the search pattern case insensitive
// for case sensitive search, just do SearchPattern := SearchPattern +
AParam instead of the for loop.
for i:=1 to length(AParam) do
begin
c:=AParam[i];
SearchPattern := SearchPattern +
'['+uppercase(c)+LowerCase(c)+']';
end;
SearchPattern := SearchPattern+'*';
end;

SendCmd('XPAT ' + SearchPattern, 221);

// code taken from XHDR
BeginWork(wmRead, 0);
try
LLine := IOHandler.ReadLn;
LCanContinue := True;
while (LLine <> '.') and LCanContinue do
begin
ParseXHDRLine(LLine,LMsg,LHeaderData);
FOnXHDREntry(AHeader,LMsg,LHeaderData,LCanContinue);
LLine := IOHandler.ReadLn;
end;
finally
EndWork(wmRead);
end;
end
else
begin
raise EIdNNTPNoOnXHDREntry.Create(RSNNTPNoOnXHDREntry);
end;
end;

----------------------------------------------------------------------
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Internet Winsock All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.