aboutsummaryrefslogtreecommitdiff
path: root/include/olm/pickle.h
blob: 4e46910f3ca1755911ead38e785b2da8242b95ec (plain)
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
/* Copyright 2015-2016 OpenMarket Ltd
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#ifndef OLM_PICKLE_H_
#define OLM_PICKLE_H_

#include <stdint.h>

#ifdef __cplusplus
extern "C" {
#endif

#define olm_pickle_uint32_length(value) 4
uint8_t * olm_pickle_uint32(uint8_t * pos, uint32_t value);
uint8_t const * olm_unpickle_uint32(
    uint8_t const * pos, uint8_t const * end,
    uint32_t *value
);


#define olm_pickle_bool_length(value) 1
uint8_t * olm_pickle_bool(uint8_t * pos, int value);
uint8_t const * olm_unpickle_bool(
    uint8_t const * pos, uint8_t const * end,
    int *value
);

#define olm_pickle_bytes_length(bytes, bytes_length) (bytes_length)
uint8_t * olm_pickle_bytes(uint8_t * pos, uint8_t const * bytes,
                           size_t bytes_length);
uint8_t const * olm_unpickle_bytes(uint8_t const * pos, uint8_t const * end,
                                   uint8_t * bytes, size_t bytes_length);


#ifdef __cplusplus
} // extern "C"
#endif

#endif /* OLM_PICKLE_H */