| Line | |
|---|
| 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 | |
|---|
| 31 | class UserlandCheck { |
|---|
| 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 | |
|---|
| 54 | void NT_repair_userland_problems() { |
|---|
| 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 | |
|---|
Note: See
TracBrowser
for help on using the repository browser.