summaryrefslogtreecommitdiff
path: root/tools/libltgrey.c
diff options
context:
space:
mode:
authorJohn Denker <jsd@av8n.com>2012-07-30 04:55:41 (GMT)
committerJohn Denker <jsd@av8n.com>2012-07-30 04:55:41 (GMT)
commit67eb4c6c804c728db329a7f4a77d5a3cbd1b993c (patch)
tree1d28e818ca5ae77ab586267b2e90f8b74fb398c0 /tools/libltgrey.c
parent292a76b35fd16cf11613f79ea38693449e3317f6 (diff)
get40 seems to be working
Diffstat (limited to 'tools/libltgrey.c')
-rw-r--r--tools/libltgrey.c27
1 files changed, 25 insertions, 2 deletions
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 <const int> 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;
+}