Annotation of cvsweb/cvsweb.cgi, Revision 3.1
3.1 ! knu 1: #!/usr/bin/perl -ws
1.1 jfieber 2: #
3.1 ! knu 3: # cvsweb - a CGI interface to CVS trees.
1.1 jfieber 4: #
3.1 ! knu 5: # Written in their spare time by
! 6: # Bill Fenner <fenner@FreeBSD.org> (original work)
! 7: # extended by Henner Zeller <zeller@think.de>,
! 8: # Henrik Nordstrom <hno@hem.passagen.se>
! 9: # Ken Coar <coar@Apache.Org>
! 10: # Dick Balaska <dick@buckosoft.com>
! 11: # Akinori MUSHA <knu@FreeBSD.org>
! 12: #
! 13: # Based on:
! 14: # * Bill Fenners cvsweb.cgi revision 1.28 available from:
! 15: # http://www.freebsd.org/cgi/cvsweb.cgi/www/en/cgi/cvsweb.cgi
1.1 jfieber 16: #
1.21 wosch 17: # Copyright (c) 1996-1998 Bill Fenner
3.1 ! knu 18: # (c) 1998-1999 Henner Zeller
! 19: # (c) 1999 Henrik Nordstrom
! 20: # (c) 2000 Akinori MUSHA
1.21 wosch 21: # All rights reserved.
22: #
23: # Redistribution and use in source and binary forms, with or without
24: # modification, are permitted provided that the following conditions
25: # are met:
26: # 1. Redistributions of source code must retain the above copyright
27: # notice, this list of conditions and the following disclaimer.
28: # 2. Redistributions in binary form must reproduce the above copyright
29: # notice, this list of conditions and the following disclaimer in the
30: # documentation and/or other materials provided with the distribution.
31: #
32: # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
33: # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
34: # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
35: # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
36: # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37: # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
38: # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39: # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
40: # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
41: # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
42: # SUCH DAMAGE.
43: #
3.1 ! knu 44: # $Id: cvsweb.cgi,v 3.1.1.1 2000/07/19 21:55:57 knu Exp $
1.21 wosch 45: #
3.1 ! knu 46: ###
! 47:
! 48: use strict;
1.21 wosch 49:
3.1 ! knu 50: use vars qw (
! 51: $config $allow_version_select $verbose
! 52: %CVSROOT %CVSROOTdescr %MIRRORS %DEFAULTVALUE %ICONS %MTYPES
! 53: %alltags @tabcolors %fileinfo %tags @branchnames %nameprinted
! 54: %symrev %revsym @allrevisions %date %author @revdisplayorder
! 55: @revisions %state %difflines %log %branchpoint @revorder $prcgi
! 56: @prcategories $prcategories
! 57: $checkoutMagic $doCheckout $scriptname $scriptwhere
! 58: $where $Browser $nofilelinks $maycompress @stickyvars
! 59: %functionlineregexp
! 60: %input $query $barequery $sortby $bydate $byrev $byauthor
! 61: $bylog $byfile $hr_default $logsort $cvstree $cvsroot
! 62: $mimetype $defaultTextPlain $defaultViewable $allow_compress
! 63: $GZIPBIN $backicon $diricon $fileicon $fullname $newname
! 64: $cvstreedefault $body_tag $logo $defaulttitle $address
! 65: $backcolor $long_intro $short_instruction $shortLogLen
! 66: $show_author $dirtable $tablepadding $columnHeaderColorDefault
! 67: $columnHeaderColorSorted $hr_breakable $hr_funout $hr_ignwhite
! 68: $hr_ignkeysubst $diffcolorHeading $diffcolorEmpty $diffcolorRemove
! 69: $diffcolorChange $diffcolorAdd $diffcolorDarkChange $difffontface
! 70: $difffontsize $inputTextSize $mime_types $allow_annotate
! 71: $allow_markup $use_java_script $open_extern_window
! 72: $extern_window_width $extern_window_height $edit_option_form
! 73: $checkout_magic $show_subdir_lastmod $show_log_in_markup $v
! 74: $navigationHeaderColor $tableBorderColor $markupLogColor
! 75: $tabstop $state $annTable $sel $curbranch @HideModules
! 76: $module $use_descriptions %descriptions @mytz $dwhere $moddate
! 77: $use_moddate
! 78: );
! 79:
! 80: ##### Start of Configuration Area ########
! 81: # == EDIT this ==
! 82: # User configuration is stored in
! 83: $config = $ENV{'CVSWEB_CONFIG'} || '/usr/local/etc/cvsweb.conf';
! 84:
! 85: # == Configuration defaults ==
! 86: # Defaults for configuration variables that shouldn't need
! 87: # to be configured..
! 88: $allow_version_select = 1;
! 89:
! 90: ##### End of Configuration Area ########
! 91:
! 92: ######## Configuration variables #########
! 93: # These are defined to allow checking with perl -cw
! 94: %CVSROOT = %MIRRORS = %DEFAULTVALUE = %ICONS = %MTYPES =
! 95: %tags = %alltags = @tabcolors = ();
! 96: $cvstreedefault = $body_tag = $logo = $defaulttitle = $address =
! 97: $backcolor = $long_intro = $short_instruction = $shortLogLen =
! 98: $show_author = $dirtable = $tablepadding = $columnHeaderColorDefault =
! 99: $columnHeaderColorSorted = $hr_breakable = $hr_funout = $hr_ignwhite =
! 100: $hr_ignkeysubst = $diffcolorHeading = $diffcolorEmpty = $diffcolorRemove =
! 101: $diffcolorChange = $diffcolorAdd = $diffcolorDarkChange = $difffontface =
! 102: $difffontsize = $inputTextSize = $mime_types = $allow_annotate =
! 103: $allow_markup = $use_java_script = $open_extern_window =
! 104: $extern_window_width = $extern_window_height = $edit_option_form =
! 105: $checkout_magic = $show_subdir_lastmod = $show_log_in_markup = $v =
! 106: $navigationHeaderColor = $tableBorderColor = $markupLogColor =
! 107: $tabstop = $use_moddate = $moddate = undef;
1.21 wosch 108:
3.1 ! knu 109: ##### End of configuration variables #####
! 110:
! 111: use Time::Local;
! 112: use IPC::Open2;
1.1 jfieber 113:
114: $verbose = $v;
3.1 ! knu 115: $checkoutMagic = "~checkout~";
! 116: $where = defined($ENV{'PATH_INFO'}) ? $ENV{'PATH_INFO'} : "";
! 117: $doCheckout = ($where =~ /^\/$checkoutMagic/);
! 118: $where =~ s|^/($checkoutMagic)?||;
! 119: $where =~ s|/+$||;
1.1 jfieber 120: ($scriptname = $ENV{'SCRIPT_NAME'}) =~ s|^/?|/|;
3.1 ! knu 121: $scriptname =~ s|/+$||;
! 122: if ($where) {
! 123: $scriptwhere = $scriptname . '/' . urlencode($where);
! 124: }
! 125: else {
! 126: $scriptwhere = $scriptname;
! 127: }
! 128: $scriptwhere =~ s|/+$||;
! 129:
! 130: # in lynx, it it very annoying to have two links
! 131: # per file, so disable the link at the icon
! 132: # in this case:
! 133: $Browser = $ENV{'HTTP_USER_AGENT'};
! 134: $nofilelinks = ($Browser =~ m'^Lynx/');
! 135:
! 136: # newer browsers accept gzip content encoding
! 137: # and state this in a header
! 138: # (netscape did always but didn't state it)
! 139: # It has been reported that these
! 140: # braindamaged MS-Internet Exploders claim that they
! 141: # accept gzip .. but don't in fact and
! 142: # display garbage then :-/
! 143: # Turn off gzip if running under mod_perl. piping does
! 144: # not work as expected inside the server. One can probably
! 145: # achieve the same result using Apache::GZIPFilter.
! 146: $maycompress =(($ENV{'HTTP_ACCEPT_ENCODING'} =~ m|gzip|
! 147: || $Browser =~ m%^Mozilla/3%)
! 148: && ($Browser !~ m/MSIE/)
! 149: && !defined($ENV{'MOD_PERL'}));
! 150:
! 151: # put here the variables we need in order
! 152: # to hold our state - they will be added (with
! 153: # their current value) to any link/query string
! 154: # you construct
! 155: @stickyvars = ('cvsroot','hideattic','sortby','logsort','f','only_with_tag');
1.1 jfieber 156:
3.1 ! knu 157: if (-f $config) {
! 158: do "$config";
! 159: }
! 160: else {
! 161: &fatal("500 Internal Error",
! 162: 'Configuration not found. Set the variable <code>$config</code> '
! 163: . 'in cvsweb.cgi, or the environment variable '
! 164: . '<code>CVSWEB_CONFIG</code>, to your <b>cvsweb.conf</b> '
! 165: . 'configuration file first.');
! 166: }
! 167:
! 168: undef %input;
1.9 fenner 169: if ($query = $ENV{'QUERY_STRING'}) {
170: foreach (split(/&/, $query)) {
1.7 fenner 171: s/%(..)/sprintf("%c", hex($1))/ge; # unquote %-quoted
172: if (/(\S+)=(.*)/) {
3.1 ! knu 173: $input{$1} = $2 if ($2 ne "");
! 174: }
! 175: else {
1.7 fenner 176: $input{$_}++;
177: }
178: }
179: }
1.10 wosch 180:
3.1 ! knu 181: # For backwards compability, set only_with_tag to only_on_branch if set.
! 182: $input{only_with_tag} = $input{only_on_branch}
! 183: if (defined($input{only_on_branch}));
1.10 wosch 184:
3.1 ! knu 185: $DEFAULTVALUE{'cvsroot'} = $cvstreedefault;
1.10 wosch 186:
3.1 ! knu 187: foreach (keys %DEFAULTVALUE)
! 188: {
! 189: # replace not given parameters with the default parameters
! 190: if (!defined($input{$_}) || $input{$_} eq "") {
! 191: # Empty Checkboxes in forms return -- nothing. So we define a helper
! 192: # variable in these forms (copt) which indicates that we just set
! 193: # parameters with a checkbox
! 194: if (!defined($input{"copt"})) {
! 195: # 'copt' isn't defined --> empty input is not the result
! 196: # of empty input checkbox --> set default
! 197: $input{$_} = $DEFAULTVALUE{$_} if (defined($DEFAULTVALUE{$_}));
! 198: }
! 199: else {
! 200: # 'copt' is defined -> the result of empty input checkbox
! 201: # -> set to zero (disable) if default is a boolean (0|1).
! 202: $input{$_} = 0
! 203: if (defined($DEFAULTVALUE{$_})
! 204: && ($DEFAULTVALUE{$_} eq "0" || $DEFAULTVALUE{$_} eq "1"));
! 205: }
1.10 wosch 206: }
207: }
3.1 ! knu 208:
! 209: $barequery = "";
! 210: foreach (@stickyvars) {
! 211: # construct a query string with the sticky non default parameters set
! 212: if (defined($input{$_}) && $input{$_} ne "" && $input{$_} ne $DEFAULTVALUE{$_}) {
! 213: if ($barequery) {
! 214: $barequery = $barequery . "&";
! 215: }
! 216: my $thisval = urlencode($_) . "=" . urlencode($input{$_});
! 217: $barequery .= $thisval;
! 218: }
! 219: }
! 220: # is there any query ?
! 221: if ($barequery) {
! 222: $query = "?$barequery";
! 223: $barequery = "&" . $barequery;
! 224: }
! 225: else {
! 226: $query = "";
! 227: }
! 228:
! 229: # get actual parameters
! 230: $sortby = $input{"sortby"};
! 231: $bydate = 0;
! 232: $byrev = 0;
! 233: $byauthor = 0;
! 234: $bylog = 0;
! 235: $byfile = 0;
! 236: if ($sortby eq "date") {
! 237: $bydate = 1;
! 238: }
! 239: elsif ($sortby eq "rev") {
! 240: $byrev = 1;
! 241: }
! 242: elsif ($sortby eq "author") {
! 243: $byauthor = 1;
! 244: }
! 245: elsif ($sortby eq "log") {
! 246: $bylog = 1;
! 247: }
! 248: else {
! 249: $byfile = 1;
! 250: }
! 251:
! 252: $hr_default = $input{'f'} eq 'h';
! 253:
! 254: $logsort = $input{"logsort"};
1.10 wosch 255:
1.12 fenner 256:
3.1 ! knu 257: ## Default CVS-Tree
! 258: if (!defined($CVSROOT{$cvstreedefault})) {
! 259: &fatal("500 Internal Error",
! 260: "<code>\$cvstreedefault</code> points to a repository "
! 261: . "not defined in <code>%CVSROOT</code> "
! 262: . "(edit your configuration file $config)");
! 263: }
! 264:
! 265: # alternate CVS-Tree, configured in cvsweb.conf
! 266: if ($input{'cvsroot'} && $CVSROOT{$input{'cvsroot'}}) {
! 267: $cvstree = $input{'cvsroot'};
! 268: } else {
! 269: $cvstree = $cvstreedefault;
1.10 wosch 270: }
271:
3.1 ! knu 272: $cvsroot = $CVSROOT{$cvstree};
1.10 wosch 273:
3.1 ! knu 274: # create icons out of description
! 275: foreach my $k (keys %ICONS) {
! 276: no strict 'refs';
! 277: my ($itxt,$ipath,$iwidth,$iheight) = @{$ICONS{$k}};
! 278: if ($ipath) {
! 279: $ {"${k}icon"} = "<IMG SRC=\"$ipath\" ALT=\"$itxt\" BORDER=\"0\" WIDTH=\"$iwidth\" HEIGHT=\"$iheight\">";
1.16 wosch 280: }
3.1 ! knu 281: else {
! 282: $ {"${k}icon"} = $itxt;
1.24 wosch 283: }
284: }
285:
3.1 ! knu 286: # Do some special configuration for cvstrees
! 287: do "$config-$cvstree" if (-f "$config-$cvstree");
! 288:
! 289: $prcategories = '(?:' . join('|', @prcategories) . ')';
1.24 wosch 290:
3.1 ! knu 291: $fullname = $cvsroot . '/' . $where;
! 292: $mimetype = &getMimeTypeFromSuffix ($fullname);
! 293: $defaultTextPlain = ($mimetype eq "text/plain");
! 294: $defaultViewable = $allow_markup && viewable($mimetype);
! 295:
! 296: # search for GZIP if compression allowed
! 297: # We've to find out if the GZIP-binary exists .. otherwise
! 298: # ge get an Internal Server Error if we try to pipe the
! 299: # output through the nonexistent gzip ..
! 300: # any more elegant ways to prevent this are welcome!
! 301: if ($allow_compress && $maycompress) {
! 302: foreach (split(/:/, $ENV{PATH})) {
! 303: if (-x "$_/gzip") {
! 304: $GZIPBIN = "$_/gzip";
! 305: last;
1.16 wosch 306: }
307: }
308: }
309:
3.1 ! knu 310: if (-d $fullname) {
! 311: #
! 312: # ensure, that directories always end with (exactly) one '/'
! 313: # to allow relative URL's. If they're not, make a redirect.
! 314: ##
! 315: my $pathinfo = defined($ENV{'PATH_INFO'}) ? $ENV{'PATH_INFO'} : "";
! 316: if (!($pathinfo =~ m|/$|) || ($pathinfo =~ m |/{2,}$|)) {
! 317: redirect ($scriptwhere . '/' . $query);
! 318: }
! 319: else {
! 320: $where .= '/';
! 321: $scriptwhere .= '/';
! 322: }
! 323: }
! 324:
! 325: if (!-d $cvsroot) {
! 326: &fatal("500 Internal Error",'$CVSROOT not found!<P>The server on which the CVS tree lives is probably down. Please try again in a few minutes.');
! 327: }
! 328:
! 329: #
! 330: # See if the module is in our forbidden list.
! 331: #
! 332: $where =~ m:([^/]*):;
! 333: $module = $1;
! 334: if ($module && &forbidden_module($module)) {
! 335: &fatal("403 Forbidden", "Access to $where forbidden.");
! 336: }
! 337: ##############################
! 338: # View a directory
! 339: ###############################
! 340: elsif (-d $fullname) {
! 341: my $dh = do {local(*DH);};
! 342: opendir($dh, $fullname) || &fatal("404 Not Found","$where: $!");
! 343: my @dir = readdir($dh);
! 344: closedir($dh);
! 345: my @subLevelFiles = findLastModifiedSubdirs(@dir)
! 346: if ($show_subdir_lastmod);
! 347: getDirLogs($cvsroot,$where,@subLevelFiles);
! 348:
! 349: if ($where eq '/') {
! 350: html_header("$defaulttitle");
! 351: print $long_intro;
! 352: }
! 353: else {
! 354: html_header("$where");
! 355: print $short_instruction;
! 356: }
! 357:
! 358: my $descriptions;
! 359: if (($use_descriptions) && open (DESC, "<$cvsroot/CVSROOT/descriptions")) {
! 360: while (<DESC>) {
! 361: chomp;
! 362: my ($dir,$description) = /(\S+)\s+(.*)/;
! 363: $descriptions{$dir} = $description;
! 364: }
! 365: }
! 366:
! 367: print "<P><a name=\"dirlist\"></a>\n";
! 368: # give direct access to dirs
! 369: if ($where eq '/') {
! 370: chooseMirror();
! 371: chooseCVSRoot();
! 372: }
! 373: else {
! 374: print "<p>Current directory: <b>", &clickablePath($where,0), "</b>\n";
! 375:
! 376: print "<P>Current tag: <B>", $input{only_with_tag}, "</b>\n" if
! 377: $input{only_with_tag};
1.16 wosch 378:
1.1 jfieber 379: }
3.1 ! knu 380:
! 381:
! 382: print "<HR NOSHADE>\n";
1.1 jfieber 383: # Using <MENU> in this manner violates the HTML2.0 spec but
384: # provides the results that I want in most browsers. Another
385: # case of layout spooging up HTML.
3.1 ! knu 386:
! 387: my $infocols = 0;
! 388: if ($dirtable) {
! 389: if (defined($tableBorderColor)) {
! 390: # Can't this be done by defining the border for the inner table?
! 391: print "<table border=0 cellpadding=0 width=\"100%\"><tr><td bgcolor=\"$tableBorderColor\">";
! 392: }
! 393: print "<table width=\"100%\" border=0 cellspacing=1 cellpadding=$tablepadding>\n";
! 394: $infocols++;
! 395: print "<tr><th align=left bgcolor=\"" . (($byfile) ?
! 396: $columnHeaderColorSorted :
! 397: $columnHeaderColorDefault) . "\">";
! 398: print "<a href=\"./" . &toggleQuery("sortby","file") .
! 399: "#dirlist\">" if (!$byfile);
! 400: print "File";
! 401: print "</a>" if (!$byfile);
! 402: print "</th>";
! 403: # do not display the other column-headers, if we do not have any files
! 404: # with revision information:
! 405: if (scalar(%fileinfo)) {
! 406: $infocols++;
! 407: print "<th align=left bgcolor=\"" . (($byrev) ?
! 408: $columnHeaderColorSorted :
! 409: $columnHeaderColorDefault) . "\">";
! 410: print "<a href=\"./" . &toggleQuery ("sortby","rev") .
! 411: "#dirlist\">" if (!$byrev);
! 412: print "Rev.";
! 413: print "</a>" if (!$byrev);
! 414: print "</th>";
! 415: $infocols++;
! 416: print "<th align=left bgcolor=\"" . (($bydate) ?
! 417: $columnHeaderColorSorted :
! 418: $columnHeaderColorDefault) . "\">";
! 419: print "<a href=\"./" . &toggleQuery ("sortby","date") .
! 420: "#dirlist\">" if (!$bydate);
! 421: print "Age";
! 422: print "</a>" if (!$bydate);
! 423: print "</th>";
! 424: if ($show_author) {
! 425: $infocols++;
! 426: print "<th align=left bgcolor=\"" . (($byauthor) ?
! 427: $columnHeaderColorSorted :
! 428: $columnHeaderColorDefault) . "\">";
! 429: print "<a href=\"./" . &toggleQuery ("sortby","author") .
! 430: "#dirlist\">" if (!$byauthor);
! 431: print "Author";
! 432: print "</a>" if (!$byauthor);
! 433: print "</th>";
! 434: }
! 435: $infocols++;
! 436: print "<th align=left bgcolor=\"" . (($bylog) ?
! 437: $columnHeaderColorSorted :
! 438: $columnHeaderColorDefault) . "\">";
! 439: print "<a href=\"./", toggleQuery("sortby","log"), "#dirlist\">" if (!$bylog);
! 440: print "Last log entry";
! 441: print "</a>" if (!$bylog);
! 442: print "</th>";
! 443: }
! 444: elsif ($use_descriptions) {
! 445: print "<th align=left bgcolor=\"". $columnHeaderColorDefault . "\">";
! 446: print "Description";
! 447: $infocols++;
! 448: }
! 449: print "</tr>\n";
! 450: }
! 451: else {
! 452: print "<menu>\n";
! 453: }
! 454: my $dirrow = 0;
! 455:
! 456: my $i;
1.9 fenner 457: lookingforattic:
458: for ($i = 0; $i <= $#dir; $i++) {
459: if ($dir[$i] eq "Attic") {
3.1 ! knu 460: last lookingforattic;
1.9 fenner 461: }
462: }
3.1 ! knu 463: if (!$input{'hideattic'} && ($i <= $#dir) &&
! 464: opendir($dh, $fullname . "/Attic")) {
! 465: splice(@dir, $i, 1,
! 466: grep((s|^|Attic/|,!m|/\.|), readdir($dh)));
! 467: closedir($dh);
1.9 fenner 468: }
3.1 ! knu 469:
! 470: my $hideAtticToggleLink = "<a href=\"./" .
! 471: &toggleQuery ("hideattic") .
! 472: "#dirlist\">[Hide]</a>" if (!$input{'hideattic'});
! 473:
1.9 fenner 474: # Sort without the Attic/ pathname.
3.1 ! knu 475: # place directories first
! 476:
! 477: my $attic;
! 478: my $url;
! 479: my $fileurl;
! 480: my $filesexists;
! 481: my $filesfound;
! 482:
! 483: foreach (sort { &fileSortCmp } @dir) {
1.1 jfieber 484: if ($_ eq '.') {
485: next;
486: }
1.19 wosch 487: # ignore CVS lock and stale NFS files
3.1 ! knu 488: next if (/^#cvs\.|^,|^\.nfs/);
! 489:
! 490: # Check whether to show the CVSROOT path
! 491: next if ($input{'hidecvsroot'} && ($_ eq 'CVSROOT'));
! 492:
! 493: # Check whether the module is in the restricted list
! 494: next if ($_ && &forbidden_module($_));
! 495:
! 496: # Ignore non-readable files
! 497: next if ($input{'hidenonreadable'} && !(-r "$fullname/$_"));
1.18 wosch 498:
1.9 fenner 499: if (s|^Attic/||) {
3.1 ! knu 500: $attic = " (in the Attic) " . $hideAtticToggleLink;
! 501: }
! 502: else {
1.9 fenner 503: $attic = "";
504: }
3.1 ! knu 505:
! 506: if ($_ eq '..' || -d "$fullname/$_") {
! 507: next if ($_ eq '..' && $where eq '/');
! 508: my ($rev,$date,$log,$author,$filename) = @{$fileinfo{$_}}
! 509: if (defined($fileinfo{$_}));
! 510: print "<tr bgcolor=\"" . @tabcolors[$dirrow%2] . "\"><td>" if ($dirtable);
! 511: if ($_ eq '..') {
! 512: $url = "../" . $query;
! 513: if ($nofilelinks) {
! 514: print $backicon;
! 515: }
! 516: else {
! 517: print &link($backicon,$url);
! 518: }
! 519: print " ", &link("Previous Directory",$url);
! 520: }
! 521: else {
! 522: $url = urlencode($_) . '/' . $query;
! 523: print "<A NAME=\"$_\"></A>";
! 524: if ($nofilelinks) {
! 525: print $diricon;
! 526: }
! 527: else {
! 528: print &link($diricon,$url);
! 529: }
! 530: print " ", &link($_ . "/", $url), $attic;
! 531: if ($_ eq "Attic") {
! 532: print " <a href=\"./" .
! 533: &toggleQuery ("hideattic") .
! 534: "#dirlist\">[Don't hide]</a>";
! 535: }
! 536: }
! 537: # Show last change in dir
! 538: if ($filename) {
! 539: print "</td><td> </td><td> " if ($dirtable);
! 540: if ($date) {
! 541: print " <i>" . readableTime(time() - $date,0) . "</i>";
! 542: }
! 543: if ($show_author) {
! 544: print "</td><td> " if ($dirtable);
! 545: print $author;
! 546: }
! 547: print "</td><td> " if ($dirtable);
! 548: $filename =~ s%^[^/]+/%%;
! 549: print "$filename/$rev";
! 550: print "<BR>" if ($dirtable);
! 551: if ($log) {
! 552: print " <font size=-1>"
! 553: . &htmlify(substr($log,0,$shortLogLen));
! 554: if (length $log > 80) {
! 555: print "...";
! 556: }
! 557: print "</font>";
! 558: }
! 559: }
! 560: else {
! 561: my ($dwhere) = ($where ne "/" ? $where : "") . $_;
! 562: if ($use_descriptions && defined $descriptions{$dwhere}) {
! 563: print "<TD COLSPAN=" . ($infocols-1) . "> " if $dirtable;
! 564: print $descriptions{$dwhere};
! 565: } elsif ($dirtable && $infocols > 1) {
! 566: # close the row with the appropriate number of
! 567: # columns, so that the vertical seperators are visible
! 568: my($cols) = $infocols;
! 569: while ($cols > 1) {
! 570: print "</td><td> ";
! 571: $cols--;
! 572: }
! 573: }
! 574: }
! 575: if ($dirtable) {
! 576: print "</td></tr>\n";
! 577: }
! 578: else {
! 579: print "<br>\n";
! 580: }
! 581: $dirrow++;
1.9 fenner 582: }
3.1 ! knu 583: elsif (s/,v$//) {
! 584: $fileurl = ($attic ? "Attic/" : "") . urlencode($_);
! 585: $url = $fileurl . $query;
! 586: my $rev = '';
! 587: my $date = '';
! 588: my $log = '';
! 589: my $author = '';
! 590: $filesexists++;
! 591: next if (!defined($fileinfo{$_}));
! 592: ($rev,$date,$log,$author) = @{$fileinfo{$_}};
! 593: $filesfound++;
! 594: print "<tr bgcolor=\"" . @tabcolors[$dirrow%2] . "\"><td>" if ($dirtable);
! 595: print "<A NAME=\"$_\"></A>";
! 596: if ($nofilelinks) {
! 597: print $fileicon;
! 598: }
! 599: else {
! 600: print &link($fileicon,$url);
! 601: }
! 602: print " ", &link($_, $url), $attic;
! 603: print "</td><td> " if ($dirtable);
! 604: download_link($fileurl,
! 605: $rev, $rev,
! 606: $defaultViewable ? "text/x-cvsweb-markup" : undef);
! 607: print "</td><td> " if ($dirtable);
! 608: if ($date) {
! 609: print " <i>" . readableTime(time() - $date,0) . "</i>";
! 610: }
! 611: if ($show_author) {
! 612: print "</td><td> " if ($dirtable);
! 613: print $author;
! 614: }
! 615: print "</td><td> " if ($dirtable);
! 616: if ($log) {
! 617: print " <font size=-1>" . &htmlify(substr($log,0,$shortLogLen));
! 618: if (length $log > 80) {
! 619: print "...";
! 620: }
! 621: print "</font>";
! 622: }
! 623: print "</td>" if ($dirtable);
! 624: print (($dirtable) ? "</tr>" : "<br>");
! 625: $dirrow++;
! 626: }
! 627: print "\n";
! 628: }
! 629: if ($dirtable && defined($tableBorderColor)) {
! 630: print "</td></tr></table>";
! 631: }
! 632: print "". ($dirtable == 1) ? "</table>" : "</menu>" . "\n";
! 633:
! 634: if ($filesexists && !$filesfound) {
! 635: print "<P><B>NOTE:</B> There are $filesexists files, but none matches the current tag ($input{only_with_tag})\n";
! 636: }
! 637: if ($input{only_with_tag} && (!%tags || !$tags{$input{only_with_tag}})) {
! 638: %tags = %alltags
! 639: }
! 640: if (scalar %tags
! 641: || $input{only_with_tag}
! 642: || $edit_option_form
! 643: || defined($input{"options"})) {
! 644: print "<hr size=1 NOSHADE>";
! 645: }
! 646:
! 647: if (scalar %tags || $input{only_with_tag}) {
! 648: print "<FORM METHOD=\"GET\" ACTION=\"./\">\n";
! 649: foreach my $var (@stickyvars) {
! 650: print "<INPUT TYPE=HIDDEN NAME=\"$var\" VALUE=\"$input{$var}\">\n"
! 651: if (defined($input{$var})
! 652: && $input{$var} ne $DEFAULTVALUE{$var}
! 653: && $input{$var} ne ""
! 654: && $var ne "only_with_tag");
! 655: }
! 656: print "Show only files with tag:\n";
! 657: print "<SELECT NAME=only_with_tag";
! 658: print " onchange=\"submit()\"" if ($use_java_script);
! 659: print ">";
! 660: print "<OPTION VALUE=\"\">All tags / default branch\n";
! 661: foreach my $tag (reverse sort { lc $a cmp lc $b } keys %tags) {
! 662: print "<OPTION",defined($input{only_with_tag}) &&
! 663: $input{only_with_tag} eq $tag ? " SELECTED":"",
! 664: ">$tag\n";
! 665: }
! 666: print "</SELECT>\n";
! 667: print "<INPUT TYPE=SUBMIT VALUE=\"Go\">\n";
1.9 fenner 668: print "</FORM>\n";
669: }
3.1 ! knu 670: my $formwhere = $scriptwhere;
! 671: $formwhere =~ s|Attic/?$|| if ($input{'hideattic'});
! 672:
! 673: if ($edit_option_form || defined($input{"options"})) {
! 674: print "<FORM METHOD=\"GET\" ACTION=\"${formwhere}\">\n";
! 675: print "<INPUT TYPE=HIDDEN NAME=\"copt\" VALUE=\"1\">\n";
! 676: if ($cvstree ne $cvstreedefault) {
! 677: print "<INPUT TYPE=HIDDEN NAME=\"cvsroot\" VALUE=\"$cvstree\">\n";
! 678: }
! 679: print "<center><table cellpadding=0 cellspacing=0>";
! 680: print "<tr bgcolor=\"$columnHeaderColorDefault\"><th colspan=2>Preferences</th></tr>";
! 681: print "<tr><td>Sort files by <SELECT name=\"sortby\">";
! 682: print "<OPTION VALUE=\"\">File";
! 683: print "<OPTION",$bydate ? " SELECTED" : ""," VALUE=date>Age";
! 684: print "<OPTION",$byauthor ? " SELECTED" : ""," VALUE=author>Author"
! 685: if ($show_author);
! 686: print "<OPTION",$byrev ? " SELECTED" : ""," VALUE=rev>Revision";
! 687: print "<OPTION",$bylog ? " SELECTED" : ""," VALUE=log>Log message";
! 688: print "</SELECT></td>";
! 689: print "<td>revisions by: \n";
! 690: print "<SELECT NAME=logsort>\n";
! 691: print "<OPTION VALUE=cvs",$logsort eq "cvs" ? " SELECTED" : "", ">Not sorted";
! 692: print "<OPTION VALUE=date",$logsort eq "date" ? " SELECTED" : "", ">Commit date";
! 693: print "<OPTION VALUE=rev",$logsort eq "rev" ? " SELECTED" : "", ">Revision";
! 694: print "</SELECT></td></tr>";
! 695: print "<tr><td>Diff format: ";
! 696: printDiffSelect();
! 697: print "</td>";
! 698: print "<td>Show Attic files: ";
! 699: print "<INPUT NAME=hideattic TYPE=CHECKBOX", $input{'hideattic'}?" CHECKED":"",
! 700: "></td></tr>\n";
! 701: print "<tr><td align=center colspan=2><input type=submit value=\"Change Options\">";
! 702: print "</td></tr></table></center></FORM>\n";
1.12 fenner 703: }
1.2 jfieber 704: print &html_footer;
1.1 jfieber 705: print "</BODY></HTML>\n";
3.1 ! knu 706: }
! 707:
! 708: ###############################
! 709: # View Files
! 710: ###############################
! 711: elsif (-f $fullname . ',v') {
! 712: if (defined($input{'rev'}) || $doCheckout) {
! 713: &doCheckout($fullname, $input{'rev'});
! 714: exit;
! 715: }
! 716: if (defined($input{'annotate'}) && $allow_annotate) {
! 717: &doAnnotate($input{'annotate'});
! 718: exit;
! 719: }
! 720: if (defined($input{'r1'}) && defined($input{'r2'})) {
! 721: &doDiff($fullname, $input{'r1'}, $input{'tr1'},
! 722: $input{'r2'}, $input{'tr2'}, $input{'f'});
! 723: exit;
! 724: }
! 725: print("going to dolog($fullname)\n") if ($verbose);
! 726: &doLog($fullname);
! 727: ##############################
! 728: # View Diff
! 729: ##############################
! 730: }
! 731: elsif ($fullname =~ s/\.diff$// && -f $fullname . ",v" &&
! 732: $input{'r1'} && $input{'r2'}) {
! 733:
! 734: # $where-diff-removal if 'cvs rdiff' is used
! 735: # .. but 'cvs rdiff'doesn't support some options
! 736: # rcsdiff does (-w and -p), so it is disabled
! 737: # $where =~ s/\.diff$//;
! 738:
1.12 fenner 739: # Allow diffs using the ".diff" extension
740: # so that browsers that default to the URL
741: # for a save filename don't save diff's as
742: # e.g. foo.c
3.1 ! knu 743: &doDiff($fullname, $input{'r1'}, $input{'tr1'},
1.12 fenner 744: $input{'r2'}, $input{'tr2'}, $input{'f'});
745: exit;
3.1 ! knu 746: }
! 747: elsif (($newname = $fullname) =~ s|/([^/]+)$|/Attic/$1| &&
! 748: -f $newname . ",v") {
1.12 fenner 749: # The file has been removed and is in the Attic.
750: # Send a redirect pointing to the file in the Attic.
3.1 ! knu 751: (my $newplace = $scriptwhere) =~ s|/([^/]+)$|/Attic/$1|;
1.12 fenner 752: &redirect($newplace);
753: exit;
3.1 ! knu 754: }
! 755: elsif (0 && (my @files = &safeglob($fullname . ",v"))) {
! 756: http_header("text/plain");
1.12 fenner 757: print "You matched the following files:\n";
758: print join("\n", @files);
759: # Find the tags from each file
760: # Display a form offering diffs between said tags
3.1 ! knu 761: }
! 762: else {
! 763: my $fh = do {local(*FH);};
! 764: my ($xtra, $module);
1.12 fenner 765: # Assume it's a module name with a potential path following it.
1.13 fenner 766: $xtra = $& if (($module = $where) =~ s|/.*||);
1.12 fenner 767: # Is there an indexed version of modules?
3.1 ! knu 768: if (open($fh, "$cvsroot/CVSROOT/modules")) {
! 769: while (<$fh>) {
! 770: if (/^(\S+)\s+(\S+)/o && $module eq $1
! 771: && -d "${cvsroot}/$2" && $module ne $2) {
! 772: &redirect($scriptname . '/' . $2 . $xtra);
1.12 fenner 773: }
3.1 ! knu 774: }
1.12 fenner 775: }
776: &fatal("404 Not Found","$where: no such file or directory");
3.1 ! knu 777: }
! 778: ## End MAIN
! 779:
! 780: sub printDiffSelect {
! 781: my ($use_java_script) = @_;
! 782: $use_java_script = 0 if (!defined($use_java_script));
! 783: my ($f) = $input{'f'};
! 784: print "<SELECT NAME=\"f\"";
! 785: print " onchange=\"submit()\"" if ($use_java_script);
! 786: print ">\n";
! 787: print "<OPTION VALUE=h",$f eq "h" ? " SELECTED" : "", ">Colored Diff";
! 788: print "<OPTION VALUE=H",$f eq "H" ? " SELECTED" : "", ">Long Colored Diff";
! 789: print "<OPTION VALUE=u",$f eq "u" ? " SELECTED" : "", ">Unidiff";
! 790: print "<OPTION VALUE=c",$f eq "c" ? " SELECTED" : "", ">Context Diff";
! 791: print "<OPTION VALUE=s",$f eq "s" ? " SELECTED" : "", ">Side by Side";
! 792: print "</SELECT>";
! 793: }
! 794:
! 795: sub findLastModifiedSubdirs {
! 796: my (@dirs) = @_;
! 797: my ($dirname, @files);
! 798:
! 799: foreach $dirname (@dirs) {
! 800: next if ($dirname eq ".");
! 801: next if ($dirname eq "..");
! 802: my ($dir) = "$fullname/$dirname";
! 803: next if (!-d $dir);
! 804:
! 805: my ($lastmod) = undef;
! 806: my ($lastmodtime) = undef;
! 807: my $dh = do {local(*DH);};
! 808:
! 809: opendir($dh,$dir) || next;
! 810: my (@filenames) = readdir($dh);
! 811: closedir($dh);
! 812:
! 813: foreach my $filename (@filenames) {
! 814: $filename = "$dirname/$filename";
! 815: my ($file) = "$fullname/$filename";
! 816: next if ($filename !~ /,v$/ || !-f $file);
! 817: $filename =~ s/,v$//;
! 818: my $modtime = -M $file;
! 819: if (!defined($lastmod) || $modtime < $lastmodtime) {
! 820: $lastmod = $filename;
! 821: $lastmodtime = $modtime;
! 822: }
! 823: }
! 824: push(@files, $lastmod) if (defined($lastmod));
! 825: }
! 826: return @files;
1.12 fenner 827: }
828:
829: sub htmlify {
3.1 ! knu 830: my($string, $pr) = @_;
1.12 fenner 831:
3.1 ! knu 832: # Special Characters; RFC 1866
1.12 fenner 833: $string =~ s/&/&/g;
3.1 ! knu 834: $string =~ s/\"/"/g;
1.12 fenner 835: $string =~ s/</</g;
836: $string =~ s/>/>/g;
837:
3.1 ! knu 838: # get URL's as link ..
! 839: $string =~ s`(http|ftp|https)(://[-a-zA-Z0-9%.~:_/]+)([?&]([-a-zA-Z0-9%.~:_]+)=([-a-zA-Z0-9%.~:_])+)*`<A HREF="$1$2$3">$1$2$3</A>`;
! 840: # get e-mails as link
! 841: $string =~ s`([-a-zA-Z0-9_.]+@([-a-zA-Z0-9]+\.)+[A-Za-z]{2,4})`<A HREF="mailto:$1">$1</A>`;
! 842:
! 843: # get #PR as link ..
! 844: if ($pr && defined($prcgi)) {
! 845: 1 while $string =~ s`\b(pr[:#]?\s*(?:#?\d+[,\s]\s*)*#?)(\d+)\b`$1<A HREF="$prcgi?pr=$2">$2</A>`i;
! 846: $string =~ s`\b${prcategories}/(\d+)\b`<A HREF="$prcgi?pr=$1">$&</A>`igo;
! 847: }
! 848:
! 849: return $string;
! 850: }
! 851:
! 852: sub spacedHtmlText {
! 853: my($string, $pr) = @_;
! 854:
! 855: # Cut trailing spaces
! 856: s/\s+$//;
! 857:
! 858: # Expand tabs
! 859: $string =~ s/\t+/' ' x (length($&) * $tabstop - length($`) % $tabstop)/e
! 860: if (defined($tabstop));
! 861:
! 862: # replace <tab> and <space> (\001 is to protect us from htmlify)
! 863: # gzip can make excellent use of this repeating pattern :-)
! 864: $string =~ s/\001/\001%/g; #protect our & substitute
! 865: if ($hr_breakable) {
! 866: # make every other space 'breakable'
! 867: $string =~ s/ / \001nbsp; \001nbsp; \001nbsp; \001nbsp;/g; # <tab>
! 868: $string =~ s/ / \001nbsp;/g; # 2 * <space>
! 869: # leave single space as it is
! 870: }
! 871: else {
! 872: $string =~ s/ /\001nbsp;\001nbsp;\001nbsp;\001nbsp;\001nbsp;\001nbsp;\001nbsp;\001nbsp;/g;
! 873: $string =~ s/ /\001nbsp;/g;
1.12 fenner 874: }
875:
3.1 ! knu 876: $string = htmlify($string);
! 877:
! 878: # unescape
! 879: $string =~ s/\001([^%])/&$1/g;
! 880: $string =~ s/\001%/\001/g;
! 881:
! 882: return $string;
1.12 fenner 883: }
884:
885: sub link {
3.1 ! knu 886: my($name, $where) = @_;
1.12 fenner 887:
3.1 ! knu 888: return "<A HREF=\"$where\">$name</A>\n";
1.12 fenner 889: }
890:
891: sub revcmp {
3.1 ! knu 892: my($rev1, $rev2) = @_;
! 893: my(@r1) = split(/\./, $rev1);
! 894: my(@r2) = split(/\./, $rev2);
! 895: my($a,$b);
1.12 fenner 896:
897: while (($a = shift(@r1)) && ($b = shift(@r2))) {
898: if ($a != $b) {
899: return $a <=> $b;
900: }
901: }
902: if (@r1) { return 1; }
903: if (@r2) { return -1; }
904: return 0;
905: }
906:
907: sub fatal {
3.1 ! knu 908: my($errcode, $errmsg) = @_;
! 909: if (defined($ENV{'MOD_PERL'})) {
! 910: Apache->request->status((split(/ /, $errcode))[0]);
! 911: }
! 912: else {
! 913: print "Status: $errcode\n";
! 914: }
! 915: html_header("Error");
1.12 fenner 916: print "Error: $errmsg\n";
917: print &html_footer;
918: exit(1);
919: }
920:
921: sub redirect {
3.1 ! knu 922: my($url) = @_;
! 923: if (defined($ENV{'MOD_PERL'})) {
! 924: Apache->request->status(301);
! 925: Apache->request->header_out(Location => $url);
! 926: }
! 927: else {
! 928: print "Status: 301 Moved\n";
! 929: print "Location: $url\n";
! 930: }
! 931: html_header("Moved");
1.12 fenner 932: print "This document is located <A HREF=$url>here</A>.\n";
933: print &html_footer;
934: exit(1);
935: }
936:
937: sub safeglob {
3.1 ! knu 938: my ($filename) = @_;
! 939: my ($dirname);
! 940: my (@results);
! 941: my $dh = do {local(*DH);};
1.12 fenner 942:
943: ($dirname = $filename) =~ s|/[^/]+$||;
944: $filename =~ s|.*/||;
945:
3.1 ! knu 946: if (opendir($dh, $dirname)) {
! 947: my $glob = $filename;
! 948: my $t;
1.12 fenner 949: # transform filename from glob to regex. Deal with:
950: # [, {, ?, * as glob chars
951: # make sure to escape all other regex chars
952: $glob =~ s/([\.\(\)\|\+])/\\$1/g;
953: $glob =~ s/\*/.*/g;
954: $glob =~ s/\?/./g;
955: $glob =~ s/{([^}]+)}/($t = $1) =~ s-,-|-g; "($t)"/eg;
3.1 ! knu 956: foreach (readdir($dh)) {
1.12 fenner 957: if (/^${glob}$/) {
958: push(@results, $dirname . "/" .$_);
959: }
960: }
961: }
962:
963: @results;
964: }
965:
3.1 ! knu 966: sub getMimeTypeFromSuffix {
! 967: my ($fullname) = @_;
! 968: my ($mimetype, $suffix);
! 969: my $fh = do {local(*FH);};
! 970:
! 971: ($suffix = $fullname) =~ s/^.*\.([^.]*)$/$1/;
! 972: $mimetype = $MTYPES{$suffix};
! 973: $mimetype = $MTYPES{'*'} if (!$mimetype);
! 974:
! 975: if (!$mimetype && -f $mime_types) {
! 976: # okey, this is something special - search the
! 977: # mime.types database
! 978: open ($fh, "<$mime_types");
! 979: while (<$fh>) {
! 980: if ($_ =~ /^\s*(\S+\/\S+).*\b$suffix\b/) {
! 981: $mimetype = $1;
! 982: last;
! 983: }
! 984: }
! 985: close ($fh);
! 986: }
! 987:
! 988: # okey, didn't find anything useful ..
! 989: if (!($mimetype =~ /\S\/\S/)) {
! 990: $mimetype = "text/plain";
! 991: }
! 992: return $mimetype;
! 993: }
! 994:
! 995: ###############################
! 996: # show Annotation
! 997: ###############################
! 998: sub doAnnotate ($$) {
! 999: my ($rev) = @_;
! 1000: my ($pid);
! 1001: my ($pathname, $filename);
! 1002: my $reader = do {local(*FH);};
! 1003: my $writer = do {local(*FH);};
! 1004:
! 1005: # make sure the revisions a wellformed, for security
! 1006: # reasons ..
! 1007: if (!($rev =~ /^[\d\.]+$/)) {
! 1008: &fatal("404 Not Found",
! 1009: "Malformed query \"$ENV{'QUERY_STRING'}\"");
! 1010: }
1.12 fenner 1011:
3.1 ! knu 1012: ($pathname = $where) =~ s/(Attic\/)?[^\/]*$//;
! 1013: ($filename = $where) =~ s/^.*\///;
! 1014:
! 1015: http_header();
! 1016:
! 1017: navigateHeader ($scriptwhere,$pathname,$filename,$rev, "annotate");
! 1018: print "<h3 align=center>Annotation of $pathname$filename, Revision $rev</h3>\n";
! 1019:
! 1020: # this seems to be necessary
! 1021: $| = 1; $| = 0; # Flush
! 1022:
! 1023: # this annotate version is based on the
! 1024: # cvs annotate-demo Perl script by Cyclic Software
! 1025: # It was written by Cyclic Software, http://www.cyclic.com/, and is in
! 1026: # the public domain.
! 1027: # we could abandon the use of rlog, rcsdiff and co using
! 1028: # the cvsserver in a similiar way one day (..after rewrite)
! 1029: $pid = open2($reader, $writer, "cvs server") || fatal ("500 Internal Error",
! 1030: "Fatal Error - unable to open cvs for annotation");
! 1031:
! 1032: # OK, first send the request to the server. A simplified example is:
! 1033: # Root /home/kingdon/zwork/cvsroot
! 1034: # Argument foo/xx
! 1035: # Directory foo
! 1036: # /home/kingdon/zwork/cvsroot/foo
! 1037: # Directory .
! 1038: # /home/kingdon/zwork/cvsroot
! 1039: # annotate
! 1040: # although as you can see there are a few more details.
! 1041:
! 1042: print $writer "Root $cvsroot\n";
! 1043: print $writer "Valid-responses ok error Valid-requests Checked-in Updated Merged Removed M E\n";
! 1044: # Don't worry about sending valid-requests, the server just needs to
! 1045: # support "annotate" and if it doesn't, there isn't anything to be done.
! 1046: print $writer "UseUnchanged\n";
! 1047: print $writer "Argument -r\n";
! 1048: print $writer "Argument $rev\n";
! 1049: print $writer "Argument $where\n";
! 1050:
! 1051: # The protocol requires us to fully fake a working directory (at
! 1052: # least to the point of including the directories down to the one
! 1053: # containing the file in question).
! 1054: # So if $where is "dir/sdir/file", then @dirs will be ("dir","sdir","file")
! 1055: my @dirs = split (/\//, $where);
! 1056: my $path = "";
! 1057: foreach (@dirs) {
! 1058: if ($path eq "") {
! 1059: # In our example, $_ is "dir".
! 1060: $path = $_;
1.44 knu 1061: }
3.1 ! knu 1062: else {
! 1063: print $writer "Directory " . $path . "\n";
! 1064: print $writer "$cvsroot/" . $path ."\n";
! 1065: # In our example, $_ is "sdir" and $path becomes "dir/sdir"
! 1066: # And the next time, "file" and "dir/sdir/file" (which then gets
! 1067: # ignored, because we don't need to send Directory for the file).
! 1068: $path = $path . "/" . $_;
! 1069: }
! 1070: }
! 1071: # And the last "Directory" before "annotate" is the top level.
! 1072: print $writer "Directory .\n";
! 1073: print $writer "$cvsroot\n";
! 1074:
! 1075: print $writer "annotate\n";
! 1076: # OK, we've sent our command to the server. Thing to do is to
! 1077: # close the writer side and get all the responses. If "cvs server"
! 1078: # were nicer about buffering, then we could just leave it open, I think.
! 1079: close ($writer) || die "cannot close: $!";
! 1080:
! 1081: # Ready to get the responses from the server.
! 1082: # For example:
! 1083: # E Annotations for foo/xx
! 1084: # E ***************
! 1085: # M 1.3 (kingdon 06-Sep-97): hello
! 1086: # ok
! 1087: my ($lineNr) = 0;
! 1088: my ($oldLrev, $oldLusr) = ("", "");
! 1089: my ($revprint, $usrprint);
! 1090: if ($annTable) {
! 1091: print "<table border=0 cellspacing=0 cellpadding=0>\n";
! 1092: }
! 1093: else {
! 1094: print "<pre>";
! 1095: }
! 1096: while (<$reader>) {
! 1097: my @words = split;
! 1098: # Adding one is for the (single) space which follows $words[0].
! 1099: my $rest = substr ($_, length ($words[0]) + 1);
! 1100: if ($words[0] eq "E") {
! 1101: next;
! 1102: }
! 1103: elsif ($words[0] eq "M") {
! 1104: $lineNr++;
! 1105: my $lrev = substr ($_, 2, 13);
! 1106: my $lusr = substr ($_, 16, 9);
! 1107: my $line = substr ($_, 36);
! 1108: # we should parse the date here ..
! 1109: if ($lrev eq $oldLrev) {
! 1110: $revprint = " ";
! 1111: }
! 1112: else {
! 1113: $revprint = $lrev; $oldLusr = "";
! 1114: }
! 1115: if ($lusr eq $oldLusr) {
! 1116: $usrprint = " ";
! 1117: }
! 1118: else {
! 1119: $usrprint = $lusr;
! 1120: }
! 1121: $oldLrev = $lrev;
! 1122: $oldLusr = $lusr;
! 1123: # is there a less timeconsuming way to strip spaces ?
! 1124: ($lrev = $lrev) =~ s/\s+//g;
! 1125: my $isCurrentRev = ("$rev" eq "$lrev");
! 1126:
! 1127: print "<b>" if ($isCurrentRev);
! 1128: printf ("%8s%s%8s %4d:", $revprint, ($isCurrentRev ? "|" : " "), $usrprint, $lineNr);
! 1129: print spacedHtmlText($line);
! 1130: print "</b>" if ($isCurrentRev);
! 1131: }
! 1132: elsif ($words[0] eq "ok") {
! 1133: # We could complain about any text received after this, like the
! 1134: # CVS command line client. But for simplicity, we don't.
! 1135: }
! 1136: elsif ($words[0] eq "error") {
! 1137: fatal ("500 Internal Error", "Error occured during annotate: <b>$_</b>");
! 1138: }
! 1139: }
! 1140: if ($annTable) {
! 1141: print "</table>";
! 1142: }
! 1143: else {
! 1144: print "</pre>";
! 1145: }
! 1146: close ($reader) || warn "cannot close: $!";
! 1147: wait;
! 1148: }
! 1149:
! 1150: ###############################
! 1151: # make Checkout
! 1152: ###############################
! 1153: sub doCheckout {
! 1154: my ($fullname, $rev) = @_;
! 1155: my ($mimetype,$revopt);
! 1156: my $fh = do {local(*FH);};
! 1157:
! 1158: # make sure the revisions a wellformed, for security
! 1159: # reasons ..
! 1160: if (defined($rev) && !($rev =~ /^[\d\.]+$/)) {
! 1161: &fatal("404 Not Found",
! 1162: "Malformed query \"$ENV{'QUERY_STRING'}\"");
! 1163: }
! 1164:
! 1165: # get mimetype
! 1166: if (defined($input{"content-type"}) && ($input{"content-type"} =~ /\S\/\S/)) {
! 1167: $mimetype = $input{"content-type"}
! 1168: }
! 1169: else {
! 1170: $mimetype = &getMimeTypeFromSuffix($fullname);
! 1171: }
! 1172:
! 1173: if (defined($rev)) {
! 1174: $revopt = "-r$rev";
! 1175: if ($use_moddate) {
! 1176: readLog($fullname,$rev);
! 1177: $moddate=$date{$rev};
! 1178: }
! 1179: }
! 1180: else {
! 1181: $revopt = "-rHEAD";
! 1182: if ($use_moddate) {
! 1183: readLog($fullname);
! 1184: $moddate=$date{$symrev{HEAD}};
! 1185: }
! 1186: }
! 1187:
! 1188: ### just for the record:
! 1189: ### 'cvs co' seems to have a bug regarding single checkout of
! 1190: ### directories/files having spaces in it;
! 1191: ### this is an issue that should be resolved on cvs's side
! 1192: #
! 1193: # Safely for a child process to read from.
! 1194: if (! open($fh, "-|")) { # child
! 1195: open(STDERR, ">&STDOUT"); # Redirect stderr to stdout
! 1196: exec("cvs", "-d", "$cvsroot", "co", "-p", "$revopt", "$where");
! 1197: }
! 1198: #===================================================================
! 1199: #Checking out squid/src/ftp.c
! 1200: #RCS: /usr/src/CVS/squid/src/ftp.c,v
! 1201: #VERS: 1.1.1.28.6.2
! 1202: #***************
! 1203:
! 1204: # Parse CVS header
! 1205: my ($revision, $filename, $cvsheader);
! 1206: while(<$fh>) {
! 1207: last if (/^\*\*\*\*/);
! 1208: $revision = $1 if (/^VERS: (.*)$/);
! 1209: if (/^Checking out (.*)$/) {
! 1210: $filename = $1;
! 1211: $filename =~ s/^\.\/*//;
1.12 fenner 1212: }
3.1 ! knu 1213: $cvsheader .= $_;
! 1214: }
! 1215: if ($filename ne $where) {
! 1216: &fatal("500 Internal Error",
! 1217: "Unexpected output from cvs co: $cvsheader"
! 1218: . "<p><b>Check whether the directory $cvsroot/CVSROOT exists "
! 1219: . "and the script has write-access to the CVSROOT/history "
! 1220: . "file if it exists."
! 1221: . "<br>The script needs to place lock files in the "
! 1222: . "directory the file is in as well.</b>");
! 1223: }
! 1224: $| = 1;
! 1225:
! 1226: if ($mimetype eq "text/x-cvsweb-markup") {
! 1227: &cvswebMarkup($fh,$fullname,$revision);
! 1228: }
! 1229: else {
! 1230: http_header($mimetype);
! 1231: print <$fh>;
! 1232: }
! 1233: close($fh);
! 1234: }
! 1235:
! 1236: sub cvswebMarkup {
! 1237: my ($filehandle,$fullname,$revision) = @_;
! 1238: my ($pathname, $filename);
! 1239:
! 1240: ($pathname = $where) =~ s/(Attic\/)?[^\/]*$//;
! 1241: ($filename = $where) =~ s/^.*\///;
! 1242: my ($fileurl) = urlencode($filename);
! 1243:
! 1244: http_header();
! 1245:
! 1246: navigateHeader ($scriptwhere, $pathname, $filename, $revision, "view");
! 1247: print "<HR noshade>";
! 1248: print "<table width=\"100%\"><tr><td bgcolor=\"$markupLogColor\">";
! 1249: print "File: ", &clickablePath($where, 1);
! 1250: print " ";
! 1251: &download_link(urlencode($fileurl), $revision, "(download)");
! 1252: if (!$defaultTextPlain) {
! 1253: print " ";
! 1254: &download_link(urlencode($fileurl), $revision, "(as text)",
! 1255: "text/plain");
! 1256: }
! 1257: print "<BR>\n";
! 1258: if ($show_log_in_markup) {
! 1259: readLog($fullname); #,$revision);
! 1260: printLog($revision,0);
! 1261: }
! 1262: else {
! 1263: print "Version: <B>$revision</B><BR>\n";
! 1264: print "Tag: <B>", $input{only_with_tag}, "</b><br>\n" if
! 1265: $input{only_with_tag};
! 1266: }
! 1267: print "</td></tr></table>";
! 1268: my @content = <$filehandle>;
! 1269: my $url = download_url($fileurl, $revision, $mimetype);
! 1270: print "<HR noshade>";
! 1271: if ($mimetype =~ /^image/) {
! 1272: print "<IMG SRC=\"$url$barequery\"><BR>";
! 1273: }
! 1274: else {
! 1275: print "<PRE>";
! 1276: foreach (@content) {
! 1277: print spacedHtmlText($_);
1.12 fenner 1278: }
3.1 ! knu 1279: print "</PRE>";
! 1280: }
1.12 fenner 1281: }
1282:
3.1 ! knu 1283: sub viewable($) {
! 1284: my ($mimetype) = @_;
! 1285:
! 1286: $mimetype =~ m%^text/% ||
! 1287: $mimetype =~ m%^image/% ||
! 1288: 0;
! 1289: }
! 1290:
! 1291: ###############################
! 1292: # Show Colored Diff
! 1293: ###############################
! 1294: sub doDiff {
! 1295: my($fullname, $r1, $tr1, $r2, $tr2, $f) = @_;
! 1296: my $fh = do {local(*FH);};
! 1297: my ($rev1, $rev2, $sym1, $sym2, @difftype, $diffname, $f1, $f2);
1.12 fenner 1298:
1299: if ($r1 =~ /([^:]+)(:(.+))?/) {
1300: $rev1 = $1;
1301: $sym1 = $3;
1302: }
3.1 ! knu 1303: if ($r1 eq 'text') {
1.12 fenner 1304: $rev1 = $tr1;
3.1 ! knu 1305: $sym1 = "";
1.12 fenner 1306: }
1307: if ($r2 =~ /([^:]+)(:(.+))?/) {
1308: $rev2 = $1;
1309: $sym2 = $3;
1310: }
3.1 ! knu 1311: if ($r2 eq 'text') {
1.12 fenner 1312: $rev2 = $tr2;
3.1 ! knu 1313: $sym2 = "";
1.12 fenner 1314: }
3.1 ! knu 1315: # make sure the revisions a wellformed, for security
! 1316: # reasons ..
1.12 fenner 1317: if (!($rev1 =~ /^[\d\.]+$/) || !($rev2 =~ /^[\d\.]+$/)) {
1318: &fatal("404 Not Found",
1319: "Malformed query \"$ENV{'QUERY_STRING'}\"");
1320: }
1321: #
1322: # rev1 and rev2 are now both numeric revisions.
1323: # Thus we do a DWIM here and swap them if rev1 is after rev2.
1324: # XXX should we warn about the fact that we do this?
1325: if (&revcmp($rev1,$rev2) > 0) {
3.1 ! knu 1326: my ($tmp1, $tmp2) = ($rev1, $sym1);
1.12 fenner 1327: ($rev1, $sym1) = ($rev2, $sym2);
1328: ($rev2, $sym2) = ($tmp1, $tmp2);
1329: }
3.1 ! knu 1330: my $human_readable = 0;
1.12 fenner 1331: if ($f eq 'c') {
3.1 ! knu 1332: @difftype = qw{-c};
1.12 fenner 1333: $diffname = "Context diff";
3.1 ! knu 1334: }
! 1335: elsif ($f eq 's') {
! 1336: @difftype = qw{--side-by-side --width=164};
1.12 fenner 1337: $diffname = "Side by Side";
3.1 ! knu 1338: }
! 1339: elsif ($f eq 'H') {
! 1340: $human_readable = 1;
! 1341: @difftype = qw{--unified=15};
! 1342: $diffname = "Long Human readable";
! 1343: }
! 1344: elsif ($f eq 'h') {
! 1345: @difftype =qw{-u};
! 1346: $human_readable = 1;
! 1347: $diffname = "Human readable";
! 1348: }
! 1349: elsif ($f eq 'u') {
! 1350: @difftype = qw{-u};
1.12 fenner 1351: $diffname = "Unidiff";
1352: }
3.1 ! knu 1353: else {
! 1354: fatal ("400 Bad arguments", "Diff format $f not understood");
! 1355: }
! 1356:
! 1357: # apply special options
! 1358: if ($human_readable) {
! 1359: if ($hr_funout) {
! 1360: push @difftype, '-p';
! 1361:
! 1362: my($re1, $re2);
! 1363:
! 1364: while (($re1, $re2) = each %functionlineregexp) {
! 1365: if ($fullname =~ /$re1/) {
! 1366: push @difftype, '-F', '$re2';
! 1367: last;
! 1368: }
! 1369: }
! 1370: }
! 1371: if ($hr_ignwhite) {
! 1372: push @difftype, '-w';
! 1373: }
! 1374: if ($hr_ignkeysubst) {
! 1375: push @difftype, '-kk';
! 1376: }
! 1377: }
! 1378: if (! open($fh, "-|")) { # child
! 1379: open(STDERR, ">&STDOUT"); # Redirect stderr to stdout
! 1380: exec("rcsdiff",@difftype,"-r$rev1","-r$rev2",$fullname);
! 1381: }
! 1382: if ($human_readable) {
! 1383: http_header();
! 1384: &human_readable_diff($fh, $rev2);
! 1385: exit;
! 1386: }
! 1387: else {
! 1388: http_header("text/plain");
1.44 knu 1389: }
1.12 fenner 1390: #
1391: #===================================================================
1392: #RCS file: /home/ncvs/src/sys/netinet/tcp_output.c,v
1393: #retrieving revision 1.16
1394: #retrieving revision 1.17
1395: #diff -c -r1.16 -r1.17
1396: #*** /home/ncvs/src/sys/netinet/tcp_output.c 1995/11/03 22:08:08 1.16
1397: #--- /home/ncvs/src/sys/netinet/tcp_output.c 1995/12/05 17:46:35 1.17
1398: #
1399: # Ideas:
1400: # - nuke the stderr output if it's what we expect it to be
1401: # - Add "no differences found" if the diff command supplied no output.
1402: #
1403: #*** src/sys/netinet/tcp_output.c 1995/11/03 22:08:08 1.16
1404: #--- src/sys/netinet/tcp_output.c 1995/12/05 17:46:35 1.17 RELENG_2_1_0
1405: # (bogus example, but...)
1406: #
3.1 ! knu 1407: if (grep { $_ eq '-u'} @difftype) {
1.12 fenner 1408: $f1 = '---';
1409: $f2 = '\+\+\+';
3.1 ! knu 1410: }
! 1411: else {
1.12 fenner 1412: $f1 = '\*\*\*';
1413: $f2 = '---';
1414: }
3.1 ! knu 1415: while (<$fh>) {
1.12 fenner 1416: if (m|^$f1 $cvsroot|o) {
1417: s|$cvsroot/||o;
1418: if ($sym1) {
1419: chop;
1420: $_ .= " " . $sym1 . "\n";
1421: }
3.1 ! knu 1422: }
! 1423: elsif (m|^$f2 $cvsroot|o) {
1.12 fenner 1424: s|$cvsroot/||o;
1425: if ($sym2) {
1426: chop;
1427: $_ .= " " . $sym2 . "\n";
1428: }
1429: }
1430: print $_;
1431: }
3.1 ! knu 1432: close($fh);
1.12 fenner 1433: }
1434:
3.1 ! knu 1435: ###############################
! 1436: # Show Logs ..
! 1437: ###############################
! 1438: sub getDirLogs {
! 1439: my ($cvsroot,$dirname,@otherFiles) = @_;
! 1440: my ($state,$otherFiles,$tag, $file, $date, $branchpoint, $branch, $log);
! 1441: my ($rev, $revision, $revwanted, $filename, $head, $author);
! 1442:
! 1443: $tag = $input{only_with_tag};
! 1444:
! 1445: my ($DirName) = "$cvsroot/$where";
! 1446: my (@files, @filetags);
! 1447: my $fh = do {local(*FH);};
! 1448:
! 1449: push(@files, &safeglob("$DirName/*,v"));
! 1450: push(@files, &safeglob("$DirName/Attic/*,v")) if (!$input{'hideattic'});
! 1451: foreach $file (@otherFiles) {
! 1452: push(@files, "$DirName/$file");
! 1453: }
! 1454:
! 1455: # just execute rlog if there are any files
! 1456: if ($#files < 0) {
! 1457: return;
! 1458: }
! 1459:
! 1460: if ($tag) {
! 1461: #can't use -r<tag> as - is allowed in tagnames, but misinterpreated by rlog..
! 1462: if (! open($fh, "-|")) {
! 1463: close(STDERR); # rlog may complain; ignore.
! 1464: exec("rlog",@files);
! 1465: }
! 1466: }
! 1467: else {
! 1468: my $kidpid = open($fh, "-|");
! 1469: if (! $kidpid) {
! 1470: close(STDERR); # rlog may complain; ignore.
! 1471: exec("rlog","-r",@files);
! 1472: }
! 1473: }
! 1474: $state = "start";
! 1475: while (<$fh>) {
! 1476: if ($state eq "start") {
! 1477: #Next file. Initialize file variables
! 1478: $rev = undef;
! 1479: $revwanted = undef;
! 1480: $branch = undef;
! 1481: $branchpoint = undef;
! 1482: $filename = undef;
! 1483: $log = undef;
! 1484: $revision = undef;
! 1485: $branch = undef;
! 1486: %symrev = ();
! 1487: @filetags = ();
! 1488: #jump to head state
! 1489: $state = "head";
! 1490: }
! 1491: print "$state:$_" if ($verbose);
! 1492: again:
! 1493: if ($state eq "head") {
! 1494: #$rcsfile = $1 if (/^RCS file: (.+)$/); #not used (yet)
! 1495: $filename = $1 if (/^Working file: (.+)$/);
! 1496: $head = $1 if (/^head: (.+)$/);
! 1497: $branch = $1 if (/^branch: (.+)$/);
! 1498: }
! 1499: if ($state eq "head" && /^symbolic names/) {
! 1500: $state = "tags";
! 1501: ($branch = $head) =~ s/\.\d+$// if (!defined($branch));
! 1502: $branch =~ s/(\.?)(\d+)$/${1}0.$2/;
! 1503: $symrev{MAIN} = $branch;
! 1504: $symrev{HEAD} = $branch;
! 1505: $alltags{MAIN} = 1;
! 1506: $alltags{HEAD} = 1;
! 1507: push (@filetags, "MAIN", "HEAD");
! 1508: next;
! 1509: }
! 1510: if ($state eq "tags" &&
! 1511: /^\s+(.+):\s+([\d\.]+)\s+$/) {
! 1512: push (@filetags, $1);
! 1513: $symrev{$1} = $2;
! 1514: $alltags{$1} = 1;
! 1515: next;
! 1516: }
! 1517: if ($state eq "tags" && /^\S/) {
! 1518: if (defined($tag) && (defined($symrev{$tag}) || $tag eq "HEAD")) {
! 1519: $revwanted = $tag eq "HEAD" ? $symrev{"MAIN"} : $symrev{$tag};
! 1520: ($branch = $revwanted) =~ s/\b0\.//;
! 1521: ($branchpoint = $branch) =~ s/\.?\d+$//;
! 1522: $revwanted = undef if ($revwanted ne $branch);
! 1523: }
! 1524: elsif (defined($tag) && $tag ne "HEAD") {
! 1525: print "Tag not found, skip this file" if ($verbose);
! 1526: $state = "skip";
! 1527: next;
! 1528: }
! 1529: foreach my $tagfound (@filetags) {
! 1530: $tags{$tagfound} = 1;
! 1531: }
! 1532: $state = "head";
! 1533: goto again;
! 1534: }
! 1535: if ($state eq "head" && /^----------------------------$/) {
! 1536: $state = "log";
! 1537: $rev = undef;
! 1538: $date = undef;
! 1539: $log = "";
! 1540: # Try to reconstruct the relative filename if RCS spits out a full path
! 1541: $filename =~ s%^\Q$DirName\E/%%;
! 1542: next;
! 1543: }
! 1544: if ($state eq "log") {
! 1545: if (/^----------------------------$/
! 1546: || /^=============================/) {
! 1547: # End of a log entry.
! 1548: my $revbranch;
! 1549: ($revbranch = $rev) =~ s/\.\d+$//;
! 1550: print "$filename $rev Wanted: $revwanted "
! 1551: . "Revbranch: $revbranch Branch: $branch "
! 1552: . "Branchpoint: $branchpoint\n" if ($verbose);
! 1553: if (!defined($revwanted) && defined($branch)
! 1554: && $branch eq $revbranch || !defined($tag)) {
! 1555: print "File revision $rev found for branch $branch\n"
! 1556: if ($verbose);
! 1557: $revwanted = $rev;
! 1558: }
! 1559: if (defined($revwanted) ? $rev eq $revwanted :
! 1560: defined($branchpoint) ? $rev eq $branchpoint :
! 1561: 0 && ($rev eq $head)) { # Don't think head is needed here..
! 1562: print "File info $rev found for $filename\n" if ($verbose);
! 1563: my @finfo = ($rev,$date,$log,$author,$filename);
! 1564: my ($name);
! 1565: ($name = $filename) =~ s%/.*%%;
! 1566: $fileinfo{$name} = [ @finfo ];
! 1567: $state = "done" if ($rev eq $revwanted);
! 1568: }
! 1569: $rev = undef;
! 1570: $date = undef;
! 1571: $log = "";
! 1572: }
! 1573: elsif (!defined($date) && m|^date:\s+(\d+)/(\d+)/(\d+)\s+(\d+):(\d+):(\d+);|) {
! 1574: my $yr = $1;
! 1575: # damn 2-digit year routines :-)
! 1576: if ($yr > 100) {
! 1577: $yr -= 1900;
! 1578: }
! 1579: $date = &Time::Local::timegm($6,$5,$4,$3,$2 - 1,$yr);
! 1580: ($author) = /author: ([^;]+)/;
! 1581: $state = "log";
! 1582: $log = '';
! 1583: next;
! 1584: }
! 1585: elsif (!defined($rev) && m/^revision (.*)$/) {
! 1586: $rev = $1;
! 1587: next;
! 1588: }
! 1589: else {
! 1590: $log = $log . $_;
! 1591: }
! 1592: }
! 1593: if (/^===============/) {
! 1594: $state = "start";
! 1595: next;
! 1596: }
! 1597: }
! 1598: if ($. == 0) {
! 1599: fatal("500 Internal Error",
! 1600: "Failed to spawn GNU rlog on <em>'".join(", ", @files)."'</em><p>did you set the <b>\$ENV{PATH}</b> in your configuration file correctly ?");
! 1601: }
! 1602: close($fh);
! 1603: }
! 1604:
! 1605: sub readLog {
! 1606: my($fullname,$revision) = @_;
! 1607: my ($symnames, $head, $rev, $br, $brp, $branch, $branchrev);
! 1608: my $fh = do {local(*FH);};
! 1609:
! 1610: if (defined($revision)) {
! 1611: $revision = "-r$revision";
! 1612: }
! 1613: else {
! 1614: $revision = "";
! 1615: }
! 1616:
! 1617: undef %symrev;
! 1618: undef %revsym;
! 1619: undef @allrevisions;
! 1620: undef %date;
! 1621: undef %author;
! 1622: undef %state;
! 1623: undef %difflines;
! 1624: undef %log;
1.12 fenner 1625:
1626: print("Going to rlog '$fullname'\n") if ($verbose);
3.1 ! knu 1627: if (! open($fh, "-|")) { # child
! 1628: if ($revision ne '') {
! 1629: exec("rlog",$revision,$fullname);
! 1630: }
! 1631: else {
! 1632: exec("rlog",$fullname);
! 1633: }
1.44 knu 1634: }
3.1 ! knu 1635: while (<$fh>) {
1.1 jfieber 1636: print if ($verbose);
1637: if ($symnames) {
1638: if (/^\s+([^:]+):\s+([\d\.]+)/) {
1639: $symrev{$1} = $2;
3.1 ! knu 1640: }
! 1641: else {
1.1 jfieber 1642: $symnames = 0;
1643: }
3.1 ! knu 1644: }
! 1645: elsif (/^head:\s+([\d\.]+)/) {
! 1646: $head = $1;
! 1647: }
! 1648: elsif (/^branch:\s+([\d\.]+)/) {
! 1649: $curbranch = $1;
! 1650: }
! 1651: elsif (/^symbolic names/) {
1.1 jfieber 1652: $symnames = 1;
3.1 ! knu 1653: }
! 1654: elsif (/^-----/) {
1.1 jfieber 1655: last;
1656: }
1657: }
3.1 ! knu 1658: ($curbranch = $head) =~ s/\.\d+$// if (!defined($curbranch));
1.7 fenner 1659:
1.1 jfieber 1660: # each log entry is of the form:
1661: # ----------------------------
1662: # revision 3.7.1.1
1663: # date: 1995/11/29 22:15:52; author: fenner; state: Exp; lines: +5 -3
1664: # log info
1665: # ----------------------------
1666: logentry:
1667: while (!/^=========/) {
3.1 ! knu 1668: $_ = <$fh>;
1.12 fenner 1669: last logentry if (!defined($_)); # EOF
1.1 jfieber 1670: print "R:", $_ if ($verbose);
1671: if (/^revision ([\d\.]+)/) {
1672: $rev = $1;
3.1 ! knu 1673: unshift(@allrevisions,$rev);
! 1674: }
! 1675: elsif (/^========/ || /^----------------------------$/) {
1.1 jfieber 1676: next logentry;
3.1 ! knu 1677: }
! 1678: else {
1.12 fenner 1679: # The rlog output is syntactically ambiguous. We must
1680: # have guessed wrong about where the end of the last log
1681: # message was.
1682: # Since this is likely to happen when people put rlog output
1683: # in their commit messages, don't even bother keeping
1684: # these lines since we don't know what revision they go with
1685: # any more.
1686: next logentry;
1687: # &fatal("500 Internal Error","Error parsing RCS output: $_");
1.1 jfieber 1688: }
3.1 ! knu 1689: $_ = <$fh>;
1.1 jfieber 1690: print "D:", $_ if ($verbose);
3.1 ! knu 1691: if (m|^date:\s+(\d+)/(\d+)/(\d+)\s+(\d+):(\d+):(\d+);\s+author:\s+(\S+);\s+state:\s+(\S+);\s+(lines:\s+([0-9\s+-]+))?|) {
! 1692: my $yr = $1;
! 1693: # damn 2-digit year routines :-)
! 1694: if ($yr > 100) {
! 1695: $yr -= 1900;
! 1696: }
! 1697: $date{$rev} = &Time::Local::timegm($6,$5,$4,$3,$2 - 1,$yr);
1.1 jfieber 1698: $author{$rev} = $7;
1.9 fenner 1699: $state{$rev} = $8;
3.1 ! knu 1700: $difflines{$rev} = $10;
! 1701: }
! 1702: else {
1.1 jfieber 1703: &fatal("500 Internal Error", "Error parsing RCS output: $_");
1704: }
1705: line:
3.1 ! knu 1706: while (<$fh>) {
1.1 jfieber 1707: print "L:", $_ if ($verbose);
1708: next line if (/^branches:\s/);
1709: last line if (/^----------------------------$/ || /^=========/);
1710: $log{$rev} .= $_;
1711: }
1712: print "E:", $_ if ($verbose);
1713: }
3.1 ! knu 1714: close($fh);
1.1 jfieber 1715: print "Done reading RCS file\n" if ($verbose);
3.1 ! knu 1716:
! 1717: @revorder = reverse sort {revcmp($a,$b)} @allrevisions;
! 1718: print "Done sorting revisions",join(" ",@revorder),"\n" if ($verbose);
! 1719:
1.1 jfieber 1720: #
1721: # HEAD is an artificial tag which is simply the highest tag number on the main
1.8 fenner 1722: # branch, unless there is a branch tag in the RCS file in which case it's the
1723: # highest revision on that branch. Find it by looking through @revorder; it
1724: # is the first commit listed on the appropriate branch.
3.1 ! knu 1725: # This is not neccesary the same revision as marked as head in the RCS file.
! 1726: my $headrev = $curbranch || "1";
! 1727: ($symrev{"MAIN"} = $headrev) =~ s/(\.?)(\d+)$/${1}0.$2/;
1.1 jfieber 1728: revision:
3.1 ! knu 1729: foreach $rev (@revorder) {
! 1730: if ($rev =~ /^(\S*)\.\d+$/ && $headrev eq $1) {
! 1731: $symrev{"HEAD"} = $rev;
1.1 jfieber 1732: last revision;
1733: }
1734: }
3.1 ! knu 1735: ($symrev{"HEAD"} = $headrev) =~ s/\.\d+$//
! 1736: if (!defined($symrev{"HEAD"}));
1.1 jfieber 1737: print "Done finding HEAD\n" if ($verbose);
1738: #
1739: # Now that we know all of the revision numbers, we can associate
1740: # absolute revision numbers with all of the symbolic names, and
1741: # pass them to the form so that the same association doesn't have
1742: # to be built then.
1743: #
3.1 ! knu 1744: undef @branchnames;
! 1745: undef %branchpoint;
! 1746: undef $sel;
! 1747:
! 1748: foreach (reverse sort keys %symrev) {
1.1 jfieber 1749: $rev = $symrev{$_};
3.1 ! knu 1750: if ($rev =~ /^((.*)\.)?\b0\.(\d+)$/) {
1.7 fenner 1751: push(@branchnames, $_);
1.1 jfieber 1752: #
1753: # A revision number of A.B.0.D really translates into
1754: # "the highest current revision on branch A.B.D".
1755: #
1756: # If there is no branch A.B.D, then it translates into
1757: # the head A.B .
1758: #
3.1 ! knu 1759: # This reasoning also applies to the main branch A.B,
! 1760: # with the branch number 0.A, with the exception that
! 1761: # it has no head to translate to if there is nothing on
! 1762: # the branch, but I guess this can never happen?
! 1763: # (the code below gracefully forgets about the branch
! 1764: # if it should happen)
! 1765: #
! 1766: $head = defined($2) ? $2 : "";
1.1 jfieber 1767: $branch = $3;
3.1 ! knu 1768: $branchrev = $head . ($head ne "" ? "." : "") . $branch;
! 1769: my $regex;
! 1770: ($regex = $branchrev) =~ s/\./\\./g;
1.1 jfieber 1771: $rev = $head;
1772:
1773: revision:
3.1 ! knu 1774: foreach my $r (@revorder) {
! 1775: if ($r =~ /^${regex}\b/) {
! 1776: $rev = $branchrev;
1.1 jfieber 1777: last revision;
1778: }
1779: }
3.1 ! knu 1780: next if ($rev eq "");
! 1781: if ($rev ne $head && $head ne "") {
1.8 fenner 1782: $branchpoint{$head} .= ", " if ($branchpoint{$head});
1783: $branchpoint{$head} .= $_;
1784: }
1.1 jfieber 1785: }
3.1 ! knu 1786: $revsym{$rev} .= ", " if ($revsym{$rev});
! 1787: $revsym{$rev} .= $_;
1.1 jfieber 1788: $sel .= "<OPTION VALUE=\"${rev}:${_}\">$_\n";
1789: }
1790: print "Done associating revisions with branches\n" if ($verbose);
3.1 ! knu 1791:
! 1792: my ($onlyonbranch, $onlybranchpoint);
! 1793: if ($onlyonbranch = $input{'only_with_tag'}) {
! 1794: $onlyonbranch = $symrev{$onlyonbranch};
! 1795: if ($onlyonbranch =~ s/\b0\.//) {
! 1796: ($onlybranchpoint = $onlyonbranch) =~ s/\.\d+$//;
! 1797: }
! 1798: else {
! 1799: $onlybranchpoint = $onlyonbranch;
! 1800: }
! 1801: if (!defined($onlyonbranch) || $onlybranchpoint eq "") {
! 1802: fatal("404 Tag not found","Tag $input{'only_with_tag'} not defined");
! 1803: }
1.8 fenner 1804: }
1.1 jfieber 1805:
3.1 ! knu 1806: undef @revisions;
! 1807:
! 1808: foreach (@allrevisions) {
1.7 fenner 1809: ($br = $_) =~ s/\.\d+$//;
3.1 ! knu 1810: ($brp = $br) =~ s/\.\d+$//;
1.7 fenner 1811: next if ($onlyonbranch && $br ne $onlyonbranch &&
3.1 ! knu 1812: $_ ne $onlybranchpoint);
! 1813: unshift(@revisions,$_);
! 1814: }
! 1815:
! 1816: if ($logsort eq "date") {
! 1817: # Sort the revisions in commit order an secondary sort on revision
! 1818: # (secondary sort needed for imported sources, or the first main
! 1819: # revision gets before the same revision on the 1.1.1 branch)
! 1820: @revdisplayorder = sort {$date{$b} <=> $date{$a} || -revcmp($a, $b)} @revisions;
! 1821: }
! 1822: elsif ($logsort eq "rev") {
! 1823: # Sort the revisions in revision order, highest first
! 1824: @revdisplayorder = reverse sort {revcmp($a,$b)} @revisions;
! 1825: }
! 1826: else {
! 1827: # No sorting. Present in the same order as rlog / cvs log
! 1828: @revdisplayorder = @revisions;
! 1829: }
! 1830:
! 1831: }
! 1832:
! 1833: sub printLog($;$) {
! 1834: my ($link, $br, $brp);
! 1835: ($_,$link) = @_;
! 1836: ($br = $_) =~ s/\.\d+$//;
! 1837: ($brp = $br) =~ s/\.?\d+$//;
! 1838: my ($isDead, $prev);
! 1839:
! 1840: $link = 1 if (!defined($link));
! 1841: $isDead = ($state{$_} eq "dead");
! 1842:
! 1843: if ($link && !$isDead) {
! 1844: my ($filename);
! 1845: ($filename = $where) =~ s/^.*\///;
! 1846: my ($fileurl) = urlencode($filename);
1.4 fenner 1847: print "<a NAME=\"rev$_\"></a>";
3.1 ! knu 1848: if (defined($revsym{$_})) {
! 1849: foreach my $sym (split(", ", $revsym{$_})) {
! 1850: print "<a NAME=\"$sym\"></a>";
! 1851: }
1.4 fenner 1852: }
3.1 ! knu 1853: if (defined($revsym{$br}) && $revsym{$br} && !defined($nameprinted{$br})) {
! 1854: foreach my $sym (split(", ", $revsym{$br})) {
1.4 fenner 1855: print "<a NAME=\"$sym\"></a>";
1856: }
3.1 ! knu 1857: $nameprinted{$br} = 1;
1.4 fenner 1858: }
3.1 ! knu 1859: print "\n Revision ";
! 1860: &download_link($fileurl, $_, $_,
! 1861: $defaultViewable ? "text/x-cvsweb-markup" : undef);
! 1862: if ($defaultViewable) {
! 1863: print " / ";
! 1864: &download_link($fileurl, $_, "(download)", $mimetype);
! 1865: }
! 1866: if (not $defaultTextPlain) {
! 1867: print " / ";
! 1868: &download_link($fileurl, $_, "(as text)",
! 1869: "text/plain");
! 1870: }
! 1871: if (!$defaultViewable) {
! 1872: print " / ";
! 1873: &download_link($fileurl, $_, "(view)", "text/x-cvsweb-markup");
! 1874: }
! 1875: if ($allow_annotate) {
! 1876: print " - <a href=\"" . $scriptname . "/" . urlencode($where) . "?annotate=$_$barequery\">";
! 1877: print "annotate</a>";
! 1878: }
! 1879: # Plus a select link if enabled, and this version isn't selected
! 1880: if ($allow_version_select) {
! 1881: if ((!defined($input{"r1"}) || $input{"r1"} ne $_)) {
! 1882: print " - <A HREF=\"${scriptwhere}?r1=$_$barequery" .
! 1883: "\">[select for diffs]</A>\n";
! 1884: }
! 1885: else {
! 1886: print " - <b>[selected]</b>";
! 1887: }
! 1888: }
! 1889: }
! 1890: else {
! 1891: print "Revision <B>$_</B>";
! 1892: }
! 1893: if (/^1\.1\.1\.\d+$/) {
! 1894: print " <i>(vendor branch)</i>";
! 1895: }
! 1896: if (defined @mytz) {
! 1897: my ($est) = $mytz[(localtime($date{$_}))[8]];
! 1898: print ", <i>" . scalar localtime($date{$_}) . " $est</i> (";
! 1899: } else {
! 1900: print ", <i>" . scalar gmtime($date{$_}) . " UTC</i> (";
! 1901: }
! 1902: print readableTime(time() - $date{$_},1) . " ago)";
! 1903: print " by ";
! 1904: print "<i>" . $author{$_} . "</i>\n";
! 1905: print "<BR>Branch: <b>",$link?link_tags($revsym{$br}):$revsym{$br},"</b>\n"
! 1906: if ($revsym{$br});
! 1907: print "<BR>CVS Tags: <b>",$link?link_tags($revsym{$_}):$revsym{$_},"</b>"
! 1908: if ($revsym{$_});
! 1909: print "<BR>Branch point for: <b>",$link?link_tags($branchpoint{$_}):$branchpoint{$_},"</b>\n"
! 1910: if ($branchpoint{$_});
! 1911: # Find the previous revision
! 1912: my @prevrev = split(/\./, $_);
! 1913: do {
! 1914: if (--$prevrev[$#prevrev] <= 0) {
1.1 jfieber 1915: # If it was X.Y.Z.1, just make it X.Y
3.1 ! knu 1916: pop(@prevrev);
! 1917: pop(@prevrev);
! 1918: }
! 1919: $prev = join(".", @prevrev);
! 1920: } until (defined($date{$prev}) || $prev eq "");
! 1921: if ($prev ne "") {
! 1922: if ($difflines{$_}) {
! 1923: print "<BR>Changes since <b>$prev: $difflines{$_} lines</b>";
! 1924: }
! 1925: }
! 1926: if ($isDead) {
! 1927: print "<BR><B><I>FILE REMOVED</I></B>\n";
! 1928: }
! 1929: elsif ($link) {
! 1930: my %diffrev = ();
! 1931: $diffrev{$_} = 1;
! 1932: $diffrev{""} = 1;
! 1933: print "<BR>Diff";
! 1934: #
! 1935: # Offer diff to previous revision
! 1936: if ($prev) {
! 1937: $diffrev{$prev} = 1;
! 1938: print " to previous <A HREF=\"${scriptwhere}.diff?r1=$prev";
! 1939: print "&r2=$_" . $barequery . "\">$prev</A>\n";
! 1940: if (!$hr_default) { # offer a human readable version if not default
! 1941: print "(<A HREF=\"${scriptwhere}.diff?r1=$prev";
! 1942: print "&r2=$_" . $barequery . "&f=h\">colored</A>)\n";
! 1943: }
! 1944: }
! 1945: #
! 1946: # Plus, if it's on a branch, and it's not a vendor branch,
! 1947: # offer a diff with the branch point.
! 1948: if ($revsym{$brp} && !/^1\.1\.1\.\d+$/ && !defined($diffrev{$brp})) {
! 1949: print " to branchpoint <A HREF=\"${scriptwhere}.diff?r1=$brp";
! 1950: print "&r2=$_" . $barequery . "\">$brp</A>\n";
! 1951: if (!$hr_default) { # offer a human readable version if not default
! 1952: print "(<A HREF=\"${scriptwhere}.diff?r1=$brp";
! 1953: print "&r2=$_" . $barequery . "&f=h\">colored</A>)\n";
1.1 jfieber 1954: }
1955: }
3.1 ! knu 1956: #
! 1957: # Plus, if it's on a branch, and it's not a vendor branch,
! 1958: # offer to diff with the next revision of the higher branch.
! 1959: # (e.g. change gets committed and then brought
! 1960: # over to -stable)
! 1961: if (/^\d+\.\d+\.\d+/ && !/^1\.1\.1\.\d+$/) {
! 1962: my ($i,$nextmain);
! 1963: for ($i = 0; $i < $#revorder && $revorder[$i] ne $_; $i++){}
! 1964: my (@tmp2) = split(/\./, $_);
! 1965: for ($nextmain = ""; $i > 0; $i--) {
! 1966: my ($next) = $revorder[$i-1];
! 1967: my (@tmp1) = split(/\./, $next);
1.1 jfieber 1968: if ($#tmp1 < $#tmp2) {
3.1 ! knu 1969: $nextmain = $next;
! 1970: last;
! 1971: }
! 1972: # Only the highest version on a branch should have
! 1973: # a diff for the "next main".
! 1974: last if (join(".",@tmp1[0..$#tmp1-1])
! 1975: eq join(".",@tmp2[0..$#tmp1-1]));
! 1976: }
! 1977: if (!defined($diffrev{$nextmain})) {
! 1978: $diffrev{$nextmain} = 1;
! 1979: print " next main <A HREF=\"${scriptwhere}.diff?r1=$nextmain";
! 1980: print "&r2=$_" . $barequery .
! 1981: "\">$nextmain</A>\n";
! 1982: if (!$hr_default) { # offer a human readable version if not default
! 1983: print "(<A HREF=\"${scriptwhere}.diff?r1=$nextmain";
! 1984: print "&r2=$_" . $barequery .
! 1985: "&f=h\">colored</A>)\n";
1.1 jfieber 1986: }
1987: }
1988: }
3.1 ! knu 1989: # Plus if user has selected only r1, then present a link
! 1990: # to make a diff to that revision
! 1991: if (defined($input{"r1"}) && !defined($diffrev{$input{"r1"}})) {
! 1992: $diffrev{$input{"r1"}} = 1;
! 1993: print " to selected <A HREF=\"${scriptwhere}.diff?"
! 1994: . "r1=$input{'r1'}&r2=$_" . $barequery
! 1995: . "\">$input{'r1'}</A>\n";
! 1996: if (!$hr_default) { # offer a human readable version if not default
! 1997: print "(<A HREF=\"${scriptwhere}.diff?r1=$input{'r1'}";
! 1998: print "&r2=$_" . $barequery .
! 1999: "&f=h\">colored</A>)\n";
! 2000:
! 2001: }
1.9 fenner 2002: }
1.1 jfieber 2003: }
3.1 ! knu 2004: print "<PRE>\n";
! 2005: print &htmlify($log{$_}, 1);
! 2006: print "</PRE>\n";
! 2007: }
! 2008:
! 2009: sub doLog {
! 2010: my($fullname) = @_;
! 2011: my ($diffrev, $upwhere, $filename, $backurl);
! 2012:
! 2013: readLog($fullname);
! 2014:
! 2015: html_header("CVS log for $where");
! 2016: ($upwhere = $where) =~ s|(Attic/)?[^/]+$||;
! 2017: ($filename = $where) =~ s|^.*/||;
! 2018: $backurl = $scriptname . "/" . urlencode($upwhere) . $query;
! 2019: print &link($backicon, "$backurl#$filename"),
! 2020: " <b>Up to ", &clickablePath($upwhere, 1), "</b><p>\n";
! 2021: print "<A HREF=\"#diff\">Request diff between arbitrary revisions</A>\n";
! 2022: print "<HR NOSHADE>\n";
! 2023: if ($curbranch) {
! 2024: print "Default branch: ";
! 2025: print ($revsym{$curbranch} || $curbranch);
! 2026: }
! 2027: else {
! 2028: print "No default branch";
! 2029: }
! 2030: print "<BR>\n";
! 2031: if ($input{only_with_tag}) {
! 2032: print "Current tag: $input{only_with_tag}<BR>\n";
! 2033: }
! 2034:
! 2035: undef %nameprinted;
! 2036:
! 2037: for (my $i = 0; $i <= $#revdisplayorder; $i++) {
! 2038: print "<HR size=1 NOSHADE>";
! 2039: printLog($revdisplayorder[$i]);
! 2040: }
! 2041:
! 2042: print "<HR NOSHADE>";
1.1 jfieber 2043: print "<A NAME=diff>\n";
2044: print "This form allows you to request diff's between any two\n";
2045: print "revisions of a file. You may select a symbolic revision\n";
2046: print "name using the selection box or you may type in a numeric\n";
2047: print "name using the type-in text box.\n";
2048: print "</A><P>\n";
3.1 ! knu 2049: print "<FORM METHOD=\"GET\" ACTION=\"${scriptwhere}.diff\" NAME=\"diff_select\">\n";
! 2050: foreach (@stickyvars) {
! 2051: print "<INPUT TYPE=HIDDEN NAME=\"$_\" VALUE=\"$input{$_}\">\n"
! 2052: if (defined($input{$_})
! 2053: && ($input{$_} ne $DEFAULTVALUE{$_} && $input{$_} ne ""));
! 2054: }
1.1 jfieber 2055: print "Diffs between \n";
2056: print "<SELECT NAME=\"r1\">\n";
2057: print "<OPTION VALUE=\"text\" SELECTED>Use Text Field\n";
2058: print $sel;
2059: print "</SELECT>\n";
3.1 ! knu 2060: $diffrev = $revdisplayorder[$#revdisplayorder];
! 2061: $diffrev = $input{"r1"} if (defined($input{"r1"}));
! 2062: print "<INPUT TYPE=\"TEXT\" SIZE=\"$inputTextSize\" NAME=\"tr1\" VALUE=\"$diffrev\" onChange='document.diff_select.r1.selectedIndex=0'>\n";
1.1 jfieber 2063: print " and \n";
2064: print "<SELECT NAME=\"r2\">\n";
2065: print "<OPTION VALUE=\"text\" SELECTED>Use Text Field\n";
2066: print $sel;
2067: print "</SELECT>\n";
3.1 ! knu 2068: $diffrev = $revdisplayorder[0];
! 2069: $diffrev = $input{"r2"} if (defined($input{"r2"}));
! 2070: print "<INPUT TYPE=\"TEXT\" SIZE=\"$inputTextSize\" NAME=\"tr2\" VALUE=\"$diffrev\" onChange='docuement.diff_select.r2.selectedIndex=0'>\n";
! 2071: print "<BR>Type of Diff should be a ";
! 2072: printDiffSelect();
! 2073: print "<INPUT TYPE=SUBMIT VALUE=\" Get Diffs \">\n";
1.1 jfieber 2074: print "</FORM>\n";
1.7 fenner 2075: print "<HR noshade>\n";
3.1 ! knu 2076: if (@branchnames) {
! 2077: print "<A name=branch></A>\n";
! 2078: print "<FORM METHOD=\"GET\" ACTION=\"$scriptwhere\">\n";
! 2079: foreach (@stickyvars) {
! 2080: next if ($_ eq "only_with_tag");
! 2081: next if ($_ eq "logsort");
! 2082: print "<INPUT TYPE=HIDDEN NAME=\"$_\" VALUE=\"$input{$_}\">\n"
! 2083: if (defined($input{$_}) && $input{$_} ne $DEFAULTVALUE{$_}
! 2084: && $input{$_} ne "");
! 2085: }
! 2086: print "View only Branch: \n";
! 2087: print "<SELECT NAME=\"only_with_tag\"";
! 2088: print " onchange=\"submit()\"" if ($use_java_script);
! 2089: print ">\n";
! 2090: print "<OPTION VALUE=\"\"";
! 2091: print " SELECTED" if (defined($input{"only_with_tag"}) &&
! 2092: $input{"only_with_tag"} eq "");
! 2093: print ">Show all branches\n";
! 2094: foreach (reverse sort @branchnames) {
1.9 fenner 2095: print "<OPTION";
3.1 ! knu 2096: print " SELECTED" if (defined($input{"only_with_tag"})
! 2097: && $input{"only_with_tag"} eq $_);
1.9 fenner 2098: print ">${_}\n";
3.1 ! knu 2099: }
! 2100: print "</SELECT>\n";
! 2101: print "<INPUT TYPE=SUBMIT VALUE=\" View Branch \">\n";
! 2102: print "</FORM>\n";
1.7 fenner 2103: }
3.1 ! knu 2104: print "<A name=logsort></A>\n";
! 2105: print "<FORM METHOD=\"GET\" ACTION=\"$scriptwhere\">\n";
! 2106: foreach (@stickyvars) {
! 2107: next if ($_ eq "only_with_tag");
! 2108: next if ($_ eq "logsort");
! 2109: print "<INPUT TYPE=HIDDEN NAME=\"$_\" VALUE=\"$input{$_}\">\n"
! 2110: if (defined($input{$_}) && $input{$_} ne $DEFAULTVALUE{$_}
! 2111: && $input{$_} ne "");
! 2112: }
! 2113: print "Sort log by: \n";
! 2114: print "<SELECT NAME=\"logsort\"";
! 2115: print " onchange=\"submit()\"" if ($use_java_script);
! 2116: print ">\n";
! 2117: print "<OPTION VALUE=cvs",$logsort eq "cvs" ? " SELECTED" : "", ">Not sorted";
! 2118: print "<OPTION VALUE=date",$logsort eq "date" ? " SELECTED" : "", ">Commit date";
! 2119: print "<OPTION VALUE=rev",$logsort eq "rev" ? " SELECTED" : "", ">Revision";
1.7 fenner 2120: print "</SELECT>\n";
3.1 ! knu 2121: print "<INPUT TYPE=SUBMIT VALUE=\" Sort \">\n";
1.7 fenner 2122: print "</FORM>\n";
1.2 jfieber 2123: print &html_footer;
1.1 jfieber 2124: print "</BODY></HTML>\n";
1.10 wosch 2125: }
2126:
3.1 ! knu 2127: sub flush_diff_rows ($$$$)
! 2128: {
! 2129: my $j;
! 2130: my ($leftColRef,$rightColRef,$leftRow,$rightRow) = @_;
! 2131: if ($state eq "PreChangeRemove") { # we just got remove-lines before
! 2132: for ($j = 0 ; $j < $leftRow; $j++) {
! 2133: print "<tr><td bgcolor=\"$diffcolorRemove\">@$leftColRef[$j]</td>";
! 2134: print "<td bgcolor=\"$diffcolorEmpty\"> </td></tr>\n";
! 2135: }
! 2136: }
! 2137: elsif ($state eq "PreChange") { # state eq "PreChange"
! 2138: # we got removes with subsequent adds
! 2139: for ($j = 0; $j < $leftRow || $j < $rightRow ; $j++) { # dump out both cols
! 2140: print "<tr>";
! 2141: if ($j < $leftRow) {
! 2142: print "<td bgcolor=\"$diffcolorChange\">@$leftColRef[$j]</td>";
! 2143: }
! 2144: else {
! 2145: print "<td bgcolor=\"$diffcolorDarkChange\"> </td>";
! 2146: }
! 2147: if ($j < $rightRow) {
! 2148: print "<td bgcolor=\"$diffcolorChange\">@$rightColRef[$j]</td>";
! 2149: }
! 2150: else {
! 2151: print "<td bgcolor=\"$diffcolorDarkChange\"> </td>";
! 2152: }
! 2153: print "</tr>\n";
! 2154: }
! 2155: }
! 2156: }
! 2157:
! 2158: ##
! 2159: # Function to generate Human readable diff-files
! 2160: # human_readable_diff(String revision_to_return_to);
! 2161: ##
! 2162: sub human_readable_diff($){
! 2163: my ($i,$difftxt, $where_nd, $filename, $pathname, $scriptwhere_nd);
! 2164: my ($fh, $rev) = @_;
! 2165: my ($date1, $date2, $r1d, $r2d, $r1r, $r2r, $rev1, $rev2, $sym1, $sym2);
! 2166: my (@rightCol, @leftCol);
! 2167:
! 2168: ($where_nd = $where) =~ s/.diff$//;
! 2169: ($filename = $where_nd) =~ s/^.*\///;
! 2170: ($pathname = $where_nd) =~ s/(Attic\/)?[^\/]*$//;
! 2171: ($scriptwhere_nd = $scriptwhere) =~ s/.diff$//;
! 2172:
! 2173: navigateHeader ($scriptwhere_nd, $pathname, $filename, $rev, "diff");
! 2174:
! 2175: # Read header to pick up read revision and date, if possible
! 2176: while (<$fh>) {
! 2177: ($r1d,$r1r) = /\t(.*)\t(.*)$/ if (/^--- /);
! 2178: ($r2d,$r2r) = /\t(.*)\t(.*)$/ if (/^\+\+\+ /);
! 2179: last if (/^\+\+\+ /);
! 2180: }
! 2181: if (defined($r1r) && $r1r =~ /^(\d+\.)+\d+$/) {
! 2182: $rev1 = $r1r;
! 2183: $date1 = $r1d;
! 2184: }
! 2185: if (defined($r2r) && $r2r =~ /^(\d+\.)+\d+$/) {
! 2186: $rev2 = $r2r;
! 2187: $date2 = $r2d;
! 2188: }
! 2189:
! 2190: print "<h3 align=center>Diff for /$where_nd between version $rev1 and $rev2</h3>\n";
! 2191:
! 2192: print "<table border=0 cellspacing=0 cellpadding=0 width=\"100%\">\n";
! 2193: print "<tr bgcolor=\"#ffffff\">\n";
! 2194: print "<th width=\"50%\" valign=TOP>";
! 2195: print "version $rev1";
! 2196: print ", $date1" if (defined($date1));
! 2197: print "<br>Tag: $sym1\n" if ($sym1);
! 2198: print "</th>\n";
! 2199: print "<th width=\"50%\" valign=TOP>";
! 2200: print "version $rev2";
! 2201: print ", $date2" if (defined($date2));
! 2202: print "<br>Tag: $sym2\n" if ($sym1);
! 2203: print "</th>\n";
! 2204:
! 2205: my $fs = "<font face=\"$difffontface\" size=\"$difffontsize\">";
! 2206: my $fe = "</font>";
! 2207:
! 2208: my $leftRow = 0;
! 2209: my $rightRow = 0;
! 2210: my ($oldline, $newline, $funname, $diffcode, $rest);
! 2211:
! 2212: # Process diff text
! 2213: # The diffrows are could make excellent use of
! 2214: # cascading style sheets because we've to set the
! 2215: # font and color for each row. anyone ...?
! 2216: ####
! 2217: while (<$fh>) {
! 2218: $difftxt = $_;
! 2219:
! 2220: if ($difftxt =~ /^@@/) {
! 2221: ($oldline,$newline,$funname) = $difftxt =~ /@@ \-([0-9]+).*\+([0-9]+).*@@(.*)/;
! 2222: print "<tr bgcolor=\"$diffcolorHeading\"><td width=\"50%\">";
! 2223: print "<table width=\"100%\" border=1 cellpadding=5><tr><td><b>Line $oldline</b>";
! 2224: print " <font size=-1>$funname</font></td></tr></table>";
! 2225: print "</td><td width=\"50%\">";
! 2226: print "<table width=\"100%\" border=1 cellpadding=5><tr><td><b>Line $newline</b>";
! 2227: print " <font size=-1>$funname</font></td></tr></table>";
! 2228: print "</td>\n";
! 2229: $state = "dump";
! 2230: $leftRow = 0;
! 2231: $rightRow = 0;
! 2232: }
! 2233: else {
! 2234: ($diffcode,$rest) = $difftxt =~ /^([-+ ])(.*)/;
! 2235: $_ = spacedHtmlText ($rest);
! 2236:
! 2237: # Add fontface, size
! 2238: $_ = "$fs $_$fe";
! 2239:
! 2240: #########
! 2241: # little state machine to parse unified-diff output (Hen, zeller@think.de)
! 2242: # in order to get some nice 'ediff'-mode output
! 2243: # states:
! 2244: # "dump" - just dump the value
! 2245: # "PreChangeRemove" - we began with '-' .. so this could be the start of a 'change' area or just remove
! 2246: # "PreChange" - okey, we got several '-' lines and moved to '+' lines -> this is a change block
! 2247: ##########
! 2248:
! 2249: if ($diffcode eq '+') {
! 2250: if ($state eq "dump") { # 'change' never begins with '+': just dump out value
! 2251: print "<tr><td bgcolor=\"$diffcolorEmpty\"> </td><td bgcolor=\"$diffcolorAdd\">$_</td></tr>\n";
! 2252: }
! 2253: else { # we got minus before
! 2254: $state = "PreChange";
! 2255: $rightCol[$rightRow++] = $_;
! 2256: }
! 2257: }
! 2258: elsif ($diffcode eq '-') {
! 2259: $state = "PreChangeRemove";
! 2260: $leftCol[$leftRow++] = $_;
! 2261: }
! 2262: else { # empty diffcode
! 2263: flush_diff_rows \@leftCol, \@rightCol, $leftRow, $rightRow;
! 2264: print "<tr><td>$_</td><td>$_</td></tr>\n";
! 2265: $state = "dump";
! 2266: $leftRow = 0;
! 2267: $rightRow = 0;
! 2268: }
! 2269: }
! 2270: }
! 2271: flush_diff_rows \@leftCol, \@rightCol, $leftRow, $rightRow;
! 2272:
! 2273: # state is empty if we didn't have any change
! 2274: if (!$state) {
! 2275: print "<tr><td colspan=2> </td></tr>";
! 2276: print "<tr bgcolor=\"$diffcolorEmpty\" >";
! 2277: print "<td colspan=2 align=center><b>- No viewable Change -</b></td></tr>";
! 2278: }
! 2279: print "</table>";
! 2280: close($fh);
! 2281:
! 2282: print "<br><hr noshade width=\"100%\">\n";
! 2283:
! 2284: print "<table border=0>";
! 2285:
! 2286: print "<tr><td>";
! 2287: # print legend
! 2288: print "<table border=1><tr><td>";
! 2289: print "Legend:<br><table border=0 cellspacing=0 cellpadding=1>\n";
! 2290: print "<tr><td align=center bgcolor=\"$diffcolorRemove\">Removed from v.$rev1</td><td bgcolor=\"$diffcolorEmpty\"> </td></tr>";
! 2291: print "<tr bgcolor=\"$diffcolorChange\"><td align=center colspan=2>changed lines</td></tr>";
! 2292: print "<tr><td bgcolor=\"$diffcolorEmpty\"> </td><td align=center bgcolor=\"$diffcolorAdd\">Added in v.$rev2</td></tr>";
! 2293: print "</table></td></tr></table>\n";
! 2294:
! 2295: print "<td>";
! 2296: # Print format selector
! 2297: print "<FORM METHOD=\"GET\" ACTION=\"${scriptwhere}\">\n";
! 2298: foreach my $var (keys %input) {
! 2299: next if ($var eq "f");
! 2300: next if (defined($DEFAULTVALUE{$var})
! 2301: && $DEFAULTVALUE{$var} eq $input{$var});
! 2302: print "<INPUT TYPE=HIDDEN NAME=\"",urlencode($var),"\" VALUE=\"",
! 2303: urlencode($input{$var}),"\">\n";
! 2304: }
! 2305: printDiffSelect($use_java_script);
! 2306: print "<INPUT TYPE=SUBMIT VALUE=\"Show\">\n";
! 2307: print "</FORM>\n";
! 2308: print "</td>";
! 2309:
! 2310: print "</tr></table>";
! 2311: }
! 2312:
! 2313: sub navigateHeader ($$$$$) {
! 2314: my ($swhere,$path,$filename,$rev,$title) = @_;
! 2315: $swhere = "" if ($swhere eq $scriptwhere);
! 2316: $swhere = urlencode($filename) if ($swhere eq "");
! 2317: print "<\!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">";
! 2318: print "<HTML>\n<HEAD>\n";
! 2319: print '<!-- CVSweb $Revision: 3.1.1.1 $ -->';
! 2320: print "\n<TITLE>$path$filename - $title - $rev</TITLE></HEAD>\n";
! 2321: print "<BODY BGCOLOR=\"$backcolor\">\n";
! 2322: print "<table width=\"100%\" border=0 cellspacing=0 cellpadding=1 bgcolor=\"$navigationHeaderColor\">";
! 2323: print "<tr valign=bottom><td>";
! 2324: print "<a href=\"$swhere$query#rev$rev\">$backicon";
! 2325: print "</a> <b>Return to ", &link("$filename","$swhere$query#rev$rev")," CVS log";
! 2326: print "</b> $fileicon</td>";
! 2327:
! 2328: print "<td align=right>$diricon <b>Up to ", &clickablePath($path, 1), "</b></td>";
! 2329: print "</tr></table>";
! 2330: }
! 2331:
! 2332: sub plural_write ($$)
! 2333: {
! 2334: my ($num,$text) = @_;
! 2335: if ($num != 1) {
! 2336: $text = $text . "s";
! 2337: }
! 2338: if ($num > 0) {
! 2339: return $num . " " . $text;
! 2340: }
! 2341: else {
! 2342: return "";
! 2343: }
! 2344: }
! 2345:
! 2346: ##
! 2347: # print readable timestamp in terms of
! 2348: # '..time ago'
! 2349: # H. Zeller <zeller@think.de>
! 2350: ##
! 2351: sub readableTime ($$)
! 2352: {
! 2353: my ($i, $break, $retval);
! 2354: my ($secs,$long) = @_;
! 2355:
! 2356: # this function works correct for time >= 2 seconds
! 2357: if ($secs < 2) {
! 2358: return "very little time";
! 2359: }
! 2360:
! 2361: my %desc = (1 , 'second',
! 2362: 60, 'minute',
! 2363: 3600, 'hour',
! 2364: 86400, 'day',
! 2365: 604800, 'week',
! 2366: 2628000, 'month',
! 2367: 31536000, 'year');
! 2368: my @breaks = sort {$a <=> $b} keys %desc;
! 2369: $i = 0;
! 2370: while ($i <= $#breaks && $secs >= 2 * $breaks[$i]) {
! 2371: $i++;
! 2372: }
! 2373: $i--;
! 2374: $break = $breaks[$i];
! 2375: $retval = plural_write(int ($secs / $break), $desc{"$break"});
! 2376:
! 2377: if ($long == 1 && $i > 0) {
! 2378: my $rest = $secs % $break;
! 2379: $i--;
! 2380: $break = $breaks[$i];
! 2381: my $resttime = plural_write(int ($rest / $break),
! 2382: $desc{"$break"});
! 2383: if ($resttime) {
! 2384: $retval = $retval . ", " . $resttime;
! 2385: }
! 2386: }
! 2387:
! 2388: return $retval;
! 2389: }
! 2390:
! 2391: ##
! 2392: # clickablePath(String pathname, boolean last_item_clickable)
! 2393: #
! 2394: # returns a html-ified path whereas each directory is a link for
! 2395: # faster navigation. last_item_clickable controls whether the
! 2396: # basename (last directory/file) is a link as well
! 2397: ##
! 2398: sub clickablePath($$) {
! 2399: my ($pathname,$clickLast) = @_;
! 2400: my $retval = '';
! 2401:
! 2402: if ($pathname eq '/') {
! 2403: # this should never happen - chooseCVSRoot() is
! 2404: # intended to do this
! 2405: $retval = "[$cvstree]";
! 2406: }
! 2407: else {
! 2408: $retval = $retval . " <a href=\"${scriptname}/${query}#dirlist\">[$cvstree]</a>";
! 2409: my $wherepath = '';
! 2410: my ($lastslash) = $pathname =~ m|/$|;
! 2411: foreach (split(/\//, $pathname)) {
! 2412: $retval = $retval . " / ";
! 2413: $wherepath = $wherepath . '/' . $_;
! 2414: my ($last) = "$wherepath/" eq "/$pathname"
! 2415: || "$wherepath" eq "/$pathname";
! 2416: if ($clickLast || !$last) {
! 2417: $retval = $retval . "<a href=\"${scriptname}"
! 2418: . urlencode($wherepath)
! 2419: . (!$last || $lastslash ? '/' : '')
! 2420: . ${query}
! 2421: . (!$last || $lastslash ? "#dirlist" : "")
! 2422: . "\">$_</a>";
! 2423: }
! 2424: else { # do not make a link to the current dir
! 2425: $retval = $retval . $_;
! 2426: }
! 2427: }
! 2428: }
! 2429: return $retval;
! 2430: }
! 2431:
! 2432: sub chooseCVSRoot() {
! 2433: my @foo;
! 2434: foreach (sort keys %CVSROOT) {
! 2435: if (-d $CVSROOT{$_}) {
! 2436: push(@foo, $_);
! 2437: }
! 2438: }
! 2439: if (@foo > 1) {
! 2440: my ($k);
! 2441: print "<form method=\"GET\" action=\"${scriptwhere}\">\n";
! 2442: foreach $k (keys %input) {
! 2443: print "<input type=hidden NAME=$k VALUE=$input{$k}>\n"
! 2444: if ($input{$k}) && ($k ne "cvsroot");
! 2445: }
! 2446: # Form-Elements look wierd in Netscape if the background
! 2447: # isn't gray and the form elements are not placed
! 2448: # within a table ...
! 2449: print "<table><tr>";
! 2450: print "<td>CVS Root:</td>";
! 2451: print "<td>\n<select name=\"cvsroot\"";
! 2452: print " onchange=\"submit()\"" if ($use_java_script);
! 2453: print ">\n";
! 2454: foreach $k (@foo) {
! 2455: print "<option value=\"$k\"";
! 2456: print " selected" if ("$k" eq "$cvstree");
! 2457: print ">" . ($CVSROOTdescr{"$k"} ? $CVSROOTdescr{"$k"} :
! 2458: $k). "</option>\n";
! 2459: }
! 2460: print "</select>\n</td>";
! 2461: print "<td><input type=submit value=\"Go\"></td>";
! 2462: print "</tr></table></form>";
! 2463: }
! 2464: else {
! 2465: # no choice ..
! 2466: print "CVS Root: <b>[$cvstree]</b>";
! 2467: }
! 2468: }
! 2469:
! 2470: sub chooseMirror() {
! 2471: my ($mirror,$moremirrors);
! 2472: $moremirrors = 0;
! 2473: # This code comes from the original BSD-cvsweb
! 2474: # and may not be useful for your site; If you don't
! 2475: # set %MIRRORS this won't show up, anyway
! 2476: #
! 2477: # Should perhaps exlude the current site somehow..
! 2478: if (keys %MIRRORS) {
! 2479: print "\nThis cvsweb is mirrored in:\n";
! 2480: foreach $mirror (keys %MIRRORS) {
! 2481: print ", " if ($moremirrors);
! 2482: print qq(<a href="$MIRRORS{$mirror}">$mirror</A>\n);
! 2483: $moremirrors = 1;
! 2484: }
! 2485: print "<p>\n";
! 2486: }
! 2487: }
! 2488:
! 2489: sub fileSortCmp {
! 2490: my ($comp) = 0;
! 2491: my ($c,$d,$af,$bf);
! 2492:
! 2493: ($af = $a) =~ s/,v$//;
! 2494: ($bf = $b) =~ s/,v$//;
! 2495: my ($rev1,$date1,$log1,$author1,$filename1) = @{$fileinfo{$af}}
! 2496: if (defined($fileinfo{$af}));
! 2497: my ($rev2,$date2,$log2,$author2,$filename2) = @{$fileinfo{$bf}}
! 2498: if (defined($fileinfo{$bf}));
! 2499:
! 2500: if (defined($filename1) && defined($filename2) && $af eq $filename1 && $bf eq $filename2) {
! 2501: # Two files
! 2502: $comp = -revcmp($rev1, $rev2) if ($byrev && $rev1 && $rev2);
! 2503: $comp = ($date2 <=> $date1) if ($bydate && $date1 && $date2);
! 2504: $comp = ($log1 cmp $log2) if ($bylog && $log1 && $log2);
! 2505: $comp = ($author1 cmp $author2) if ($byauthor && $author1 && $author2);
! 2506: }
! 2507: if ($comp == 0) {
! 2508: # Directories first, then sorted on name if no other sort critera
! 2509: # available.
! 2510: my $ad = ((-d "$fullname/$a")?"D":"F");
! 2511: my $bd = ((-d "$fullname/$b")?"D":"F");
! 2512: ($c=$a) =~ s|.*/||;
! 2513: ($d=$b) =~ s|.*/||;
! 2514: $comp = ("$ad$c" cmp "$bd$d");
! 2515: }
! 2516: return $comp;
! 2517: }
! 2518:
! 2519: # make A url for downloading
! 2520: sub download_url {
! 2521: my ($url,$revision,$mimetype) = @_;
! 2522:
! 2523: $revision =~ s/\b0\.//;
! 2524:
! 2525: if (defined($checkout_magic)
! 2526: && (!defined($mimetype) || $mimetype ne "text/x-cvsweb-markup")) {
! 2527: my ($path);
! 2528: ($path = $where) =~ s|/[^/]*$|/|;
! 2529: $url = "$scriptname/$checkoutMagic/${path}$url";
! 2530: }
! 2531: $url .= "?rev=$revision";
! 2532: $url .= "&content-type=$mimetype" if (defined($mimetype));
! 2533:
! 2534: return $url;
! 2535: }
! 2536:
! 2537: # Presents a link to download the
! 2538: # selected revision
! 2539: sub download_link {
! 2540: my ($url,$revision,$textlink,$mimetype) = @_;
! 2541: my ($fullurl) = download_url($url,$revision,$mimetype);
! 2542: my ($paren) = $textlink =~ /^\(/;
! 2543: $textlink =~ s/^\(// if ($paren);
! 2544: $textlink =~ s/\)$// if ($paren);
! 2545: print "(" if ($paren);
! 2546: print "<A HREF=\"$fullurl";
! 2547: print $barequery;
! 2548: print "\"";
! 2549: if ($open_extern_window && (!defined($mimetype) || $mimetype ne "text/x-cvsweb-markup")) {
! 2550: print " target=\"cvs_checkout\"";
! 2551: # we should have
! 2552: # 'if (document.cvswin==null) document.cvswin=window.open(...'
! 2553: # in order to allow the user to resize the window; otherwise
! 2554: # the user may resize the window, but on next checkout - zap -
! 2555: # its original (configured s. cvsweb.conf) size is back again
! 2556: # .. annoying (if $extern_window_(width|height) is defined)
! 2557: # but this if (..) solution is far from perfect
! 2558: # what we need to do as well is
! 2559: # 1) save cvswin in an invisible frame that always exists
! 2560: # (document.cvswin will be void on next load)
! 2561: # 2) on close of the cvs_checkout - window set the cvswin
! 2562: # variable to 'null' again - so that it will be
! 2563: # reopenend with the configured size
! 2564: # anyone a JavaScript programmer ?
! 2565: # .. so here without if (..):
! 2566: # currently, the best way is to comment out the size parameters
! 2567: # ($extern_window...) in cvsweb.conf.
! 2568: if ($use_java_script) {
! 2569: print " onClick=\"window.open('$fullurl','cvs_checkout',";
! 2570: print "'resizeable,scrollbars";
! 2571: print ",status,toolbar" if (defined($mimetype)
! 2572: && $mimetype eq "text/html");
! 2573: print ",width=$extern_window_width" if (defined($extern_window_width));
! 2574: print ",height=$extern_window_height" if (defined($extern_window_height));
! 2575: print"');\"";
! 2576: }
! 2577: }
! 2578: print "><b>$textlink</b></A>";
! 2579: print ")" if ($paren);
! 2580: }
! 2581:
! 2582: # Returns a Query string with the
! 2583: # specified parameter toggled
! 2584: sub toggleQuery($$) {
! 2585: my ($toggle,$value) = @_;
! 2586: my ($newquery,$var);
! 2587: my (%vars);
! 2588: %vars = %input;
! 2589: if (defined($value)) {
! 2590: $vars{$toggle} = $value;
! 2591: }
! 2592: else {
! 2593: $vars{$toggle} = $vars{$toggle} ? 0 : 1;
! 2594: }
! 2595: # Build a new query of non-default paramenters
! 2596: $newquery = "";
! 2597: foreach $var (@stickyvars) {
! 2598: my ($value) = defined($vars{$var}) ? $vars{$var} : "";
! 2599: my ($default) = defined($DEFAULTVALUE{$var}) ? $DEFAULTVALUE{$var} : "";
! 2600: if ($value ne $default) {
! 2601: $newquery .= "&" if ($newquery ne "");
! 2602: $newquery .= urlencode($var) . "=" . urlencode($value);
! 2603: }
! 2604: }
! 2605: if ($newquery) {
! 2606: return '?' . $newquery;
! 2607: }
! 2608: return "";
! 2609: }
! 2610:
! 2611: sub urlencode {
! 2612: my ($in) = @_;
! 2613: my ($out);
! 2614: ($out = $in) =~ s/([\000-+{-\377])/sprintf("%%%02x", ord($1))/ge;
! 2615: return $out;
! 2616: }
! 2617:
! 2618: sub http_header {
! 2619: my $content_type = shift || "text/html";
! 2620: my $is_mod_perl = defined($ENV{'MOD_PERL'});
! 2621: if (defined($moddate)) {
! 2622: if ($is_mod_perl) {
! 2623: Apache->request->header_out(Last_modified => scalar gmtime($moddate) . " GMT");
! 2624: }
! 2625: else {
! 2626: print "Last-Modified: " . scalar gmtime($moddate) . " GMT\n";
! 2627: }
! 2628: }
! 2629: if ($is_mod_perl) {
! 2630: Apache->request->content_type($content_type);
! 2631: }
! 2632: else {
! 2633: print "Content-type: $content_type\n";
! 2634: }
! 2635: if ($allow_compress && $maycompress) {
! 2636: my $fh = do {local(*FH);};
! 2637: if (defined($GZIPBIN) && open($fh, "|$GZIPBIN -1 -c")) {
! 2638: if ($is_mod_perl) {
! 2639: Apache->request->content_encoding("x-gzip");
! 2640: Apache->request->header_out(Vary => "Accept-Encoding");
! 2641: Apache->request->send_http_header;
! 2642: }
! 2643: else {
! 2644: print "Content-encoding: x-gzip\n";
! 2645: print "Vary: Accept-Encoding\n"; #RFC 2068, 14.43
! 2646: print "\n"; # Close headers
! 2647: }
! 2648: $| = 1; $| = 0; # Flush header output
! 2649: select ($fh);
! 2650: # print "<!-- gzipped -->" if ($content_type eq "text/html");
! 2651: }
! 2652: else {
! 2653: if ($is_mod_perl) {
! 2654: Apache->request->send_http_header;
! 2655: }
! 2656: else {
! 2657: print "\n"; # Close headers
! 2658: }
! 2659: print "<font size=-1>Unable to find gzip binary in the \$PATH to compress output</font><br>";
! 2660: }
! 2661: }
! 2662: else {
! 2663: if ($is_mod_perl) {
! 2664: Apache->request->send_http_header;
! 2665: }
! 2666: else {
! 2667: print "\n"; # Close headers
! 2668: }
! 2669: }
! 2670: }
! 2671:
! 2672: sub html_header($) {
! 2673: my ($title) = @_;
! 2674: my $version = '$Revision: 3.1.1.1 $';
! 2675: http_header();
! 2676: print <<EOH;
! 2677: <!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN"
! 2678: "http://www.w3.org/TR/REC-html40/loose.dtd">
! 2679: <html>
! 2680: <title>$title</title>
! 2681: <!-- hennerik CVSweb $version -->
! 2682: </head>
! 2683: $body_tag
! 2684: $logo <h1 align="center">$title</h1>
! 2685: EOH
! 2686: }
! 2687:
! 2688: sub html_footer {
! 2689: return "<hr noshade><address>$address</address>\n";
! 2690: }
! 2691:
! 2692: sub link_tags
! 2693: {
! 2694: my ($tags) = @_;
! 2695: my ($ret) = "";
! 2696: my ($fileurl,$filename);
! 2697:
! 2698: ($filename = $where) =~ s/^.*\///;
! 2699: $fileurl = urlencode($filename);
! 2700:
! 2701: foreach my $sym (split(", ", $tags)) {
! 2702: $ret .= ",\n" if ($ret ne "");
! 2703: $ret .= "<A HREF=\"$fileurl"
! 2704: . toggleQuery('only_with_tag',$sym) . "\">$sym</A>";
! 2705: }
! 2706: return $ret."\n";
! 2707: }
! 2708:
! 2709: #
! 2710: # See if a module is listed in the config file's @HideModule list.
! 2711: #
! 2712: sub forbidden_module {
! 2713: my($module) = @_;
! 2714:
! 2715: for (my $i=0; $i < @HideModules; $i++) {
! 2716: return 1 if $module eq $HideModules[$i];
! 2717: }
! 2718:
! 2719: return 0;
1.1 jfieber 2720: }
CVSweb