Noise-C
 All Data Structures Files Functions Variables Typedefs Macros Groups Pages
protobufs.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 Southern Storm Software, Pty Ltd.
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included
12  * in all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20  * DEALINGS IN THE SOFTWARE.
21  */
22 
23 #ifndef NOISE_PROTOBUFS_H
24 #define NOISE_PROTOBUFS_H
25 
27 #include <stddef.h>
28 #include <stdint.h>
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 typedef struct
35 {
36  uint8_t *data;
37  size_t size;
38  size_t posn;
39  int error;
40 
42 
44  (NoiseProtobuf *pbuf, const uint8_t *data, size_t size);
46  (NoiseProtobuf *pbuf, uint8_t *data, size_t size);
47 int noise_protobuf_prepare_measure(NoiseProtobuf *pbuf, size_t max_size);
48 
51  (NoiseProtobuf *pbuf, uint8_t **data, size_t *size);
53  (NoiseProtobuf *pbuf, uint8_t **data, size_t *size);
54 int noise_protobuf_finish_measure(NoiseProtobuf *pbuf, size_t *size);
55 
56 int noise_protobuf_write_int32(NoiseProtobuf *pbuf, int tag, int32_t value);
57 int noise_protobuf_write_uint32(NoiseProtobuf *pbuf, int tag, uint32_t value);
58 int noise_protobuf_write_int64(NoiseProtobuf *pbuf, int tag, int64_t value);
59 int noise_protobuf_write_uint64(NoiseProtobuf *pbuf, int tag, uint64_t value);
60 int noise_protobuf_write_sint32(NoiseProtobuf *pbuf, int tag, int32_t value);
61 int noise_protobuf_write_sint64(NoiseProtobuf *pbuf, int tag, int64_t value);
62 int noise_protobuf_write_sfixed32(NoiseProtobuf *pbuf, int tag, int32_t value);
63 int noise_protobuf_write_fixed32(NoiseProtobuf *pbuf, int tag, uint32_t value);
64 int noise_protobuf_write_sfixed64(NoiseProtobuf *pbuf, int tag, int64_t value);
65 int noise_protobuf_write_fixed64(NoiseProtobuf *pbuf, int tag, uint64_t value);
66 int noise_protobuf_write_float(NoiseProtobuf *pbuf, int tag, float value);
67 int noise_protobuf_write_double(NoiseProtobuf *pbuf, int tag, double value);
68 int noise_protobuf_write_bool(NoiseProtobuf *pbuf, int tag, int value);
70  (NoiseProtobuf *pbuf, int tag, const char *str, size_t size);
72  (NoiseProtobuf *pbuf, int tag, const void *data, size_t size);
73 int noise_protobuf_write_end_element(NoiseProtobuf *pbuf, size_t *end_posn);
75  (NoiseProtobuf *pbuf, int tag, size_t end_posn);
76 
77 int noise_protobuf_peek_tag(const NoiseProtobuf *pbuf);
78 size_t noise_protobuf_peek_size(const NoiseProtobuf *pbuf);
79 int noise_protobuf_read_int32(NoiseProtobuf *pbuf, int tag, int32_t *value);
80 int noise_protobuf_read_uint32(NoiseProtobuf *pbuf, int tag, uint32_t *value);
81 int noise_protobuf_read_int64(NoiseProtobuf *pbuf, int tag, int64_t *value);
82 int noise_protobuf_read_uint64(NoiseProtobuf *pbuf, int tag, uint64_t *value);
83 int noise_protobuf_read_sint32(NoiseProtobuf *pbuf, int tag, int32_t *value);
84 int noise_protobuf_read_sint64(NoiseProtobuf *pbuf, int tag, int64_t *value);
85 int noise_protobuf_read_sfixed32(NoiseProtobuf *pbuf, int tag, int32_t *value);
86 int noise_protobuf_read_fixed32(NoiseProtobuf *pbuf, int tag, uint32_t *value);
87 int noise_protobuf_read_sfixed64(NoiseProtobuf *pbuf, int tag, int64_t *value);
88 int noise_protobuf_read_fixed64(NoiseProtobuf *pbuf, int tag, uint64_t *value);
89 int noise_protobuf_read_float(NoiseProtobuf *pbuf, int tag, float *value);
90 int noise_protobuf_read_double(NoiseProtobuf *pbuf, int tag, double *value);
91 int noise_protobuf_read_bool(NoiseProtobuf *pbuf, int tag, int *value);
93  (NoiseProtobuf *pbuf, int tag, char *str, size_t max_size, size_t *size);
95  (NoiseProtobuf *pbuf, int tag, char **str, size_t max_size, size_t *size);
97  (NoiseProtobuf *pbuf, int tag, void *data, size_t max_size, size_t *size);
99  (NoiseProtobuf *pbuf, int tag, void **data, size_t max_size, size_t *size);
101  (NoiseProtobuf *pbuf, int tag, size_t *end_posn);
102 int noise_protobuf_read_end_element(NoiseProtobuf *pbuf, size_t end_posn);
104  (const NoiseProtobuf *pbuf, size_t end_posn);
107 
109  (void **array, size_t *count, size_t *max, const void *value, size_t size);
111  (char ***array, size_t **len_array, size_t *count, size_t *max,
112  const char *value, size_t size);
114  (void ***array, size_t **len_array, size_t *count, size_t *max,
115  const void *value, size_t size);
116 
118  (void **array, size_t *count, size_t *max, size_t index,
119  const void *value, size_t size);
120 
121 void noise_protobuf_free_memory(void *ptr, size_t size);
122 
123 #ifdef __cplusplus
124 };
125 #endif
126 
127 #endif
int noise_protobuf_write_float(NoiseProtobuf *pbuf, int tag, float value)
int noise_protobuf_read_uint64(NoiseProtobuf *pbuf, int tag, uint64_t *value)
int noise_protobuf_read_string(NoiseProtobuf *pbuf, int tag, char *str, size_t max_size, size_t *size)
int noise_protobuf_prepare_input(NoiseProtobuf *pbuf, const uint8_t *data, size_t size)
int noise_protobuf_add_to_string_array(char ***array, size_t **len_array, size_t *count, size_t *max, const char *value, size_t size)
int noise_protobuf_read_float(NoiseProtobuf *pbuf, int tag, float *value)
int noise_protobuf_write_bytes(NoiseProtobuf *pbuf, int tag, const void *data, size_t size)
int noise_protobuf_write_sfixed64(NoiseProtobuf *pbuf, int tag, int64_t value)
int noise_protobuf_finish_input(NoiseProtobuf *pbuf)
int noise_protobuf_write_end_element(NoiseProtobuf *pbuf, size_t *end_posn)
int noise_protobuf_read_at_end_element(const NoiseProtobuf *pbuf, size_t end_posn)
int noise_protobuf_read_skip(NoiseProtobuf *pbuf)
Constants for algorithm identifiers, limit values, etc.
int noise_protobuf_add_to_array(void **array, size_t *count, size_t *max, const void *value, size_t size)
int noise_protobuf_write_bool(NoiseProtobuf *pbuf, int tag, int value)
int noise_protobuf_write_fixed32(NoiseProtobuf *pbuf, int tag, uint32_t value)
int noise_protobuf_read_sint32(NoiseProtobuf *pbuf, int tag, int32_t *value)
int noise_protobuf_insert_into_array(void **array, size_t *count, size_t *max, size_t index, const void *value, size_t size)
int noise_protobuf_write_sint32(NoiseProtobuf *pbuf, int tag, int32_t value)
int noise_protobuf_finish_output_shift(NoiseProtobuf *pbuf, uint8_t **data, size_t *size)
int noise_protobuf_write_fixed64(NoiseProtobuf *pbuf, int tag, uint64_t value)
int noise_protobuf_peek_tag(const NoiseProtobuf *pbuf)
size_t noise_protobuf_peek_size(const NoiseProtobuf *pbuf)
int noise_protobuf_write_start_element(NoiseProtobuf *pbuf, int tag, size_t end_posn)
int noise_protobuf_read_sfixed64(NoiseProtobuf *pbuf, int tag, int64_t *value)
int noise_protobuf_read_double(NoiseProtobuf *pbuf, int tag, double *value)
int noise_protobuf_finish_output(NoiseProtobuf *pbuf, uint8_t **data, size_t *size)
int noise_protobuf_read_alloc_string(NoiseProtobuf *pbuf, int tag, char **str, size_t max_size, size_t *size)
int noise_protobuf_read_fixed64(NoiseProtobuf *pbuf, int tag, uint64_t *value)
int noise_protobuf_read_stop(NoiseProtobuf *pbuf)
int noise_protobuf_write_sint64(NoiseProtobuf *pbuf, int tag, int64_t value)
int noise_protobuf_read_fixed32(NoiseProtobuf *pbuf, int tag, uint32_t *value)
int noise_protobuf_read_int32(NoiseProtobuf *pbuf, int tag, int32_t *value)
int noise_protobuf_write_sfixed32(NoiseProtobuf *pbuf, int tag, int32_t value)
int noise_protobuf_read_sfixed32(NoiseProtobuf *pbuf, int tag, int32_t *value)
void noise_protobuf_free_memory(void *ptr, size_t size)
int noise_protobuf_finish_measure(NoiseProtobuf *pbuf, size_t *size)
size_t size
Definition: protobufs.h:37
int noise_protobuf_write_uint64(NoiseProtobuf *pbuf, int tag, uint64_t value)
int noise_protobuf_read_uint32(NoiseProtobuf *pbuf, int tag, uint32_t *value)
int noise_protobuf_write_int32(NoiseProtobuf *pbuf, int tag, int32_t value)
int noise_protobuf_write_int64(NoiseProtobuf *pbuf, int tag, int64_t value)
int noise_protobuf_read_bool(NoiseProtobuf *pbuf, int tag, int *value)
int noise_protobuf_add_to_bytes_array(void ***array, size_t **len_array, size_t *count, size_t *max, const void *value, size_t size)
int noise_protobuf_write_uint32(NoiseProtobuf *pbuf, int tag, uint32_t value)
int noise_protobuf_write_double(NoiseProtobuf *pbuf, int tag, double value)
int noise_protobuf_read_int64(NoiseProtobuf *pbuf, int tag, int64_t *value)
int noise_protobuf_write_string(NoiseProtobuf *pbuf, int tag, const char *str, size_t size)
int noise_protobuf_prepare_output(NoiseProtobuf *pbuf, uint8_t *data, size_t size)
int noise_protobuf_read_end_element(NoiseProtobuf *pbuf, size_t end_posn)
int noise_protobuf_read_start_element(NoiseProtobuf *pbuf, int tag, size_t *end_posn)
int noise_protobuf_read_sint64(NoiseProtobuf *pbuf, int tag, int64_t *value)
int noise_protobuf_prepare_measure(NoiseProtobuf *pbuf, size_t max_size)
size_t posn
Definition: protobufs.h:38
int noise_protobuf_read_bytes(NoiseProtobuf *pbuf, int tag, void *data, size_t max_size, size_t *size)
int noise_protobuf_read_alloc_bytes(NoiseProtobuf *pbuf, int tag, void **data, size_t max_size, size_t *size)
uint8_t * data
Definition: protobufs.h:36