DTNMA Reference Tools v2.1.0 - 13.gc5c0bac
Delay-Tolerant Networking Management Architecture (DTNMA) Tool Suite
Loading...
Searching...
No Matches
cace_data.h File Reference

This file contains the definitions, prototypes, constants, and other information necessary for the identification and processing of AMM Resource Identifiers (ARIs). More...

#include "cace/config.h"
#include <sys/types.h>
#include <m-core.h>
#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
+ Include dependency graph for cace_data.h:
+ This graph shows which files directly or indirectly include this file:

Data Structures

struct  cace_data_t
 Heap data for TSTR and BSTR types. More...
 

Macros

#define CACE_DATA_INIT_NULL
 Static initializer for a data store.
 
#define M_OPL_cace_data_t()
 Default OPLIST for cace_data_t.
 

Typedefs

typedef uint8_t * cace_data_ptr_t
 Data pointer for cace_data_t.
 
typedef struct cace_data_s cace_data_a1_t[1]
 A definition to use length-one-array trick for store-by-value and pass-by-reference semantics.
 

Functions

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, 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_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.
 
static int cace_data_extend_back (cace_data_t *data, ssize_t extra)
 Alter the size at the back of the array by a difference value.
 
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_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_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_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_from_m_string (cace_data_t *data, const struct m_string_s *src)
 Copy a text C-string from an M-STRING object.
 

Detailed Description

This file contains the definitions, prototypes, constants, and other information necessary for the identification and processing of AMM Resource Identifiers (ARIs).

Every object in the AMM can be uniquely identified using an ARI.

Macro Definition Documentation

◆ CACE_DATA_INIT_NULL

#define CACE_DATA_INIT_NULL
Value:
{ \
.owned = false, .ptr = NULL, .len = 0 \
}

Static initializer for a data store.

See also
cace_data_init()

◆ M_OPL_cace_data_t

#define M_OPL_cace_data_t ( )
Value:
(INIT(API_2(cace_data_init)), INIT_SET(API_6(cace_data_init_set)), CLEAR(API_2(cace_data_deinit)), \
SET(API_2(cace_data_copy)), MOVE(API_6(cace_data_move)), SWAP(API_6(cace_data_swap)), \
HASH(API_2(cace_data_hash)), EQUAL(API_6(cace_data_equal)))
int cace_data_deinit(cace_data_t *data)
De-initialize a data struct, freeing if necessary.
Definition cace_data.c:72
bool cace_data_equal(const cace_data_t *lt, const cace_data_t *rt)
Interface for M*LIB items.
Definition cace_data.c:187
int cace_data_copy(cace_data_t *data, const cace_data_t *src)
Copy between two data structs, both already initialized.
Definition cace_data.c:115
int cace_data_init(cace_data_t *data)
Initialize an empty data struct.
Definition cace_data.c:42
void cace_data_swap(cace_data_t *data, cace_data_t *other)
Swap between two data structs, both already initialized.
Definition cace_data.c:134
size_t cace_data_hash(const cace_data_t *data)
Interface for M*LIB items.
Definition cace_data.c:152
void cace_data_move(cace_data_t *data, cace_data_t *src)
Move between two data structs, both already initialized.
Definition cace_data.c:124
int cace_data_init_set(cace_data_t *data, const cace_data_t *src)
Definition cace_data.c:65

Default OPLIST for cace_data_t.

Typedef Documentation

◆ cace_data_a1_t

typedef struct cace_data_s cace_data_a1_t[1]

A definition to use length-one-array trick for store-by-value and pass-by-reference semantics.

◆ cace_data_ptr_t

typedef uint8_t* cace_data_ptr_t

Data pointer for cace_data_t.

Function Documentation

◆ cace_data_append_byte()

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.

References cace_data_extend_back(), CHKERR1, cace_data_t::len, and cace_data_t::ptr.

Referenced by cace_ari_cbor_decode_label(), cace_ari_cbor_decode_optdate(), cace_ari_cbor_decode_primval(), cace_ari_text_encode_lit(), and cace_slash_unescape().

◆ cace_data_append_from()

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.

Parameters
[in,out]dataThe data to copy into, which must not be NULL.
lenThe total length to allocate, which may be non-zero.
srcAn optional source buffer to copy from, from which len bytes will be copied.
Returns
Zero upon success.

References cace_data_extend_back(), CHKERR1, cace_data_t::len, and cace_data_t::ptr.

Referenced by read_cbor().

◆ cace_data_clear()

int cace_data_clear ( cace_data_t data)

Clear the data, freeing if necessary.

Parameters
[in,out]dataThe data to clear, which must not be NULL.
Returns
Zero upon success.

References cace_data_int_free(), cace_data_int_reset(), and CHKERR1.

◆ cace_data_cmp()

int cace_data_cmp ( const cace_data_t lt,
const cace_data_t rt 
)

Interface for M*LIB items.

References CHKRET, cace_data_t::len, and cace_data_t::ptr.

Referenced by cace_ari_cmp().

◆ cace_data_copy()

int cace_data_copy ( cace_data_t data,
const cace_data_t src 
)

Copy between two data structs, both already initialized.

Parameters
[in,out]dataThe data to copy to, which must not be NULL.
srcThe data to copy from, which must not be NULL.
Returns
Zero upon success.

References cace_data_copy_from(), cace_data_int_free(), CHKERR1, cace_data_t::len, and cace_data_t::ptr.

Referenced by cace_ari_set_bstr(), and cace_slash_unescape().

◆ cace_data_copy_from()

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.

Parameters
[in,out]dataThe data to copy into, which must not be NULL.
lenThe total length to allocate, which may be non-zero.
srcAn optional source buffer to copy from, from which len bytes will be copied.
Returns
Zero upon success.

References cace_data_int_reset(), cace_data_resize(), CHKERR1, cace_data_t::owned, and cace_data_t::ptr.

Referenced by cace_ari_cbor_decode_label(), cace_ari_cbor_decode_optdate(), cace_ari_cbor_decode_primval(), cace_ari_cbor_encode(), cace_ari_set_label_tstr(), cace_ari_set_tstr(), cace_data_copy(), cace_data_copy_from_cstr(), cace_data_from_m_string(), and cace_data_init_set().

◆ cace_data_copy_from_cstr()

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.

References cace_data_copy_from(), and CHKERR1.

◆ cace_data_deinit()

int cace_data_deinit ( cace_data_t data)

De-initialize a data struct, freeing if necessary.

Parameters
[in,out]dataThe data to de-initialize, which must not be NULL.
Returns
Zero upon success.
Postcondition
The struct must be initialized before using again.

References cace_data_int_free(), and CHKERR1.

Referenced by agentParseHex(), agentShowHexReports(), cace_amp_msg_decode(), cace_amp_msg_encode(), cace_amp_proxy_cli_recv(), cace_amp_proxy_cli_send(), cace_amp_proxy_msg_recv(), cace_amp_proxy_msg_send(), cace_ari_cbor_decode_optdate(), cace_ari_date_from_text(), cace_ari_lit_deinit(), cace_ari_text_encode_lit(), cace_slash_unescape(), check_cnst(), check_convert(), check_decoding(), check_encoding(), check_lookup(), check_match(), check_normalize(), LLVMFuzzerTestOneInput(), read_cborhex(), refdm_db_insert_execset(), refdm_db_insert_rptset(), stdin_recv(), stdout_send(), suiteSetUp(), test_ari_cmp(), test_ari_equal(), test_ari_hash(), test_cace_ari_cbor_decode_invalid(), test_cace_ari_cbor_decode_partial(), test_cace_ari_text_is_identity(), test_cace_base16_decode_invalid(), test_cace_base16_decode_valid(), test_cace_base16_encode(), test_cace_base64_decode_invalid(), test_cace_base64_decode_valid(), test_cace_date_decode_invalid(), test_cace_date_decode_valid(), test_cace_decfrac_decode_invalid(), test_cace_decfrac_decode_valid(), test_cace_slash_escape_valid(), test_cace_slash_unescape_invalid(), test_cace_slash_unescape_valid(), test_cace_timeperiod_decode_invalid(), test_cace_timeperiod_decode_valid(), test_cace_uri_percent_decode_invalid(), test_cace_uri_percent_decode_valid(), test_cace_uri_percent_encode_valid(), test_cace_utctime_decode_invalid(), test_cace_utctime_decode_valid(), TEST_CASE(), TEST_CASE(), TEST_CASE(), test_util_ari_decode(), test_util_ari_encode(), transform_cbor_str_to_cace_data(), write_cbor(), and write_cborhex().

◆ cace_data_equal()

bool cace_data_equal ( const cace_data_t lt,
const cace_data_t rt 
)

Interface for M*LIB items.

References CHKFALSE, cace_data_t::len, and cace_data_t::ptr.

Referenced by cace_ari_equal().

◆ cace_data_extend_back()

static int cace_data_extend_back ( cace_data_t data,
ssize_t  extra 
)
inlinestatic

Alter the size at the back of the array by a difference value.

Parameters
[in,out]dataThe data to resize, which must not be NULL.
extraThe difference of the desired size from the current size. This may be negative to shrink the data.
Returns
Zero upon success.

References cace_data_resize(), and cace_data_t::len.

Referenced by cace_base64_decode(), cace_data_append_byte(), and cace_data_append_from().

◆ cace_data_extend_front()

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.

Parameters
[in,out]dataThe data to resize, which must not be NULL.
extraThe difference of the desired size from the current size. This may be negative to shrink the data.
Returns
Zero upon success.

References cace_data_resize(), CHKERR1, cace_data_t::len, and cace_data_t::ptr.

Referenced by read_cbor().

◆ cace_data_from_m_string()

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.

Parameters
[in,out]dataThe data to copy to, which must not be NULL.
srcThe string to copy from, which must not be NULL.
Returns
Zero upon success.

References cace_data_copy_from().

◆ cace_data_hash()

size_t cace_data_hash ( const cace_data_t data)

Interface for M*LIB items.

References CHKRET, cace_data_t::len, and cace_data_t::ptr.

Referenced by cace_ari_hash_visit_lit().

◆ cace_data_init()

◆ cace_data_init_set()

int cace_data_init_set ( cace_data_t data,
const cace_data_t src 
)

◆ cace_data_init_view()

◆ cace_data_init_view_cstr()

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.

References cace_data_init_view(), and CHKERR1.

Referenced by cace_ari_date_from_text().

◆ cace_data_is_empty()

bool cace_data_is_empty ( const cace_data_t data)

References cace_data_t::len.

◆ cace_data_move()

void cace_data_move ( cace_data_t data,
cace_data_t src 
)

Move between two data structs, both already initialized.

Parameters
[in,out]dataThe data to move to, which must not be NULL.
[in,out]srcThe data to move from, which must not be NULL.

References cace_data_int_free(), cace_data_int_reset(), and CHKVOID.

◆ cace_data_resize()

int cace_data_resize ( cace_data_t data,
size_t  len 
)

Resize the data, copying if necessary.

Parameters
[in,out]dataThe data to resize, which must not be NULL.
lenThe new total size.
Returns
Zero upon success.

References cace_data_int_free(), cace_data_int_reset(), CACE_REALLOC, CHKERR1, cace_data_t::len, cace_data_t::owned, cace_data_t::ptr, and UNLIKELY.

Referenced by cace_base16_decode(), cace_base64_decode(), cace_data_copy_from(), cace_data_extend_back(), and cace_data_extend_front().

◆ cace_data_swap()

void cace_data_swap ( cace_data_t data,
cace_data_t other 
)

Swap between two data structs, both already initialized.

Parameters
[in,out]dataThe data to swap to, which must not be NULL.
[in,out]otherThe data to swap with, which must not be NULL.

References CHKVOID.

Referenced by cace_ari_set_bstr().