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