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 --- src/pickle.cpp | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'src/pickle.cpp') diff --git a/src/pickle.cpp b/src/pickle.cpp index 00f7cd4..1158306 100644 --- a/src/pickle.cpp +++ b/src/pickle.cpp @@ -13,6 +13,7 @@ * limitations under the License. */ #include "olm/pickle.hh" +#include "olm/pickle.h" std::uint8_t * olm::pickle( std::uint8_t * pos, @@ -196,3 +197,37 @@ std::uint8_t const * olm::unpickle( ); return pos; } + +////// pickle.h implementations + +uint8_t * olm_pickle_uint32(uint8_t * pos, uint32_t value) { + return olm::pickle(pos, value); +} + +uint8_t const * olm_unpickle_uint32( + uint8_t const * pos, uint8_t const * end, + uint32_t *value +) { + return olm::unpickle(pos, end, *value); +} + +uint8_t * olm_pickle_bool(uint8_t * pos, int value) { + return olm::pickle(pos, (bool)value); +} + +uint8_t const * olm_unpickle_bool( + uint8_t const * pos, uint8_t const * end, + int *value +) { + return olm::unpickle(pos, end, *reinterpret_cast(value)); +} + +uint8_t * olm_pickle_bytes(uint8_t * pos, uint8_t const * bytes, + size_t bytes_length) { + return olm::pickle_bytes(pos, bytes, bytes_length); +} + +uint8_t const * olm_unpickle_bytes(uint8_t const * pos, uint8_t const * end, + uint8_t * bytes, size_t bytes_length) { + return olm::unpickle_bytes(pos, end, bytes, bytes_length); +} -- 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. --- src/pickle.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/pickle.cpp') diff --git a/src/pickle.cpp b/src/pickle.cpp index 1158306..fc3e2b4 100644 --- a/src/pickle.cpp +++ b/src/pickle.cpp @@ -200,34 +200,34 @@ std::uint8_t const * olm::unpickle( ////// pickle.h implementations -uint8_t * olm_pickle_uint32(uint8_t * pos, uint32_t value) { +uint8_t * _olm_pickle_uint32(uint8_t * pos, uint32_t value) { return olm::pickle(pos, value); } -uint8_t const * olm_unpickle_uint32( +uint8_t const * _olm_unpickle_uint32( uint8_t const * pos, uint8_t const * end, uint32_t *value ) { return olm::unpickle(pos, end, *value); } -uint8_t * olm_pickle_bool(uint8_t * pos, int value) { +uint8_t * _olm_pickle_bool(uint8_t * pos, int value) { return olm::pickle(pos, (bool)value); } -uint8_t const * olm_unpickle_bool( +uint8_t const * _olm_unpickle_bool( uint8_t const * pos, uint8_t const * end, int *value ) { return olm::unpickle(pos, end, *reinterpret_cast(value)); } -uint8_t * olm_pickle_bytes(uint8_t * pos, uint8_t const * bytes, +uint8_t * _olm_pickle_bytes(uint8_t * pos, uint8_t const * bytes, size_t bytes_length) { return olm::pickle_bytes(pos, bytes, 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) { return olm::unpickle_bytes(pos, end, bytes, bytes_length); } -- cgit v1.2.3