DTNMA Reference Tools v2.0.0 - 8.g8c05a00
Delay-Tolerant Networking Management Architecture (DTNMA) Tool Suite
|
#include "cace_data.h"
#include "cace/util/defs.h"
#include <m-core.h>
#include <m-string.h>
#include <string.h>
Functions | |
static void | cace_data_int_reset (cace_data_t *data) |
static void | cace_data_int_free (cace_data_t *data) |
int | cace_data_init (cace_data_t *data) |
Initialize an empty data struct. | |
int | cace_data_init_view (cace_data_t *data, size_t len, const cace_data_ptr_t src) |
Initialize a data struct as an overlay on optional external data. | |
int | cace_data_init_view_cstr (cace_data_t *data, const char *src) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
int | cace_data_init_set (cace_data_t *data, const cace_data_t *src) |
int | cace_data_deinit (cace_data_t *data) |
De-initialize a data struct, freeing if necessary. | |
int | cace_data_copy_from (cace_data_t *data, size_t len, cace_data_ptr_t src) |
Set an initialized data struct to a given size. | |
int | cace_data_copy_from_cstr (cace_data_t *data, const char *src) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
int | cace_data_copy (cace_data_t *data, const cace_data_t *src) |
Copy between two data structs, both already initialized. | |
void | cace_data_move (cace_data_t *data, cace_data_t *src) |
Move between two data structs, both already initialized. | |
void | cace_data_swap (cace_data_t *data, cace_data_t *other) |
Swap between two data structs, both already initialized. | |
bool | cace_data_is_empty (const cace_data_t *data) |
size_t | cace_data_hash (const cace_data_t *data) |
Interface for M*LIB items. | |
int | cace_data_cmp (const cace_data_t *lt, const cace_data_t *rt) |
Interface for M*LIB items. | |
bool | cace_data_equal (const cace_data_t *lt, const cace_data_t *rt) |
Interface for M*LIB items. | |
int | cace_data_clear (cace_data_t *data) |
Clear the data, freeing if necessary. | |
int | cace_data_resize (cace_data_t *data, size_t len) |
Resize the data, copying if necessary. | |
int | cace_data_extend_front (cace_data_t *data, ssize_t extra) |
Alter the size at the front of the array by a difference value. | |
int | cace_data_append_from (cace_data_t *data, size_t len, cace_data_ptr_t src) |
Append an initialized data struct with a given size. | |
int | cace_data_append_byte (cace_data_t *data, uint8_t val) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
int | cace_data_from_m_string (cace_data_t *data, const struct m_string_s *src) |
Copy a text C-string from an M-STRING object. | |
int cace_data_append_from | ( | cace_data_t * | data, |
size_t | len, | ||
cace_data_ptr_t | src | ||
) |
Append an initialized data struct with a given size.
[in,out] | data | The data to copy into, which must not be NULL. |
len | The total length to allocate, which may be non-zero. | |
src | An optional source buffer to copy from, from which len bytes will be copied. |
References cace_data_extend_back(), CHKERR1, cace_data_t::len, and cace_data_t::ptr.
int cace_data_clear | ( | cace_data_t * | data | ) |
Clear the data, freeing if necessary.
[in,out] | data | The data to clear, which must not be NULL. |
References CHKERR1.
int cace_data_copy | ( | cace_data_t * | data, |
const cace_data_t * | src | ||
) |
Copy between two data structs, both already initialized.
[in,out] | data | The data to copy to, which must not be NULL. |
src | The data to copy from, which must not be NULL. |
References cace_data_copy_from(), CHKERR1, cace_data_t::len, and cace_data_t::ptr.
Referenced by cace_ari_set_bstr(), and cace_slash_unescape().
int cace_data_copy_from | ( | cace_data_t * | data, |
size_t | len, | ||
cace_data_ptr_t | src | ||
) |
Set an initialized data struct to a given size.
[in,out] | data | The data to copy into, which must not be NULL. |
len | The total length to allocate, which may be non-zero. | |
src | An optional source buffer to copy from, from which len bytes will be copied. |
References cace_data_resize(), CHKERR1, cace_data_t::owned, and cace_data_t::ptr.
Referenced by cace_ari_cbor_encode(), cace_ari_set_tstr(), cace_data_copy(), cace_data_copy_from_cstr(), and cace_data_from_m_string().
int cace_data_deinit | ( | cace_data_t * | data | ) |
De-initialize a data struct, freeing if necessary.
[in,out] | data | The data to de-initialize, which must not be NULL. |
References CHKERR1.
Referenced by cace_amp_msg_decode(), cace_amp_msg_encode(), cace_amp_proxy_cli_recv(), cace_amp_proxy_cli_send(), cace_amp_proxy_msg_send(), cace_ari_date_from_text(), cace_ari_lit_deinit(), cace_slash_unescape(), refdm_db_insert_rptset(), and transform_cbor_str_to_cace_data().
int cace_data_extend_front | ( | cace_data_t * | data, |
ssize_t | extra | ||
) |
Alter the size at the front of the array by a difference value.
[in,out] | data | The data to resize, which must not be NULL. |
extra | The difference of the desired size from the current size. This may be negative to shrink the data. |
References cace_data_resize(), CHKERR1, cace_data_t::len, and cace_data_t::ptr.
int cace_data_from_m_string | ( | cace_data_t * | data, |
const struct m_string_s * | src | ||
) |
Copy a text C-string from an M-STRING object.
The copy includes a terminating null.
[in,out] | data | The data to copy to, which must not be NULL. |
src | The string to copy from, which must not be NULL. |
References cace_data_copy_from().
int cace_data_init | ( | cace_data_t * | data | ) |
Initialize an empty data struct.
[in,out] | data | The data to initialize, which must not be NULL. |
References CHKERR1.
Referenced by cace_amp_msg_encode(), cace_amp_proxy_cli_send(), cace_amp_proxy_msg_send(), cace_ari_set_bstr(), cace_ari_set_tstr(), cace_slash_unescape(), and refdm_db_insert_rptset().
int cace_data_init_view | ( | cace_data_t * | data, |
size_t | len, | ||
cace_data_ptr_t | src | ||
) |
Initialize a data struct as an overlay on optional external data.
[in,out] | data | The data to initialize, which must not be NULL. |
len | The total length to allocate, which may be zero. | |
src | An optional source buffer to point to. |
References CHKERR1, cace_data_t::len, cace_data_t::owned, and cace_data_t::ptr.
Referenced by cace_amp_msg_decode(), cace_amp_proxy_cli_recv(), cace_amp_proxy_msg_recv(), cace_ari_set_aritype_text(), cace_ari_set_tstr(), cace_data_init_view_cstr(), cace_slash_unescape(), and transform_cbor_str_to_cace_data().
void cace_data_move | ( | cace_data_t * | data, |
cace_data_t * | src | ||
) |
Move between two data structs, both already initialized.
[in,out] | data | The data to move to, which must not be NULL. |
[in,out] | src | The data to move from, which must not be NULL. |
References CHKVOID.
int cace_data_resize | ( | cace_data_t * | data, |
size_t | len | ||
) |
Resize the data, copying if necessary.
[in,out] | data | The data to resize, which must not be NULL. |
len | The new total size. |
References CACE_REALLOC, CHKERR1, cace_data_t::len, cace_data_t::owned, and cace_data_t::ptr.
Referenced by cace_base16_decode(), cace_base64_decode(), cace_data_copy_from(), cace_data_extend_back(), and cace_data_extend_front().
void cace_data_swap | ( | cace_data_t * | data, |
cace_data_t * | other | ||
) |
Swap between two data structs, both already initialized.
[in,out] | data | The data to swap to, which must not be NULL. |
[in,out] | other | The data to swap with, which must not be NULL. |
References CHKVOID.
Referenced by cace_ari_set_bstr().