-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.h
51 lines (39 loc) · 896 Bytes
/
config.h
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
#ifndef MC_CONFIG_H
#define MC_CONFIG_H
#include <vector>
#include <assert.h>
namespace mc
{
static const char VER[]="1.0";
static const size_t MAX_KEYLEN = 250;
static const size_t MAX_VALUELEN = 1024*1024;
static const size_t MAX_WRITE_SIZE = 4*1204;
static const size_t MAX_EPOLL_EVENTS = 128;
struct sysevent
{
enum event_type
{
system
,session
};
event_type t_;
void *user_;
explicit sysevent(event_type t, void* u)
:t_(t)
,user_(u)
{}
};
typedef std::vector<unsigned char> buffer;
inline buffer serialize_sysevent(const sysevent& c)
{
return buffer(reinterpret_cast<const unsigned char*>(&c)
,reinterpret_cast<const unsigned char*>(&c) + sizeof(c)
);
}
inline sysevent deserialize_sysevent(const buffer& b)
{
assert(b.size() == sizeof(sysevent));
return sysevent(*reinterpret_cast<const sysevent*>(b.data()));
}
}
#endif