Movatterモバイル変換


[0]ホーム

URL:


\n"; print "

$urn:

\n"; print "Minutes of the $sesnam working group from the " . &end($ietfnum) . " IETF"; print "\n\n"; return; } my($link)="$wgpath/$date/$sesnam-minutes-$date.txt"; if (-f $link) { print "Status: 200 OK\r\n"; print "Content-type: text/html\r\n\r\n"; print "\nCitation for $urn\n"; print "\n"; print "

$urn:

\n"; print "Minutes of the $sesnam working group from the " . &end($ietfnum) . " IETF"; print "\n\n"; return; } &urn_error("404 Not Found\n");}sub end { my($inarg)=@_; return $inarg . "st" if ($inarg =~ /1$/); return $inarg . "nd" if ($inarg =~ /2$/); return $inarg . "rd" if ($inarg =~ /3$/); return $inarg . "th";}sub resolverfc { my($flag,@bib,$i,$k,$j,$done,@ref); my($l,$link); my($scheme, $value) = @_; $scheme =~ tr/A-Z/a-z/; if (!defined $cite{$scheme}) { &urn_error("404 Not Found\n"); } $flag = 0; open(INPUT, "$cite{$scheme}"); while () { $flag = 1 if (/^0*$value /);Moats Informational [Page 7] RFC 2648 A URN Namespace for IETF Documents August 1999 if ($flag == 1) { last if (/^$/); chop; push @bib,$_; } } if ($scheme ne "rfc") { print "Status: 200 OK\r\n"; print "Content-type: text/html\r\n\r\n"; $bib[0] =~ s/^[0-9]*\s*//; for ($i=0; $i<=$#bib; $i+=1) { last if ($bib[$i] =~ s/\./.<\/B>/); } for ($i=0;$i<=$#bib;$i+=1) { $k=$bib[$i]; while ($k =~ /(fyi|std|rfc|bcp)([0-9]+)(.*)/i) { push @ref,"$1$2"; $k=$3; } $done=""; foreach $j (@ref) { next if ($done =~ $j); $done .= "$j "; $l = $j; $l =~ tr/A-Z/a-z/; $link=&make_link("$l"); $bib[$i] =~ s/$j/$j<\/A>/g; } } print "\nCitation for $urn\n"; print "\n"; $link=&make_link("$scheme$value"); print "

$scheme$value:

\n"; foreach $i (@bib) { print "$i\n"; } print "\n\n"; } else { print "Status: 200 OK\r\n"; print "Content-type: text/html\r\n\r\n"; $bib[0] =~ s/^[0-9]*\s*//; $j=0; for ($i=0; $i<=$#bib; $i+=1) { $j += ($bib[$i] =~ s/, "/,"/); $j += ($bib[$i] =~ s/",/"<\/B>,/); } for ($i=0;$i<=$#bib;$i+=1) {Moats Informational [Page 8] RFC 2648 A URN Namespace for IETF Documents August 1999 $k=$bib[$i]; while ($k =~ /(fyi\s|std\s|rfc|bcp)([0-9]+)(.*)/i) { push @ref,"$1$2"; $k=$3; } $done=""; foreach $j (@ref) { next if ($done =~ $j); $done .= "$j "; $l = $j; $l =~ s/\s//g; $l =~ tr/A-Z/a-z/; $link=&make_link("$l"); $bib[$i] =~ s/$j/$j<\/A>/g; } } print "\nCitation for $urn\n"; print "\n"; $link=&make_link("$scheme$value"); print "

$scheme$value:

\n"; foreach $i (@bib) { print "$i\n"; } print "\n\n"; }}sub make_link { my($sc); my($inarg)=@_; ($sc=$1) if ($inarg =~ /([a-z]*)/); return "/$sc/$inarg.ps" if (-e "/ftp/$sc/$inarg.ps"); return "/$sc/$inarg.html" if (-e "/ftp/$sc/$inarg.html"); return "/$sc/$inarg.txt";}sub urn_error { my($code) = @_; #store failure code here... print "Status: $code"; print "Content-type: text/html\n\n\n"; print "URN Resolution: I2C $code\n"; print "\n"; print "

URN to URC resolution failed for the URN:

\n"; print "

$urn

\n"; print "\n"; print "\n"; exit;Moats Informational [Page 9] RFC 2648 A URN Namespace for IETF Documents August 1999};sub resolveid { my($flag,@bib,$i,$k,$j,$count,@ref); my($l,$link, $hdr, $done); my($value) = @_; my($scheme) = "id"; open(INPUT, "$cite{$scheme}"); while () {## capture record# if ($flag == 1 || /^\s+\"/) { push @bib,$_; ($hdr = -1, $count = 0, $flag = 1) if (/^\s+\"/); $count++ if (/^\s+$/); } if ($count == 1) { $hdr = $#bib if ($hdr == -1); } if ($count == 2) { for ($i=0; $i<=$hdr; $i+=1) { if ($bib[$i] =~ /<(.*)>/) { $l = $1; if ($l eq "draft-$value.txt" || $l eq "draft-$value.ps") { print "Status: 200 OK\r\n"; print "Content-type: text/html\r\n\r\n"; print "\nCitation for $urn\n"; print "\n"; print "$l:\n"; print "
\n";                foreach $i (@bib) {                  print "$i";                }                print "
\n"; print "\n\n"; exit; } } } $flag = 0; @bib = (); } } &urn_error("404 Not Found\n");}Moats Informational [Page 10] RFC 2648 A URN Namespace for IETF Documents August 1999A.2 I2L#!/usr/local/bin/perluse strict;## this is a URN 2 URL resolver for the ietf namespace#my(%pathbase) = ( rfc => "rfc/rfc", fyi => "fyi/fyi", std => "std/std", bcp => "bcp/bcp", id => "internet-drafts/draft-");my(%number2date) = ( 44 => "99mar", 43 => "98dec", 42 => "98aug", 41 => "98apr", 40 => "97dec", 39 => "97aug", 38 => "97apr", 37 => "96dec", 36 => "96jun", 35 => "96mar", 34 => "95dec", 33 => "95jul", 32 => "95apr", 31 => "94dec", 30 => "94jul", 29 => "94mar", 28 => "93nov", 27 => "93jul", 26 => "93mar", 25 => "92nov", 24 => "92jul", 23 => "92mar", 22 => "91nov", 21 => "91jul", 20 => "91mar", 19 => "90dec" );my($wgpath) = "/ftp/ietf";my($urn) = $ENV{'QUERY_STRING'};my($host) = $ENV{'SERVER_NAME'}; #get my host name for ftp: URLsmy($accept) = $ENV{'HTTP_ACCEPT'}; #this is the "Accept:" HTTP header(&resolveid($1), exit) if ($urn =~ /urn:ietf:id:(\S+)/i);(&resolverfc($1, $2), exit) if ($urn =~ /urn:ietf:(\w*):(\d*)/i);(&resolvemtg($1, $2), exit) if ($urn =~ /urn:ietf:mtg:(\d*)-(\w*)/i);&urn_error("400 Bad Request\n");sub resolvemtg { my($ietfnum, $sesnam) = @_; &urn_error("404 Not Found\n") if (!defined $number2date{$ietfnum}); my($date)=$number2date{$ietfnum}; my($link)="$wgpath/$sesnam/$sesnam-minutes-$date.txt"; if (-f $link) { print "Status: 302 Moved temporarily\n"; print "Location: $link\n";Moats Informational [Page 11] RFC 2648 A URN Namespace for IETF Documents August 1999 return; } my($link)="$wgpath/$date/$sesnam-minutes-$date.txt"; if (-f $link) { print "Status: 302 Moved temporarily\n"; print "Location: $link\n"; return; } &urn_error("404 Not Found\n");}sub end { my($inarg)=@_; return $inarg . "st" if ($inarg =~ /1$/); return $inarg . "nd" if ($inarg =~ /2$/); return $inarg . "rd" if ($inarg =~ /3$/); return $inarg . "th";}sub resolverfc { my($flag,@bib,$i,$k,$j,$done,@ref); my($l,$link); my($scheme, $value) = @_; $scheme =~ tr/A-Z/a-z/; &urn_error("404 Not Found\n")if (!defined $pathbase{$scheme}); my($txttry)="/ftp/$pathbase{$scheme}$value.txt"; my($pstry)="/ftp/$pathbase{$scheme}$value.ps"; my($htmltry)="/ftp/$pathbase{$scheme}$value.html";MIME_SWITCH: { if ($accept =~ /application\/postscript/ && -f $pstry) { print "Status: 302 Moved temporarily\n"; print "Location: http://$host/$pathbase{$scheme}$value.ps\n\n"; last MIME_SWITCH; } if ($accept =~ /text\/html/ && -f $htmltry) { print "Status: 302 Moved temporarily0; print "Location: http://$host/$pathbase{$scheme}$value.html\n\n"; last MIME_SWITCH; } if ($accept =~ /\*\/\*|text\/plain/ && -f $txttry) { print "Status: 302 Moved temporarily\n"; print "Location: http://$host/$pathbase{$scheme}$value.txt\n\n"; last MIME_SWITCH; } &urn_error("404 Not Found\n"); }}Moats Informational [Page 12] RFC 2648 A URN Namespace for IETF Documents August 1999sub urn_error { my($code) = @_; #store failure code here... print "Status: $code"; print "Content-type: text/html\n\n\n"; print "URN Resolution: I2L $code\n"; print "\n"; print "

URN to URL resolution failed for the URN:

\n"; print "

$urn

\n"; print "\n"; print "\n"; exit;}sub resolveid { my($flag,@bib,$i,$k,$j,$done,@ref); my($l,$link); my($scheme) = "id"; my($value) = @_; $scheme =~ tr/A-Z/a-z/; &urn_error("404 Not Found\n")if (!defined $pathbase{$scheme}); my($txttry)="/ftp/$pathbase{$scheme}$value.txt"; my($pstry)="/ftp/$pathbase{$scheme}$value.ps"; my($htmltry)="/ftp/$pathbase{$scheme}$value.html";MIME_SWITCH: { if ($accept =~ /application\/postscript/ && -f $pstry) { print "Status: 302 Moved temporarily\n"; print "Location: http://$host/$pathbase{$scheme}$value.ps\n\n"; last MIME_SWITCH; } if ($accept =~ /text\/html/ && -f $htmltry) { print "Status: 302 Moved temporarily\n"; print "Location: http://$host/$pathbase{$scheme}$value.html\n\n"; last MIME_SWITCH; } if ($accept =~ /\*\/\*|text\/plain/ && -f $txttry) { print "Status: 302 Moved temporarily\n"; print "Location: http://$host/$pathbase{$scheme}$value.txt\n\n"; last MIME_SWITCH; } &urn_error("404 Not Found\n"); }}Moats Informational [Page 13] RFC 2648 A URN Namespace for IETF Documents August 1999A.3 I2Ls#!/usr/local/bin/perluse strict;## this is a URN 2 URLs resolver for the ietf namespace#my(@urls);my(%pathbase) = ( rfc => "rfc/rfc", fyi => "fyi/fyi", std => "std/std", bcp => "bcp/bcp", id => "internet-drafts/draft-");my(%number2date) = ( 44 => "99mar", 43 => "98dec", 42 => "98aug", 41 => "98apr", 40 => "97dec", 39 => "97aug", 38 => "97apr", 37 => "96dec", 36 => "96jun", 35 => "96mar", 34 => "95dec", 33 => "95jul", 32 => "95apr", 31 => "94dec", 30 => "94jul", 29 => "94mar", 28 => "93nov", 27 => "93jul", 26 => "93mar", 25 => "92nov", 24 => "92jul", 23 => "92mar", 22 => "91nov", 21 => "91jul", 20 => "91mar", 19 => "90dec" );my($wgpath) = "/ftp/ietf";my($urn) = $ENV{'QUERY_STRING'};my($host) = $ENV{'SERVER_NAME'}; #get my host name for ftp: URLsmy($accept) = $ENV{'HTTP_ACCEPT'}; #this is the "Accept:" HTTP header(&resolveid($1), exit) if ($urn =~ /urn:ietf:id:(\S+)/i);(&resolve1($1, $2), exit) if ($urn =~ /urn:ietf:(\w*):(\d*)/i);(&resolve2($1, $2), exit) if ($urn =~ /urn:ietf:mtg:(\d*)-(\w*)/i);&urn_error("400 Bad Request\n");sub resolve2 { my($ietfnum, $sesnam) = @_; &urn_error("404 Not Found\n") if (!defined $number2date{$ietfnum}); my($date)=$number2date{$ietfnum}; my($link)="$wgpath/$sesnam/$sesnam-minutes-$date.txt"; if (-f $link) {Moats Informational [Page 14] RFC 2648 A URN Namespace for IETF Documents August 1999 $link=~s/^\/ftp\///; my($ftplink)="ftp://$host/$link"; my($httplink)="http://$host/$link"; my($glink)="gopher://$host:70/0/$link"; if ($accept =~ /text\/uri-list/) { #look for text/uri-list, otherwise text/html print "Status: 200 OK\n"; print "Content-type: text/uri-list\n\n\n"; print "#$urn\n"; print "$ftplink\n"; print "$httplink\n"; print "$glink\n"; } if ($accept =~ /\*\/\*|text\/html/) { print "Status: 200 OK\n"; print "Content-type: text/html\n\n\n"; print "URN Resolution: I2Ls\n"; print "\n"; print "

URN $urn resolves to the following URLs:

\n"; print "
\n\n\n"; } return; } my($link)="$wgpath/$date/$sesnam-minutes-$date.txt"; if (-f $link) { $link=~s/^\/ftp\///; my($ftplink)="ftp://$host/$link"; my($httplink)="http://$host/$link"; my($glink)="gopher://$host:70/0/$link"; if ($accept =~ /text\/uri-list/) { #look for text/uri-list, otherwise text/html print "Status: 200 OK\n"; print "Content-type: text/uri-list\n\n\n"; print "#$urn\n"; print "$ftplink\n"; print "$httplink\n"; print "$glink\n"; } if ($accept =~ /\*\/\*|text\/html/) { print "Status: 200 OK\n"; print "Content-type: text/html\n\n\n"; print "URN Resolution: I2Ls\n"; print "\n";Moats Informational [Page 15] RFC 2648 A URN Namespace for IETF Documents August 1999 print "

URN $urn resolves to the following URLs:

\n"; print "
\n\n\n"; } return; } &urn_error("404 Not Found\n");}sub resolve1 { my($flag,@bib,$i,$k,$j,$done,@ref); my($l,$link); my($scheme, $value) = @_; $scheme =~ tr/A-Z/a-z/; &urn_error("404 Not Found\n")if (!defined $pathbase{$scheme}); my($try)="/ftp/$pathbase{$scheme}$value.txt"; if (-f $try) { push(@urls, "http://$host/$pathbase{$scheme}$value.txt"); push(@urls, "ftp://$host/$pathbase{$scheme}$value.txt"); push(@urls, "gopher://$host:70/0/$pathbase{$scheme}$value.txt"); } $try="/ftp/$pathbase{$scheme}$value.ps"; if (-f $try) { push(@urls, "http://$host/$pathbase{$scheme}$value.ps"); push(@urls, "ftp://$host/$pathbase{$scheme}$value.ps"); push(@urls, "gopher://$host:70/0/$pathbase{$scheme}$value.ps"); } $try="/ftp/$pathbase{$scheme}$value.html"; if (-f $try) { push(@urls, "http://$host/$pathbase{$scheme}$value.html"); push(@urls, "ftp://$host/$pathbase{$scheme}$value.html"); } &urn_error("404 Not Found\n") if ($#urls == -1);MIME_SWITCH: { if ($accept =~ /text\/uri-list/) { #look for text/uri-list, otherwise text/html print "Status: 200 OK\n"; print "Content-type: text/uri-list\n\n\n"; print "#$urn\n"; foreach $i (@urls) { print "$i\n"; }Moats Informational [Page 16] RFC 2648 A URN Namespace for IETF Documents August 1999 last MIME_SWITCH; } if ($accept =~ /\*\/\*|text\/html/) { print "Status: 200 OK\n"; print "Content-type: text/html\n\n\n"; print "URN Resolution: I2Ls\n"; print "\n"; print "

URN $urn resolves to the following URLs:

\n"; print "
\n\n\n"; last MIME_SWITCH; } }}sub urn_error { my($code) = @_; #store failure code here... print "Status: $code"; print "Content-type: text/html\n\n\n"; print "URN Resolution: I2L $code\n"; print "\n"; print "

URN to URL resolution failed for the URN:

\n"; print "

$urn

\n"; print "\n"; print "\n"; exit;}sub resolveid { my($flag,@bib,$i,$k,$j,$done,@ref); my($l,$link); my($value) = @_; my($scheme) = "id"; $scheme =~ tr/A-Z/a-z/; &urn_error("404 Not Found\n")if (!defined $pathbase{$scheme}); my($try)="/ftp/$pathbase{$scheme}$value.txt"; if (-f $try) { push(@urls, "http://$host/$pathbase{$scheme}$value.txt"); push(@urls, "ftp://$host/$pathbase{$scheme}$value.txt"); push(@urls, "gopher://$host:70/0/$pathbase{$scheme}$value.txt"); } $try="/ftp/$pathbase{$scheme}$value.ps"; if (-f $try) { push(@urls, "http://$host/$pathbase{$scheme}$value.ps");Moats Informational [Page 17] RFC 2648 A URN Namespace for IETF Documents August 1999 push(@urls, "ftp://$host/$pathbase{$scheme}$value.ps"); push(@urls, "gopher://$host:70/0/$pathbase{$scheme}$value.ps"); } $try="/ftp/$pathbase{$scheme}$value.html"; if (-f $try) { push(@urls, "http://$host/$pathbase{$scheme}$value.html"); push(@urls, "ftp://$host/$pathbase{$scheme}$value.html"); } &urn_error("404 Not Found\n") if ($#urls == -1);MIME_SWITCH: { if ($accept =~ /text\/uri-list/) { #look for text/uri-list, otherwise text/html print "Status: 200 OK\n"; print "Content-type: text/uri-list\n\n\n"; print "#$urn\n"; foreach $i (@urls) { print "$i\n"; } last MIME_SWITCH; } if ($accept =~ /\*\/\*|text\/html/) { print "Status: 200 OK\n"; print "Content-type: text/html\n\n\n"; print "URN Resolution: I2Ls\n"; print "\n"; print "

URN $urn resolves to the following URLs:

\n"; print "
\n\n\n"; last MIME_SWITCH; } }}A.4 I2Ns#!/usr/local/bin/perluse strict;## this is a URN 2 URNs resolver for the ietf namespace#Moats Informational [Page 18] RFC 2648 A URN Namespace for IETF Documents August 1999my(%cite) = ( rfc => "/ftp/rfc/rfc-index.txt", fyi => "/ftp/fyi/fyi-index.txt", std => "/ftp/std/std-index.txt", bcp => "/ftp/rfc/bcp-index.txt");my(%number2date) = ( 44 => "99mar", 43 => "98dec", 42 => "98aug", 41 => "98apr", 40 => "97dec", 39 => "97aug", 38 => "97apr", 37 => "96dec", 36 => "96jun", 35 => "96mar", 34 => "95dec", 33 => "95jul", 32 => "95apr", 31 => "94dec", 30 => "94jul", 29 => "94mar", 28 => "93nov", 27 => "93jul", 26 => "93mar", 25 => "92nov", 24 => "92jul", 23 => "92mar", 22 => "91nov", 21 => "91jul", 20 => "91mar", 19 => "90dec" );my($wgpath) = "/ftp/ietf";my($urn) = $ENV{'QUERY_STRING'};my($host) = $ENV{'SERVER_NAME'}; #get my host name for ftp: URLsmy($port) = $ENV={'SERVER_PORT'};my($accept) = $ENV{'HTTP_ACCEPT'}; #this is the "Accept:" HTTP header(&resolve1($1, $2), exit) if ($urn =~ /urn:ietf:(\w*):(\d*)/i);(&resolve2($1, $2), exit) if ($urn =~ /urn:ietf:mtg:(\d*)-(\w*)/i);&urn_error("400 Bad Request\n");sub resolve2 { my($ietfnum, $sesnam) = @_; &urn_error("404 Not Found\n") if (!defined $number2date{$ietfnum}); my($date)=$number2date{$ietfnum}; my($link)="$wgpath/$sesnam/$sesnam-minutes-$date.txt"; if (-f $link) { if ($accept =~ /text\/uri-list/) { print "Status: 200 OK\n"; print "Content-type: text/uri-list\n\n\n"; print "#$urn\n"; return; } if ($accept =~ /\*\/\*|text]\/html/) { print "Status: 200 OK\n"; print "Content-type: text/html\n\n\n"; print "URN Resolution: I2Ns\n"; print "\n"; print "

URN $urn resolves to the following URNs:

\n"; print "
\n\n\n"; return; } } my($link)="$wgpath/$date/$sesnam-minutes-$date.txt"; if (-f $link) { if ($accept =~ /text\/uri-list/) { print "Status: 200 OK\n"; print "Content-type: text/uri-list\n\n\n"; print "#$urn\n"; return; } if ($accept =~ /\*\/\*|text\/html/) { print "Status: 200 OK\n"; print "Content-type: text/html\n\n\n"; print "URN Resolution: I2Ns\n"; print "\n"; print "

URN $urn resolves to the following URNs:

\n"; print "
\n\n\n"; return; } } &urn_error("404 Not Found\n");}sub end { my($inarg)=@_; return $inarg . "st" if ($inarg =~ /1$/); return $inarg . "nd" if ($inarg =~ /2$/); return $inarg . "rd" if ($inarg =~ /3$/); return $inarg . "th";}sub resolve1 { my($flag,@bib,$i,$k,$j,$done,@ref); my($l,$link); my($scheme, $value) = @_; $scheme =~ tr/A-Z/a-z/; if (!defined $cite{$scheme}) { &urn_error("404 Not Found\n"); } $flag = 0; open(INPUT, "$cite{$scheme}"); while () { $flag = 1 if (/^0*$value /); if ($flag == 1) {Moats Informational [Page 20] RFC 2648 A URN Namespace for IETF Documents August 1999 last if (/^$/); chop; push @bib,$_; } } $k=join " ",@bib; while ($k =~ /(\S*)\s*(fyi|std|rfc|bcp)\s*([0-9]+)(.*)/i) { $k=$4; $a=$2; $b=$3; if (($a ne $scheme || $b ne $value) && ($1 !~ /obso/i)){ $a =~ tr/A-Z/a-z/; $b =~ s/^0*//; push @ref,"urn:ietf:$a:$b"; } }MIME_SWITCH: { if ($accept =~ /text\/uri-list/) { print "Status: 200 OK\n"; print "Content-type: text/uri-list\n\n\n"; print "#$urn\n"; foreach $i (@ref) { print "$i\n"; } last MIME_SWITCH; } if ($accept =~ /\*\/\*|text\/html/) { print "Status: 200 OK\n"; print "Content-type: text/html\n\n\n"; print "URN Resolution: I2Ns\n"; print "\n"; print "

URN $urn resolves to the following URNs:

\n"; print "
\n\n\n";Moats Informational [Page 21] RFC 2648 A URN Namespace for IETF Documents August 1999 }}}sub make_link { my($sc); my($inarg)=@_; ($sc=$1) if ($inarg =~ /([a-z]*)/); return "/$sc/$inarg.ps" if (-e "/ftp/$sc/$inarg.ps"); return "/$sc/$inarg.html" if (-e "/ftp/$sc/$inarg.html"); return "/$sc/$inarg.txt";}sub urn_error { my($code) = @_; #store failure code here... print "Status: $code"; print "Content-type: text/html\n\n\n"; print "URN Resolution: I2Ns $code\n"; print "\n"; print "

URN to URN resolution failed for the URN:

\n"; print "

$urn

\n"; print "\n"; print "\n"; exit;};A.5 I2R#!/usr/local/bin/perluse strict;## this is a URN 2 resource resolver for the ietf namespace#my(%pathbase) = ( rfc => "rfc/rfc", fyi => "fyi/fyi", std => "std/std", bcp => "bcp/bcp", id => "internet-drafts/draft-");my(%number2date) = ( 44 => "99mar", 43 => "98dec", 42 => "98aug", 41 => "98apr",Moats Informational [Page 22] RFC 2648 A URN Namespace for IETF Documents August 1999 40 => "97dec", 39 => "97aug", 38 => "97apr", 37 => "96dec", 36 => "96jun", 35 => "96mar", 34 => "95dec", 33 => "95jul", 32 => "95apr", 31 => "94dec", 30 => "94jul", 29 => "94mar", 28 => "93nov", 27 => "93jul", 26 => "93mar", 25 => "92nov", 24 => "92jul", 23 => "92mar", 22 => "91nov", 21 => "91jul", 20 => "91mar", 19 => "90dec" );my($wgpath) = "/ftp/ietf";my($urn) = $ENV{'QUERY_STRING'};my($host) = $ENV{'SERVER_NAME'}; #get my host name for ftp: URLsmy($accept) = $ENV{'HTTP_ACCEPT'}; #this is the "Accept:" HTTP headerprint "$urn\n";(&resolveid($1), exit) if ($urn =~ /urn:ietf:id:(\S+)/i);(&resolve1($1, $2), exit) if ($urn =~ /urn:ietf:(\w*):(\d*)/i);(&resolve2($1, $2), exit) if ($urn =~ /urn:ietf:mtg:(\d*)-(\w*)/i);&urn_error("400 Bad Request\n");sub resolve2 { my($ietfnum, $sesnam) = @_; &urn_error("404 Not Found\n") if (!defined $number2date{$ietfnum}); my($date)=$number2date{$ietfnum}; my($link)="$wgpath/$sesnam/$sesnam-minutes-$date.txt"; if (-f $link) { print "Status: 200 OK\n"; print "Content-type: text/plain\n\n"; open(FILE, "$link"); while () { print $_; } close FILE; return; } my($link)="$wgpath/$date/$sesnam-minutes-$date.txt"; if (-f $link) { print "Status: 200 OK\n"; print "Content-type: text/plain\n\n"; open(FILE, "$link"); while () { print $_; } close FILE; return; } &urn_error("404 Not Found\n");}Moats Informational [Page 23] RFC 2648 A URN Namespace for IETF Documents August 1999sub end { my($inarg)=@_; return $inarg . "st" if ($inarg =~ /1$/); return $inarg . "nd" if ($inarg =~ /2$/); return $inarg . "rd" if ($inarg =~ /3$/); return $inarg . "th";}sub resolve1 { my($flag,@bib,$i,$k,$j,$done,@ref); my($l,$link); my($scheme, $value) = @_; $scheme =~ tr/A-Z/a-z/; &urn_error("404 Not Found\n")if (!defined $pathbase{$scheme}); my($txttry)="/ftp/$pathbase{$scheme}$value.txt"; my($pstry)="/ftp/$pathbase{$scheme}$value.ps"; my($htmltry)="/ftp/$pathbase{$scheme}$value.html";MIME_SWITCH: { if ($accept =~ /application\/postscript/ && -f $pstry) { print "Status: 200 OK\n"; print "Content-type: application/postscript\n\n"; open(FILE, "$pstry"); while () { print $_; } close FILE; last MIME_SWITCH; } if ($accept =~ /text\/html/ && -f $htmltry) { print "Status: 200 OK\n"; print "Content-type: text/html\n\n"; open(FILE, "$htmltry"); while () { print $_; } close FILE; last MIME_SWITCH; } if ($accept =~ /\*\/\*|text\/plain/ && -f $txttry) { print "Status: 200 OK\n"; print "Content-type: text/plain\n\n"; open(FILE, "$txttry"); while () { print $_; } close FILE; last MIME_SWITCH; }Moats Informational [Page 24] RFC 2648 A URN Namespace for IETF Documents August 1999 &urn_error("404 Not Found\n"); }}sub resolveid { my($flag,@bib,$i,$k,$j,$done,@ref); my($l,$link); my($scheme) = "id"; my($value) = @_; $scheme =~ tr/A-Z/a-z/; &urn_error("404 Not Found\n")if (!defined $pathbase{$scheme}); my($txttry)="/ftp/$pathbase{$scheme}$value.txt"; my($pstry)="/ftp/$pathbase{$scheme}$value.ps"; my($htmltry)="/ftp/$pathbase{$scheme}$value.html";MIME_SWITCH: { if ($accept =~ /application\/postscript/ && -f $pstry) { print "Status: 200 OK\n"; print "Content-type: application/postscript\n\n"; open(FILE, "$pstry"); while () { print $_; } close FILE; last MIME_SWITCH; } if ($accept =~ /text\/html/ && -f $htmltry) { print "Status: 200 OK\n"; print "Content-type: text/html\n\n"; open(FILE, "$htmltry"); while () { print $_; } close FILE; last MIME_SWITCH; } if ($accept =~ /\*\/\*|text\/plain/ && -f $txttry) { print "Status: 200 OK\n"; print "Content-type: text/plain\n\n"; open(FILE, "$txttry"); while () { print $_; } close FILE; last MIME_SWITCH; } &urn_error("404 Not Found\n"); }}Moats Informational [Page 25] RFC 2648 A URN Namespace for IETF Documents August 1999sub urn_error { my($code) = @_; #store failure code here... print "Status: $code"; print "Content-type: text/html\n\n\n"; print "URN Resolution: I2R $code\n"; print "\n"; print "

URN to URL resolution failed for the URN:

\n"; print "

$urn

\n"; print "\n"; print "\n"; exit;}A.6 I2Rs#!/usr/local/bin/perluse strict;## this is a URN 2 resources resolver for the ietf namespace#my(@urls);my(%pathbase) = ( rfc => "rfc/rfc", fyi => "fyi/fyi", std => "std/std", bcp => "bcp/bcp", id => "internet-drafts/draft-");my(%number2date) = ( 44 => "99mar", 43 => "98dec", 42 => "98aug", 41 => "98apr", 40 => "97dec", 39 => "97aug", 38 => "97apr", 37 => "96dec", 36 => "96jun", 35 => "96mar", 34 => "95dec", 33 => "95jul", 32 => "95apr", 31 => "94dec", 30 => "94jul", 29 => "94mar", 28 => "93nov", 27 => "93jul", 26 => "93mar", 25 => "92nov", 24 => "92jul", 23 => "92mar", 22 => "91nov", 21 => "91jul", 20 => "91mar", 19 => "90dec" );my($wgpath) = "/ftp/ietf";my($urn) = $ENV{'QUERY_STRING'};Moats Informational [Page 26] RFC 2648 A URN Namespace for IETF Documents August 1999my($host) = $ENV{'SERVER_NAME'}; #get my host name for ftp: URLsmy($accept) = $ENV{'HTTP_ACCEPT'}; #this is the "Accept:" HTTP header(&resolveid($1), exit) if ($urn =~ /urn:ietf:id:(\s*)/i);(&resolve1($1, $2), exit) if ($urn =~ /urn:ietf:(\w*):(\d*)/i);(&resolve2($1, $2), exit) if ($urn =~ /urn:ietf:mtg:(\d*)-(\w*)/i);&urn_error("400 Bad Request\n");sub resolve2 { my($ietfnum, $sesnam) = @_; my(@vers,$i); &urn_error("404 Not Found\n") if (!defined $number2date{$ietfnum}); my($date)=$number2date{$ietfnum}; my($link)="$wgpath/$sesnam/$sesnam-minutes-$date.txt"; if (-f $link) { push(@vers,$link); } $link="$wgpath/$date/$sesnam-minutes-$date.txt"; if (-f $link) { push(@vers,$link); } &urn_error("404 Not Found\n") if ($#vers==-1); print "Status: 200 OK\n"; print "Content-type: multipart/alternative; boundary=endpart\n\n"; foreach $i (@vers) { print "--endpart\n"; if ($i =~ /html$/) { print "Content-Type: text/html\n\n"; } if ($i =~ /txt$/) { print "Content-Type: text/plain\n\n"; } if ($i =~ /ps$/) { print "Content-Type: application/postscript\n\n"; } open(FILE, "$i"); while () { print "$_"; } close FILE; } print "--endpart\n";}sub resolve1 { my($flag,@bib,$i,$k,$j,$done,@ref);Moats Informational [Page 27] RFC 2648 A URN Namespace for IETF Documents August 1999 my($l,$link,@vers); my($scheme, $value) = @_; $scheme =~ tr/A-Z/a-z/; &urn_error("404 Not Found\n")if (!defined $pathbase{$scheme}); my($try)="/ftp/$pathbase{$scheme}$value.txt"; if (-f $try) { push(@vers, $try); } $try="/ftp/$pathbase{$scheme}$value.ps"; if (-f $try) { push(@vers, $try); } $try="/ftp/$pathbase{$scheme}$value.html"; if (-f $try) { push(@vers, $try); } print "Status: 200 OK\n"; print "Content-type: multipart/alternative; boundary=endpart\n\n"; foreach $i (@vers) { print "--endpart\n"; if ($i =~ /html$/) { print "Content-Type: text/html\n\n"; } if ($i =~ /txt$/) { print "Content-Type: text/plain\n\n"; } if ($i =~ /ps$/) { print "Content-Type: application/postscript\n\n"; } open(FILE, "$i"); while () { print "$_"; } close FILE; } print "--endpart\n";}sub resolveid { my($flag,@bib,$i,$k,$j,$done,@ref); my($l,$link,@vers); my($scheme) = "id"; my($value) = @_; $scheme =~ tr/A-Z/a-z/; &urn_error("404 Not Found\n")if (!defined $pathbase{$scheme}); my($try)="/ftp/$pathbase{$scheme}$value.txt"; if (-f $try) {Moats Informational [Page 28] RFC 2648 A URN Namespace for IETF Documents August 1999 push(@vers, $try); } $try="/ftp/$pathbase{$scheme}$value.ps"; if (-f $try) { push(@vers, $try); } $try="/ftp/$pathbase{$scheme}$value.html"; if (-f $try) { push(@vers, $try); } print "Status: 200 OK\n"; print "Content-type: multipart/alternative; boundary=endpart\n\n"; foreach $i (@vers) { print "--endpart\n"; if ($i =~ /html$/) { print "Content-Type: text/html\n\n"; } if ($i =~ /txt$/) { print "Content-Type: text/plain\n\n"; } if ($i =~ /ps$/) { print "Content-Type: application/postscript\n\n"; } open(FILE, "$i"); while () { print "$_"; } close FILE; } print "--endpart\n";}sub urn_error { my($code) = @_; #store failure code here... print "Status: $code"; print "Content-type: text/html\n\n\n"; print "URN Resolution: I2Rs $code\n"; print "\n"; print "

URN to URL resolution failed for the URN:

\n"; print "

$urn

\n"; print "
[8]ページ先頭

©2009-2025 Movatter.jp