From: M.T.Hamilton@lut.ac.uk ("[*] M.T.Hamilton")
Newsgroups: comp.infosystems.gopher
Subject: WAIS based Veronica implementation
Date: 8 Jan 93 17:47:07 GMT
Distribution: comp
Original-To: genie-folk@genie.lut.ac.uk, Steve Guest <S.P.Guest@lut.ac.uk>,
        Jon Knight <J.P.Knight@lut.ac.uk>
Original-Cc: pub@lut.ac.uk, gopher-news@boombox.micro.umn.edu
Mime-Version: 1.0
Content-Type: MULTIPART/MIXED; BOUNDARY="1461776719-502643440-726521217:#12584"

--1461776719-502643440-726521217:#12584
Content-Type: TEXT/PLAIN; charset=US-ASCII

Hi!

I've got Veronica (the Gopher directory service) working using WAIS as the
underlying index mechanism (see attachment) - so now you no longer need a
NeXT machine to run it on :-) Perhaps this will be useful to someone! 

You can see this code in action on a little database (Vera!) of the
contents of some nearby gophers, running on port 8000 of genie.lut.ac.uk -
URL=gopher://genie.lut.ac.uk:8000/7/Vera, e.g. to try it out with the Unix
curses client: 

  ~(martin:261) > gopher genie.lut.ac.uk 8000

To build your own Veronica database, simply take a collection of Gopher
directory objects such as those returned by the Veronica tree-walk, and
index them with WAIS type 'one_line' - then point veronicad at the WAIS
source. 

One area where I think this software would be particularly useful is in
providing a full-text search of the local gopher server(s) only, say as a
root menu item.  Users would be able to say something like this: 

  "does this server know anything about genetic algorithms?"

or

  "where the $#!@ were those class timetables / research papers / ... ?"

What do the rest of you think?!?  Will it catch on?

Martin
--
M.T.Hamilton@lut.ac.uk | cp141@freenet.cleveland.edu | mhamilto@nyx.cs.du.edu
Dept of Computer Studies, Loughborough University of Technology, LE11 3TU, UK
+44.(0)509.222799  "i hope it all melts and is gone by the time i leave"-pjf.

--1461776719-502643440-726521217:#12584
Content-Type: APPLICATION/octet-stream; name=veronicad
Content-ID: <Pine.3.05.9301081956.E12584@genie.lut.ac.uk>
Content-Description: The source

#!/usr/local/bin/perl
#
# Code by Steve Foster, University of Nevada
# WAIS port by Martin Hamilton, Loughborough University, UK
#

#
# Things you might want to change:
#
$host = "genie.lut.ac.uk";               # Host it's running on
$port = 8000;                            # Port number
$waisq = "/usr/local/bin/waisq";         # WAIS query agent
$waissrc = "Vera.src";                   # Source name
$datadir = "/usr/local/etc/Veronica";    # Working directory
$work = "/var/tmp/waisque.$$";           # This query's name
$errs = "/var/tmp/waiserr.$$";           # stderr from $waisq
$log = "/var/log/veronica.log";          # Log file

$query = <STDIN>;
chop($query);
chop($query);
$query =~ s/^\s*//;

if (length($query) < 1) {
  print "7Vera\tVera\t$host\t$port\r\n";
  print ".\r\n";
  exit;
}

return 1 if (-t STDIN);
$sockaddr = 'S n a4 x8';
$hersockaddr = getpeername(STDIN);
($ramily,$rport,$raddr) = unpack($sockaddr,$hersockaddr); 
($a, $b, $c, $d) = unpack('C4', $raddr);

open (LOG, ">>$log" ) || die;
print LOG $a,".",$b,".",$c,".",$d,": ",$query,"\n";

open(SAVEERR, ">&STDERR"); 
open(STDERR, ">$errs");

system("$waisq -f - -S $waissrc -s $datadir -g $query >$work");

close(STDERR);
open(STDERR, ">&SAVEERR");

open(RETURNS, "$errs") || die;
while(<RETURNS>) {
  $_ =~ s/^.*Found\s(.*)\sitems.$/$1/;
  $items = $_;
}
close(RETURNS);

print LOG "Found: ", $items, " items\n";
die if ($items eq 0);

open(SAVEERR, ">&STDERR"); 
open(STDERR, ">$errs");

for($count = 1; $count <= $items; $count++) {
  open(LINKS, "$waisq -f $work -s $datadir -v $count |");
  while(<LINKS>){
    $_ =~ s/\r//;
    $_ =~ s/\n//;
    if (length($_) > 0) {
      print $_, "\r\n";
      print LOG "Returning link:", $_, "\n";
    }
  }
  close(LINKS);
}

close(STDERR);
open(STDERR, ">&SAVEERR");

unlink("$work");
unlink("$errs");

close(LOG);


--1461776719-502643440-726521217:#12584--
Newsgroups: comp.infosystems.gopher