X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Fgraphs%2Ftools%2Fdraw_graph.cgi;h=e807d97e04edd9917cc4e7bee2692c42b9a77c12;hb=e7e2a523299d807370b292b44e77f46fad1638c9;hp=9f24c7a071e7b95c416dd5bba5d7d8b3891b5fe0;hpb=e85bc43c20254aa85463748eeb95e2e60ed0ccf1;p=helm.git diff --git a/helm/graphs/tools/draw_graph.cgi b/helm/graphs/tools/draw_graph.cgi index 9f24c7a07..e807d97e0 100755 --- a/helm/graphs/tools/draw_graph.cgi +++ b/helm/graphs/tools/draw_graph.cgi @@ -10,7 +10,10 @@ use FindBin; chdir $FindBin::Bin; # chdir to the directory of this perl script -my $d = new HTTP::Daemon LocalPort => 8083; +$drawgraphport = $ENV{'DRAW_GRAPH_PORT'} || $drawgraphport; + +my $d = new HTTP::Daemon LocalPort => $drawgraphport + or die "Error: port $drawgraphport not available."; print "Please contact me at: url, ">\n"; $SIG{CHLD} = "IGNORE"; # do not accumulate defunct processes @@ -22,25 +25,30 @@ while (my $c = $d->accept) { my $http_query = $r->url->equery; my $cgi = new CGI("$http_query"); my $url = $cgi->param('url'); - $url = uri_unescape($url).'¶m.PID='.$$; - print "URL: $url\n"; + $url = $url.'¶m.PID='.$$; + print "URL: $url\n"; my $ua = LWP::UserAgent->new; my $request = HTTP::Request->new(GET => "$url"); my $response = $ua->request($request, "prova0.$$.dot"); - if (system("make PID=$$ > log.$$") == 0) { + if (system("make PID=$$ > log.$$") == 0) { $c->send_file_response("prova.$$.html"); - } else { - $c->send_error(RC_INTERNAL_SERVER_ERROR); - } + } else { + $c->send_error(RC_INTERNAL_SERVER_ERROR); + } } elsif ($r->method eq 'GET' && $r->url->path eq "/get_gif") { my $http_query = $r->url->equery; my $cgi = new CGI("$http_query"); my $pid = $cgi->param('pid'); - print "Returning GIF: $pid\n"; + print "Returning GIF: $pid\n"; $c->send_file_response("prova.$pid.gif"); - system("make PID=$pid clean ; rm -f prova0.$pid.dot"); + system("make PID=$pid clean ; rm -f prova0.$pid.dot"); + } elsif ($r->method eq 'GET' && $r->url->path eq "/help"){ + print "Help requested!\n"; + my $response = new HTTP::Response; + $response->content("Graph Drawer Version: ???"); + $c->send_response($response); } else { $c->send_error(RC_FORBIDDEN) }