%# -*-perl-*- $Id: bsearch.html,v 1.3 2000/11/08 22:22:17 xi Exp $ <%doc> ############################################################################### # Usenet Indexer - A nice and fast usenet indexer # Copyright (C) 2000 Christian Laursen # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ############################################################################### <%perl> my $buffer; my $searchtime; local *FILE; if (open (FILE, "<$resfile") && (stat($resfile))[7]) { read (FILE, $buffer, 16); my ($secs1,$usecs1,$secs2,$usecs2) = unpack("LLLL", $buffer); my $secs = $secs2 - $secs1; my $usecs = $usecs2 - $usecs1; if ($usecs < 0) { $secs--; $usecs += 1000000; } $searchtime = sprintf ("%d.%06d", $secs, $usecs); $m->out('Results: '.(((stat($resfile))[7]-16) / 8)."\n"); $m->out("Searchtime: $searchtime\n"); if ($offset =~ /^\d+$/) { seek (FILE, $offset * 8 + 16, 0); } my $i = 0; my $show = 25; while (read (FILE, $buffer, 8) && $i++ < $show) { my ($id,$hits) = unpack("II", $buffer); my $hfile = sprintf("../data/article/%08x.headers", $id); my ($from, $subject); open (FILE2, "<$hfile") or die "Couldn't read file: $!"; while () { if (m/^From: (.*)$/) { $from = $1; } elsif (m/^Subject: (.*)$/) { $subject = $1; } } close FILE2; $m->out("Id: $id\n"); $m->out("From: $from\n"); $m->out("Subject: $subject\n"); $m->out("Score: $hits\n"); } close FILE; } <%args> $search => '' @groups => () $maxage => 0 $offset => 0 <%init> &deja_init; my $resfile = search(\$search, \@groups, $maxage);