Article View: borland.public.cppbuilder.internet.socket
Article #1646Re: Tranlation problem
From: Roger Hemme
Date: Fri, 15 Dec 2006 06:13
Date: Fri, 15 Dec 2006 06:13
113 lines
4740 bytes
4740 bytes
Remy Lebeau (TeamB) skrev:
> What exactly are you trying to do? What exactly is not working for you?
> Please be more specific.
> You did not show the original C++ code that you are trying to translate, and
> it is not in the newsgroup archives. I cannot tell you if the translation
> is accurate or not.
>
>
You're right. I should have been more spesific.Sorry about that.
I'm trying download newsgroup articles in a threaded layout.
I found the discussion here:
http://216.101.185.148/scripts/isapi.dll/thread?id=5D6C5471&thread=1267947
The BCB-code:
TTreeNode* __fastcall FindParentMessage(TStrings *Messages, AnsiString
References)
{
if( !References.IsEmpty() )
{
char *pFirst = References.c_str();
char *pStop = (pFirst+2);
char *pStart, *pEnd = References.AnsiLastChar();
// scan through the reference list from back to front as
// newer messages in a discussion are at the end of the list
while( pEnd > pStop )
{
// find the end of the MsgID
while( (pEnd > pStop) && (*pEnd != '>') ) --pEnd;
if( pEnd == pStop ) break;
// find the start of the MsgID
pStart = (pEnd-1);
while( (pStart >= pFirst) && (*pStart != '<') ) --pStart;
if( pStart < pFirst ) break;
// find the MsgID in the stored list. chances are, the
parent
// message was downloaded just prior to the message
currently
// being processed, so scan the stored messages from
last to
first
AnsiString MsgIdToFind(pStart, pEnd-pStart+1);
for(int idx = Messages->Count-1; idx >= 0; --idx)
{
if( Messages->Strings[idx] == MsgIdToFind )
// MsgID was found
return (TTreeNode*)Messages->Objects[idx];
}
// keep going
pEnd = (pStart-1);
}
}
// MsgID not found
return NULL;
}
//...
TStringList *Messages = new TStringList;
try
{
TStringList *XOverData = new TStringList;
try
{
int ArticleIndex, ByteCount, LineCount;
AnsiString Subject, From, MsgId, References, ExtraData;
TDateTime dtDate;
TTreeNode *Node;
// use whatever article indexes you are actually downloading
IdNNTP1->XOVER(AnsiString(IdNNTP1->MsgLow) + "-" +
AnsiString(IdNNTP1->MsgHigh), XOverData);
TreeView1->Items->BeginUpdate();
try
{
for(int x = 0; x < XOverData->Count; ++x)
{
IdNNTP1->ParseXOVER(XOverData->Strings[x],
ArticleIndex,
Subject, From, dtDate, MsgId, References, ByteCount, LineCount, ExtraData);
Node = FindParentMessage(Messages, References);
if( Node )
Node = TreeView1->Items->AddChild(Node, Subject);
else
Node = TreeView1->Items->Add(NULL, Subject);
}
Messages->AddObject(MsgId, Node);
}
}
__finally {
TreeView1->Items->EndUpdate();
}
}
__finally {
delete XOverData;
}
}
__finally {
delete Messages;
}
Technical Details
Message-ID:
<45823D21.30200@net.nl>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news2.google.com!news.germany.com!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<4581cf08@newsgroups.borland.com> <4581d5f4$2@newsgroups.borland.com> <4581DE1B.7050909@net.nl> <45820e5d@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,882d665e9542934a X-Google-Attributes: gid11508e,public X-Google-Language: ENGLISH,ASCII-7-bit Message-ID: <45823D21.30200@net.nl> Date: Fri, 15 Dec 2006 07:13:53 +0100 From: Roger Hemme <rog@net.nl> User-Agent: Mozilla Thunderbird 1.0.7 (Windows/20050923) X-Accept-Language: nb, no, nn MIME-Version: 1.0 Newsgroups: borland.public.cppbuilder.internet.socket To: "Remy Lebeau (TeamB)" <no.spam@no.spam.com> Subject: Re: Tranlation problem References: <4581cf08@newsgroups.borland.com> <4581d5f4$2@newsgroups.borland.com> <4581DE1B.7050909@net.nl> <45820e5d@newsgroups.borland.com> In-Reply-To: <45820e5d@newsgroups.borland.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 85.164.106.48 X-Trace: newsgroups.borland.com 1166163163 85.164.106.48 (14 Dec 2006 22:12:43 -0700) Lines: 114 Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news2.google.com!news.germany.com!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail