Article View: news.software.readers
Article #42934Re: [slrn] Could extract_article_header() return # of lines?
From: Lloyd Zusman
Date: Sun, 30 Aug 1998 00:00
Date: Sun, 30 Aug 1998 00:00
116 lines
5032 bytes
5032 bytes
bluemoon@ux6.cso.uiuc.edu (Dawn Owens-Nicholson) writes:
> Lloyd Zusman <ljz@asfast.com> wrote:
> > I'd be happy if this was simply the contents of the "Lines:" header, which
> > is currently ignored by `extract_acticle_header()'.
>
> I believe it's a bug in extract_article_header(). extract_article_header()
> doesn't ignore Lines:, you have to make the target article the most recently
> read article (selecting the article and, optionally, hiding it, for
> instance) in order for extract_article_header("Lines") to do the right
> thing.
Hmmm ... how would I do that? Here's some sample code that
illustrates how I'm traversing all the articles in a given newsgroup.
Note that if I'm looking for certain other headers (such as the "From"
header), this works fine. Also note that my application requires that
I do this within `article_mode_hook()' ...
%%% Sample only ...
define article_mode_hook ()
{
call( "header_bob" );
uncollapse_threads();
do
{
%%% What do I do here to make each article the
%%% 'most recently read' article?
variable stringLines = extract_article_header( "Lines" );
variable integerLines = integer( strtrim( stringLines ) );
%%% At this point, `stringLines' is the empty string and
%%% `integerLines' is zero.
variable stringFrom = extract_article_header( "From" );
%%% At this point, `stringFrom' contains the text from
%%% the appropriate "From:" line.
} while ( header_down( 1 ) );
collapse_threads();
call( "header_bob" );
}
> [ ... ]
>
> > I'm happy to supply a patch to slrn which would provide this functionality,
> > but before I do, I'm wondering if there is some compelling reason for not
> > doing this.
>
> I can't think of any, but there are two bugs here, one of which I think JED
> already knows about (the leading whitespace bug).
Here's a potential fix for one of the bugs. It allows the "Lines"
header to be recognized even if the header is not for the "most
recently raed" article.
The `slrn_extract_header' routine in `art.c' is what gets called by
`extract_article_header'. Here's the beginning of the code in this
routine (with some of the lines wrapped to fit within 80 columns):
char *slrn_extract_header (char *hdr, unsigned int len) /*{{{*/
{
Slrn_Article_Line_Type *l;
if (Slrn_Current_Header == NULL)
return NULL;
if ((len > 2) && (hdr[len-1] == ' ') && (hdr[len-2] == ':'))
len--;
if (Slrn_Current_Header != Header_Showing)
{
if (0 == slrn_case_strncmp ((unsigned char *)"From: ",
(unsigned char *) hdr, len))
return Slrn_Current_Header->from;
if (0 == slrn_case_strncmp ((unsigned char *)"Subject: ",
(unsigned char *)hdr, len))
return Slrn_Current_Header->subject;
if (0 == slrn_case_strncmp ((unsigned char *)"Message-Id: ",
(unsigned char *)hdr, len))
return Slrn_Current_Header->msgid;
if (0 == slrn_case_strncmp ((unsigned char *)"Date: ",
(unsigned char *) hdr, len))
return Slrn_Current_Header->date;
if (0 == slrn_case_strncmp ((unsigned char *)"References: ",
(unsigned char *)hdr, len))
return Slrn_Current_Header->refs;
if (0 == slrn_case_strncmp ((unsigned char *)"Xref: ",
(unsigned char *) hdr, len))
return Slrn_Current_Header->from;
/***** FIX STARTS HERE *****/
if (0 == slrn_case_strncmp ((unsigned char *)"Lines: ",
(unsigned char *) hdr, len))
{
static char linesBuf[16];
sprintf(linesBuf, "%d", Slrn_Current_Header->lines);
return linesBuf;
}
/***** FIX ENDS HERE *****/
return NULL;
}
/* ... etc. ... */
Can anyone see anything wrong with this proposed fix?
--
Lloyd Zusman
ljz@asfast.com
Technical Details
Message-ID:
<lt1zpypadr.fsf@asfast.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.mbox.zip!not-for-mailReferences:
<slrn6uha35.l0.ljz@sunspot.tiac.net> <slrn6uj1m0.ff1.bluemoon@ux6.cso.uiuc.edu>Show Full Headers
Complete Article Headers
Message-ID: <lt1zpypadr.fsf@asfast.com> Subject: Re: [slrn] Could extract_article_header() return # of lines? Date: Sun, 30 Aug 1998 00:00:00 +0000 From: Lloyd Zusman <ljz@asfast.com> References: <slrn6uha35.l0.ljz@sunspot.tiac.net> <slrn6uj1m0.ff1.bluemoon@ux6.cso.uiuc.edu> Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.mbox.zip!not-for-mail X-Deja-AN: 386212166 X-Complaints-To: newsabuse@supernews.com X-Trace: 904503467 NHG18.M.GE264CCFD usenet46.supernews.com Organization: http://www.supernews.com, The World's Usenet: Discussions Start Here Newsgroups: news.software.readers