1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632
|
#!/usr/bin/perl -s
#
# cvsweb - a CGI interface to a CVS repository tree.
#
# Note, this is under RCS control in /home/fenner:
# #Header: /home/fenner/cvsweb/RCS/cvsweb,v 1.6 1996/09/12 21:56:32 fenner Exp #
#
# ... and CVS (cvs-buildpackage) control at the Debian GNU/Linux maintainer's.
# $Header: /usr/local/cvsroot/cvsweb/cvsweb.in,v 1.7 1998/03/08 21:00:39 karlheg Exp $
#
# Written by Bill Fenner <fenner@freebsd.org>.
#
# Copyright (C) 1996
# William C. Fenner. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. Neither the name of the author nor the names of any co-contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY William C. Fenner AND CONTRIBUTORS ``AS IS''
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL William C. Fenner, HIS BROTHER B1FF, OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
#
# This script has been modified for the Debian GNU/Linux distribution
# by Karl M. Hegbloom <karlheg@debian.org>. I'll do my best to
# forward modifications and patches upstream, where they apply. The
# Debian GNU/Linux packageing and other modifications are hereby
# Copyright 1998, Software in the Public Interest, Inc., subject to
# the terms of the original licence as stated above by the script's
# author. Share the software, folks.
#
# To do:
# - Parse the ,v yourself instead of using rlog output, since people
# sometimes paste rlog output into commit entries, making it impossible
# to parse.
# - Figure out how to do directory-wide diff's (get named tags cheaply?)
#
# Maybe:
# - Port it to guile-scsh or scheme48-scsh
# - compile or `undump' the perl version
# Read the configuration data.
require '/etc/cvsweb.conf';
require 'timelocal.pl';
require 'ctime.pl';
$cvsweb_version = "@cvsweb_version@";
# $cvsweb_version = "DEBUG";
if (defined($rcsbinaries)) {
$ENV{'PATH'} = $rcsbinaries . ":" . $ENV{'PATH'};
}
$verbose = $v;
($where = $ENV{'PATH_INFO'}) =~ s|^/||;
$where =~ s|/$||;
$fullname = $cvsroot . '/' . $where;
($scriptname = $ENV{'SCRIPT_NAME'}) =~ s|^/?|/|;
$scriptname =~ s|/$||;
$scriptwhere = $scriptname . '/' . $where;
$scriptwhere =~ s|/$||;
foreach $pattern ( @restrict ) {
if ( $fullname =~ m!$pattern! ) {
&fatal("403 - Forbidden", "Access to /$where is prohibited.");
}
}
if (!-d $cvsroot) {
&fatal("500 Internal Error",'$CVSROOT not found!');
}
if (-d $fullname) {
# Something that would be nice to support, although I have no real
# good idea of how, would be to get full directory diff's, using
# symbolic names (revision numbers would be meaningless).
# The problem is finding a list of symbolic names that is common
# to all the files in the directory.
#
opendir(DIR, $fullname) || &fatal("404 Not Found","$where: $!");
@dir = readdir(DIR);
closedir(DIR);
print "Content-type: text/html\n\n";
print "<HTML><HEAD><TITLE>${title}: /$where</TITLE></HEAD>\n";
print "<BODY ";
if (defined ($bgcolor)) {
print "BGCOLOR=\"" . $bgcolor . "\" ";
}
if (defined ($background)) {
print "BACKGROUND=\"" . $background . "\"";
}
print ">\n<!-- Generated by cvsweb-$cvsweb_version -->\n";
print "$h1\n";
if ($where eq '') {
print $intro;
} else {
print $shortinstr;
}
print "<p>Current directory: <b><a href=\"${scriptname}\">\ROOT/</a>";
$d = "";
foreach $s (split(?/?, $where)) {
$d = "$d/$s";
print "<a href=\"${scriptname}${d}\">${s}/</a>";
}
print "</b>\n";
print "<BR><BR><HR><TABLE>\n";
@dir = sort (@dir);
foreach (@dir) {
if ($_ eq '..') {
last if ($where eq '');
($updir = $scriptwhere) =~ s|[^/]+$||;
if (defined($backicon)) {
print "<TH><IMG SRC=\"$backicon\" ALT=\"[UP ]\" ";
if (defined($backicon_w) && defined($backicon_h)) {
print "WIDTH=\"$backicon_w\" HEIGHT=\"$backicon_h\"";
}
print ">";
} else {
print "[UP ]";
}
print " ", &link("Previous Directory",$updir), "</TH><BR>";
last;
}
}
print "<TR><TD WIDTH=33% VALIGN=TOP><PRE>\n";
$n_dir_col = int (@dir / 3);
$n_dir = 0;
foreach (@dir) {
next if ($_ eq '.' || $_ eq '..');
if ($n_dir > $n_dir_col) {
print "</PRE></TD><TD WIDTH=33% VALIGN=TOP><PRE>\n";
$n_dir = 0;
}
if (-d $fullname . "/" . $_) {
if (defined($diricon)) {
print "<IMG SRC=\"$diricon\" ALT=\"[DIR]\" ";
if (defined($diricon_w) && defined($diricon_h)) {
print "WIDTH=\"$diricon_w\" HEIGHT=\"$diricon_h\"";
}
print ">";
} else {
print "[DIR]";
}
print " ",
&link($_ . "/", $scriptwhere . '/' . $_ . '/'), "<BR>";
} elsif (s/,v$//o) {
if (defined($lambdaicon) && m/\.(?:el|lsp|lisp|scm)$/oi) {
print "<IMG SRC=\"$lambdaicon\" ALT=\"[ L ]\" ";
if (defined($lambdaicon_w) && defined($lambdaicon_h)) {
print "WIDTH=\"$lambdaicon_w\" HEIGHT=\"$lambdaicon_h\"";
}
print ">";
}
elsif (defined($cicon) && m/\.(?:c|cxx|cpp)$/oi) {
print "<IMG SRC=\"$cicon\" ALT=\"[ C ]\" ";
if (defined($cicon_w) && defined($cicon_h)) {
print "WIDTH=\"$cicon_w\" HEIGHT=\"$cicon_h\"";
}
print ">";
}
elsif (defined($hicon) && m/\.(?:h|hpp)$/oi) {
print "<IMG SRC=\"$hicon\" ALT=\"[ H ]\"";
if (defined($hicon_w) && defined($hicon_h)) {
print "WIDTH=\"$hicon_w\" HEIGHT=\"$hicon_h\"";
}
print ">";
}
elsif (defined($texticon)) {
print "<IMG SRC=\"$texticon\" ALT=\"[TXT]\"";
if (defined($texticon_w) && defined($texticon_h)) {
print "WIDTH=\"$texticon_w\" HEIGHT=\"$texticon_h\"";
}
print ">";
} else {
print "[TXT]";
}
print " ", &link($_, $scriptwhere . '/' . $_), "<BR>";
}
$n_dir += 1;
}
print "</PRE></TD></TR></TABLE>\n";
print "<HR><ADDRESS>Created by cvsweb-$cvsweb_version</ADDRESS><BR>\n";
print $tailhtml,"\n";
print "</BODY></HTML>\n";
} elsif (-f $fullname . ',v') {
if ($_ = $ENV{'QUERY_STRING'}) {
s/%(..)/sprintf("%c", hex($1))/ge; # unquote %-quoted
if (/rev=([\d\.]+)/) {
$rev = $1;
open(RCS, "co -p$rev '$fullname' 2>&1 |") ||
&fail("500 Internal Error", "Couldn't co: $!");
# /home/ncvs/src/sys/netinet/igmp.c,v --> standard output
# revision 1.1.1.2
# /*
$_ = <RCS>;
if (/^\Q$fullname\E,v\s+-->\s+standard output\s*$/o) {
# As expected
} else {
&fatal("500 Internal Error",
"Unexpected output from co: $_");
}
$_ = <RCS>;
if (/^revision\s+$rev\s*$/) {
# As expected
} else {
&fatal("500 Internal Error",
"Unexpected output from co: $_");
}
$| = 1;
if ($gzip_output) {
print "Content-type: text/plain\n";
print "Content-encoding: x-gzip\n\n";
open(GZIP, "|gzip -9 -c");
print GZIP <RCS>;
close(GZIP);
}
else {
print "Content-type: text/plain\n\n";
print <RCS>;
}
close(RCS);
exit;
}
if (/r1=([^&:]+)(:([^&]+))?/) {
$rev1 = $1;
$sym1 = $3;
}
if ($rev1 eq 'text') {
if (/tr1=([^&]+)/) {
$rev1 = $1;
}
}
if (/r2=([^&:]+)(:([^&]+))?/) {
$rev2 = $1;
$sym2 = $3;
}
if ($rev2 eq 'text') {
if (/tr2=([^&]+)/) {
$rev2 = $1;
}
}
if (!($rev1 =~ /^[\d\.]+$/) || !($rev2 =~ /^[\d\.]+$/)) {
&fatal("404 Not Found",
"Malformed query \"$ENV{'QUERY_STRING'}\"");
}
#
# rev1 and rev2 are now both numeric revisions.
# Thus we do a DWIM here and swap them if rev1 is after rev2.
# XXX should we warn about the fact that we do this?
if (&revcmp($rev1,$rev2) > 0) {
($tmp1, $tmp2) = ($rev1, $sym1);
($rev1, $sym1) = ($rev2, $sym2);
($rev2, $sym2) = ($tmp1, $tmp2);
}
#
$difftype = "-u";
$diffname = "Unidiff";
if (/f=([^&]+)/) {
if ($1 eq 'c') {
$difftype = '-c';
$diffname = "Context diff";
}
}
# XXX should this just be text/plain
# or should it have an HTML header and then a <pre>
print "Content-type: text/plain\n\n";
open(RCSDIFF, "rcsdiff $difftype -r$rev1 -r$rev2 '$fullname' 2>&1 |") ||
&fail("500 Internal Error", "Couldn't rcsdiff: $!");
#
#===================================================================
#RCS file: /home/ncvs/src/sys/netinet/tcp_output.c,v
#retrieving revision 1.16
#retrieving revision 1.17
#diff -c -r1.16 -r1.17
#*** /home/ncvs/src/sys/netinet/tcp_output.c 1995/11/03 22:08:08 1.16
#--- /home/ncvs/src/sys/netinet/tcp_output.c 1995/12/05 17:46:35 1.17
#
# Ideas:
# - nuke the stderr output if it's what we expect it to be
# - Add "no differences found" if the diff command supplied no output.
#
#*** src/sys/netinet/tcp_output.c 1995/11/03 22:08:08 1.16
#--- src/sys/netinet/tcp_output.c 1995/12/05 17:46:35 1.17 RELENG_2_1_0
# (bogus example, but...)
#
if ($difftype eq '-u') {
$f1 = '---';
$f2 = '\+\+\+';
} else {
$f1 = '\*\*\*';
$f2 = '---';
}
while (<RCSDIFF>) {
if (m|^$f1 $cvsroot|o) {
s|$cvsroot/||o;
if ($sym1) {
chop;
$_ .= " " . $sym1 . "\n";
}
} elsif (m|^$f2 $cvsroot|o) {
s|$cvsroot/||o;
if ($sym2) {
chop;
$_ .= " " . $sym2 . "\n";
}
}
print $_;
}
close(RCSDIFF);
exit;
}
open(RCS, "rlog '$fullname'|") || &fatal("500 Internal Error",
"Failed to spawn rlog");
while (<RCS>) {
print if ($verbose);
if ($symnames) {
if (/^\s+([^:]+):\s+([\d\.]+)/) {
$symrev{$1} = $2;
if ($revsym{$2}) {
$revsym{$2} .= ", ";
}
$revsym{$2} .= $1;
} else {
$symnames = 0;
}
} elsif (/^symbolic names/) {
$symnames = 1;
} elsif (/^-----/) {
last;
}
}
# each log entry is of the form:
# ----------------------------
# revision 3.7.1.1
# date: 1995/11/29 22:15:52; author: fenner; state: Exp; lines: +5 -3
# log info
# ----------------------------
logentry:
while (!/^=========/) {
$_ = <RCS>;
print "R:", $_ if ($verbose);
if (/^revision ([\d\.]+)/) {
$rev = $1;
} elsif (/^========/ || /^----------------------------$/) {
next logentry;
} else {
&fatal("500 Internal Error","Error parsing RCS output: $_");
}
$_ = <RCS>;
print "D:", $_ if ($verbose);
if (m|^date:\s+(\d+)/(\d+)/(\d+)\s+(\d+):(\d+):(\d+);\s+author:\s+(\S+);|) {
$yr = $1;
# damn 2-digit year routines
if ($yr > 100) {
$yr -= 1900;
}
$date{$rev} = &timelocal($6,$5,$4,$3,$2 - 1,$yr);
$author{$rev} = $7;
} else {
&fatal("500 Internal Error", "Error parsing RCS output: $_");
}
line:
while (<RCS>) {
print "L:", $_ if ($verbose);
next line if (/^branches:\s/);
last line if (/^----------------------------$/ || /^=========/);
$log{$rev} .= $_;
}
print "E:", $_ if ($verbose);
}
close(RCS);
print "Done reading RCS file\n" if ($verbose);
#
# Sort the revisions into commit-date order.
@revorder = sort {$date{$b} <=> $date{$a}} keys %date;
print "Done sorting revisions\n" if ($verbose);
#
# HEAD is an artificial tag which is simply the highest tag number on the main
# branch. Find it by looking through @revorder; it should at least
# be near the beginning (In fact, it *should* be the first commit listed on
# the main branch.)
revision:
for ($i = 0; $i <= $#revorder; $i++) {
if ($revorder[$i] =~ /^\d+\.\d+$/) {
if ($revsym{$revorder[$i]}) {
$revsym{$revorder[$i]} .= ", ";
}
$revsym{$revorder[$i]} .= "HEAD";
$symrev{"HEAD"} = $revorder[$i];
last revision;
}
}
print "Done finding HEAD\n" if ($verbose);
#
# Now that we know all of the revision numbers, we can associate
# absolute revision numbers with all of the symbolic names, and
# pass them to the form so that the same association doesn't have
# to be built then.
#
# should make this a case-insensitive sort
foreach (sort keys %symrev) {
$rev = $symrev{$_};
if ($rev =~ /^(\d+(\.\d+)+)\.0\.(\d+)$/) {
#
# A revision number of A.B.0.D really translates into
# "the highest current revision on branch A.B.D".
#
# If there is no branch A.B.D, then it translates into
# the head A.B .
#
# This is pure speculation.
#
$head = $1;
$branch = $3;
$regex = $head . "." . $branch;
$regex =~ s/\./\./g;
# <
# \____/
$rev = $head;
revision:
foreach $r (@revorder) {
if ($r =~ /^${regex}/) {
$rev = $head . "." . $branch;
last revision;
}
}
$revsym{$rev} .= ", " if ($revsym{$rev});
$revsym{$rev} .= $_;
}
$sel .= "<OPTION VALUE=\"${rev}:${_}\">$_\n";
}
print "Done associating revisions with branches\n" if ($verbose);
print "Content-type: text/html\n\n";
print "<HTML><HEAD><TITLE>CVS log for $where</TITLE></HEAD>\n";
print "<BODY ";
if (defined ($bgcolor)) {
print "BGCOLOR=\"" . $bgcolor . "\" ";
}
if (defined ($background)) {
print "BACKGROUND=\"" . $background . "\"";
}
print ">\n<!-- Generated by cvsweb-$cvsweb_version -->\n";
print "<H1 align=center>CVS log for $where</H1>\n";
($upwhere = $where) =~ s|[^/]+$||;
print "Up to ", &link($upwhere,$scriptname . "/" . $upwhere);
print "<BR>\n";
print "<A HREF=\"#diff\">Request diff between arbitrary revisions</A>\n";
print "<HR>\n";
# The other possible U.I. I can see is to have each revision be hot
# and have the first one you click do ?r1=foo
# and since there's no r2 it keeps going & the next one you click
# adds ?r2=foo and performs the query.
# I suppose there's no reason we can't try both and see which one
# people prefer...
for ($i = 0; $i <= $#revorder; $i++) {
$_ = $revorder[$i];
# print "RCS revision <b>$_</b>\n";
print "<A HREF=\"$scriptwhere?rev=$_\"><b>$_</b></A>";
if (/^1\.1\.1\.\d+$/) {
print " <i>(vendor branch)</i>";
}
# print "<BR>\n";
# print "Checked in on <i>" . &ctime($date{$_}) . "</i> by ";
# print "<i>" . $author{$_} . "</i><BR>\n";
print " <i>" . &ctime($date{$_}) . "</i> by ";
print "<i>" . $author{$_} . "</i>\n";
if ($revsym{$_}) {
# print "CVS Tags: <b>$revsym{$_}</b><BR>\n";
print "<BR>CVS Tags: <b>$revsym{$_}</b>";
}
if (($br = $_) =~ s/\.\d+$// && $revsym{$br}) {
# print "Branch: <b>$revsym{$br}</b><BR>\n";
if ($revsym{$_}) {
print "; ";
} else {
print "<BR>";
}
print "Branch: <b>$revsym{$br}</b>";
}
# Find the previous revision on this branch.
@prevrev = split(/\./, $_);
if (--$prevrev[$#prevrev] == 0) {
# If it was X.Y.Z.1, just make it X.Y
if ($#prevrev > 1) {
pop(@prevrev);
pop(@prevrev);
} else {
# It was rev 1.1 (XXX does CVS use revisions
# greater than 1.x?)
if ($prevrev[0] != 1) {
print "<i>* I can't figure out the previous revision! *</i>\n";
}
}
}
if ($prevrev[$#prevrev] != 0) {
$prev = join(".", @prevrev);
print "<BR><A HREF=\"$scriptwhere?r1=$prev";
print "&r2=$_\">Diffs to $prev</A>\n";
#
# Plus, if it's on a branch, and it's not a vendor branch,
# offer to diff with the immediately-preceding commit if it
# is not the previous revision as calculated above
# and if it is on the HEAD (or at least on a higher branch)
# (e.g. change gets committed and then brought
# over to -stable)
if (!/^1\.1\.1\.\d+$/ && ($i != $#revorder) &&
($prev ne $revorder[$i+1])) {
@tmp1 = split(/\./, $revorder[$i+1]);
@tmp2 = split(/\./, $_);
if ($#tmp1 < $#tmp2) {
print "; <A HREF=\"$scriptwhere?r1=$revorder[$i+1]";
print "&r2=$_\">Diffs to $revorder[$i+1]</A>\n";
}
}
}
# print "Log message:<BR>\n";
print "<PRE>\n";
print &htmlify($log{$_});
print "</PRE><HR>\n";
}
print "<A NAME=diff>\n";
print "This form allows you to request diffs between any two\n";
print "revisions of a file. You may select a symbolic revision\n";
print "name using the selection box or you may type in a numeric\n";
print "revision using the type-in text box.\n";
print "</A><P>\n";
print "<FORM METHOD=\"GET\" ACTION=\"$scriptwhere\">\n";
print "Diffs between \n";
print "<SELECT NAME=\"r1\">\n";
print "<OPTION VALUE=\"text\" SELECTED>Use Text Field\n";
print $sel;
print "</SELECT>\n";
print "<INPUT TYPE=\"TEXT\" NAME=\"tr1\" VALUE=\"$revorder[$#revorder]\">\n";
print " and \n";
print "<SELECT NAME=\"r2\">\n";
print "<OPTION VALUE=\"text\" SELECTED>Use Text Field\n";
print $sel;
print "</SELECT>\n";
print "<INPUT TYPE=\"TEXT\" NAME=\"tr2\" VALUE=\"$revorder[0]\">\n";
print "<BR><INPUT TYPE=RADIO NAME=\"f\" VALUE=u CHECKED>Unidiff<br>\n";
print "<INPUT TYPE=RADIO NAME=\"f\" VALUE=c>Context diff<br>\n";
print "<INPUT TYPE=SUBMIT VALUE=\"Get Diffs\">\n";
print "</FORM>\n";
print "<HR><ADDRESS>Created by cvsweb-$cvsweb_version</ADDRESS><BR>\n";
print $tailhtml,"\n";
print "</BODY></HTML>\n";
} else {
&fatal("404 Not Found","$where: no such file or directory");
}
sub htmlify {
local($string) = @_;
$string =~ s/&/&/g;
$string =~ s/</</g;
$string =~ s/>/>/g;
$string;
}
sub link {
local($name, $where) = @_;
"<A HREF=\"$where\">$name</A>\n";
}
sub revcmp {
local($rev1, $rev2) = @_;
local(@r1) = split(/\./, $rev1);
local(@r2) = split(/\./, $rev2);
local($a,$b);
while (($a = pop(@r1)) && ($b = pop(@r2))) {
if ($a != $b) {
return $a <=> $b;
}
}
if (@r1) { return 1; }
if (@r2) { return -1; }
return 0;
}
sub fatal {
local($errcode, $errmsg) = @_;
print "Status: $errcode\n";
print "Content-type: text/html\n";
print "\n";
print "<HTML><HEAD><TITLE>Error</TITLE></HEAD>\n";
print "<BODY>Error: $errmsg</BODY></HTML>\n";
exit(1);
}
#
# Example set of environment variables passed to CGI script:
#
#HTTP_USER_AGENT: Mozilla/1.1N (X11; I; SunOS 4.1.3_U1 sun4m) via proxy gateway CERN-HTTPD/3.0 libwww/2.17
#SERVER_NAME: www.freebsd.org
#QUERY_STRING: baz
#SCRIPT_FILENAME: /usr/local/www/cgi-bin/env.pl
#SERVER_PORT: 80
#HTTP_ACCEPT: */*, image/gif, image/x-xbitmap, image/jpeg
#SERVER_PROTOCOL: HTTP/1.0
#HTTP_COOKIE: s=beta26429821397802167
#PATH_INFO: /foo/bar
#REMOTE_ADDR: 13.1.64.94
#DOCUMENT_ROOT: /usr/local/www/data/
#PATH: /sbin:/bin:/usr/sbin:/usr/bin
#PATH_TRANSLATED: /usr/local/www/data//foo/bar
#GATEWAY_INTERFACE: CGI/1.1
#REQUEST_METHOD: GET
#SCRIPT_NAME: /cgi-bin/env.pl
#SERVER_SOFTWARE: Apache/1.0.0
#REMOTE_HOST: beta.xerox.com
#SERVER_ADMIN: webmaster@freebsd.org
|