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