#!/usr/bin/perl # refactored from www/en/cgi/query-pr-summary.cgi $project = 'FreeBSD'; $mail_prefix = 'freebsd-'; $mail_unass = 'freebsd-bugs'; $ports_unass = 'ports-bugs'; # put these in each of your .cgi files #require '/c/gnats/tools/cgi-lib.pl'; #require '/c/gnats/tools/cgi-style.pl'; #require '/c/gnats/tools/query-pr-common.pl'; #require 'getopts.pl'; %mons = ('Jan', '01', 'Feb', '02', 'Mar', '03', 'Apr', '04', 'May', '05', 'Jun', '06', 'Jul', '07', 'Aug', '08', 'Sep', '09', 'Oct', '10', 'Nov', '11', 'Dec', '12'); $table = "
) { chop; local ($cat, $desc, $responsible, $notify) = split(/:/); push(@categories, $cat); $catdesc{$cat} = $desc; } } # XXX not yet used # XXX statedesc? sub get_states { @states = (); open(Q, 'query-pr --list-states 2>/dev/null |') || die "Cannot get states\n"; while() { chop; local ($state, $type, $desc) = split(/:/); push(@states, $state); $statedesc{$state} = $desc; } } # XXX not yet used # XXX classdesc? sub get_classes { @classes = (); open(Q, 'query-pr --list-classes 2>/dev/null |') || die "Cannot get classes\n"; while() { chop; local ($class, $type, $desc) = split(/:/); push(@classes, $class); $classdesc{$class} = $desc; } } # XXX now returns @prs sub read_gnats { # XXX MCL these next two changes STILL do not do what I want!!! # local($report) = @_[0]; local($report) = @_; $report=~s/"//g; #print "query-pr $report 2>/dev/null |"; open(Q, "query-pr $report 2>/dev/null |") || die "Cannot query the PR's\n"; while() { chop; if(/^>Number:/) { $number = &getline($_); #print $number; } elsif (/Arrival-Date:/) { $date = &getline($_); # strip timezone if any (between HH:MM:SS and YYYY at end of line): $date =~ s/(\d\d:\d\d:\d\d)\D+(\d{4})$/\1 \2/; ($dow,$mon,$day,$time,$year,$xtra) = split(/[ \t]+/, $date); $day = "0$day" if $day =~ /^[0-9]$/; $date = "$year/$mons{$mon}/$day"; } elsif (/>Last-Modified:/) { $lastmod = &getline($_); if ($lastmod =~ /^[ ]*$/) { $lastmod = $date; } else { # strip timezone if any (between HH:MM:SS and YYYY at end of line): $lastmod =~ s/(\d\d:\d\d:\d\d)\D+(\d{4})$/\1 \2/; ($dow,$mon,$day,$time,$year,$xtra) = split(/[ \t]+/, $lastmod); $day = "0$day" if $day =~ /^[0-9]$/; $lastmod = "$year/$mons{$mon}/$day"; } } elsif (/>Category:/) { $cat = &getline($_); } elsif (/>Severity:/) { $sev = &getline($_); } elsif (/>Responsible:/) { $resp = &getline($_); $resp =~ s/@.*//; $resp =~ tr/A-Z/a-z/; $resp = "" if (($resp =~ /$mail_unass/o) or ($resp =~ /$ports_unass/o)); $resp =~ s/^$mail_prefix//; } elsif (/>State:/) { $status = &getline($_); $status =~ s/(.).*/\1/; } elsif (/>Synopsis:/) { $syn = &getline($_); $syn =~ s/[\t]+/ /g; } elsif (/^$/) { $_ = sprintf("%s/%s", $cat, $number); $status{$_} = $status; $date{$_} = $date; $resp{$_} = $resp; $syn{$_} = $syn; $sev{$_} = $sev; $lastmod{$_} = $lastmod; push(@prs,$_); } } close(Q); @prs; } # XXX changed to use address of prs as param 2 # XXX add query_pr_ref as param sub gnats_summary { local($report) = @_[0]; local($htmlmode) = @_[1]; local($prs) = @_[2]; local($counter) = 0; foreach (@{$prs}) { $state = $status{$_}; $date = $date{$_}; $resp = $resp{$_}; $syn = $syn{$_}; $severity = $sev{$_}; ($cat, $number) = m|^([^/]+)/(\d+)$|; next if (($report ne '') && (eval($report) == 0)); if ($htmlmode) { $title = "$_"; $syn = &html_fixline($syn); gnats_summary_line_html($counter, $state, $date, $title, $resp, $syn); } else { $title = substr($cat,0,5) . '/' . $number; gnats_summary_line_text($counter, $state, $date, $title, $resp, $syn); } $counter++; } if ($htmlmode) { print "${table_e}\n" if $counter; } else { print "\n" if $counter; } $counter; } sub gnats_summary_line_html { local($counter) = shift; local($state) = shift; local($date) = shift; local($title) = shift; local($resp) = shift; local($syn) = shift; if ($counter == 0) { print "$table\n" } print " S Submitted Tracker Resp. Description \n"; } sub gnats_summary_line_text { local($counter) = shift; local($state) = shift; local($date) = shift; local($title) = shift; local($resp) = shift; local($syn) = shift; # Print the banner line if this is the first iteration. print "S Tracker Resp. Description\n" . "----------------------------------------" . "----------------------------------------\n" if ($counter == 0); print "$state " . $title . (' ' x (13 - length($title))) . $resp . (' ' x (11 - length($resp))) . substr($syn,0,54) . "\n"; } # XXX not yet used # XXX add self_ref as param sub displayform { print qq` $state $date $title $resp $syn Please select the items you wish to search for. Multiple items are AND'ed together.
`; }