head     1.3;
branch   ;
access   ;
symbols  ;
locks    ; strict;
comment  @# @;


1.3
date     95.03.07.14.16.58;  author yonah;  state Exp;
branches ;
next     1.2;

1.2
date     94.11.15.03.17.33;  author nocturne;  state Exp;
branches ;
next     1.1;

1.1
date     94.11.15.03.14.00;  author nocturne;  state Exp;
branches ;
next     ;


desc
@marc eichin's callsign gateway
@


1.3
log
@*** empty log message ***
@
text
@#!/usr/athena/bin/perl
# written by Mark Eichin
# $Id: callsign,v 1.2 1994/11/15 03:17:33 nocturne Exp $

# in progress.
# based on geo.pl

# Hmm. httpd leaves SIGALRM set to SIG_IGN...
#

$SIG{'ALRM'} = 'bailout';   

alarm(60);
sub bailout {
    $SIG{'ALRM'} = "bailout2";
    alarm (10);
    &chat'print("quit\n\r");
    print "</pre>";
    print "<p>Sorry, query took more than 60 seconds. Please try again later.\n";
    exit;
}

sub bailout2 {
    exit;
}

require 'our-chat2.pl';

$query=$ENV{'QUERY_STRING'};

print("Content-Type: text/html\n\n");
$query =join(' ', @@ARGV) if $ARGV[0];
print("\n");
&do_callsign($query);

sub listen {
        local($secs) = @@_;
        local($return,$tmp) = "";
        while (length($tmp = &chat'expect($secs, '(.|\n)+', '$&'))) {
                print $tmp if $trace;
                $return .= $tmp;
        }
	$return;
}
# Call-Sign: N1DPU                    Class: TECHNICIAN
# Previously: KA1MRJ                  Class: NOVICE
# Real Name: MARK W EICHIN            Birthday: FEB 7, 1967
# Mailing Address: 15 POLARIS DR, NEW MILFORD, CT  06776
# Station Address: SAME AS MAILING ADDRESS
# Valid From: JUL 12, 1985            To: JUL 12, 1995
# Records Last Processed: JUL 12, 1985

sub show_credits {
    print "<p><hr>\n";
    print "Send comments to <a href=\"http://www.mit.edu:8001/comment\">eichin@@mit.edu</a>.\n";
    print "<p>\n";
    print "To access the data directly, <pre>   telnet callsign.cs.buffalo.edu 2000</pre>\n";
    return;
}

sub do_callsign {
    local($request)=@@_;
    $request =~ s/\+/ /g;

    if(!$request){
	 print "<isindex><h1>Enter the amateur radio callsign you wish to look up</h1>";
	 print "e.g. <a href=\"/callsign?n1dpu\">\"N1DPU\"</a> <p>";
	 print "This server contains mostly information on locations within the US\n";
	 print "and is provided by the University of Buffalo.<p>";
	 print "Gateway written by <A HREF=\"/people/eichin/mwe.html\">Mark Eichin</A>.\n";
	 &show_credits;
	 return;
    }
print "<isindex>";

&chat'open_port('callsign.cs.buffalo.edu', 2000) || die "open: $!";
$_=&listen(2);
# particularly bogus possible behaviour. 
## < 0x0   fffb01fffb03
## RCVD will ECHO
## SENT do ECHO
## RCVD will SUPPRESS GO AHEAD
## SENT do SUPPRESS GO AHEAD
## > 0x0   fffd01fffd03

if($_ eq "\377\373\001\377\373\003") {
    &chat'print("\377\375\001\377\375\003");
}

while(!/Callbook/){
$_=&listen(5);
}
print("<h1>Amateur License Callbook Query:  \"$request\"</h1><pre>\n");

if($request =~ /^info$/i) {
    &chat'print("more 0\n\r");
    &chat'print("info\n\r");
} else {
    &chat'print("call $request\n\r");
}
$_=&listen(3);
split(/\n/);
shift; # skip the echo'ed query
foreach $dataline (@@_){
	chop($dataline);
	print("$dataline\n") if ($dataline ne ">>");
}
&chat'print("quit\n\r");
print "</pre>";
&show_credits;
}
@


1.2
log
@fixed to use a fixed version of chat2.pl that works under solaris
@
text
@d1 1
a1 1
#!/afs/athena/contrib/perl/p
d3 1
a3 1
# $Id: callsign,v 1.1 1994/11/15 03:14:00 nocturne Exp nocturne $
@


1.1
log
@Initial revision
@
text
@d1 1
a1 1
#!/usr/local/bin/perl
d3 1
a3 1
# $Id: callsign.pl,v 1.3 93/12/31 09:12:51 bert Exp $
d27 1
a27 1
require 'chat2.pl';
@
