=head1 SYNOPSIS
-B<minc> [-B<dfhnps>]
+B<minc> [-B<dmnp>]
=head1 DESCRIPTION
use Errno;
use Fcntl qw(O_WRONLY O_EXCL O_CREAT);
use FileHandle;
-use File::Basename;
use File::stat;
-use Getopt::Std;
+use Getopt::Std; $Getopt::Std::STANDARD_HELP_VERSION = 1;
use Log::Dispatch;
use Log::Dispatch::File;
use POSIX qw(strftime WEXITSTATUS WIFEXITED);
+our $VERSION = 1;
+
# If a filter set's header is $MAGIC_TO_TOKEN, that set is compared
# against headers matching this regex (taken from procmail).
my $MAGIC_TO_REGEX = '^((Original-)?(Resent-)?(To|Cc|Bcc)|(X-Envelope |Apparently(-Resent)?)-To)';
Dump (using Data::Dumper) the FILTERS list and exit. This is useful
for testing the syntax of .mincfilter.
-=item B<-h>
+=item B<--help>
Show help.
+=item B<-m> I<MAX>
+
+Stop processing after I<MAX> messages.
+
=item B<-n>
Dry run; do not actually incorporate the mail, but log and report to
=cut
my $dumpfilters = 0;
+my $maxmsgs;
our $run = 1;
my $printfilenames = 0;
-our $opt_d;
-our $opt_h;
-our $opt_n;
-our $opt_p;
+my %opts;
-if (not getopts('dhnp')) {
+if (not getopts('dm:np', \%opts)) {
exit(2);
}
-if ($opt_d) {
+if ($opts{'d'}) {
$dumpfilters = 1;
-} elsif ($opt_h) {
- print("Sorry bub, no help.\n");
- exit;
-} elsif ($opt_n) {
+} elsif ($opts{'n'}) {
$run = 0;
}
-if ($opt_p) {
+if (defined($opts{'m'})) {
+ $maxmsgs = $opts{'m'};
+}
+
+if ($opts{'p'}) {
$printfilenames = 1;
}
sub filter_mail {
my @msglist = @_;
my $msgcount = scalar(@msglist);
+ my $msgcountlen = length($msgcount);
my @baton;
my $msg;
my $mhfolder;
@baton = spam_start_hook();
-
STDOUT->autoflush(1);
print("$msgcount messages...");
foreach $msg (@msglist) {
print("\r");
if (not $FOLDERS{$mhfolder}) {
- print(' ' x length($msgcount));
+ print(' ' x $msgcountlen);
print(" \r+$mhfolder\n");
$FOLDERS{$mhfolder} = 1;
}
printf('%6d SPAM %6d saved %6d/%1d',
$spam, $saved, $spam + $saved, $msgcount);
+
+ defined($maxmsgs) and ($spam + $saved < $maxmsgs or last);
}
print("\n");
Design by Eric Gillespie and Doug Porter <dsp@waterspout.com>.
+This program is free software; you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
=cut
# Local variables: