aboutsummaryrefslogtreecommitdiffstats
path: root/rspamc.pl.in
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2010-07-02 18:28:10 +0400
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2010-07-02 18:28:10 +0400
commit10a3c7a278b569bc978614f3b6e78d29f10a87e0 (patch)
treecdf224a34daa92921117b9dd5d1f98e2ead3e474 /rspamc.pl.in
parent9ac84380ce6d4ceb40bc0f4ca10c8c2ce8818790 (diff)
downloadrspamd-10a3c7a278b569bc978614f3b6e78d29f10a87e0.tar.gz
rspamd-10a3c7a278b569bc978614f3b6e78d29f10a87e0.zip
* Take callback argument in Mail::Rspamd::Client for processing files and directories
* Print results if rspamc is called for a directory
Diffstat (limited to 'rspamc.pl.in')
-rwxr-xr-xrspamc.pl.in31
1 files changed, 18 insertions, 13 deletions
diff --git a/rspamc.pl.in b/rspamc.pl.in
index 077832438..a71e061f1 100755
--- a/rspamc.pl.in
+++ b/rspamc.pl.in
@@ -10,6 +10,7 @@
use Socket qw(:DEFAULT :crlf);
use Term::Cap;
use Mail::Rspamd::Client;
+use Data::Dumper;
my %cfg = (
'conf_file' => '@CMAKE_INSTALL_PREFIX@/etc/rspamd.conf',
@@ -186,6 +187,22 @@ sub print_rspamc_result {
}
}
+sub print_item_result {
+ my ($file, $res) = @_;
+ $terminal->Tputs( 'md', 1, *STDOUT );
+ print "Results for item $file:\n\n";
+ $terminal->Tputs( 'me', 1, *STDOUT );
+
+ while (my ($host, $result) = each (%{ $res })) {
+ if ($cfg{control}) {
+ print_control_result ($host, $result);
+ }
+ else {
+ print_rspamc_result ($host, $result);
+ }
+ }
+
+}
############################# Main part ###########################################
my %args;
@@ -330,17 +347,5 @@ if (!defined ($path[0]) || ! $cfg{'require_input'}) {
}
}
else {
- my $res = $rspamd->process_path (@path);
-
- while (my ($item, $result) = each (%{ $res })) {
- print "Results for item $item:\n";
- while (my ($host, $r) = each (%{ $result })) {
- if ($cfg{control}) {
- print_control_result ($host, $r);
- }
- else {
- print_rspamc_result ($host, $r);
- }
- }
- }
+ $rspamd->process_path (\&print_item_result, @path);
}