git://git.exim.org
/
exim.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix bad use of library, copying string over itself
[exim.git]
/
src
/
src
/
exiqgrep.src
diff --git
a/src/src/exiqgrep.src
b/src/src/exiqgrep.src
index fd8b5a6c3a8f18f1901aedc6c635397bca9833e4..c4f7c4b58aac30f11964b775b9429c6e7e5aea62 100644
(file)
--- a/
src/src/exiqgrep.src
+++ b/
src/src/exiqgrep.src
@@
-1,5
+1,4
@@
#!PERL_COMMAND
#!PERL_COMMAND
-# $Cambridge: exim/src/src/exiqgrep.src,v 1.1 2004/10/07 10:39:01 ph10 Exp $
# Utility for searching and displaying queue information.
# Written by Matt Hubbard 15 August 2002
# Utility for searching and displaying queue information.
# Written by Matt Hubbard 15 August 2002
@@
-16,10
+15,13
@@
# Routine for extracting the UTC timestamp from message ID
# lifted from eximstat utility
# Routine for extracting the UTC timestamp from message ID
# lifted from eximstat utility
-# Version 1.
1
+# Version 1.
2
use strict;
use strict;
+BEGIN { pop @INC if $INC[-1] eq '.' };
+
use Getopt::Std;
use Getopt::Std;
+use File::Basename;
# Have this variable point to your exim binary.
my $exim = 'BIN_DIRECTORY/exim';
# Have this variable point to your exim binary.
my $exim = 'BIN_DIRECTORY/exim';
@@
-44,8
+46,18
@@
if ($^O eq 'darwin') { # aka MacOS X
$base = 62;
};
$base = 62;
};
-getopts('hf:r:y:o:s:zxlibRc',\%opt);
+if ($ARGV[0] eq '--version') {
+ print basename($0) . ": $0\n",
+ "build: EXIM_RELEASE_VERSIONEXIM_VARIANT_VERSION\n",
+ "perl(runtime): $]\n";
+ exit 0;
+}
+
+getopts('hf:r:y:o:s:C:zxlibRca',\%opt);
+if ($ARGV[0]) { &help; exit;}
if ($opt{h}) { &help; exit;}
if ($opt{h}) { &help; exit;}
+if ($opt{a}) { $eargs = '-bp'; }
+if ($opt{C} && -e $opt{C} && -f $opt{C} && -R $opt{C}) { $eargs .= ' -C '.$opt{C}; }
# Read message queue output into hash
&collect();
# Read message queue output into hash
&collect();
@@
-61,6
+73,7
@@
sub help() {
Exim message queue display utility.
-h This help message.
Exim message queue display utility.
-h This help message.
+ -C Specify which exim.conf to use.
Selection criteria:
-f <regexp> Match sender address sender (field is "< >" wrapped)
Selection criteria:
-f <regexp> Match sender address sender (field is "< >" wrapped)
@@
-79,16
+92,17
@@
Display options:
-i Message IDs only
-b Brief Format
-R Reverse order
-i Message IDs only
-b Brief Format
-R Reverse order
+ -a All recipients (including delivered)
EOF
}
sub collect() {
EOF
}
sub collect() {
- open(QUEUE,"$exim $eargs |") or die("Error open
n
ing pipe: $!\n");
+ open(QUEUE,"$exim $eargs |") or die("Error opening pipe: $!\n");
while(<QUEUE>) {
chomp();
my $line = $_;
#Should be 1st line of record, if not error.
while(<QUEUE>) {
chomp();
my $line = $_;
#Should be 1st line of record, if not error.
- if ($line =~ /^\s*(\w+)\s+((?:\d+(?:\.\d+)?[A-Z])?)\s*(\w{6}-\w{6}-\w{2})\s+(<.*?>)/) {
+ if ($line =~ /^\s*(\w+)\s+((?:\d+(?:\.\d+)?[A-Z]
?
)?)\s*(\w{6}-\w{6}-\w{2})\s+(<.*?>)/) {
my $msg = $3;
$id{$msg}{age} = $1;
$id{$msg}{size} = $2;
my $msg = $3;
$id{$msg}{age} = $1;
$id{$msg}{size} = $2;
@@
-116,13
+130,13
@@
sub selection() {
foreach my $msg (keys(%id)) {
if ($opt{f}) {
# Match sender address
foreach my $msg (keys(%id)) {
if ($opt{f}) {
# Match sender address
- next unless ($id{$msg}{from} =~ /$opt{f}/);
+ next unless ($id{$msg}{from} =~ /$opt{f}/
i
);
}
if ($opt{r}) {
# Match any recipient address
my $match = 0;
foreach my $rcpt (@{$id{$msg}{rcpt}}) {
}
if ($opt{r}) {
# Match any recipient address
my $match = 0;
foreach my $rcpt (@{$id{$msg}{rcpt}}) {
- $match++ if ($rcpt =~ /$opt{r}/);
+ $match++ if ($rcpt =~ /$opt{r}/
i
);
}
next unless ($match);
}
}
next unless ($match);
}