Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
matrix-org
Olm
Commits
07b33ace
Commit
07b33ace
authored
May 17, 2016
by
Richard van der Hoff
Browse files
C bindings for pickle functions
parent
294cf482
Changes
2
Hide whitespace changes
Inline
Side-by-side
include/olm/pickle.h
0 → 100644
View file @
07b33ace
/* 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 */
src/pickle.cpp
View file @
07b33ace
...
...
@@ -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
<
bool
*>
(
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
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment