#!/usr/gnu/bin/perl.tmp
#sioan 11/96
$nargs=$#ARGV+1;
if ("$nargs" eq 0) {
print "Content-type: text/html\n\n";
print " \n";
print "
Finger Gateway \n";
print " \n";
print " \n";
print " \n";
print " Search for people in DECE \n";
print " \n";
print " \n";
print " \n";
print " \n";
print "
\n";
print " National \n";
print " Technical \n";
print " University \n";
print " of Athens \n";
print "
\n";
print " Department of Electrical and ComputerEngineering \n";
print " \n";
print "
\n";
print "
\n";
print " Search for people in DECE
\n";
print " \n";
print " \n";
print "
\n";
print "
\n";
print " \n";
print "
\n";
print " \n";
print " \n";
print " \n";
exit 2;
}
sub dokill
{
print "Exiting.. \n";
exit 1;
}
$SIG{'INT'} = 'dokill';
(@pname) = @ARGV;
$args=$#ARGV+1;
foreach $i (0 .. $args) {
$pname[$i] =~ s/\\//g;
}
$port = 105 unless $port;
$them="alexander.cc.ece.ntua.gr" unless $them;
if (! @pname) {
print "Content-type: text/html\n\n";
print "\n";
print "\n";
print "\n Not found !\n";
print "\n";
print "
\n";
print "National \n";
print "Technical\n";
print "University of \n";
print "Athens\n";
print "
\n";
print "
Argument Missing
\n";
print "You should have supplied an argument to this page. Please try again.\n";
print "\n";
print "\n";
exit 0;
}
$AF_INET = 2;
$SOCK_STREAM = 1;
$sockaddr = 'S n a4 x8';
($name,$aliases,$proto) = getprotobyname('tcp');
($name,$aliases,$port) = getservbyname($port,'tcp')
unless $port =~ /^\d+$/;
($name,$aliases,$type,$len,$thataddr) = gethostbyname($them);
$that=pack($sockaddr,$AF_INET,$port,$thataddr);
# Make the socket filehandle.
socket(S,$AF_INET,$SOCK_STREAM,$PROTO) || die "socket failed\n";
connect (S, $that) || die "connect failed\n";
# Set socket to be command buffered.
select(S); $| = 1; select(STDOUT);
#Check if there is a match
print S "query name=@pname return name\n";
read (S, $status,3);
if ("$status" eq 102) {
# print STDERR "Match found\n" ;
read (S, $buf,8);
read (S, $buf,1);
#Check if it is "was" or "were"
if ("$buf" eq "a") {
$exist=1;
}
else {
$exist=2;
}
do {$tmp=;} until ($tmp eq "200:Ok.\n");
if ("$exist" eq 2) {
query("name"); @name=@result unless not $result[0];
print "Content-type: text/html\n\n";
print "Valid names are:
\n\n\n";
(@name2)=@name;
foreach $i (0 .. $#name2) {
$name2[$i] =~ s/ /+/g;
}
foreach $i (0 .. $#name) {
print " $name[$i]\n";
}
print "";
exit 2;
}
}
else {
$exist=0;
$tmp=;
print "Content-type: text/html\n\n";
print "\n";
print "\n";
print "\n @pname not found\n";
print "\n";
print "
\n";
print "National \n";
print "Technical\n";
print "University of \n";
print "Athens\n";
print "
\n";
print "
Not Found
\n";
print "@pname is not a valid name. Please try again.\n";
print "\n";
print "\n";
exit 1;
}
# general query sub
sub query {
local($buf);
local($status);
print S "query name=@pname return $_[0]\n";
$buf=;
read(S,$status,1);
read(S,$status,3);
if ("$status" eq 200) {
@result="";
$i=0;
while (1) {
do {read(S,$buf,1);} until ($buf eq ":");
read(S,$buf,1);
if ("$buf" ne O) {
do {read(S,$buf,1);} until ($buf eq ":");
do {read(S,$buf,1);} until ($buf eq ":");
read(S,$buf,1);
chop($result[$i] = );
}
else {
last
}
$i++;
}
$buf=;
#return @result;
}
else {
# print STDERR "project not present \n";
$result[0]="";
$buf=;
$buf=;
}
}
# -- End of sub
# Make the queries:
query("department"); @department=@result unless not $result[0];
query("email"); @email=@result unless not $result[0];
query("name"); @name=@result unless not $result[0];
query("address"); @address=@result unless not $result[0];
query("title"); @title=@result unless not $result[0];
query("phone"); @phone=@result unless not $result[0];
query("hours"); @hours=@result unless not $result[0];
query("project"); @project=@result unless not $result[0];
query("other"); @other=@result unless not $result[0];
query("office_location"); @office_location=@result unless not $result[0];
query("office_address"); @office_address=@result unless not $result[0];
query("home_phone"); @home_phone=@result unless not $result[0];
query("office_phone"); @office_phone=@result unless not $result[0];
query("birthday"); @birthday=@result unless not $result[0];
query("fax"); @fax=@result unless not $result[0];
query("www"); @www=@result unless not $result[0];
query("division"); @division=@result unless not $result[0];
query("mailto"); @mailto=@result unless not $result[0];
# Create the html Output
print "Content-type: text/html\n\n";
print "\n";
print "\n";
print "\n @name personal Home Page \n";
print "\n";
print "
\n";
print "National \n";
print "Technical\n";
print "University of \n";
print "Athens\n";
print "
Department of @department \n";
print "\n";
print "
\n";
print "@name is a @title at the @department department ";
if (@division) {print "(@division division) ";}
print "of the National Technical University of Athens.";
print "
\n";
print "
\n";
print "\n";
if (@office_location) {
print "Office location: $office_location[0]\n";
foreach $i (1 .. $#office_location) {
print " $office_location[$i]\n";
}
}
if (@office_address) {
print "Office address: $office_address[0]\n";
foreach $i (1 .. $#office_address) {
print " $office_address[$i]\n";
}
}
if (@office_phone) {
print "Office phone: $office_phone[0]\n";
foreach $i (1 .. $#office_phone) {
print " $office_phone[$i]\n";
}
}
if (@fax) {
print "Fax: $fax[0]\n";
foreach $i (1 .. $#fax) {
print " $fax[$i]\n";
}
}
if (@hours) {
print "Office hours: @hours
\n";
}
print "
\n";
if (@address) {
print "Home Address: $address[0]\n";
foreach $i (1 .. $#address) {
print " $address[$i]\n";
}
}
if (@phone) {
print "Preferred Phone: $phone[0]\n";
foreach $i (1 .. $#phone) {
print " $phone[$i]\n";
}
}
if (@home_phone) {
print "Home Phone: $home_phone[0]\n";
foreach $i (1 .. $#home_phone) {
print " $home_phone[$i]\n";
}
}
if (@mailto) {
print "E-mail: $mailto[0]\n";
foreach $i (1 .. $#email) {
print " $mailto[$i]\n";
}
}
if (@www) {
print "WWW: $www[0]\n";
foreach $i (1 .. $#www) {
print " $www[$i]\n";
}
}
print "
\n";
if (@other) {
print "Additional
information: @other
\n";
}
if (@project) {
print "
@name is currently working on @project
\n";
}
print "\n\n";
# ------------------------------------ THE END ---------------------------