Imported Upstream version 1.1.1
[platform/upstream/iotivity.git] / resource / csdk / connectivity / lib / libcoap-4.1.1 / include / coap / coap_list.h
1 /* coap_list.h -- CoAP list structures
2  *
3  * Copyright (C) 2010,2011 Olaf Bergmann <bergmann@tzi.org>
4  *
5  * This file is part of the CoAP library libcoap. Please see
6  * README for terms of use.
7  */
8
9 #ifndef _COAP_LIST_H_
10 #define _COAP_LIST_H_
11
12 struct coap_linkedlistnode
13 {
14     struct coap_linkedlistnode *next;
15     void *data;
16
17     /**
18      * Callback function that is called from coap_delete to release
19      * additional memory allocated by data Set to NULL if you do not
20      * need this. Note that data is free'd automatically. */
21     void (*delete_func)(void *);
22 };
23
24 typedef struct coap_linkedlistnode coap_list_t;
25
26 /**
27  * Adds node to given queue, ordered by specified order function. Returns 1
28  * when insert was successful, 0 otherwise.
29  */
30 int coap_insert(coap_list_t **queue, coap_list_t *node, int (*order)(void *, void *));
31
32 /* destroys specified node */
33 int coap_delete(coap_list_t *node);
34
35 /* removes all items from given queue and frees the allocated storage */
36 void coap_delete_list(coap_list_t *queue);
37
38 /**
39  * Creates a new list node and adds the given data object. The memory allocated
40  * by data will be released by coap_delete() with the new node. Returns the
41  * new list node.
42  */
43 coap_list_t *coap_new_listnode(void *data, void (*delete_func)(void *));
44
45 #endif /* _COAP_LIST_H_ */