+++ /dev/null
---- t-prot 2002-03-25 02:15:50.000000000 +0100
-+++ t-prot-d 2002-03-28 16:27:02.000000000 +0100
-@@ -9,12 +9,13 @@
- $EX_OK $EX_USAGE $EX_DATAERR $EX_UNAVAILABLE $EX_BOUNCE
- $ad $ads $boun $cr $diff $elli $footers $hdrs $indent $lsig $maxsig
- $mda $ml $ms $mua $ofile $sendmail $sig $sysl $trad $trsp
-+ $dc $debugpath
- );
-
-
- # Version info
- $VER = '0.54';
--$REV = '';
-+$REV = '-debug';
- $REL = q$Revision: 1.51 $; chop($REL);
- # From <sysexits.h>
- # (you might have to adjust those if not using GNU libc)
-@@ -29,6 +30,10 @@
- $sendmail = '/usr/sbin/sendmail -oi'; # MTA expecting mail on STDIN
- $boun = "Blocked by $0: This user does not accept TOFUed email. Please see <http://learn.to/edit_messages/> and <http://www.escape.de/users/tolot/mutt/> for more info. Have a nice day!\n";
- $ofile = '-'; # use STDOUT if nothing is specified
-+$dc = 0; # debug dump counter
-+$debugpath = '/tmp';
-+ # this should better be changed by command line for
-+ # confidential messages
- # end of user adjusted vals
-
-
-@@ -39,6 +44,7 @@
- -A=DIRECTORY ad footer directory, treat ad footers as signature
- -c merge multiple blank lines
- -d, --debug print notice to syslog when bouncing; requires -p
-+ --debugpath=DIR where to dump debug info
- --diff tolerate diffs appended *after* the signature
- -e force ellipsis for excessive punctuation
- -h, --help show this short help and exit
-@@ -64,9 +70,30 @@
- # version(): print version info and exit with appropriate exit code
- sub version {
- print "$0 v$VER$REV ($REL), Jochen Striepe <t-prot\@tolot.escape.de>
-+This is a debugging version. DO NOT INSTALL THIS VERSION FOR DAILY USE!
- Get the latest version at <http://www.escape.de/users/tolot/mutt/>\n";
- exit($EX_OK);
- }
-+
-+# write useful debugging output
-+# usage: debug_dump('/tmp/foo', $foo, $bar, @klotz);
-+sub debug_dump {
-+ if (scalar(@_)<2) { die "bad parameters"; }
-+ my $f = shift;
-+ if (-l $f) { die "We won't write to $f for security reasons"; }
-+
-+ open(DBG, ">$f") || die "Could not open $f: $!";
-+ my $foo;
-+ while (@_) {
-+ $foo = shift;
-+ chomp($foo);
-+ $^W = 0;
-+ print DBG "$foo\n";
-+ $^W = 1;
-+ }
-+ close DBG;
-+}
-+
-
- # remove_footers(): remove any trailing appearance of footers contained
- # in the given directory.
-@@ -139,6 +166,7 @@
- for ($x=0; $x<$#$lines; $x++) { if (@$lines[$x] =~ /^$/) { last; }; }
- @hdr = @$lines[0..$x];
- splice(@$lines, 0, $x+1);
-+ debug_dump($debugpath.'_'.$$.'_'.$dc++, @$lines);
-
- # See if we have a multipart content type. If yes, see if it is already
- # ripped (e.g. by mutt(1)), otherwise only leave the first part if it
-@@ -240,6 +268,7 @@
- last;
- }
- }
-+ debug_dump($debugpath.'_'.$$.'_'.$dc++, @$lines);
-
- # Pipe message/rfc822 parts to another instance of process_msg()
- # for further processing.
-@@ -267,12 +296,15 @@
- }
- }
- }
-+ debug_dump($debugpath.'_'.$$.'_'.$dc++, @$lines);
-
- # Remove ML footers:
- remove_footers($lines, \@ftr, $footers, undef);
-+ debug_dump($debugpath.'_'.$$.'_'.$dc++, @$lines);
-
- # Remove ad footers:
- remove_footers($lines, \@ads, $ads, undef);
-+ debug_dump($debugpath.'_'.$$.'_'.$dc++, @$lines);
-
- # Remove signature:
- if (scalar(@$lines)) {
-@@ -307,6 +339,7 @@
- }
- }
- }
-+ debug_dump($debugpath.'_'.$$.'_'.$dc++, @$lines);
-
- # Now care about TOFU.
- # One common mispractice is M$ style TOFU:
-@@ -331,6 +364,7 @@
- $j = scalar(@$lines)-$x;
- splice(@$lines, $x);
- }
-+ debug_dump($debugpath.'_'.$$.'_'.$dc++, @$lines);
-
- # Nothing? Then try traditional TOFU:
- if ($trad && (!$j) && !$vrb[$#$lines]) {
-@@ -345,6 +379,7 @@
- pop(@$lines);
- }
- }
-+ debug_dump($debugpath.'_'.$$.'_'.$dc++, @$lines);
-
- # OK, if we found TOFU, we will leave a message that we were here...
- if ($j) {
-@@ -368,6 +403,7 @@
-
- push(@$lines, "[---=| TOFU protection by $0: $j lines snipped |=---]\n");
- }
-+ debug_dump($debugpath.'_'.$$.'_'.$dc++, @$lines);
-
-
- # Care for trailing whitespaces:
-@@ -376,6 +412,7 @@
- if (!$vrb[$x]) { $$lines[$x] =~ s/[\ \t]+$//; }
- }
- }
-+ debug_dump($debugpath.'_'.$$.'_'.$dc++, @$lines);
-
- # Care for punctuation abuse:
- if ($elli) {
-@@ -383,6 +420,7 @@
- if (!$vrb[$x]) { $$lines[$x] =~ s/([.?!])(\1{2})\1+/$1 . $2/eg; }
- }
- }
-+ debug_dump($debugpath.'_'.$$.'_'.$dc++, @$lines);
-
- # (Nearly) at last care for multiple blank lines. (Do not do this
- # earlier -- the way it is done right now would screw up the verbatim
-@@ -396,6 +434,7 @@
- else { $t = 0; }
- }
- }
-+ debug_dump($debugpath.'_'.$$.'_'.$dc++, @$lines);
-
- # Everything changing the body is done now. Time to fix the line count
- # header so naive clients do not get confused. Just to be sure, append
-@@ -428,12 +467,13 @@
- # get command line params:
- $0 =~ s!^.*/!!;
- Getopt::Mixed::init('a A=s c d e h i=s L=s l m M=s o=s P=s p=s r S:i'.
-- ' s t v w debug>d diff help>h mua>M version>v');
-+ ' s t v w debug>d debugpath diff help>h mua>M version>v');
- while (my ($opt, $val, $pretty) = nextOption()) {
- if ($opt eq 'a') { $ad = 1; }
- elsif ($opt eq 'A') { $ads = $val; }
- elsif ($opt eq 'c') { $cr = 1; }
- elsif ($opt eq 'd') { $sysl = 1; }
-+ elsif ($opt eq 'debugpath') { $debugpath = $val; }
- elsif ($opt eq 'diff') { $diff = 1; }
- elsif ($opt eq 'e') { $elli = 1; }
- elsif ($opt eq 'i') { $ifile = $val; }
-@@ -454,17 +494,26 @@
- }
- Getopt::Mixed::cleanup();
- if (($ml && $footers eq '')||($ad && $ads eq '')) { help(); }
--
-+$debugpath .= '/t-prot-d';
-
- # Read message:
- open(IN, $ifile) || die "Could not open $ifile: $!";
- my @message = <IN>;
- close IN;
-+debug_dump($debugpath.'_'.$$.'_'.$dc++,
-+ $VER.$REV, $REL,
-+ "ad=$ad", "ads=$ads", "cr=$cr", "sysl=$sysl", "elli=$elli", "ml=$ml",
-+ "ms=$ms", "mda=$mda", "mua=$mua", "hdrs=$hdrs", "lsig=$lsig", "sig=$sig",
-+ "trad=$trad", "trsp=$trsp", "footers=$footers", "ifile=$ifile",
-+ "ofile=$ofile", "maxsig=$maxsig", "indent=$indent", "sendmail=$sendmail",
-+ "boun=$boun");
-+debug_dump($debugpath.'_'.$$.'_'.$dc++, @message);
-
- # this should be self-explanatory:
- process_msg(\@message);
-
- # Finally, print clean lines:
- write_msg(($mda?"|$sendmail $mda":">$ofile"), \@message);
-+debug_dump($debugpath.'_'.$$.'_'.$dc++, @message);
-
- # eof