Provided by: libcoap3_4.3.0-2build1_amd64 bug

NAME

       coap_string, coap_new_string, coap_delete_string, coap_new_str_const,
       coap_delete_str_const, coap_new_binary, coap_delete_binary, coap_resize_binary,
       coap_new_bin_const - Work with CoAP string functions

SYNOPSIS

       #include <coap3/coap.h>

       coap_string_t *coap_new_string(size_t size);

       void coap_delete_string(coap_string_t *string);

       coap_str_const_t *coap_new_str_const(const uint8_t *data, size_t size);

       void coap_delete_str_const(coap_str_const_t *string);

       coap_str_const_t *coap_make_str_const(const char *string);

       int coap_string_equal(coap_string_t *string1, coap_string_t *string2);

       coap_binary_t *coap_new_binary(size_t size);

       void coap_delete_binary(coap_binary_t *binary);

       coap_binary_t *coap_resize_binary(coap_binary_t *binary, size_t new_size);

       coap_bin_const_t *coap_new_bin_const(const uint8_t *data, size_t size);

       void coap_delete_bin_const(coap_bin_const_t *binary);

       int coap_binary_equal(coap_binary_t *binary1, coap_binary_t *binary2);

       For specific (D)TLS library support, link with -lcoap-3-notls, -lcoap-3-gnutls,
       -lcoap-3-openssl, -lcoap-3-mbedtls or -lcoap-3-tinydtls. Otherwise, link with -lcoap-3 to
       get the default (D)TLS library support.

DESCRIPTION

       There is support for storing strings (usually readable data) and for storing binary data.
       These are used by a number of functions and provide the information in some of the
       callbacks.

       There are 4 supported string/binary types as follows

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

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

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

           /*
            * Coap binary data definition with const data
            */
           typedef struct coap_bin_const_t {
             size_t length;    /* length of binary data */
             const uint8_t *s; /* read-only binary data */
           } coap_bin_const_t;

       The coap_new_string() function allocates a new coap_string_t of size where s points to
       uninitialized data of length size with an extra trailing NULL at size + 1. length is set
       to size.

       The coap_delete_string() function is used to delete the coap_string_t created by
       coap_new_string().

       The coap_new_str_const() function allocates a coap_str_const_t of size where s is filled
       in with data and has a trailing NULL added. length is set to size. s is read-only.

       The coap_delete_str_const() function is used to delete the coap_str_const_t created by
       coap_new_str_const().

       The coap_make_str_const() function is used to take some read-only text and uses a static
       coap_str_const_t for use in different function calls. There are two static entries that
       are cycled through so that a single function call can call coap_make_str_const() twice.

       The coap_string_equal() function is used to compare two different string objects string1
       and string2.

       The coap_new_binary() function allocates a new coap_binary_t of size where s points to
       uninitialized data of length size. length is set to size.

       The coap_resize_binary() function is used resize the size of s to the new size of
       new_size. The data between the old length and the new_size is unitialized. length is set
       to new_size.

       The coap_delete_binary() function is used to delete the coap_binary_t created by
       coap_new_binary().

       The coap_new_bin_const() function allocates a coap_bin_const_t of size where s is filled
       in with in with data and has a trailing NULL added. length is set to size. s is read-only.

       The coap_delete_bin_const() function is used to delete the coap_bin_const_t created by
       coap_new_bin_const().

       The coap_binary_equal() function is used to compare two different binary objects binary1
       and binary2.

RETURN VALUES

       The coap_new_string() function returns a pointer to an allocated coap_string_t or NULL if
       there was a failure.

       The coap_new_str_const() function returns a pointer to an allocated coap_str_const_t or
       NULL if there was a failure.

       The coap_new_binary() function returns a pointer to an allocated coap_binary_t or NULL if
       there was a failure.

       The coap_resize_binary() function returns a pointer to an re-allocated coap_binary_t or
       NULL if there was a failure.

       The coap_new_bin_const() function returns a pointer to an allocated coap_bin_const_t or
       NULL if there was a failure.

SEE ALSO

       coap_attribute(3), coap_context(3), coap_handler(3), coap_pdu_setup(3) and
       coap_resource(3)

FURTHER INFORMATION

       "RFC7252: The Constrained Application Protocol (CoAP)"

BUGS

       Please report bugs on the mailing list for libcoap:
       libcoap-developers@lists.sourceforge.net or raise an issue on GitHub at
       https://github.com/obgm/libcoap/issues

AUTHORS

       The libcoap project <libcoap-developers@lists.sourceforge.net>