yangtse: curl-www/auto log.cgi,1.28,1.29 logdnld.cgi,NONE,1.1

[email protected]
Newsgroups gmane.comp.web.curl.www.cvs
Message-ID <[email protected]>
Update of /cvsroot/curl/curl-www/auto
In directory labb:/tmp/cvs-serv10459/auto

Modified Files:
	log.cgi 
Added Files:
	logdnld.cgi 
Log Message:
Add "download build log" link to download a single build log in raw format

Index: log.cgi
===================================================================
RCS file: /cvsroot/curl/curl-www/auto/log.cgi,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- log.cgi	13 Mar 2007 13:40:16 -0000	1.28
+++ log.cgi	14 Mar 2007 19:30:48 -0000	1.29
@@ -110,6 +110,10 @@
     #
     print @out;
     #
+    print "<div><br>\n";
+    print "<a href=\"logdnld.cgi/build-$id.log\">Download build log</a>\n";
+    print "</div><br>\n";
+    #
 }
 else {
     print "File not found!";

--- NEW FILE: logdnld.cgi ---
#!/usr/bin/perl

# $Id: logdnld.cgi,v 1.1 2007-03-14 19:30:48 yangtse Exp $

use strict;

require "CGI.pm";

my $req = new CGI;

my $fname = $req->path_info();

# Strip invalid characters from single build log filename
$fname =~ s/[^-0-9_a-zA-Z\.]//g;

# Validate single build log filename format
exit(0) unless ($fname =~ /^build-(\d\d\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)-(\d+)\.log$/);

my $build = "inbox/$fname";

# Verify file exists
exit(0) unless (-f $build);

if(open(my $logfile, "<$build")) {
    #
    my $buffer;
    my $nbytes = -s $build;
    #
    binmode $logfile;
    binmode STDOUT;
    #
    print "Content-Type: application/octet-stream\n";
    print "Content-Disposition: attachment; filename=$fname\n";
    print "Content-Length: $nbytes\n\n";
    #
    while(read($logfile, $buffer, 4096)) {
        print $buffer;
    }
    #
    print "\n"; # extra LF
    #
    close($logfile);
}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.