Question on non-dbm history files
Edward Vielmetti
emv at math.lsa.umich.edu
Thu Mar 1 05:44:17 AEST 1990
In article <1990Feb28.172640.25896 at utzoo.uucp> henry at utzoo.uucp (Henry Spencer) writes:
In article <253 at uucs1.UUCP> gaf at uucs1.UUCP () writes:
>Regarding the 2.11 software...
>If I understand rightly, these ever-growing files in my admin/history.d
>directory are used to detect duplicate articles. Okay, but is that all
>they're for?
The one other purpose that dbm (and the assorted substitutes for it)
is intended to fulfill is random article lookup by message-ID. Most of
the news readers will try to do this in some circumstances, but the
circumstances in question are usually use of some obscure command that
nobody ever invokes in practice.
Here's an extremely rough cut at "article", a program to fetch
usenet articles by Message-ID over NNTP, intended to be somewhat
less obscure than most news readers. Invoke it like so:
article "<253 at uucs1.UUCP>"
once you've configured it appropriately.
I would like to teach it to cope with history file formats & be
generally more nice, but for me it works just dandy for now.
Followups to comp.lang.perl where this will probably be hacked
on to pieces.
--Ed
Edward Vielmetti, U of Michigan math dept.
#!/usr/local/bin/perl
# article -- fetch usenet articles by Message-ID.
# usage: article "<253 at uucs1.UUCP>"
# what we have here is perl to fetch articles by id.
# it should do the following:
# cope with B and C formats in dbm or flat file format
# cope with NNTP to the default server
# cope with NNTP to any server specified, or a list.
#
# something like this will work for groups with an
# Original-message-id:
# tag:
#
# cat pointer | article `sed -n -e 's/^Original-message-id: //p'`
# suggested by eci386!clewis
# socket code mailed to me by cmf at obie.cis.pitt.edu (Carl M. Fongheiser)
# history: dbmopen(HIST,'/usr/spool/news/lib/news/history',0666);
# what you get back are offsets to the history file ? dunno.
# Configuration information -- change to reflect your site.
$nntpserver='stag.math.lsa.umich.edu'; # look at ENV, also list;
# should also read dbm or grep
# history file.
$newslib='/usr/spool/news/lib/news/'; # news library
$newspool='/usr/spool/news/'; # news spool
$defport='nntp'; # default nntp port
$debug = 1; # uh, if it don't work
$prog = $0;
$art = $ARGV[0];
if ($nntpserver) {
do 'sys/socket.h' || die "$prog: Can't do sys/socket.h: $@";
$sockaddr = 'S n a4 x8';
chop($hostname = `hostname`);
($name,$aliases,$proto) = getprotobyname('tcp');
($name,$aliases,$port) = getservbyname($defport, 'tcp')
unless $port =~ /^\d+$/;
($name,$aliases,$type,$len,$nntpaddr) = gethostbyname($nntpserver);
($name,$aliases,$type,$len,$localaddr) = gethostbyname($hostname);
$nntp_saddr = pack($sockaddr, &AF_INET, $port, $nntpaddr);
$local_saddr = pack($sockaddr, &AF_INET, 0, $localaddr);
socket(S, &PF_INET, &SOCK_STREAM, $proto) || die "socket: $!";
bind(S, $local_saddr) || die "$prog: bind: $!";
connect(S, $nntp_saddr) || die "$prog: connect: $!";
select(S); $| = 1; select(stdout); # flush after lines
if ($_ = <S>, /^2/) {
$debug && print(STDERR "$prog: connected to nntp server: $_");
} else {
die "$prog: failure: $_\n";
}
print S "article $art\n";
$debug && print (STDERR "$prog: send command article $art\n");
if ($_ = <S>, /^2/) {
$debug && print(STDERR "$prog: article cmd OK: $_");
} else {
die "$prog: failure: $_\n";
}
while ( ($_ = <S>) && !(/^\.\r\n/) ) {
s/^\.//; # take care of hidden dot ....
s/\r$//; # take care of trailing cr
print (STDOUT $_);
}
close(STDOUT);
print (S "quit\n");
close(S);
}
More information about the Alt.sources
mailing list