summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/greylist.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/tools/greylist.c b/tools/greylist.c
index 3ba502d..613c1a4 100644
--- a/tools/greylist.c
+++ b/tools/greylist.c
@@ -11,6 +11,7 @@
#include <fstream> /* for ofstream() */
#include <fcntl.h> /* for creat() */
#include <sys/time.h> /* for gettimeofday() */
+#include <sstream>
// requires apt-get install libboost-filesystem-dev:
#include <boost/filesystem.hpp>
@@ -67,6 +68,17 @@ public:
void update(const string msg, const timeval new_mod, const timeval new_ac);
};
+string time_out(const int ttt){
+ int sec(ttt % 60);
+ int min((ttt / 60) % 60);
+ int hr(ttt / 3600);
+ stringstream foo;
+ foo << hr
+ << ":" << setw(2) << setfill('0') << min
+ << ":" << setw(2) << setfill('0') << sec;
+ return foo.str();
+}
+
void scan(const string p){
timeval now;
gettimeofday(&now, NULL);
@@ -88,12 +100,12 @@ void scan(const string p){
}
int mod_age = now.tv_sec - mystat.st_mtime;
int ac_age = now.tv_sec - mystat.st_atime;
- cout << setw(10) << mod_age
- << " " << setw(10) << ac_age;
+ cout << setw(10) << time_out(mod_age)
+ << " " << setw(10) << time_out(ac_age);
if (mod_age < minimum_age) {
cout << " young";
} else if (mod_age == ac_age) {
- cout << " never used";
+ cout << " unused";
}
}
cout << '\n';
@@ -109,8 +121,8 @@ void whatsit::update(const string msg, const timeval new_mod, const timeval new_
cerr << progname << ": "
<< msg << ": " << ipbase;
if (hostname.length()) cerr << " " << hostname;
- cerr << " mod_age: " << mod_age
- << " ac_age: " << ac_age
+ cerr << " mod_age: " << time_out(mod_age)
+ << " ac_age: " << time_out(ac_age)
<< endl;
timeval upd[2] = {
// beware: access illogically comes *before* modification here: