forked from obgm/libcoap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcoap_list.c
66 lines (56 loc) · 1.4 KB
/
coap_list.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 * -*- */
/* coap_list.c -- CoAP list structures
*
* Copyright (C) 2010,2011,2015 Olaf Bergmann <[email protected]>
*
* SPDX-License-Identifier: BSD-2-Clause
*
* This file is part of the CoAP library libcoap. Please see README for terms of
* use.
*/
/*
* examples/coap_list.[ch] are DEPRECATED. You should be using
* struct coap_optlist_t instead with the following functions which are a part
* of libcoap.
*
* coap_new_optlist()
* coap_insert_optlist()
* coap_delete_optlist()
* coap_add_optlist_pdu()
*
* See 'man coap_pdu_setup' for further information.
*
* examples/coap_list.[ch] files will be removed in a future release
* They are left here to support building backward compatability of old versions
* of coap-client
*/
#include <stdio.h>
#include <string.h>
#include <coap3/coap.h>
int
coap_insert(coap_list_t **head, coap_list_t *node) {
if (!node) {
coap_log_warn("cannot create option Proxy-Uri\n");
} else {
/* must append at the list end to avoid re-ordering of
* options during sort */
LL_APPEND((*head), node);
}
return node != NULL;
}
int
coap_delete(coap_list_t *node) {
if (node) {
coap_free(node);
}
return 1;
}
void
coap_delete_list(coap_list_t *queue) {
coap_list_t *elt, *tmp;
if (!queue)
return;
LL_FOREACH_SAFE(queue, elt, tmp) {
coap_delete(elt);
}
}