1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
#include <string>
#include <sys/time.h> /* for gettimeofday(), timeval */
#include <vector>
#include <map>
#define box_state_macro \
foo(unseen) \
foo(green) \
foo(ripe) \
foo(spoiled) \
foo(fail)
// expand the codes to make some <const int> names:
#define foo(name) name,
typedef enum {
box_state_macro
} box_state;
#undef foo
class boxer{
public:
std::string dir;
std::string prefix;
int min;
int max;
boxer(const std::string _dir, const std::string _prefix,
const int _min, const int _max)
: dir(_dir), prefix(_prefix), min(_min), max(_max)
{}
};
class whatsit{
public:
std::string parent_dir;
std::string progname;
pid_t mypid;
std::string suffix;
std::string progid;
int verbosity;
std::map<box_state,std::string> decode_40;
whatsit(const std::string name, const std::string _parent_dir);
// access comes after modification:
void update(const std::string msg, const timeval new_mod,
const timeval new_ac, const int penalty, const int stain);
int setup();
int check_dns(const char* ipvar, const char* namevar);
int check_dns_sub(const char* ipvar, const char* namevar,
std::string &addr, std::string &host,
std::vector<std::string> &checked);
void dump(const std::string var);
int maybe_mkdir(const std::string somedir, const std::string msg);
int set_box(const boxer, const std::string mid, const int shift);
box_state get_box(const boxer, const std::string mid, timeval times[2]);
void scan_box(const boxer, const int copies);
box_state get_40(const std::string mid);
int set_40(const std::string mid, const int shift);
box_state get_rep(const std::string mid);
int set_rep(const std::string mid, const int shift);
};
// beware: access illogically comes *before* modification
// in the array passed to utimes:
const int upd_ac(0);
const int upd_mod(1);
const int minute(60);
const int hour(60*minute);
const int day(24*hour);
const boxer box_40 ("quarante", "mid_", 15*minute, 4*hour);
const boxer box_rep("repute", "dom_", 0, 35*day);
|