blob: 63b6de9b33c77e099061021afe3414329569ae5a (
plain) (
blame)
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
|
#ifndef SERIALIZER_H_
#define SERIALIZER_H_
// Careful with includes - this is used in kernel module too
#include "config.h"
typedef struct
{
char buffer[MAX_PAYLOAD]; // This MUST be the first member or send_reply() will blow up
char *buffer_end;
char *buffer_pointer;
} serialized_buffer_t;
void serializer_reset_read(serialized_buffer_t *buffer, size_t data_len);
void serializer_reset_write(serialized_buffer_t *buffer);
ssize_t serializer_get_written_length(serialized_buffer_t *buffer);
//
uint8_t serializer_get_uint8(serialized_buffer_t *buffer);
uint16_t serializer_get_uint16(serialized_buffer_t *buffer);
uint64_t serializer_get_uint64(serialized_buffer_t *buffer);
char *serializer_get_string(serialized_buffer_t *buffer);
//
void serializer_put_uint8(serialized_buffer_t *buffer, uint8_t value);
void serializer_put_uint16(serialized_buffer_t *buffer, uint16_t value);
void serializer_put_uint64(serialized_buffer_t *buffer, uint64_t value);
void serializer_put_string(serialized_buffer_t *buffer, const char *value);
#endif
|