#!/usr/bin/perl -w # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # use CGI qw(:standard); use XML::Sablotron qw (:all); use Socket; $|++; my ($remote, $port, $iaddr, $proto, $line); #$remote = shift || 'localhost'; $remote = "localhost"; #$port = shift || 8005; $port = 8009; $iaddr = inet_aton($remote); $paddr = sockaddr_in($port,$iaddr); $proto = getprotobyname('tcp'); $stylesheet = "./type.xsl"; $stylesheettype = "text/xsl"; print "Content-Type: text/html\n\n"; #connect to the hpsg server at $addr:$port socket(SOCK,PF_INET,SOCK_STREAM,$proto) or die "socket : $!"; # connect to the server through the socket connect(SOCK, $paddr) or die "connect : $!"; my $type_to_show = param('type'); my $string_to_parse = param('parse'); if (!$string_to_parse) { if (!$type_to_show) { $type_to_show = "likes"; } $line = "(show $type_to_show)"; } else { $line = "(parse \"$string_to_parse\")"; } #my $line = "(show likes)"; $line = "$line\n"; send SOCK,$line,0; #die; #close SOCK; #get the data my $xmlOutput =""; my $htmlOutput =""; while($line = ) { $xmlOutput = $xmlOutput.$line; } #process and output. Process($stylesheet,"arg:/data","arg:/result",undef,["data",$xmlOutput],$htmlOutput); $_ = $htmlOutput; #$_ = $xmlOutput; # pound (#) symbols must be translated to %23 for the web server to pass them #to cgis. s/#/%23/g; $htmlOutput = $_; if (/\S/) { $htmlOutput = $_; print "$htmlOutput\n"; } else { #fixme : put the XML somewhere for debugging purposes... print "

Sorry, there was an error in displaying the output.

Please inform ekoontz\@hiro-tan.dhs.org.\n"; } close SOCK;