/usr/bin/vfnmz is in namazu2-index-tools 2.0.21-20.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | #! /usr/bin/perl -w
# -*- Perl -*-
#
# vfnmz - program to preview search result with NMZ.field.* and NMZ.result.*
#
# Copyright (C) 1999 Satoru Takabayashi All rights reserved.
# Copyright (C) 2001-2004 Namazu Project All rights reserved.
# This is free software with ABSOLUTELY NO WARRANTY.
#
use strict;
my $INDEX = undef;
my $RESULT = "NMZ.result.normal";
my %FIELD_ALIASES = ('title' => 'subject', 'author' => 'from');
sub compose($$);
if (@ARGV == 0) {
print <<EOFusage;
usage: vfnmz <index> [NMZ.result.foobar]
EOFusage
exit(1);
}
if (defined($ARGV[0])) {
$INDEX = $ARGV[0];
}
if (defined($ARGV[1])) {
$RESULT = $ARGV[1];
}
$RESULT = "$INDEX/$RESULT" unless $RESULT =~ m!/!;
open(RESULT, "$RESULT") || die "$! : $RESULT\n";
chdir $INDEX;
print <<EOM;
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"
"http://www.w3.org/TR/REC-html40/strict.dtd">
<HTML>
<HEAD>
<TITLE>$INDEX</TITLE>
</HEAD>
<BODY LANG="ja">
<H1>$INDEX</H1>
<HR>
<DL>
EOM
my $template = join '', <RESULT>;
my $num = (-s "NMZ.t") / 4;
for (my $i = 0; $i < $num; $i++) {
my $composed = compose($template, $i);
print $composed;
}
sub compose($$) {
my ($template, $idx) = @_;
$template =~ s/\$\{([\w:]+)\}/getfield($1, $idx)/ge;
return $template;
}
sub getfield($$) {
my ($field, $idx) = @_;
my $buf = undef;
if ($field =~ /namazu::counter/) {
return $idx;
} elsif ($field =~ /:/) {
return "???";
}
my $aliases_regex =
join('|', sort {length($b) <=> length($a)} keys %FIELD_ALIASES);
if ($field =~ /^($aliases_regex)$/o) {
$field = $FIELD_ALIASES{$field};
}
open(FIELD, "NMZ.field.$field") || die "$! : NMZ.field.$field\n";
open(FIDX, "NMZ.field.$field.i") || die "$! : NMZ.field.$field.i\n";
seek(FIDX, $idx * 4, 0);
read(FIDX, $buf, 4);
my $ptr = unpack "N", $buf;
seek(FIELD, $ptr, 0);
my $line = <FIELD>;
chomp $line;
$line =~ s/&/&/g; # & should be processed first
$line =~ s/</</g;
$line =~ s/>/>/g;
close(FIELD);
close(FIDX);
return $line;
}
print <<EOM;
</DL>
<HR>
<P>
(bottom)
</P>
</BODY>
</HTML>
EOM
close(RESULT);
|