Annotation of cvsweb/cvsweb.cgi, Revision 1.45.2.49
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.49! knu 45: # $kId: cvsweb.cgi,v 1.17 2000/09/03 18:25:47 knu Exp $
! 46: # $FreeBSD: www/en/cgi/cvsweb.cgi,v 1.48 2000/08/25 09:21:00 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.49! 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.49! 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)) {
! 913: 1 while $string =~ s`\b(pr[:#]?\s*(?:#?\d+[,\s]\s*)*#?)(\d+)\b`sprintf('%s<A HREF="%s">%s</A>', $1, sprintf($prcgi, $2), $2)`ie;
! 914: $string =~ s`\b${prcategories}/(\d+)\b`sprintf('<A HREF="%s">%s</A>', sprintf($prcgi, $1), $&)`igeo;
! 915: }
! 916:
! 917: # get manpage specs as link ..
! 918: if (defined($mancgi)) {
! 919: $string =~ s`\b([a-zA-Z]\w+)\(([0-9n])\)\B`sprintf('<A HREF="%s">%s</A>', sprintf($mancgi, $2, $1), $&)`ge;
! 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.47 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 = "";
1192: }
1193: if ($lusr eq $oldLusr) {
1194: $usrprint = " ";
1195: }
1196: else {
1197: $usrprint = $lusr;
1198: }
1199: $oldLrev = $lrev;
1200: $oldLusr = $lusr;
1201: # is there a less timeconsuming way to strip spaces ?
1202: ($lrev = $lrev) =~ s/\s+//g;
1203: my $isCurrentRev = ($rev eq $lrev);
1.45.2.47 knu 1204:
1.45.2.46 knu 1205: print "<b>" if ($isCurrentRev);
1206: printf ("%8s%s%8s %4d:", $revprint, ($isCurrentRev ? "|" : " "), $usrprint, $lineNr);
1207: print spacedHtmlText($line);
1208: print "</b>" if ($isCurrentRev);
1209: }
1210: elsif ($words[0] eq "ok") {
1211: # We could complain about any text received after this, like the
1212: # CVS command line client. But for simplicity, we don't.
1213: }
1214: elsif ($words[0] eq "error") {
1215: fatal ("500 Internal Error", "Error occured during annotate: <b>$_</b>");
1216: }
1217: }
1218: if ($annTable) {
1219: print "</table>";
1220: }
1221: else {
1222: print "</pre>";
1223: }
1224: close ($reader) || warn "cannot close: $!";
1225: wait;
1226: }
1227:
1228: ###############################
1229: # make Checkout
1230: ###############################
1.45.2.47 knu 1231: sub doCheckout($$) {
1.45.2.46 knu 1232: my ($fullname, $rev) = @_;
1233: my ($mimetype,$revopt);
1234: my $fh = do {local(*FH);};
1235:
1.45.2.48 knu 1236: if ($rev eq 'HEAD' || $rev eq '.') {
1237: $rev = undef;
1238: }
1239:
1.45.2.46 knu 1240: # make sure the revisions a wellformed, for security
1241: # reasons ..
1.45.2.48 knu 1242: if (defined($rev) && $rev =~ /[^\w.]/) {
1.45.2.46 knu 1243: &fatal("404 Not Found",
1244: "Malformed query \"$ENV{QUERY_STRING}\"");
1245: }
1246:
1247: # get mimetype
1248: if (defined($input{"content-type"}) && ($input{"content-type"} =~ /\S\/\S/)) {
1249: $mimetype = $input{"content-type"}
1250: }
1251: else {
1252: $mimetype = &getMimeTypeFromSuffix($fullname);
1253: }
1254:
1255: if (defined($rev)) {
1256: $revopt = "-r$rev";
1257: if ($use_moddate) {
1258: readLog($fullname,$rev);
1259: $moddate=$date{$rev};
1260: }
1261: }
1262: else {
1263: $revopt = "-rHEAD";
1264: if ($use_moddate) {
1265: readLog($fullname);
1266: $moddate=$date{$symrev{HEAD}};
1267: }
1268: }
1.45.2.47 knu 1269:
1.45.2.46 knu 1270: ### just for the record:
1271: ### 'cvs co' seems to have a bug regarding single checkout of
1272: ### directories/files having spaces in it;
1273: ### this is an issue that should be resolved on cvs's side
1274: #
1275: # Safely for a child process to read from.
1276: if (! open($fh, "-|")) { # child
1277: open(STDERR, ">&STDOUT"); # Redirect stderr to stdout
1.45.2.48 knu 1278: exec("cvs", "-Rld", $cvsroot, "co", "-p", $revopt, $where);
1.45.2.47 knu 1279: }
1.45.2.46 knu 1280: #===================================================================
1281: #Checking out squid/src/ftp.c
1282: #RCS: /usr/src/CVS/squid/src/ftp.c,v
1283: #VERS: 1.1.1.28.6.2
1284: #***************
1285:
1286: # Parse CVS header
1287: my ($revision, $filename, $cvsheader);
1288: while(<$fh>) {
1289: last if (/^\*\*\*\*/);
1290: $revision = $1 if (/^VERS: (.*)$/);
1291: if (/^Checking out (.*)$/) {
1292: $filename = $1;
1293: $filename =~ s/^\.\/*//;
1294: }
1295: $cvsheader .= $_;
1296: }
1297: if ($filename ne $where) {
1298: &fatal("500 Internal Error",
1299: "Unexpected output from cvs co: $cvsheader"
1300: . "<p><b>Check whether the directory $cvsroot/CVSROOT exists "
1301: . "and the script has write-access to the CVSROOT/history "
1302: . "file if it exists."
1303: . "<br>The script needs to place lock files in the "
1304: . "directory the file is in as well.</b>");
1305: }
1306: $| = 1;
1307:
1308: if ($mimetype eq "text/x-cvsweb-markup") {
1309: &cvswebMarkup($fh,$fullname,$revision);
1310: }
1311: else {
1312: http_header($mimetype);
1313: print <$fh>;
1314: }
1315: close($fh);
1316: }
1317:
1.45.2.47 knu 1318: sub cvswebMarkup($$$) {
1.45.2.46 knu 1319: my ($filehandle,$fullname,$revision) = @_;
1320: my ($pathname, $filename);
1321:
1322: ($pathname = $where) =~ s/(Attic\/)?[^\/]*$//;
1323: ($filename = $where) =~ s/^.*\///;
1324: my ($fileurl) = urlencode($filename);
1325:
1326: http_header();
1327:
1.45.2.47 knu 1328: navigateHeader($scriptwhere, $pathname, $filename, $revision, "view");
1.45.2.46 knu 1329: print "<HR noshade>";
1330: print "<table width=\"100%\"><tr><td bgcolor=\"$markupLogColor\">";
1331: print "File: ", &clickablePath($where, 1);
1332: print " ";
1333: &download_link(urlencode($fileurl), $revision, "(download)");
1334: if (!$defaultTextPlain) {
1335: print " ";
1.45.2.47 knu 1336: &download_link(urlencode($fileurl), $revision, "(as text)",
1.45.2.46 knu 1337: "text/plain");
1338: }
1339: print "<BR>\n";
1340: if ($show_log_in_markup) {
1341: readLog($fullname); #,$revision);
1342: printLog($revision,0);
1343: }
1344: else {
1345: print "Version: <B>$revision</B><BR>\n";
1346: print "Tag: <B>", $input{only_with_tag}, "</b><br>\n" if
1347: $input{only_with_tag};
1348: }
1349: print "</td></tr></table>";
1350: my @content = <$filehandle>;
1351: my $url = download_url($fileurl, $revision, $mimetype);
1352: print "<HR noshade>";
1353: if ($mimetype =~ /^image/) {
1354: print "<IMG SRC=\"$url$barequery\"><BR>";
1355: }
1356: else {
1357: print "<PRE>";
1358: foreach (@content) {
1359: print spacedHtmlText($_);
1.12 fenner 1360: }
1.45.2.46 knu 1361: print "</PRE>";
1362: }
1.12 fenner 1363: }
1364:
1.45.2.46 knu 1365: sub viewable($) {
1366: my ($mimetype) = @_;
1367:
1.45.2.47 knu 1368: $mimetype =~ m%^(text|image)/%;
1.45.2.46 knu 1369: }
1370:
1371: ###############################
1372: # Show Colored Diff
1373: ###############################
1.45.2.47 knu 1374: sub doDiff($$$$$$) {
1.45.2.46 knu 1375: my($fullname, $r1, $tr1, $r2, $tr2, $f) = @_;
1376: my $fh = do {local(*FH);};
1377: my ($rev1, $rev2, $sym1, $sym2, @difftype, $diffname, $f1, $f2);
1.12 fenner 1378:
1379: if ($r1 =~ /([^:]+)(:(.+))?/) {
1380: $rev1 = $1;
1381: $sym1 = $3;
1382: }
1.45.2.46 knu 1383: if ($r1 eq 'text') {
1.12 fenner 1384: $rev1 = $tr1;
1.45.2.46 knu 1385: $sym1 = "";
1.12 fenner 1386: }
1387: if ($r2 =~ /([^:]+)(:(.+))?/) {
1388: $rev2 = $1;
1389: $sym2 = $3;
1390: }
1.45.2.46 knu 1391: if ($r2 eq 'text') {
1.12 fenner 1392: $rev2 = $tr2;
1.45.2.46 knu 1393: $sym2 = "";
1.12 fenner 1394: }
1.45.2.48 knu 1395:
1.45.2.46 knu 1396: # make sure the revisions a wellformed, for security
1397: # reasons ..
1.45.2.48 knu 1398: if ($rev1 =~ /[^\w.]/ || $rev2 =~ /[^\w.]/) {
1.12 fenner 1399: &fatal("404 Not Found",
1.45.2.46 knu 1400: "Malformed query \"$ENV{QUERY_STRING}\"");
1.12 fenner 1401: }
1402: #
1403: # rev1 and rev2 are now both numeric revisions.
1404: # Thus we do a DWIM here and swap them if rev1 is after rev2.
1405: # XXX should we warn about the fact that we do this?
1406: if (&revcmp($rev1,$rev2) > 0) {
1.45.2.46 knu 1407: my ($tmp1, $tmp2) = ($rev1, $sym1);
1.12 fenner 1408: ($rev1, $sym1) = ($rev2, $sym2);
1409: ($rev2, $sym2) = ($tmp1, $tmp2);
1410: }
1.45.2.46 knu 1411: my $human_readable = 0;
1.12 fenner 1412: if ($f eq 'c') {
1.45.2.46 knu 1413: @difftype = qw{-c};
1.12 fenner 1414: $diffname = "Context diff";
1.45.2.46 knu 1415: }
1416: elsif ($f eq 's') {
1417: @difftype = qw{--side-by-side --width=164};
1.12 fenner 1418: $diffname = "Side by Side";
1.45.2.46 knu 1419: }
1420: elsif ($f eq 'H') {
1421: $human_readable = 1;
1422: @difftype = qw{--unified=15};
1423: $diffname = "Long Human readable";
1424: }
1425: elsif ($f eq 'h') {
1426: @difftype =qw{-u};
1427: $human_readable = 1;
1428: $diffname = "Human readable";
1429: }
1430: elsif ($f eq 'u') {
1431: @difftype = qw{-u};
1.12 fenner 1432: $diffname = "Unidiff";
1433: }
1.45.2.46 knu 1434: else {
1435: fatal ("400 Bad arguments", "Diff format $f not understood");
1436: }
1437:
1438: # apply special options
1439: if ($showfunc) {
1.45.2.48 knu 1440: push @difftype, '-p' if $f =~ /^[cHhu]$/;
1.45.2.46 knu 1441:
1442: my($re1, $re2);
1443:
1444: while (($re1, $re2) = each %funcline_regexp) {
1445: if ($fullname =~ /$re1/) {
1446: push @difftype, '-F', '$re2';
1447: last;
1448: }
1449: }
1450: }
1451: if ($human_readable) {
1452: if ($hr_ignwhite) {
1453: push @difftype, '-w';
1454: }
1455: if ($hr_ignkeysubst) {
1456: push @difftype, '-kk';
1457: }
1458: }
1459: if (! open($fh, "-|")) { # child
1.44 knu 1460: open(STDERR, ">&STDOUT"); # Redirect stderr to stdout
1.45.2.46 knu 1461: exec("rcsdiff",@difftype,"-r$rev1","-r$rev2",$fullname);
1462: }
1463: if ($human_readable) {
1464: http_header();
1465: &human_readable_diff($fh, $rev2);
1466: exit;
1467: }
1468: else {
1469: http_header("text/plain");
1.44 knu 1470: }
1.12 fenner 1471: #
1472: #===================================================================
1473: #RCS file: /home/ncvs/src/sys/netinet/tcp_output.c,v
1474: #retrieving revision 1.16
1475: #retrieving revision 1.17
1476: #diff -c -r1.16 -r1.17
1477: #*** /home/ncvs/src/sys/netinet/tcp_output.c 1995/11/03 22:08:08 1.16
1478: #--- /home/ncvs/src/sys/netinet/tcp_output.c 1995/12/05 17:46:35 1.17
1479: #
1480: # Ideas:
1481: # - nuke the stderr output if it's what we expect it to be
1482: # - Add "no differences found" if the diff command supplied no output.
1483: #
1484: #*** src/sys/netinet/tcp_output.c 1995/11/03 22:08:08 1.16
1485: #--- src/sys/netinet/tcp_output.c 1995/12/05 17:46:35 1.17 RELENG_2_1_0
1486: # (bogus example, but...)
1487: #
1.45.2.46 knu 1488: if (grep { $_ eq '-u'} @difftype) {
1.12 fenner 1489: $f1 = '---';
1490: $f2 = '\+\+\+';
1.45.2.46 knu 1491: }
1492: else {
1.12 fenner 1493: $f1 = '\*\*\*';
1494: $f2 = '---';
1495: }
1.45.2.46 knu 1496: while (<$fh>) {
1.12 fenner 1497: if (m|^$f1 $cvsroot|o) {
1498: s|$cvsroot/||o;
1499: if ($sym1) {
1500: chop;
1501: $_ .= " " . $sym1 . "\n";
1502: }
1.45.2.46 knu 1503: }
1504: elsif (m|^$f2 $cvsroot|o) {
1.12 fenner 1505: s|$cvsroot/||o;
1506: if ($sym2) {
1507: chop;
1508: $_ .= " " . $sym2 . "\n";
1509: }
1510: }
1511: print $_;
1512: }
1.45.2.46 knu 1513: close($fh);
1.12 fenner 1514: }
1515:
1.45.2.46 knu 1516: ###############################
1517: # Show Logs ..
1518: ###############################
1.45.2.47 knu 1519: sub getDirLogs($$@) {
1.45.2.46 knu 1520: my ($cvsroot,$dirname,@otherFiles) = @_;
1521: my ($state,$otherFiles,$tag, $file, $date, $branchpoint, $branch, $log);
1522: my ($rev, $revision, $revwanted, $filename, $head, $author);
1523:
1524: $tag = $input{only_with_tag};
1525:
1526: my ($DirName) = "$cvsroot/$where";
1527: my (@files, @filetags);
1528: my $fh = do {local(*FH);};
1529:
1530: push(@files, &safeglob("$DirName/*,v"));
1531: push(@files, &safeglob("$DirName/Attic/*,v")) if (!$input{'hideattic'});
1532: foreach $file (@otherFiles) {
1533: push(@files, "$DirName/$file");
1534: }
1535:
1536: # just execute rlog if there are any files
1.45.2.47 knu 1537: if ($#files < 0) {
1.45.2.46 knu 1538: return;
1539: }
1540:
1541: if ($tag) {
1542: #can't use -r<tag> as - is allowed in tagnames, but misinterpreated by rlog..
1543: if (! open($fh, "-|")) {
1544: open(STDERR, '>/dev/null'); # rlog may complain; ignore.
1545: exec('rlog', @files);
1546: }
1547: }
1548: else {
1549: my $kidpid = open($fh, "-|");
1550: if (! $kidpid) {
1551: open(STDERR, '>/dev/null'); # rlog may complain; ignore.
1552: exec('rlog', '-r', @files);
1553: }
1554: }
1555: $state = "start";
1556: while (<$fh>) {
1557: if ($state eq "start") {
1558: #Next file. Initialize file variables
1559: $rev = undef;
1560: $revwanted = undef;
1561: $branch = undef;
1562: $branchpoint = undef;
1563: $filename = undef;
1564: $log = undef;
1565: $revision = undef;
1566: $branch = undef;
1567: %symrev = ();
1568: @filetags = ();
1569: #jump to head state
1570: $state = "head";
1571: }
1572: print "$state:$_" if ($verbose);
1573: again:
1574: if ($state eq "head") {
1575: #$rcsfile = $1 if (/^RCS file: (.+)$/); #not used (yet)
1576: $filename = $1 if (/^Working file: (.+)$/);
1577: $head = $1 if (/^head: (.+)$/);
1578: $branch = $1 if (/^branch: (.+)$/);
1579: }
1580: if ($state eq "head" && /^symbolic names/) {
1581: $state = "tags";
1.45.2.47 knu 1582: ($branch = $head) =~ s/\.\d+$// if (!defined($branch));
1.45.2.46 knu 1583: $branch =~ s/(\.?)(\d+)$/${1}0.$2/;
1584: $symrev{MAIN} = $branch;
1585: $symrev{HEAD} = $branch;
1586: $alltags{MAIN} = 1;
1587: $alltags{HEAD} = 1;
1588: push (@filetags, "MAIN", "HEAD");
1589: next;
1590: }
1591: if ($state eq "tags" &&
1592: /^\s+(.+):\s+([\d\.]+)\s+$/) {
1593: push (@filetags, $1);
1594: $symrev{$1} = $2;
1595: $alltags{$1} = 1;
1596: next;
1597: }
1598: if ($state eq "tags" && /^\S/) {
1599: if (defined($tag) && (defined($symrev{$tag}) || $tag eq "HEAD")) {
1600: $revwanted = $tag eq "HEAD" ? $symrev{"MAIN"} : $symrev{$tag};
1601: ($branch = $revwanted) =~ s/\b0\.//;
1602: ($branchpoint = $branch) =~ s/\.?\d+$//;
1603: $revwanted = undef if ($revwanted ne $branch);
1604: }
1605: elsif (defined($tag) && $tag ne "HEAD") {
1606: print "Tag not found, skip this file" if ($verbose);
1607: $state = "skip";
1608: next;
1609: }
1610: foreach my $tagfound (@filetags) {
1611: $tags{$tagfound} = 1;
1612: }
1613: $state = "head";
1614: goto again;
1615: }
1616: if ($state eq "head" && /^----------------------------$/) {
1617: $state = "log";
1618: $rev = undef;
1619: $date = undef;
1620: $log = "";
1621: # Try to reconstruct the relative filename if RCS spits out a full path
1622: $filename =~ s%^\Q$DirName\E/%%;
1623: next;
1624: }
1625: if ($state eq "log") {
1626: if (/^----------------------------$/
1627: || /^=============================/) {
1628: # End of a log entry.
1629: my $revbranch;
1630: ($revbranch = $rev) =~ s/\.\d+$//;
1631: print "$filename $rev Wanted: $revwanted "
1632: . "Revbranch: $revbranch Branch: $branch "
1633: . "Branchpoint: $branchpoint\n" if ($verbose);
1634: if (!defined($revwanted) && defined($branch)
1635: && $branch eq $revbranch || !defined($tag)) {
1636: print "File revision $rev found for branch $branch\n"
1637: if ($verbose);
1638: $revwanted = $rev;
1639: }
1640: if (defined($revwanted) ? $rev eq $revwanted :
1641: defined($branchpoint) ? $rev eq $branchpoint :
1642: 0 && ($rev eq $head)) { # Don't think head is needed here..
1643: print "File info $rev found for $filename\n" if ($verbose);
1644: my @finfo = ($rev,$date,$log,$author,$filename);
1645: my ($name);
1646: ($name = $filename) =~ s%/.*%%;
1647: $fileinfo{$name} = [ @finfo ];
1648: $state = "done" if ($rev eq $revwanted);
1649: }
1650: $rev = undef;
1651: $date = undef;
1652: $log = "";
1653: }
1654: elsif (!defined($date) && m|^date:\s+(\d+)/(\d+)/(\d+)\s+(\d+):(\d+):(\d+);|) {
1655: my $yr = $1;
1656: # damn 2-digit year routines :-)
1657: if ($yr > 100) {
1658: $yr -= 1900;
1659: }
1660: $date = &Time::Local::timegm($6,$5,$4,$3,$2 - 1,$yr);
1661: ($author) = /author: ([^;]+)/;
1662: $state = "log";
1663: $log = '';
1664: next;
1665: }
1666: elsif (!defined($rev) && m/^revision (.*)$/) {
1667: $rev = $1;
1668: next;
1669: }
1670: else {
1671: $log = $log . $_;
1672: }
1673: }
1674: if (/^===============/) {
1675: $state = "start";
1676: next;
1677: }
1678: }
1679: if ($. == 0) {
1.45.2.47 knu 1680: fatal("500 Internal Error",
1.45.2.46 knu 1681: "Failed to spawn GNU rlog on <em>'".join(", ", @files)."'</em><p>did you set the <b>\$ENV{PATH}</b> in your configuration file correctly ?");
1682: }
1683: close($fh);
1684: }
1685:
1.45.2.47 knu 1686: sub readLog($;$) {
1.45.2.46 knu 1687: my($fullname,$revision) = @_;
1688: my ($symnames, $head, $rev, $br, $brp, $branch, $branchrev);
1689: my $fh = do {local(*FH);};
1690:
1691: if (defined($revision)) {
1692: $revision = "-r$revision";
1693: }
1694: else {
1695: $revision = "";
1696: }
1697:
1698: undef %symrev;
1699: undef %revsym;
1700: undef @allrevisions;
1701: undef %date;
1702: undef %author;
1703: undef %state;
1704: undef %difflines;
1705: undef %log;
1.12 fenner 1706:
1707: print("Going to rlog '$fullname'\n") if ($verbose);
1.45.2.46 knu 1708: if (! open($fh, "-|")) { # child
1709: if ($revision ne '') {
1710: exec("rlog",$revision,$fullname);
1711: }
1712: else {
1713: exec("rlog",$fullname);
1714: }
1.44 knu 1715: }
1.45.2.46 knu 1716: while (<$fh>) {
1.1 jfieber 1717: print if ($verbose);
1718: if ($symnames) {
1719: if (/^\s+([^:]+):\s+([\d\.]+)/) {
1720: $symrev{$1} = $2;
1.45.2.46 knu 1721: }
1722: else {
1.1 jfieber 1723: $symnames = 0;
1724: }
1.45.2.46 knu 1725: }
1726: elsif (/^head:\s+([\d\.]+)/) {
1727: $head = $1;
1728: }
1729: elsif (/^branch:\s+([\d\.]+)/) {
1730: $curbranch = $1;
1731: }
1732: elsif (/^symbolic names/) {
1.1 jfieber 1733: $symnames = 1;
1.45.2.46 knu 1734: }
1735: elsif (/^-----/) {
1.1 jfieber 1736: last;
1737: }
1738: }
1.45.2.46 knu 1739: ($curbranch = $head) =~ s/\.\d+$// if (!defined($curbranch));
1.7 fenner 1740:
1.1 jfieber 1741: # each log entry is of the form:
1742: # ----------------------------
1743: # revision 3.7.1.1
1744: # date: 1995/11/29 22:15:52; author: fenner; state: Exp; lines: +5 -3
1745: # log info
1746: # ----------------------------
1747: logentry:
1748: while (!/^=========/) {
1.45.2.46 knu 1749: $_ = <$fh>;
1.12 fenner 1750: last logentry if (!defined($_)); # EOF
1.1 jfieber 1751: print "R:", $_ if ($verbose);
1752: if (/^revision ([\d\.]+)/) {
1753: $rev = $1;
1.45.2.46 knu 1754: unshift(@allrevisions,$rev);
1755: }
1756: elsif (/^========/ || /^----------------------------$/) {
1.1 jfieber 1757: next logentry;
1.45.2.46 knu 1758: }
1759: else {
1.12 fenner 1760: # The rlog output is syntactically ambiguous. We must
1761: # have guessed wrong about where the end of the last log
1762: # message was.
1763: # Since this is likely to happen when people put rlog output
1764: # in their commit messages, don't even bother keeping
1765: # these lines since we don't know what revision they go with
1766: # any more.
1767: next logentry;
1768: # &fatal("500 Internal Error","Error parsing RCS output: $_");
1.1 jfieber 1769: }
1.45.2.46 knu 1770: $_ = <$fh>;
1.1 jfieber 1771: print "D:", $_ if ($verbose);
1.45.2.46 knu 1772: 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+-]+))?|) {
1773: my $yr = $1;
1774: # damn 2-digit year routines :-)
1775: if ($yr > 100) {
1776: $yr -= 1900;
1777: }
1778: $date{$rev} = &Time::Local::timegm($6,$5,$4,$3,$2 - 1,$yr);
1.1 jfieber 1779: $author{$rev} = $7;
1.9 fenner 1780: $state{$rev} = $8;
1.45.2.46 knu 1781: $difflines{$rev} = $10;
1782: }
1783: else {
1.1 jfieber 1784: &fatal("500 Internal Error", "Error parsing RCS output: $_");
1785: }
1786: line:
1.45.2.46 knu 1787: while (<$fh>) {
1.1 jfieber 1788: print "L:", $_ if ($verbose);
1789: next line if (/^branches:\s/);
1790: last line if (/^----------------------------$/ || /^=========/);
1791: $log{$rev} .= $_;
1792: }
1793: print "E:", $_ if ($verbose);
1794: }
1.45.2.46 knu 1795: close($fh);
1.1 jfieber 1796: print "Done reading RCS file\n" if ($verbose);
1.45.2.46 knu 1797:
1798: @revorder = reverse sort {revcmp($a,$b)} @allrevisions;
1799: print "Done sorting revisions",join(" ",@revorder),"\n" if ($verbose);
1800:
1.1 jfieber 1801: #
1802: # HEAD is an artificial tag which is simply the highest tag number on the main
1.8 fenner 1803: # branch, unless there is a branch tag in the RCS file in which case it's the
1804: # highest revision on that branch. Find it by looking through @revorder; it
1805: # is the first commit listed on the appropriate branch.
1.45.2.46 knu 1806: # This is not neccesary the same revision as marked as head in the RCS file.
1807: my $headrev = $curbranch || "1";
1808: ($symrev{"MAIN"} = $headrev) =~ s/(\.?)(\d+)$/${1}0.$2/;
1.1 jfieber 1809: revision:
1.45.2.46 knu 1810: foreach $rev (@revorder) {
1811: if ($rev =~ /^(\S*)\.\d+$/ && $headrev eq $1) {
1812: $symrev{"HEAD"} = $rev;
1.1 jfieber 1813: last revision;
1814: }
1815: }
1.45.2.46 knu 1816: ($symrev{"HEAD"} = $headrev) =~ s/\.\d+$//
1817: if (!defined($symrev{"HEAD"}));
1.1 jfieber 1818: print "Done finding HEAD\n" if ($verbose);
1819: #
1820: # Now that we know all of the revision numbers, we can associate
1821: # absolute revision numbers with all of the symbolic names, and
1822: # pass them to the form so that the same association doesn't have
1823: # to be built then.
1824: #
1.45.2.46 knu 1825: undef @branchnames;
1826: undef %branchpoint;
1827: undef $sel;
1828:
1829: foreach (reverse sort keys %symrev) {
1.1 jfieber 1830: $rev = $symrev{$_};
1.45.2.46 knu 1831: if ($rev =~ /^((.*)\.)?\b0\.(\d+)$/) {
1.7 fenner 1832: push(@branchnames, $_);
1.1 jfieber 1833: #
1834: # A revision number of A.B.0.D really translates into
1835: # "the highest current revision on branch A.B.D".
1836: #
1837: # If there is no branch A.B.D, then it translates into
1838: # the head A.B .
1839: #
1.45.2.46 knu 1840: # This reasoning also applies to the main branch A.B,
1841: # with the branch number 0.A, with the exception that
1842: # it has no head to translate to if there is nothing on
1843: # the branch, but I guess this can never happen?
1844: # (the code below gracefully forgets about the branch
1845: # if it should happen)
1846: #
1847: $head = defined($2) ? $2 : "";
1.1 jfieber 1848: $branch = $3;
1.45.2.46 knu 1849: $branchrev = $head . ($head ne "" ? "." : "") . $branch;
1850: my $regex;
1851: ($regex = $branchrev) =~ s/\./\\./g;
1.1 jfieber 1852: $rev = $head;
1853:
1854: revision:
1.45.2.46 knu 1855: foreach my $r (@revorder) {
1856: if ($r =~ /^${regex}\b/) {
1857: $rev = $branchrev;
1.1 jfieber 1858: last revision;
1859: }
1860: }
1.45.2.46 knu 1861: next if ($rev eq "");
1862: if ($rev ne $head && $head ne "") {
1.8 fenner 1863: $branchpoint{$head} .= ", " if ($branchpoint{$head});
1864: $branchpoint{$head} .= $_;
1865: }
1.1 jfieber 1866: }
1.45.2.46 knu 1867: $revsym{$rev} .= ", " if ($revsym{$rev});
1868: $revsym{$rev} .= $_;
1.1 jfieber 1869: $sel .= "<OPTION VALUE=\"${rev}:${_}\">$_\n";
1870: }
1871: print "Done associating revisions with branches\n" if ($verbose);
1.45.2.46 knu 1872:
1873: my ($onlyonbranch, $onlybranchpoint);
1874: if ($onlyonbranch = $input{'only_with_tag'}) {
1875: $onlyonbranch = $symrev{$onlyonbranch};
1876: if ($onlyonbranch =~ s/\b0\.//) {
1877: ($onlybranchpoint = $onlyonbranch) =~ s/\.\d+$//;
1878: }
1879: else {
1880: $onlybranchpoint = $onlyonbranch;
1881: }
1882: if (!defined($onlyonbranch) || $onlybranchpoint eq "") {
1883: fatal("404 Tag not found","Tag $input{'only_with_tag'} not defined");
1884: }
1.8 fenner 1885: }
1.1 jfieber 1886:
1.45.2.46 knu 1887: undef @revisions;
1888:
1889: foreach (@allrevisions) {
1.7 fenner 1890: ($br = $_) =~ s/\.\d+$//;
1.45.2.46 knu 1891: ($brp = $br) =~ s/\.\d+$//;
1.7 fenner 1892: next if ($onlyonbranch && $br ne $onlyonbranch &&
1.45.2.46 knu 1893: $_ ne $onlybranchpoint);
1894: unshift(@revisions,$_);
1895: }
1896:
1897: if ($logsort eq "date") {
1898: # Sort the revisions in commit order an secondary sort on revision
1899: # (secondary sort needed for imported sources, or the first main
1900: # revision gets before the same revision on the 1.1.1 branch)
1901: @revdisplayorder = sort {$date{$b} <=> $date{$a} || -revcmp($a, $b)} @revisions;
1902: }
1903: elsif ($logsort eq "rev") {
1904: # Sort the revisions in revision order, highest first
1905: @revdisplayorder = reverse sort {revcmp($a,$b)} @revisions;
1906: }
1907: else {
1908: # No sorting. Present in the same order as rlog / cvs log
1909: @revdisplayorder = @revisions;
1910: }
1911:
1912: }
1913:
1914: sub printLog($;$) {
1915: my ($link, $br, $brp);
1916: ($_,$link) = @_;
1917: ($br = $_) =~ s/\.\d+$//;
1918: ($brp = $br) =~ s/\.?\d+$//;
1919: my ($isDead, $prev);
1920:
1921: $link = 1 if (!defined($link));
1922: $isDead = ($state{$_} eq "dead");
1923:
1924: if ($link && !$isDead) {
1925: my ($filename);
1926: ($filename = $where) =~ s/^.*\///;
1927: my ($fileurl) = urlencode($filename);
1.4 fenner 1928: print "<a NAME=\"rev$_\"></a>";
1.45.2.46 knu 1929: if (defined($revsym{$_})) {
1930: foreach my $sym (split(", ", $revsym{$_})) {
1931: print "<a NAME=\"$sym\"></a>";
1932: }
1.4 fenner 1933: }
1.45.2.46 knu 1934: if (defined($revsym{$br}) && $revsym{$br} && !defined($nameprinted{$br})) {
1935: foreach my $sym (split(", ", $revsym{$br})) {
1.4 fenner 1936: print "<a NAME=\"$sym\"></a>";
1937: }
1.45.2.46 knu 1938: $nameprinted{$br} = 1;
1.4 fenner 1939: }
1.45.2.46 knu 1940: print "\n Revision ";
1941: &download_link($fileurl, $_, $_,
1942: $defaultViewable ? "text/x-cvsweb-markup" : undef);
1943: if ($defaultViewable) {
1944: print " / ";
1945: &download_link($fileurl, $_, "(download)", $mimetype);
1946: }
1947: if (not $defaultTextPlain) {
1948: print " / ";
1.45.2.47 knu 1949: &download_link($fileurl, $_, "(as text)",
1.45.2.46 knu 1950: "text/plain");
1951: }
1952: if (!$defaultViewable) {
1953: print " / ";
1954: &download_link($fileurl, $_, "(view)", "text/x-cvsweb-markup");
1955: }
1956: if ($allow_annotate) {
1957: print " - <a href=\"" . $scriptname . "/" . urlencode($where) . "?annotate=$_$barequery\">";
1958: print "annotate</a>";
1959: }
1960: # Plus a select link if enabled, and this version isn't selected
1961: if ($allow_version_select) {
1962: if ((!defined($input{"r1"}) || $input{"r1"} ne $_)) {
1963: print " - <A HREF=\"${scriptwhere}?r1=$_$barequery" .
1964: "\">[select for diffs]</A>\n";
1965: }
1966: else {
1967: print " - <b>[selected]</b>";
1968: }
1969: }
1970: }
1971: else {
1972: print "Revision <B>$_</B>";
1973: }
1974: if (/^1\.1\.1\.\d+$/) {
1975: print " <i>(vendor branch)</i>";
1976: }
1977: if (defined @mytz) {
1978: my ($est) = $mytz[(localtime($date{$_}))[8]];
1979: print ", <i>" . scalar localtime($date{$_}) . " $est</i> (";
1980: } else {
1981: print ", <i>" . scalar gmtime($date{$_}) . " UTC</i> (";
1982: }
1983: print readableTime(time() - $date{$_},1) . " ago)";
1984: print " by ";
1985: print "<i>" . $author{$_} . "</i>\n";
1986: print "<BR>Branch: <b>",$link?link_tags($revsym{$br}):$revsym{$br},"</b>\n"
1987: if ($revsym{$br});
1988: print "<BR>CVS Tags: <b>",$link?link_tags($revsym{$_}):$revsym{$_},"</b>"
1989: if ($revsym{$_});
1990: print "<BR>Branch point for: <b>",$link?link_tags($branchpoint{$_}):$branchpoint{$_},"</b>\n"
1991: if ($branchpoint{$_});
1992: # Find the previous revision
1993: my @prevrev = split(/\./, $_);
1994: do {
1995: if (--$prevrev[$#prevrev] <= 0) {
1.1 jfieber 1996: # If it was X.Y.Z.1, just make it X.Y
1.45.2.46 knu 1997: pop(@prevrev);
1998: pop(@prevrev);
1999: }
2000: $prev = join(".", @prevrev);
2001: } until (defined($date{$prev}) || $prev eq "");
2002: if ($prev ne "") {
2003: if ($difflines{$_}) {
2004: print "<BR>Changes since <b>$prev: $difflines{$_} lines</b>";
2005: }
2006: }
2007: if ($isDead) {
2008: print "<BR><B><I>FILE REMOVED</I></B>\n";
2009: }
2010: elsif ($link) {
2011: my %diffrev = ();
2012: $diffrev{$_} = 1;
2013: $diffrev{""} = 1;
2014: print "<BR>Diff";
2015: #
2016: # Offer diff to previous revision
2017: if ($prev) {
2018: $diffrev{$prev} = 1;
2019: print " to previous <A HREF=\"${scriptwhere}.diff?r1=$prev";
2020: print "&r2=$_" . $barequery . "\">$prev</A>\n";
2021: if (!$hr_default) { # offer a human readable version if not default
2022: print "(<A HREF=\"${scriptwhere}.diff?r1=$prev";
2023: print "&r2=$_" . $barequery . "&f=h\">colored</A>)\n";
1.1 jfieber 2024: }
2025: }
1.45.2.46 knu 2026: #
2027: # Plus, if it's on a branch, and it's not a vendor branch,
2028: # offer a diff with the branch point.
2029: if ($revsym{$brp} && !/^1\.1\.1\.\d+$/ && !defined($diffrev{$brp})) {
2030: print " to branchpoint <A HREF=\"${scriptwhere}.diff?r1=$brp";
2031: print "&r2=$_" . $barequery . "\">$brp</A>\n";
2032: if (!$hr_default) { # offer a human readable version if not default
2033: print "(<A HREF=\"${scriptwhere}.diff?r1=$brp";
2034: print "&r2=$_" . $barequery . "&f=h\">colored</A>)\n";
2035: }
2036: }
2037: #
2038: # Plus, if it's on a branch, and it's not a vendor branch,
2039: # offer to diff with the next revision of the higher branch.
2040: # (e.g. change gets committed and then brought
2041: # over to -stable)
2042: if (/^\d+\.\d+\.\d+/ && !/^1\.1\.1\.\d+$/) {
2043: my ($i,$nextmain);
2044: for ($i = 0; $i < $#revorder && $revorder[$i] ne $_; $i++){}
2045: my (@tmp2) = split(/\./, $_);
2046: for ($nextmain = ""; $i > 0; $i--) {
2047: my ($next) = $revorder[$i-1];
2048: my (@tmp1) = split(/\./, $next);
1.1 jfieber 2049: if ($#tmp1 < $#tmp2) {
1.45.2.46 knu 2050: $nextmain = $next;
2051: last;
2052: }
2053: # Only the highest version on a branch should have
2054: # a diff for the "next main".
2055: last if (join(".",@tmp1[0..$#tmp1-1])
2056: eq join(".",@tmp2[0..$#tmp1-1]));
2057: }
2058: if (!defined($diffrev{$nextmain})) {
2059: $diffrev{$nextmain} = 1;
2060: print " next main <A HREF=\"${scriptwhere}.diff?r1=$nextmain";
2061: print "&r2=$_" . $barequery .
2062: "\">$nextmain</A>\n";
2063: if (!$hr_default) { # offer a human readable version if not default
2064: print "(<A HREF=\"${scriptwhere}.diff?r1=$nextmain";
2065: print "&r2=$_" . $barequery .
2066: "&f=h\">colored</A>)\n";
1.1 jfieber 2067: }
2068: }
2069: }
1.45.2.46 knu 2070: # Plus if user has selected only r1, then present a link
2071: # to make a diff to that revision
2072: if (defined($input{"r1"}) && !defined($diffrev{$input{"r1"}})) {
2073: $diffrev{$input{"r1"}} = 1;
2074: print " to selected <A HREF=\"${scriptwhere}.diff?"
2075: . "r1=$input{'r1'}&r2=$_" . $barequery
2076: . "\">$input{'r1'}</A>\n";
2077: if (!$hr_default) { # offer a human readable version if not default
2078: print "(<A HREF=\"${scriptwhere}.diff?r1=$input{'r1'}";
2079: print "&r2=$_" . $barequery .
2080: "&f=h\">colored</A>)\n";
2081:
2082: }
1.9 fenner 2083: }
1.1 jfieber 2084: }
1.45.2.46 knu 2085: print "<PRE>\n";
2086: print &htmlify($log{$_}, 1);
2087: print "</PRE>\n";
2088: }
2089:
1.45.2.47 knu 2090: sub doLog($) {
1.45.2.46 knu 2091: my($fullname) = @_;
2092: my ($diffrev, $upwhere, $filename, $backurl);
1.45.2.47 knu 2093:
1.45.2.46 knu 2094: readLog($fullname);
2095:
2096: html_header("CVS log for $where");
2097: ($upwhere = $where) =~ s|(Attic/)?[^/]+$||;
2098: ($filename = $where) =~ s|^.*/||;
2099: $backurl = $scriptname . "/" . urlencode($upwhere) . $query;
2100: print &link($backicon, "$backurl#$filename"),
2101: " <b>Up to ", &clickablePath($upwhere, 1), "</b><p>\n";
2102: print <<EOF;
2103: <A HREF="#diff">Request diff between arbitrary revisions</A>
2104: <HR NOSHADE>
2105: EOF
2106: if ($curbranch) {
2107: print "Default branch: ", ($revsym{$curbranch} || $curbranch);
2108: }
2109: else {
2110: print "No default branch";
2111: }
2112: print "<BR>\n";
2113: if ($input{only_with_tag}) {
2114: print "Current tag: $input{only_with_tag}<BR>\n";
2115: }
2116:
2117: undef %nameprinted;
2118:
2119: for (my $i = 0; $i <= $#revdisplayorder; $i++) {
2120: print "<HR size=1 NOSHADE>";
2121: printLog($revdisplayorder[$i]);
2122: }
2123:
2124: print "<HR NOSHADE>";
1.1 jfieber 2125: print "<A NAME=diff>\n";
2126: print "This form allows you to request diff's between any two\n";
2127: print "revisions of a file. You may select a symbolic revision\n";
2128: print "name using the selection box or you may type in a numeric\n";
2129: print "name using the type-in text box.\n";
2130: print "</A><P>\n";
1.45.2.46 knu 2131: print "<FORM METHOD=\"GET\" ACTION=\"${scriptwhere}.diff\" NAME=\"diff_select\">\n";
2132: foreach (@stickyvars) {
2133: print "<INPUT TYPE=HIDDEN NAME=\"$_\" VALUE=\"$input{$_}\">\n"
2134: if (defined($input{$_})
2135: && ($input{$_} ne $DEFAULTVALUE{$_} && $input{$_} ne ""));
2136: }
1.1 jfieber 2137: print "Diffs between \n";
2138: print "<SELECT NAME=\"r1\">\n";
2139: print "<OPTION VALUE=\"text\" SELECTED>Use Text Field\n";
2140: print $sel;
2141: print "</SELECT>\n";
1.45.2.46 knu 2142: $diffrev = $revdisplayorder[$#revdisplayorder];
2143: $diffrev = $input{"r1"} if (defined($input{"r1"}));
2144: print "<INPUT TYPE=\"TEXT\" SIZE=\"$inputTextSize\" NAME=\"tr1\" VALUE=\"$diffrev\" onChange='document.diff_select.r1.selectedIndex=0'>\n";
1.1 jfieber 2145: print " and \n";
2146: print "<SELECT NAME=\"r2\">\n";
2147: print "<OPTION VALUE=\"text\" SELECTED>Use Text Field\n";
2148: print $sel;
2149: print "</SELECT>\n";
1.45.2.46 knu 2150: $diffrev = $revdisplayorder[0];
2151: $diffrev = $input{"r2"} if (defined($input{"r2"}));
1.45.2.48 knu 2152: print "<INPUT TYPE=\"TEXT\" SIZE=\"$inputTextSize\" NAME=\"tr2\" VALUE=\"$diffrev\" onChange='document.diff_select.r2.selectedIndex=0'>\n";
1.45.2.46 knu 2153: print "<BR>Type of Diff should be a ";
1.45.2.47 knu 2154: printDiffSelect(0);
1.45.2.46 knu 2155: print "<INPUT TYPE=SUBMIT VALUE=\" Get Diffs \">\n";
1.1 jfieber 2156: print "</FORM>\n";
1.7 fenner 2157: print "<HR noshade>\n";
1.45.2.46 knu 2158: if (@branchnames) {
2159: print "<A name=branch></A>\n";
2160: print "<FORM METHOD=\"GET\" ACTION=\"$scriptwhere\">\n";
2161: foreach (@stickyvars) {
2162: next if ($_ eq "only_with_tag");
2163: next if ($_ eq "logsort");
2164: print "<INPUT TYPE=HIDDEN NAME=\"$_\" VALUE=\"$input{$_}\">\n"
2165: if (defined($input{$_}) && $input{$_} ne $DEFAULTVALUE{$_}
2166: && $input{$_} ne "");
2167: }
2168: print "View only Branch: \n";
2169: print "<SELECT NAME=\"only_with_tag\"";
2170: print " onchange=\"submit()\"" if ($use_java_script);
2171: print ">\n";
2172: print "<OPTION VALUE=\"\"";
2173: print " SELECTED" if (defined($input{"only_with_tag"}) &&
2174: $input{"only_with_tag"} eq "");
2175: print ">Show all branches\n";
2176: foreach (reverse sort @branchnames) {
1.9 fenner 2177: print "<OPTION";
1.45.2.46 knu 2178: print " SELECTED" if (defined($input{"only_with_tag"})
2179: && $input{"only_with_tag"} eq $_);
1.9 fenner 2180: print ">${_}\n";
1.45.2.46 knu 2181: }
2182: print "</SELECT>\n";
2183: print "<INPUT TYPE=SUBMIT VALUE=\" View Branch \">\n";
2184: print "</FORM>\n";
1.7 fenner 2185: }
1.45.2.46 knu 2186: print "<A name=logsort></A>\n";
2187: print "<FORM METHOD=\"GET\" ACTION=\"$scriptwhere\">\n";
2188: foreach (@stickyvars) {
2189: next if ($_ eq "only_with_tag");
2190: next if ($_ eq "logsort");
2191: print "<INPUT TYPE=HIDDEN NAME=\"$_\" VALUE=\"$input{$_}\">\n"
2192: if (defined($input{$_}) && $input{$_} ne $DEFAULTVALUE{$_}
2193: && $input{$_} ne "");
2194: }
2195: print "Sort log by: \n";
2196: print "<SELECT NAME=\"logsort\"";
2197: print " onchange=\"submit()\"" if ($use_java_script);
2198: print ">\n";
2199: print "<OPTION VALUE=cvs",$logsort eq "cvs" ? " SELECTED" : "", ">Not sorted";
2200: print "<OPTION VALUE=date",$logsort eq "date" ? " SELECTED" : "", ">Commit date";
2201: print "<OPTION VALUE=rev",$logsort eq "rev" ? " SELECTED" : "", ">Revision";
1.7 fenner 2202: print "</SELECT>\n";
1.45.2.46 knu 2203: print "<INPUT TYPE=SUBMIT VALUE=\" Sort \">\n";
1.7 fenner 2204: print "</FORM>\n";
1.2 jfieber 2205: print &html_footer;
1.1 jfieber 2206: print "</BODY></HTML>\n";
1.10 wosch 2207: }
2208:
1.45.2.47 knu 2209: sub flush_diff_rows($$$$) {
1.45.2.46 knu 2210: my $j;
2211: my ($leftColRef,$rightColRef,$leftRow,$rightRow) = @_;
2212: if ($state eq "PreChangeRemove") { # we just got remove-lines before
2213: for ($j = 0 ; $j < $leftRow; $j++) {
2214: print "<tr><td bgcolor=\"$diffcolorRemove\">@$leftColRef[$j]</td>";
2215: print "<td bgcolor=\"$diffcolorEmpty\"> </td></tr>\n";
2216: }
2217: }
2218: elsif ($state eq "PreChange") { # state eq "PreChange"
2219: # we got removes with subsequent adds
2220: for ($j = 0; $j < $leftRow || $j < $rightRow ; $j++) { # dump out both cols
2221: print "<tr>";
2222: if ($j < $leftRow) {
2223: print "<td bgcolor=\"$diffcolorChange\">@$leftColRef[$j]</td>";
2224: }
2225: else {
2226: print "<td bgcolor=\"$diffcolorDarkChange\"> </td>";
2227: }
2228: if ($j < $rightRow) {
2229: print "<td bgcolor=\"$diffcolorChange\">@$rightColRef[$j]</td>";
2230: }
2231: else {
2232: print "<td bgcolor=\"$diffcolorDarkChange\"> </td>";
2233: }
2234: print "</tr>\n";
2235: }
2236: }
2237: }
2238:
2239: ##
2240: # Function to generate Human readable diff-files
2241: # human_readable_diff(String revision_to_return_to);
2242: ##
2243: sub human_readable_diff($){
2244: my ($i,$difftxt, $where_nd, $filename, $pathname, $scriptwhere_nd);
2245: my ($fh, $rev) = @_;
2246: my ($date1, $date2, $r1d, $r2d, $r1r, $r2r, $rev1, $rev2, $sym1, $sym2);
2247: my (@rightCol, @leftCol);
2248:
2249: ($where_nd = $where) =~ s/.diff$//;
2250: ($filename = $where_nd) =~ s/^.*\///;
2251: ($pathname = $where_nd) =~ s/(Attic\/)?[^\/]*$//;
2252: ($scriptwhere_nd = $scriptwhere) =~ s/.diff$//;
2253:
1.45.2.47 knu 2254: navigateHeader($scriptwhere_nd, $pathname, $filename, $rev, "diff");
1.45.2.46 knu 2255:
2256: # Read header to pick up read revision and date, if possible
2257: while (<$fh>) {
2258: ($r1d,$r1r) = /\t(.*)\t(.*)$/ if (/^--- /);
2259: ($r2d,$r2r) = /\t(.*)\t(.*)$/ if (/^\+\+\+ /);
2260: last if (/^\+\+\+ /);
2261: }
2262: if (defined($r1r) && $r1r =~ /^(\d+\.)+\d+$/) {
2263: $rev1 = $r1r;
2264: $date1 = $r1d;
2265: }
2266: if (defined($r2r) && $r2r =~ /^(\d+\.)+\d+$/) {
2267: $rev2 = $r2r;
2268: $date2 = $r2d;
2269: }
1.45.2.47 knu 2270:
1.45.2.46 knu 2271: print "<h3 align=center>Diff for /$where_nd between version $rev1 and $rev2</h3>\n";
2272:
2273: print "<table border=0 cellspacing=0 cellpadding=0 width=\"100%\">\n";
2274: print "<tr bgcolor=\"#ffffff\">\n";
2275: print "<th width=\"50%\" valign=TOP>";
2276: print "version $rev1";
2277: print ", $date1" if (defined($date1));
2278: print "<br>Tag: $sym1\n" if ($sym1);
2279: print "</th>\n";
2280: print "<th width=\"50%\" valign=TOP>";
2281: print "version $rev2";
2282: print ", $date2" if (defined($date2));
2283: print "<br>Tag: $sym2\n" if ($sym1);
2284: print "</th>\n";
2285:
2286: my $fs = "<font face=\"$difffontface\" size=\"$difffontsize\">";
2287: my $fe = "</font>";
2288:
2289: my $leftRow = 0;
2290: my $rightRow = 0;
2291: my ($oldline, $newline, $funname, $diffcode, $rest);
2292:
2293: # Process diff text
2294: # The diffrows are could make excellent use of
2295: # cascading style sheets because we've to set the
2296: # font and color for each row. anyone ...?
2297: ####
2298: while (<$fh>) {
2299: $difftxt = $_;
1.45.2.47 knu 2300:
1.45.2.46 knu 2301: if ($difftxt =~ /^@@/) {
2302: ($oldline,$newline,$funname) = $difftxt =~ /@@ \-([0-9]+).*\+([0-9]+).*@@(.*)/;
2303: print "<tr bgcolor=\"$diffcolorHeading\"><td width=\"50%\">";
2304: print "<table width=\"100%\" border=1 cellpadding=5><tr><td><b>Line $oldline</b>";
2305: print " <font size=-1>$funname</font></td></tr></table>";
2306: print "</td><td width=\"50%\">";
2307: print "<table width=\"100%\" border=1 cellpadding=5><tr><td><b>Line $newline</b>";
2308: print " <font size=-1>$funname</font></td></tr></table>";
2309: print "</td>\n";
2310: $state = "dump";
2311: $leftRow = 0;
2312: $rightRow = 0;
2313: }
2314: else {
2315: ($diffcode,$rest) = $difftxt =~ /^([-+ ])(.*)/;
2316: $_ = spacedHtmlText ($rest);
2317:
2318: # Add fontface, size
2319: $_ = "$fs $_$fe";
1.45.2.47 knu 2320:
1.45.2.46 knu 2321: #########
2322: # little state machine to parse unified-diff output (Hen, zeller@think.de)
2323: # in order to get some nice 'ediff'-mode output
2324: # states:
2325: # "dump" - just dump the value
2326: # "PreChangeRemove" - we began with '-' .. so this could be the start of a 'change' area or just remove
2327: # "PreChange" - okey, we got several '-' lines and moved to '+' lines -> this is a change block
2328: ##########
2329:
2330: if ($diffcode eq '+') {
2331: if ($state eq "dump") { # 'change' never begins with '+': just dump out value
2332: print "<tr><td bgcolor=\"$diffcolorEmpty\"> </td><td bgcolor=\"$diffcolorAdd\">$_</td></tr>\n";
2333: }
2334: else { # we got minus before
2335: $state = "PreChange";
2336: $rightCol[$rightRow++] = $_;
2337: }
1.45.2.47 knu 2338: }
1.45.2.46 knu 2339: elsif ($diffcode eq '-') {
2340: $state = "PreChangeRemove";
2341: $leftCol[$leftRow++] = $_;
2342: }
2343: else { # empty diffcode
2344: flush_diff_rows \@leftCol, \@rightCol, $leftRow, $rightRow;
2345: print "<tr><td>$_</td><td>$_</td></tr>\n";
2346: $state = "dump";
2347: $leftRow = 0;
2348: $rightRow = 0;
2349: }
2350: }
2351: }
2352: flush_diff_rows \@leftCol, \@rightCol, $leftRow, $rightRow;
2353:
2354: # state is empty if we didn't have any change
2355: if (!$state) {
2356: print "<tr><td colspan=2> </td></tr>";
2357: print "<tr bgcolor=\"$diffcolorEmpty\" >";
2358: print "<td colspan=2 align=center><b>- No viewable Change -</b></td></tr>";
2359: }
2360: print "</table>";
2361: close($fh);
2362:
2363: print "<br><hr noshade width=\"100%\">\n";
2364:
2365: print "<table border=0>";
2366:
2367: print "<tr><td>";
2368: # print legend
2369: print "<table border=1><tr><td>";
2370: print "Legend:<br><table border=0 cellspacing=0 cellpadding=1>\n";
2371: print "<tr><td align=center bgcolor=\"$diffcolorRemove\">Removed from v.$rev1</td><td bgcolor=\"$diffcolorEmpty\"> </td></tr>";
2372: print "<tr bgcolor=\"$diffcolorChange\"><td align=center colspan=2>changed lines</td></tr>";
2373: print "<tr><td bgcolor=\"$diffcolorEmpty\"> </td><td align=center bgcolor=\"$diffcolorAdd\">Added in v.$rev2</td></tr>";
2374: print "</table></td></tr></table>\n";
2375:
2376: print "<td>";
2377: # Print format selector
2378: print "<FORM METHOD=\"GET\" ACTION=\"${scriptwhere}\">\n";
2379: foreach my $var (keys %input) {
2380: next if ($var eq "f");
2381: next if (defined($DEFAULTVALUE{$var})
2382: && $DEFAULTVALUE{$var} eq $input{$var});
2383: print "<INPUT TYPE=HIDDEN NAME=\"",urlencode($var),"\" VALUE=\"",
2384: urlencode($input{$var}),"\">\n";
2385: }
2386: printDiffSelect($use_java_script);
2387: print "<INPUT TYPE=SUBMIT VALUE=\"Show\">\n";
2388: print "</FORM>\n";
2389: print "</td>";
2390:
2391: print "</tr></table>";
2392: }
2393:
1.45.2.47 knu 2394: sub navigateHeader($$$$$) {
1.45.2.46 knu 2395: my ($swhere,$path,$filename,$rev,$title) = @_;
2396: $swhere = "" if ($swhere eq $scriptwhere);
2397: $swhere = urlencode($filename) if ($swhere eq "");
2398: print "<\!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">";
2399: print "<HTML>\n<HEAD>\n";
1.45.2.49! knu 2400: print '<!-- CVSweb $zRevision: 1.94 $ $kRevision: 1.17 $ -->';
1.45.2.46 knu 2401: print "\n<TITLE>$path$filename - $title - $rev</TITLE></HEAD>\n";
2402: print "<BODY BGCOLOR=\"$backcolor\">\n";
2403: print "<table width=\"100%\" border=0 cellspacing=0 cellpadding=1 bgcolor=\"$navigationHeaderColor\">";
2404: print "<tr valign=bottom><td>";
2405: print "<a href=\"$swhere$query#rev$rev\">$backicon";
2406: print "</a> <b>Return to ", &link("$filename","$swhere$query#rev$rev")," CVS log";
2407: print "</b> $fileicon</td>";
1.45.2.47 knu 2408:
1.45.2.46 knu 2409: print "<td align=right>$diricon <b>Up to ", &clickablePath($path, 1), "</b></td>";
2410: print "</tr></table>";
2411: }
2412:
1.45.2.47 knu 2413: sub plural_write($$) {
1.45.2.46 knu 2414: my ($num,$text) = @_;
2415: if ($num != 1) {
2416: $text = $text . "s";
2417: }
2418: if ($num > 0) {
2419: return $num . " " . $text;
2420: }
2421: else {
2422: return "";
2423: }
2424: }
2425:
2426: ##
2427: # print readable timestamp in terms of
2428: # '..time ago'
2429: # H. Zeller <zeller@think.de>
2430: ##
1.45.2.47 knu 2431: sub readableTime($$) {
1.45.2.46 knu 2432: my ($i, $break, $retval);
2433: my ($secs,$long) = @_;
2434:
2435: # this function works correct for time >= 2 seconds
2436: if ($secs < 2) {
2437: return "very little time";
2438: }
2439:
2440: my %desc = (1 , 'second',
2441: 60, 'minute',
2442: 3600, 'hour',
2443: 86400, 'day',
2444: 604800, 'week',
2445: 2628000, 'month',
2446: 31536000, 'year');
2447: my @breaks = sort {$a <=> $b} keys %desc;
2448: $i = 0;
1.45.2.47 knu 2449: while ($i <= $#breaks && $secs >= 2 * $breaks[$i]) {
1.45.2.46 knu 2450: $i++;
2451: }
2452: $i--;
2453: $break = $breaks[$i];
2454: $retval = plural_write(int ($secs / $break), $desc{$break});
2455:
2456: if ($long == 1 && $i > 0) {
2457: my $rest = $secs % $break;
2458: $i--;
2459: $break = $breaks[$i];
1.45.2.47 knu 2460: my $resttime = plural_write(int ($rest / $break),
1.45.2.46 knu 2461: $desc{$break});
2462: if ($resttime) {
2463: $retval = $retval . ", " . $resttime;
2464: }
2465: }
2466:
2467: return $retval;
2468: }
2469:
2470: ##
2471: # clickablePath(String pathname, boolean last_item_clickable)
2472: #
2473: # returns a html-ified path whereas each directory is a link for
2474: # faster navigation. last_item_clickable controls whether the
2475: # basename (last directory/file) is a link as well
2476: ##
2477: sub clickablePath($$) {
1.45.2.47 knu 2478: my ($pathname,$clickLast) = @_;
1.45.2.46 knu 2479: my $retval = '';
1.45.2.47 knu 2480:
1.45.2.46 knu 2481: if ($pathname eq '/') {
2482: # this should never happen - chooseCVSRoot() is
2483: # intended to do this
2484: $retval = "[$cvstree]";
2485: }
2486: else {
2487: $retval = $retval . " <a href=\"${scriptname}/${query}#dirlist\">[$cvstree]</a>";
2488: my $wherepath = '';
2489: my ($lastslash) = $pathname =~ m|/$|;
2490: foreach (split(/\//, $pathname)) {
2491: $retval = $retval . " / ";
2492: $wherepath = $wherepath . '/' . $_;
2493: my ($last) = "$wherepath/" eq "/$pathname"
2494: || $wherepath eq "/$pathname";
2495: if ($clickLast || !$last) {
2496: $retval = $retval . "<a href=\"${scriptname}"
2497: . urlencode($wherepath)
2498: . (!$last || $lastslash ? '/' : '')
2499: . ${query}
2500: . (!$last || $lastslash ? "#dirlist" : "")
2501: . "\">$_</a>";
2502: }
2503: else { # do not make a link to the current dir
2504: $retval = $retval . $_;
2505: }
2506: }
2507: }
2508: return $retval;
2509: }
2510:
2511: sub chooseCVSRoot() {
2512: my @foo;
2513: foreach (sort keys %CVSROOT) {
2514: if (-d $CVSROOT{$_}) {
2515: push(@foo, $_);
2516: }
2517: }
2518: if (@foo > 1) {
2519: my ($k);
2520: print "<form method=\"GET\" action=\"${scriptwhere}\">\n";
2521: foreach $k (keys %input) {
1.45.2.47 knu 2522: print "<input type=hidden NAME=$k VALUE=$input{$k}>\n"
1.45.2.46 knu 2523: if ($input{$k}) && ($k ne "cvsroot");
2524: }
2525: # Form-Elements look wierd in Netscape if the background
2526: # isn't gray and the form elements are not placed
2527: # within a table ...
2528: print "<table><tr>";
2529: print "<td>CVS Root:</td>";
2530: print "<td>\n<select name=\"cvsroot\"";
2531: print " onchange=\"submit()\"" if ($use_java_script);
2532: print ">\n";
2533: foreach $k (@foo) {
2534: print "<option value=\"$k\"";
2535: print " selected" if ($k eq $cvstree);
2536: print ">" . ($CVSROOTdescr{$k} ? $CVSROOTdescr{$k} :
2537: $k). "</option>\n";
2538: }
2539: print "</select>\n</td>";
2540: print "<td><input type=submit value=\"Go\"></td>";
2541: print "</tr></table></form>";
2542: }
2543: else {
2544: # no choice ..
2545: print "CVS Root: <b>[$cvstree]</b>";
2546: }
2547: }
2548:
2549: sub chooseMirror() {
2550: my ($mirror,$moremirrors);
2551: $moremirrors = 0;
2552: # This code comes from the original BSD-cvsweb
2553: # and may not be useful for your site; If you don't
2554: # set %MIRRORS this won't show up, anyway
2555: #
1.45.2.47 knu 2556: # Should perhaps exlude the current site somehow..
1.45.2.46 knu 2557: if (keys %MIRRORS) {
2558: print "\nThis cvsweb is mirrored in:\n";
2559: foreach $mirror (keys %MIRRORS) {
2560: print ", " if ($moremirrors);
2561: print qq(<a href="$MIRRORS{$mirror}">$mirror</A>\n);
2562: $moremirrors = 1;
2563: }
2564: print "<p>\n";
2565: }
2566: }
2567:
1.45.2.47 knu 2568: sub fileSortCmp() {
1.45.2.46 knu 2569: my ($comp) = 0;
2570: my ($c,$d,$af,$bf);
2571:
2572: ($af = $a) =~ s/,v$//;
2573: ($bf = $b) =~ s/,v$//;
2574: my ($rev1,$date1,$log1,$author1,$filename1) = @{$fileinfo{$af}}
2575: if (defined($fileinfo{$af}));
2576: my ($rev2,$date2,$log2,$author2,$filename2) = @{$fileinfo{$bf}}
2577: if (defined($fileinfo{$bf}));
2578:
2579: if (defined($filename1) && defined($filename2) && $af eq $filename1 && $bf eq $filename2) {
2580: # Two files
2581: $comp = -revcmp($rev1, $rev2) if ($byrev && $rev1 && $rev2);
2582: $comp = ($date2 <=> $date1) if ($bydate && $date1 && $date2);
2583: $comp = ($log1 cmp $log2) if ($bylog && $log1 && $log2);
2584: $comp = ($author1 cmp $author2) if ($byauthor && $author1 && $author2);
2585: }
2586: if ($comp == 0) {
2587: # Directories first, then sorted on name if no other sort critera
2588: # available.
2589: my $ad = ((-d "$fullname/$a")?"D":"F");
2590: my $bd = ((-d "$fullname/$b")?"D":"F");
2591: ($c=$a) =~ s|.*/||;
2592: ($d=$b) =~ s|.*/||;
2593: $comp = ("$ad$c" cmp "$bd$d");
2594: }
2595: return $comp;
2596: }
2597:
2598: # make A url for downloading
1.45.2.47 knu 2599: sub download_url($$;$) {
1.45.2.46 knu 2600: my ($url,$revision,$mimetype) = @_;
2601:
2602: $revision =~ s/\b0\.//;
2603:
2604: if (defined($checkout_magic)
2605: && (!defined($mimetype) || $mimetype ne "text/x-cvsweb-markup")) {
2606: my ($path);
2607: ($path = $where) =~ s|/[^/]*$|/|;
2608: $url = "$scriptname/$checkoutMagic/${path}$url";
2609: }
2610: $url .= "?rev=$revision";
2611: $url .= "&content-type=$mimetype" if (defined($mimetype));
2612:
2613: return $url;
2614: }
2615:
1.45.2.47 knu 2616: # Presents a link to download the
1.45.2.46 knu 2617: # selected revision
1.45.2.47 knu 2618: sub download_link($$$;$) {
1.45.2.46 knu 2619: my ($url,$revision,$textlink,$mimetype) = @_;
2620: my ($fullurl) = download_url($url,$revision,$mimetype);
2621: my ($paren) = $textlink =~ /^\(/;
2622: $textlink =~ s/^\(// if ($paren);
2623: $textlink =~ s/\)$// if ($paren);
2624: print "(" if ($paren);
2625: print "<A HREF=\"$fullurl";
2626: print $barequery;
2627: print "\"";
2628: if ($open_extern_window && (!defined($mimetype) || $mimetype ne "text/x-cvsweb-markup")) {
2629: print " target=\"cvs_checkout\"";
2630: # we should have
2631: # 'if (document.cvswin==null) document.cvswin=window.open(...'
2632: # in order to allow the user to resize the window; otherwise
2633: # the user may resize the window, but on next checkout - zap -
2634: # its original (configured s. cvsweb.conf) size is back again
2635: # .. annoying (if $extern_window_(width|height) is defined)
2636: # but this if (..) solution is far from perfect
2637: # what we need to do as well is
2638: # 1) save cvswin in an invisible frame that always exists
2639: # (document.cvswin will be void on next load)
2640: # 2) on close of the cvs_checkout - window set the cvswin
2641: # variable to 'null' again - so that it will be
2642: # reopenend with the configured size
2643: # anyone a JavaScript programmer ?
2644: # .. so here without if (..):
2645: # currently, the best way is to comment out the size parameters
2646: # ($extern_window...) in cvsweb.conf.
2647: if ($use_java_script) {
2648: print " onClick=\"window.open('$fullurl','cvs_checkout',";
2649: print "'resizeable,scrollbars";
2650: print ",status,toolbar" if (defined($mimetype)
2651: && $mimetype eq "text/html");
2652: print ",width=$extern_window_width" if (defined($extern_window_width));
2653: print ",height=$extern_window_height" if (defined($extern_window_height));
2654: print"');\"";
2655: }
2656: }
2657: print "><b>$textlink</b></A>";
2658: print ")" if ($paren);
2659: }
2660:
2661: # Returns a Query string with the
2662: # specified parameter toggled
2663: sub toggleQuery($$) {
2664: my ($toggle,$value) = @_;
2665: my ($newquery,$var);
2666: my (%vars);
2667: %vars = %input;
2668: if (defined($value)) {
2669: $vars{$toggle} = $value;
2670: }
2671: else {
2672: $vars{$toggle} = $vars{$toggle} ? 0 : 1;
2673: }
2674: # Build a new query of non-default paramenters
2675: $newquery = "";
2676: foreach $var (@stickyvars) {
2677: my ($value) = defined($vars{$var}) ? $vars{$var} : "";
2678: my ($default) = defined($DEFAULTVALUE{$var}) ? $DEFAULTVALUE{$var} : "";
2679: if ($value ne $default) {
2680: $newquery .= "&" if ($newquery ne "");
2681: $newquery .= urlencode($var) . "=" . urlencode($value);
2682: }
2683: }
2684: if ($newquery) {
2685: return '?' . $newquery;
2686: }
2687: return "";
2688: }
2689:
1.45.2.47 knu 2690: sub urlencode($) {
1.45.2.46 knu 2691: my ($in) = @_;
2692: my ($out);
2693: ($out = $in) =~ s/([\000-+{-\377])/sprintf("%%%02x", ord($1))/ge;
2694: return $out;
2695: }
2696:
1.45.2.47 knu 2697: sub http_header(;$) {
1.45.2.46 knu 2698: my $content_type = shift || "text/html";
2699: if (defined($moddate)) {
2700: if ($is_mod_perl) {
2701: Apache->request->header_out(Last_modified => scalar gmtime($moddate) . " GMT");
2702: }
2703: else {
2704: print "Last-Modified: " . scalar gmtime($moddate) . " GMT\r\n";
2705: }
2706: }
2707: if ($is_mod_perl) {
2708: Apache->request->content_type($content_type);
2709: }
2710: else {
2711: print "Content-type: $content_type\r\n";
2712: }
2713: if ($allow_compress && $maycompress) {
2714: my $fh = do {local(*FH);};
2715: if (defined($GZIPBIN) && open($fh, "|$GZIPBIN -1 -c")) {
2716: if ($is_mod_perl) {
2717: Apache->request->content_encoding("x-gzip");
2718: Apache->request->header_out(Vary => "Accept-Encoding");
2719: Apache->request->send_http_header;
2720: }
2721: else {
2722: print "Content-encoding: x-gzip\r\n";
2723: print "Vary: Accept-Encoding\r\n"; #RFC 2068, 14.43
2724: print "\r\n"; # Close headers
2725: }
2726: $| = 1; $| = 0; # Flush header output
2727: select ($fh);
2728: # print "<!-- gzipped -->" if ($content_type eq "text/html");
2729: }
2730: else {
2731: if ($is_mod_perl) {
2732: Apache->request->send_http_header;
2733: }
2734: else {
2735: print "\r\n"; # Close headers
2736: }
2737: print "<font size=-1>Unable to find gzip binary in the \$PATH to compress output</font><br>";
2738: }
2739: }
2740: else {
2741: if ($is_mod_perl) {
2742: Apache->request->send_http_header;
2743: }
2744: else {
2745: print "\r\n"; # Close headers
2746: }
2747: }
2748: }
2749:
2750: sub html_header($) {
2751: my ($title) = @_;
1.45.2.49! knu 2752: my $version = '$zRevision: 1.94 $ $kRevision: 1.17 $'; #'
1.45.2.46 knu 2753: http_header();
2754:
2755: (my $header = &cgi_style::html_header) =~ s/^.*\n\n//; # remove HTTP response header
2756:
2757: print <<EOH;
2758: <!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN"
2759: "http://www.w3.org/TR/REC-html40/loose.dtd">
2760: $header
2761: <!-- CVSweb $version -->
2762: EOH
2763: }
2764:
1.45.2.47 knu 2765: sub html_footer() {
1.45.2.46 knu 2766: return &cgi_style::html_footer;
2767: }
2768:
1.45.2.47 knu 2769: sub link_tags($) {
1.45.2.46 knu 2770: my ($tags) = @_;
2771: my ($ret) = "";
2772: my ($fileurl,$filename);
2773:
2774: ($filename = $where) =~ s/^.*\///;
2775: $fileurl = urlencode($filename);
2776:
2777: foreach my $sym (split(", ", $tags)) {
2778: $ret .= ",\n" if ($ret ne "");
2779: $ret .= "<A HREF=\"$fileurl"
2780: . toggleQuery('only_with_tag',$sym) . "\">$sym</A>";
2781: }
2782: return $ret."\n";
2783: }
2784:
2785: #
2786: # See if a module is listed in the config file's @HideModule list.
2787: #
1.45.2.47 knu 2788: sub forbidden_module($) {
1.45.2.46 knu 2789: my($module) = @_;
1.45.2.47 knu 2790:
1.45.2.46 knu 2791: for (my $i=0; $i < @HideModules; $i++) {
2792: return 1 if $module eq $HideModules[$i];
2793: }
2794:
2795: return 0;
1.1 jfieber 2796: }
CVSweb