CTaps 0.3.0
A C implementation of the Transport Services API (RFC 9621 - 9623)
Loading...
Searching...
No Matches
Message

Message and message context creation, and accessors. More...

Data Structures

struct  ct_message_t
 Opaque handle representing a single message to be sent or received. More...
 
struct  ct_message_context_t
 Opaque handle representing message metadata to pass to sending protocol. More...
 

Functions

void ct_message_free (ct_message_t *message)
 Free all resources in a message including the structure.
 
ct_message_tct_message_new (void)
 Allocate a new message on the heap.
 
ct_message_tct_message_new_with_content (const char *content, size_t length)
 Allocate a new message with content.
 
size_t ct_message_get_length (const ct_message_t *message)
 Get the length of a message.
 
ct_message_tct_message_deep_copy (const ct_message_t *message)
 Create a deep copy of a message, including its content.
 
const char * ct_message_get_content (const ct_message_t *message)
 Get the content buffer of a message.
 
void ct_message_set_content (ct_message_t *message, const void *content, size_t length)
 Set the content of a message, replacing any existing content.
 

Detailed Description

Message and message context creation, and accessors.

Function Documentation

◆ ct_message_deep_copy()

ct_message_t * ct_message_deep_copy ( const ct_message_t message)

Create a deep copy of a message, including its content.

Parameters
[in]messageMessage to copy
Returns
Pointer to newly allocated copy of the message, or NULL on failure

◆ ct_message_free()

void ct_message_free ( ct_message_t message)

Free all resources in a message including the structure.

Parameters
[in]messageMessage to free

◆ ct_message_get_content()

const char * ct_message_get_content ( const ct_message_t message)

Get the content buffer of a message.

Parameters
[in]messageMessage to query
Returns
Pointer to message content, or NULL if message is NULL

◆ ct_message_get_length()

size_t ct_message_get_length ( const ct_message_t message)

Get the length of a message.

Parameters
[in]messageMessage to query
Returns
Length of message in bytes, or 0 if message is NULL

◆ ct_message_new()

ct_message_t * ct_message_new ( void  )

Allocate a new message on the heap.

Note
The caller maintains ownership even after passing to send functions, CTaps makes deep copies internally.
Returns
Pointer to newly allocated message, or NULL on failure

◆ ct_message_new_with_content()

ct_message_t * ct_message_new_with_content ( const char *  content,
size_t  length 
)

Allocate a new message with content.

Parameters
[in]contentData buffer for the message
[in]lengthLength of data in bytes
Returns
Pointer to newly allocated message with content, or NULL on failure

◆ ct_message_set_content()

void ct_message_set_content ( ct_message_t message,
const void *  content,
size_t  length 
)

Set the content of a message, replacing any existing content.

Parameters
[in,out]messageMessage to modify
[in]contentNew data buffer for the message
[in]lengthLength of new data in bytes