#!/usr/local/bin/perl

# WIDE AREA INFORMATION SERVER SOFTWARE:
#   No guarantees or restrictions.  See the readme file for the full standard
#   disclaimer.
#
# A quick shell interface to WAIS:
#   
#      ws <dbname> word ....
#  eg. ws wais-docs  what is wais
#
#Created by Randal L. Schwartz, 
# Stonehenge Consulting Services, Portland, Oregon
# distributed without restriction.

$src = shift;
open(SRC,"$ENV{'HOME'}/wais-sources/$src.src") ||
 open(SRC,"$ENV{'HOME'}/wais-sources/$src") ||
 open(SRC,"$ENV{'WAISCOMMONSOURCEDIR'}/$src.src") ||
 open(SRC,"$ENV{'WAISCOMMONSOURCEDIR'}/$src") ||
 die "Cannot open $1.src: $!";
# print <SRC>;
while(<SRC>) {
	/:ip-name "(.*)"/ && ($ipname = $1);
	/:database-name "(.*)"/ && ($databasename = $1);
	/:tcp-port "(.*)"/ && ($tcpport = $1);
	/:tcp-port (\d+)/ && ($tcpport = $1);
}
close(SRC);
print "waissearch ", 
	"-h ", $ipname,
	" -d ", $databasename,
	" -p ", $tcpport, " ",
	@ARGV, "\n";

exec "waissearch",
	"-h", $ipname,
	"-d", $databasename,
	"-p", $tcpport,
	@ARGV;
