ARB
NT_userland_fixes.cxx
Go to the documentation of this file.
1 // ================================================================ //
2 // //
3 // File : NT_userland_fixes.cxx //
4 // Purpose : Repair situations caused by ARB bugs in userland //
5 // //
6 // Coded by Ralf Westram (coder@reallysoft.de) in November 2013 //
7 // Institute of Microbiology (Technical University Munich) //
8 // http://www.arb-home.de/ //
9 // //
10 // ================================================================ //
11 
12 #include <aw_msg.hxx>
13 
14 #include <arbdb.h>
15 #include <arb_strarray.h>
16 #include <arb_file.h>
17 
18 #include <time.h>
19 #include <vector>
20 #include <string>
21 
22 using namespace std;
23 
24 typedef void (*fixfun)();
25 
26 const long DAYS = 24*60*60L;
27 const long WEEKS = 7 * DAYS;
28 const long MONTHS = 30 * DAYS;
29 const long YEARS = 365 * DAYS;
30 
32  vector<fixfun> fixes;
33  time_t now;
34 public:
35 
36  UserlandCheck() { time(&now); }
37  void Register(fixfun fix, long IF_DEBUG(addedAt), long IF_DEBUG(expire)) {
38  fixes.push_back(fix);
39 #if defined(DEBUG)
40  if (addedAt+expire < now) {
41  aw_message(GBS_global_string("Warning: UserlandCheck #%zu has expired\n", fixes.size()));
42  }
43 #endif
44  }
45  void Run() {
46  for (vector<fixfun>::iterator f = fixes.begin(); f != fixes.end(); ++f) {
47  (*f)();
48  }
49  }
50 };
51 
52 // ------------------------------------------------------------
53 
55  // place to repair problems caused by earlier bugs
56 
57  UserlandCheck checks;
58  // generate timestamp: date "--date=2013/09/20" "+%s"
59  // date +%s
60 
61  // no checks active atm
62 
63  checks.Run();
64 }
65 
const long YEARS
const char * GBS_global_string(const char *templat,...)
Definition: arb_msg.cxx:204
STL namespace.
const long WEEKS
const long DAYS
void Register(fixfun fix, long IF_DEBUG(addedAt), long IF_DEBUG(expire))
void(* fixfun)()
void NT_repair_userland_problems()
void aw_message(const char *msg)
Definition: AW_status.cxx:932
#define IF_DEBUG(x)
Definition: arb_assert.h:303
const long MONTHS