API functions for handling strings and binary data.
More...
API functions for handling strings and binary data.
◆ coap_binary_equal
#define coap_binary_equal |
( |
|
binary1, |
|
|
|
binary2 |
|
) |
| |
Value: ((binary1)->length == (binary2)->length && ((binary1)->length == 0 || \
((binary1)->s && (binary2)->s && \
memcmp((binary1)->s, (binary2)->s, (binary1)->length) == 0)))
Compares the two binary data for equality.
- Parameters
-
binary1 | The first binary data. |
binary2 | The second binary data. |
- Returns
1
if the binary data is equal 0
otherwise.
Definition at line 197 of file str.h.
◆ COAP_MAX_STR_CONST_FUNC
#define COAP_MAX_STR_CONST_FUNC 2 |
◆ COAP_SET_STR
#define COAP_SET_STR |
( |
|
st, |
|
|
|
l, |
|
|
|
v |
|
) |
| { (st)->length = (l), (st)->s = (v); } |
Definition at line 45 of file str.h.
◆ coap_string_equal
#define coap_string_equal |
( |
|
string1, |
|
|
|
string2 |
|
) |
| |
Value: ((string1)->length == (string2)->length && ((string1)->length == 0 || \
((string1)->s && (string2)->s && \
memcmp((string1)->s, (string2)->s, (string1)->length) == 0)))
Compares the two strings for equality.
- Parameters
-
string1 | The first string. |
string2 | The second string. |
- Returns
1
if the strings are equal 0
otherwise.
Definition at line 183 of file str.h.
◆ coap_bin_const_t
CoAP binary data definition with const data.
◆ coap_binary_t
CoAP binary data definition.
◆ coap_str_const_t
CoAP string data definition with const data.
◆ coap_string_t
CoAP string data definition.
◆ coap_delete_bin_const()
Deletes the given const binary data and releases any memory allocated.
- Parameters
-
binary | The binary data to free off. |
Definition at line 104 of file str.c.
◆ coap_delete_binary()
Deletes the given coap_binary_t object and releases any memory allocated.
- Parameters
-
Definition at line 91 of file str.c.
◆ coap_delete_str_const()
Deletes the given const string and releases any memory allocated.
- Parameters
-
string | The string to free off. |
Definition at line 53 of file str.c.
◆ coap_delete_string()
Deletes the given string and releases any memory allocated.
- Parameters
-
string | The string to free off. |
Definition at line 40 of file str.c.
◆ coap_make_str_const()
Take the specified byte array (text) and create a coap_str_const_t *.
Note: the array is 2 deep as there are up to two callings of coap_make_str_const in a function call. e.g. coap_add_attr(). Caution: If there are local variable assignments, these will cycle around the var[COAP_MAX_STR_CONST_FUNC] set. No current examples do this.
- Parameters
-
- Returns
- A pointer to one of two static variables containing the coap_str_const_t * result
Definition at line 57 of file str.c.
◆ coap_new_bin_const()
Take the specified byte array (text) and create a coap_bin_const_t * Returns a new const binary object with at least size bytes storage allocated, and the provided data copied into the binary object.
The binary data must be released using coap_delete_bin_const().
- Parameters
-
data | The data to put in the new string object. |
size | The size to allocate for the binary data. |
- Returns
- A pointer to the new object or
NULL
on error.
Definition at line 95 of file str.c.
◆ coap_new_binary()
Returns a new binary object with at least size bytes storage allocated.
It is the responsibility of the caller to fill in all the appropriate information. The coap_binary_t object must be released using coap_delete_binary().
- Parameters
-
size | The size to allocate for the binary data. |
- Returns
- A pointer to the new object or
NULL
on error.
Definition at line 67 of file str.c.
◆ coap_new_str_const()
Returns a new const string object with at least size+1 bytes storage allocated, and the provided data copied into the string object.
The string must be released using coap_delete_str_const().
- Parameters
-
data | The data to put in the new string object. |
size | The size to allocate for the binary string data. |
- Returns
- A pointer to the new object or
NULL
on error.
Definition at line 44 of file str.c.
◆ coap_new_string()
Returns a new string object with at least size+1 bytes storage allocated.
It is the responsibility of the caller to fill in all the appropriate information. The string must be released using coap_delete_string().
- Parameters
-
size | The size to allocate for the string data. |
- Returns
- A pointer to the new object or
NULL
on error.
Definition at line 15 of file str.c.
◆ coap_resize_binary()
Resizes the given coap_binary_t object.
It is the responsibility of the caller to fill in all the appropriate additional information.
Note: If there is an error, binary
will separately need to be released by coap_delete_binary().
- Parameters
-
binary | The coap_binary_t object to resize. |
new_size | The new size to allocate for the binary data. |
- Returns
- A pointer to the new object or
NULL
on error.
Definition at line 71 of file str.c.