From 07b33acee5463c64ca5fa0021128f821dc5aa104 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Tue, 17 May 2016 18:45:28 +0100 Subject: C bindings for pickle functions --- include/olm/pickle.h | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 include/olm/pickle.h (limited to 'include/olm/pickle.h') diff --git a/include/olm/pickle.h b/include/olm/pickle.h new file mode 100644 index 0000000..4e46910 --- /dev/null +++ b/include/olm/pickle.h @@ -0,0 +1,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 + +#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 */ -- cgit v1.2.3 From 444ef1f70687c340ba1b0b2a22d6e63c734d5f9e Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Fri, 20 May 2016 11:59:31 +0100 Subject: Prefix for internal symbols Give a load of internal symbols "_olm_" prefixes. This better delineates the public and private interfaces in the module, and helps avoid internal symbols leaking out and possibly being abused. --- include/olm/pickle.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'include/olm/pickle.h') diff --git a/include/olm/pickle.h b/include/olm/pickle.h index 4e46910..c1e8192 100644 --- a/include/olm/pickle.h +++ b/include/olm/pickle.h @@ -21,25 +21,25 @@ 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( +#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( +#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, +#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 const * _olm_unpickle_bytes(uint8_t const * pos, uint8_t const * end, uint8_t * bytes, size_t bytes_length); -- cgit v1.2.3