1COAP_STRING(3)                  libcoap Manual                  COAP_STRING(3)
2
3
4

NAME

6       coap_string, coap_new_string, coap_delete_string, coap_new_str_const,
7       coap_delete_str_const, coap_new_binary, coap_delete_binary,
8       coap_resize_binary, coap_new_bin_const - Work with CoAP string
9       functions
10

SYNOPSIS

12       #include <coap3/coap.h>
13
14       coap_string_t *coap_new_string(size_t size);
15
16       void coap_delete_string(coap_string_t *string);
17
18       coap_str_const_t *coap_new_str_const(const uint8_t *data, size_t size);
19
20       void coap_delete_str_const(coap_str_const_t *string);
21
22       coap_str_const_t *coap_make_str_const(const char *string);
23
24       int coap_string_equal(coap_string_t *string1, coap_string_t *string2);
25
26       coap_binary_t *coap_new_binary(size_t size);
27
28       void coap_delete_binary(coap_binary_t *binary);
29
30       coap_binary_t *coap_resize_binary(coap_binary_t *binary, size_t
31       new_size);
32
33       coap_bin_const_t *coap_new_bin_const(const uint8_t *data, size_t size);
34
35       void coap_delete_bin_const(coap_bin_const_t *binary);
36
37       int coap_binary_equal(coap_binary_t *binary1, coap_binary_t *binary2);
38
39       For specific (D)TLS library support, link with -lcoap-3-notls,
40       -lcoap-3-gnutls, -lcoap-3-openssl, -lcoap-3-mbedtls or
41       -lcoap-3-tinydtls. Otherwise, link with -lcoap-3 to get the default
42       (D)TLS library support.
43

DESCRIPTION

45       There is support for storing strings (usually readable data) and for
46       storing binary data. These are used by a number of functions and
47       provide the information in some of the callbacks.
48
49       There are 4 supported string/binary types as follows
50
51           /*
52            * Coap string data definition
53            */
54           typedef struct coap_string_t {
55             size_t length;    /* length of string */
56             uint8_t *s;       /* string data */
57           } coap_string_t;
58
59           /*
60            * Coap string data definition with const data
61            */
62           typedef struct coap_str_const_t {
63             size_t length;    /* length of string */
64             const uint8_t *s; /* read-only string data */
65           } coap_str_const_t;
66
67           /*
68            * Coap binary data definition
69            */
70           typedef struct coap_binary_t {
71             size_t length;    /* length of binary data */
72             uint8_t *s;       /* binary data */
73           } coap_binary_t;
74
75           /*
76            * Coap binary data definition with const data
77            */
78           typedef struct coap_bin_const_t {
79             size_t length;    /* length of binary data */
80             const uint8_t *s; /* read-only binary data */
81           } coap_bin_const_t;
82
83       The coap_new_string() function allocates a new coap_string_t of size
84       where s points to uninitialized data of length size with an extra
85       trailing NULL at size + 1. length is set to size.
86
87       The coap_delete_string() function is used to delete the coap_string_t
88       created by coap_new_string().
89
90       The coap_new_str_const() function allocates a coap_str_const_t of size
91       where s is filled in with data and has a trailing NULL added. length is
92       set to size. s is read-only.
93
94       The coap_delete_str_const() function is used to delete the
95       coap_str_const_t created by coap_new_str_const().
96
97       The coap_make_str_const() function is used to take some read-only text
98       and uses a static coap_str_const_t for use in different function calls.
99       There are two static entries that are cycled through so that a single
100       function call can call coap_make_str_const() twice.
101
102       The coap_string_equal() function is used to compare two different
103       string objects string1 and string2.
104
105       The coap_new_binary() function allocates a new coap_binary_t of size
106       where s points to uninitialized data of length size. length is set to
107       size.
108
109       The coap_resize_binary() function is used resize the size of s to the
110       new size of new_size. The data between the old length and the new_size
111       is unitialized. length is set to new_size.
112
113       The coap_delete_binary() function is used to delete the coap_binary_t
114       created by coap_new_binary().
115
116       The coap_new_bin_const() function allocates a coap_bin_const_t of size
117       where s is filled in with in with data and has a trailing NULL added.
118       length is set to size. s is read-only.
119
120       The coap_delete_bin_const() function is used to delete the
121       coap_bin_const_t created by coap_new_bin_const().
122
123       The coap_binary_equal() function is used to compare two different
124       binary objects binary1 and binary2.
125

RETURN VALUES

127       The coap_new_string() function returns a pointer to an allocated
128       coap_string_t or NULL if there was a failure.
129
130       The coap_new_str_const() function returns a pointer to an allocated
131       coap_str_const_t or NULL if there was a failure.
132
133       The coap_new_binary() function returns a pointer to an allocated
134       coap_binary_t or NULL if there was a failure.
135
136       The coap_resize_binary() function returns a pointer to an re-allocated
137       coap_binary_t or NULL if there was a failure.
138
139       The coap_new_bin_const() function returns a pointer to an allocated
140       coap_bin_const_t or NULL if there was a failure.
141

SEE ALSO

143       coap_attribute(3), coap_context(3), coap_handler(3), coap_pdu_setup(3)
144       and coap_resource(3)
145

FURTHER INFORMATION

147       "RFC7252: The Constrained Application Protocol (CoAP)"
148

BUGS

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

AUTHORS

155       The libcoap project <libcoap-developers@lists.sourceforge.net>
156
157
158
159coap_string 4.3.0                 01/20/2022                    COAP_STRING(3)
Impressum