-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathxdr.c
More file actions
67 lines (57 loc) · 1.09 KB
/
Copy pathxdr.c
File metadata and controls
67 lines (57 loc) · 1.09 KB
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
#ifndef CBFS
#define CBFS
#include "cbfslib.h"
#endif //CLASS_NAME_H_
#include "xdr.h"
static uint8_t get8(struct buffer *input)
{
uint8_t ret = *input->data++;
input->size--;
return ret;
}
static uint16_t get16be(struct buffer *input)
{
uint16_t ret;
ret = get8(input) << 8;
ret |= get8(input);
return ret;
}
static uint32_t get32be(struct buffer *input)
{
uint32_t ret;
ret = get16be(input) << 16;
ret |= get16be(input);
return ret;
}
static uint64_t get64be(struct buffer *input)
{
uint64_t ret;
ret = get32be(input);
ret <<= 32;
ret |= get32be(input);
return ret;
}
static void put8(struct buffer *input, uint8_t val)
{
input->data[input->size] = val;
input->size++;
}
static void put16be(struct buffer *input, uint16_t val)
{
put8(input, val >> 8);
put8(input, val);
}
static void put32be(struct buffer *input, uint32_t val)
{
put16be(input, val >> 16);
put16be(input, val);
}
static void put64be(struct buffer *input, uint64_t val)
{
put32be(input, val >> 32);
put32be(input, val);
}
struct xdr xdr_be = {
get8, get16be, get32be, get64be,
put8, put16be, put32be, put64be
};