forked from troybowman/dtxmsg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dtxmsg_common.h
65 lines (52 loc) · 1.88 KB
/
dtxmsg_common.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#ifndef DTXMSG_COMMON_H
#define DTXMSG_COMMON_H
#include <CoreFoundation/CoreFoundation.h>
#include <pro.h>
//------------------------------------------------------------------------------
qstring to_qstring(CFStringRef ref);
//------------------------------------------------------------------------------
qstring get_description(CFTypeRef ref);
//------------------------------------------------------------------------------
void archive(bytevec_t *buf, CFTypeRef ref);
//------------------------------------------------------------------------------
CFTypeRef unarchive(const uchar *buf, size_t bufsize);
//------------------------------------------------------------------------------
// convert a serialized array to a CFArrayRef object
CFArrayRef deserialize(const uchar *buf, size_t bufsize, qstring *errbuf = NULL);
//------------------------------------------------------------------------------
// helper class for serializing method arguments
class message_aux_t
{
bytevec_t buf;
public:
void append_int(int32 val);
void append_long(int64 val);
void append_obj(CFTypeRef obj);
void get_bytes(bytevec_t *out) const;
};
//-----------------------------------------------------------------------------
void append_d(bytevec_t &out, uint32 num);
void append_q(bytevec_t &out, uint64 num);
void append_b(bytevec_t &out, const bytevec_t &bv);
void append_v(bytevec_t &out, const void *v, size_t len);
//-----------------------------------------------------------------------------
struct DTXMessageHeader
{
uint32 magic;
uint32 cb;
uint16 fragmentId;
uint16 fragmentCount;
uint32 length;
uint32 identifier;
uint32 conversationIndex;
uint32 channelCode;
uint32 expectsReply;
};
//-----------------------------------------------------------------------------
struct DTXMessagePayloadHeader
{
uint32 flags;
uint32 auxiliaryLength;
uint64 totalLength;
};
#endif // DTXMSG_COMMON_H