Documentation

Documentation

Includes

string.h

#include <string.h>
#include 

Macros

Marco COAP_STR_H_

#define COAP_STR_H_


      

Marco COAP_SET_STR(st,l,v)

#define COAP_SET_STR(st,l,v) { (st)->length = (l), (st)->s = (v); }


      

Marco coap_make_str_const(CStr)

#define coap_make_str_const(CStr)                                      \
 libcoap::CoAPStrConst{sizeof(CStr)-1, reinterpret_cast(CStr)}


      

Marco coap_make_str_const(string)

#define coap_make_str_const(string)                                    \
 (&(coap_str_const_t){sizeof(string)-1,(const uint8_t *)(string)})


      

Marco coap_string_equal(string1,string2)

#define coap_string_equal(string1,string2) \
       ((string1)->length == (string2)->length && ((string1)->length == 0 || \
        memcmp((string1)->s, (string2)->s, (string1)->length) == 0))
/**
 * Compares the two strings for equality
 *
 * @param string1 The first string.
 * @param string2 The second string.
 *
 * @return         @c 1 if the strings are equal
 *                 @c 0 otherwise.
 */

Functions

Func coap_delete_string

void coap_delete_string(coap_string_t *string);
/**
 * Deletes the given string and releases any memory allocated.
 *
 * @param string The string to free off.
 */

Func coap_delete_str_const

void coap_delete_str_const(coap_str_const_t *string);
/**
 * Deletes the given const string and releases any memory allocated.
 *
 * @param string The string to free off.
 */

Vars

Variable coap_string_t

coap_string_t *coap_new_string(size_t size);
/**
 * Returns a new string object with at least size+1 bytes storage allocated.
 * The string must be released using coap_delete_string().
 *
 * @param size The size to allocate for the binary string data.
 *
 * @return       A pointer to the new object or @c NULL on error.
 */

Variable coap_str_const_t

coap_str_const_t *coap_new_str_const(const uint8_t *data, size_t size);
/**
 * 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().
 *
 * @param data The data to put in the new string object.
 * @param size The size to allocate for the binary string data.
 *
 * @return       A pointer to the new object or @c NULL on error.
 */

Consts

Types

Typedefs

Typedef coap_string_t;

typedef struct coap_string_t {
 size_t length;   /**< length of string */
 uint8_t *s;      /**< string data */
} coap_string_t;
/**
 * Coap string data definition
 */

Typedef coap_str_const_t;

typedef struct coap_str_const_t {
 size_t length;   /**< length of string */
 const uint8_t *s; /**< string data */
} coap_str_const_t;
/**
 * Coap string data definition with const data
 */

Typedef coap_binary_t;

typedef struct coap_binary_t {
 size_t length;   /**< length of binary data */
 uint8_t *s;      /**< binary data */
} coap_binary_t;
/**
 * Coap binary data definition
 */