From 67eb4c6c804c728db329a7f4a77d5a3cbd1b993c Mon Sep 17 00:00:00 2001 From: John Denker Date: Sun, 29 Jul 2012 21:55:41 -0700 Subject: get40 seems to be working --- tools/libltgrey.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'tools/libltgrey.c') diff --git a/tools/libltgrey.c b/tools/libltgrey.c index 1bf7e9f..38657e3 100644 --- a/tools/libltgrey.c +++ b/tools/libltgrey.c @@ -76,10 +76,12 @@ void exeunt(const int sts){ // constructor whatsit::whatsit(const std::string name, const std::string _parent_dir) : parent_dir(_parent_dir), progname(name), mypid(getpid()), - mod_age(0), ac_age(0), verbosity(0) { - gettimeofday(&now, NULL); +// expand the codes to make some names: +# define foo(name) decode_40[name] = #name; + state_40_macro +# undef foo } void whatsit::dump(const string var){ @@ -399,3 +401,24 @@ int whatsit::check_dns_sub(const char* ipvar, const char* namevar, done: return 0; } + +state_40 whatsit::get40(const string mid){ + string fname = parent_dir + "/quarante/mid_" + mid; + cerr << ".... " << fname << endl; + struct stat mid_stat; + int rslt = stat(fname.c_str(), &mid_stat); + if (rslt != 0) { + if (errno == ENOENT) return unseen; + cerr << progid << " stat: unexpected failure for '" + << fname << "' : "; + perror(0); + return fail; + } + timeval now; + gettimeofday(&now, NULL); + int mod_age = now.tv_sec - mid_stat.st_mtime; +// int ac_age = now.tv_sec - mid_stat.st_atime; + if (mod_age < minimum_age) return young; + if (mod_age < probation) return ripe; + return spoiled; +} -- cgit v1.2.3