summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfukachan <fukachan>2001-02-06 15:55:50 +0000
committerfukachan <fukachan>2001-02-06 15:55:50 +0000
commitae08b9f68f490c046a71c3c4fed61c5149738e85 (patch)
tree7f0806984d390da5a196b870ea83026492288d44
parent6a23ba3cb8b10f54cd81a866e3c3ab1c9e1f6d9b (diff)
downloadfml8-ae08b9f68f490c046a71c3c4fed61c5149738e85.tar.gz
fml8-ae08b9f68f490c046a71c3c4fed61c5149738e85.tar.bz2
fml8-ae08b9f68f490c046a71c3c4fed61c5149738e85.zip
libexec/fmlformat output formatter
-rwxr-xr-xregress/simulation/ticket/format96
-rwxr-xr-xregress/simulation/ticket/list_up.sh4
2 files changed, 99 insertions, 1 deletions
diff --git a/regress/simulation/ticket/format b/regress/simulation/ticket/format
new file mode 100755
index 00000000..28028900
--- /dev/null
+++ b/regress/simulation/ticket/format
@@ -0,0 +1,96 @@
+#!/usr/local/bin/perl
+#
+# $Id$
+#
+
+use strict;
+use Carp;
+use vars qw(%article %options);
+use Getopt::Long;
+use lib qw(./fml/lib ./cpan/lib);
+use Jcode;
+use MIME::Base64;
+
+GetOptions(\%options, qw(debug! -D=s));
+
+my $ml_home_dir = $options{ D } || croak("-D directory");
+
+while (<>) {
+ print ;
+ my ($date, $status, $ticket_id, @articles) = split;
+ $article{ $ticket_id } = $articles[0];
+}
+
+if (%article) {
+ print "\n";
+ ShowSummary( \%article );
+}
+
+exit 0;
+
+sub ShowSummary
+{
+ my ($article) = @_;
+ my ($k, $v);
+ my $f;
+
+ while (($k, $v) = each %$article) {
+ $f = "$ml_home_dir/spool/$v";
+ printf "\n%-10s %s\n", $k;
+ print _summary($f);
+ }
+}
+
+
+sub _summary
+{
+ my ($f) = @_;
+ use FileHandle;
+
+ my $buf;
+ my $subject;
+ my $padding = ' > ';
+ my $line = 5;
+ my $fh = new FileHandle $f;
+ my $zform_is_found = 0;
+ if (defined $fh) {
+ while (<$fh>) {
+ if (1 ../^$/) {
+ if (/^(Subject:.*)=\?ISO\S+B\?(\S+)=\?=/) {
+ my ($x, $y) = ($1, $2);
+ $y = decode_base64($y);
+ $buf .= $padding;
+ $buf .= $x. Jcode::convert(\$y, 'euc')."\n";
+ $buf .= $padding."\n";
+ }
+ elsif (/^(Subject:.*)/) {
+ $buf .= $padding. $_;
+ $buf .= $padding."\n";
+ }
+ next;
+ }
+
+ # looks zform ?
+ if (/^DTD:/) {
+ $zform_is_found = 1;
+ next;
+ }
+
+ # nuke useless lines
+ next if /^\s*$/;
+ next if /^\>/;
+ next if /^\-/;
+ next if /^[-\w]+:/ && (! $zform_is_found);
+
+ # pick up effetive the first $line lines
+ if ($line--> 0) {
+ $buf .= $padding. $_;
+ }
+ else {
+ last;
+ }
+ }
+ }
+
+ $buf;
+}
diff --git a/regress/simulation/ticket/list_up.sh b/regress/simulation/ticket/list_up.sh
index 21baee0d..156bb7b4 100755
--- a/regress/simulation/ticket/list_up.sh
+++ b/regress/simulation/ticket/list_up.sh
@@ -11,7 +11,9 @@ exec /usr/local/libexec/fml/fmlticket \
--params pwd=$PWD \
-c $pwd/main.cf \
-R open \
- list /var/spool/ml/elena |sort +2
+ list /var/spool/ml/elena |sort +2|\
+ perl regress/simulation/ticket/format -D /var/spool/ml/elena
+