API functions for handling strings.
More...
API functions for handling strings.
◆ coap_make_str_const
Take the specified byte array (text) and create a coap_str_const_t *.
WARNING: The byte array must be in the local scope and not a parameter in the function call as sizeof() will return the size of the pointer, not the size of the byte array, leading to unxepected results.
- Parameters
-
Definition at line 102 of file str.h.
◆ COAP_SET_STR
#define COAP_SET_STR |
( |
|
st, |
|
|
|
l, |
|
|
|
v |
|
) |
| { (st)->length = (l), (st)->s = (v); } |
Definition at line 38 of file str.h.
◆ coap_string_equal
#define coap_string_equal |
( |
|
string1, |
|
|
|
string2 |
|
) |
| |
Value:((string1)->length == (string2)->length && ((string1)->length == 0 || \
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 115 of file str.h.
◆ 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_str_const()
Deletes the given const string and releases any memory allocated.
- Parameters
-
string | The string to free off. |
Definition at line 47 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 34 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 38 of file str.c.
◆ coap_new_string()
Returns a new string object with at least size+1 bytes storage allocated.
The string must be released using coap_delete_string().
- Parameters
-
size | The size to allocate for the binary string data. |
- Returns
- A pointer to the new object or
NULL
on error.
Definition at line 18 of file str.c.