summaryrefslogtreecommitdiff
path: root/tools/greylist.c
diff options
context:
space:
mode:
authorJohn Denker <jsd@av8n.com>2012-07-20 17:09:44 (GMT)
committerJohn Denker <jsd@av8n.com>2012-07-20 17:12:28 (GMT)
commitefd833cb48f0181c20d9c85466126540fa46c859 (patch)
treefbf4c302b2907211ce40ec76a8bbd51e53a6fe85 /tools/greylist.c
parent84867328ae43be14475b4fec15c54865e10e5cc7 (diff)
format stuff in columns
Diffstat (limited to 'tools/greylist.c')
-rw-r--r--tools/greylist.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/tools/greylist.c b/tools/greylist.c
index 910b40c..1745b32 100644
--- a/tools/greylist.c
+++ b/tools/greylist.c
@@ -111,7 +111,7 @@ string time_out(const int ttt){
return foo.str();
}
-void scan(const string p){
+void scan(const string p, const int copies=1){
timeval now;
gettimeofday(&now, NULL);
using namespace boost::filesystem;
@@ -119,7 +119,8 @@ void scan(const string p){
if (is_directory(p)) {
for (directory_iterator itr(p); itr!=directory_iterator(); ++itr) {
string basename = itr->path().filename();
- cout << setw(20) << basename << ' '; // display filename only
+ for (int ii = 0; ii < copies; ii++)
+ cout << setw(20) << left << basename << ' '; // display filename only
if (is_regular_file(itr->status())) {
// cout << " [" << file_size(itr->path()) << ']';
struct stat mystat;
@@ -177,17 +178,23 @@ int main(int _argc, char** _argv){
char** argv(_argv);
const string dirname("/var/qmail/greylist");
whatsit foo(argv[0], dirname); argc--; argv++;
+ int scanmode(0);
+ int copies(1);
while (argc > 0) {
string arg = argv[0]; argc--; argv++;
if (arg == "-scan") {
- scan(dirname);
- return 0;
- }
- else {
+ scanmode++;
+ } else if (arg == "-copy") {
+ copies++;
+ } else {
cerr << "Unrecognized arg: " << arg << endl;
exeunt(sa_syserr);
}
}
+ if (scanmode) {
+ scan(dirname, copies);
+ return 0;
+ }
return foo.doit();
}