- } elsif ($http_method eq 'GET' and $http_path eq "/get") {
- # finds the uris, urls and filenames
- my $cicuri = $inputuri,
- $typesuri = $inputuri,
- $annuri = $inputuri;
- my $annsuffix;
- if ($inputuri =~ /\.types$/) {
- $cicuri =~ s/(.*)\.types$/$1/;
- undef($annuri);
- } elsif ($inputuri =~ /\.types\.ann$/) {
- $cicuri =~ s/(.*)\.types\.ann$/$1/;
- $typesuri =~ s/(.*)\.ann$/$1/;
- $annsuffix = ".types.ann";
- } elsif ($inputuri =~ /\.ann$/) {
- $cicuri =~ s/(.*)\.ann$/$1/;
- undef($typesuri);
- $annsuffix = ".ann";
- } else {
- undef($typesuri);
- undef($annuri);
- }
-
- my $cicfilename = $cicuri;
- $cicfilename =~ s/cic:(.*)/$1/;
- $cicfilename =~ s/theory:(.*)/$1/;
- $cicfilename = $helm_dir.$cicfilename;
-
- my $cicurl = $map{$cicuri};
- my $typesurl = $map{$typesuri} if (defined($typesuri));
- my $annurl = $map{$annuri} if (defined($annuri));
- my ($cicext, $typesext, $annext);
- if ($cicurl =~ /\.xml$/) { # normal file
- $cicext = ".xml";
- } elsif ($cicurl =~ /\.xml\.gz$/) { # gzipped file
- $cicext = ".xml.gz";
- } else {
- die "unexpected extension in url: $cicurl;".
- "might be '.xml' or '.xml.gz'";
- }
- if (defined($typesuri)) { # extension selection for types file
- if ($typesurl =~ /\.xml$/) { # normal file
- $typesext = ".types.xml";
- } elsif ($typesurl =~ /\.xml\.gz$/) { # gzipped file
- $typesext = ".types.xml.gz";
- } else {
- die "unexpected extension in url: $typesurl;".
- "might be '.xml' or '.xml.gz'";
- }
- }
- if (defined($annuri)) { # extension selection for annotation file
- if ($annurl =~ /\.xml$/) { # normal file
- $annext = ".xml";
- } elsif ($annurl =~ /\.xml\.gz$/) { # gzipped file
- $annext = ".xml.gz";
- } else {
- die "unexpected extension in url: $annurl".
- "might be '.xml' or '.xml.gz'";
- }
- }
- my $typesfilename = $cicfilename.$typesext if $typesuri;
- my $annfilename = $cicfilename.$annsuffix.$annext if $annuri;
- $cicfilename .= $cicext;
-
- if (!defined($cicurl) ||
- (!defined($typesurl) && $typesuri) ||
- (!defined($annuri) && $annuri))
- {
- print "\nNOT FOUND!!!!!\n";
- $c->send_error(RC_NOT_FOUND)
- } else {
- print_request("cic",$cicuri,$cicurl,$cicfilename);
- print_request("types",$typesuri,$typesurl,$typesfilename)
- if ($typesuri);
- print_request("ann",$annuri,$annurl,$annfilename)
- if ($annuri);
-
- # Retrieves the files
-
- my $ciccontent = download(1,"cic",$cicurl,$cicfilename);
- my $typescontent =
- download(1,"types",$typesurl,$typesfilename) if ($typesuri);
- my $anncontent =
- download(1,"ann",$annurl,$annfilename) if ($annuri);
-
- # Merging the files together
-
- my $merged = <<EOT;
-<?xml version="1.0" encoding="UTF-8"?>
-<cicxml uri="$cicuri">
-$ciccontent
-$typescontent
-$anncontent
-</cicxml>
-EOT
-
- # Answering the client
- answer($c,$merged);
- }
- } elsif ($http_method eq 'GET' and $http_path eq "/getdtd") {