add an inline function to add the ubus socket to uloop
[project/ubus.git] / ubusd_id.h
1 #ifndef __UBUSD_ID_H
2 #define __UBUSD_ID_H
3
4 #include <libubox/avl.h>
5 #include <stdint.h>
6
7 struct ubus_id {
8         struct avl_node avl;
9         uint32_t id;
10 };
11
12 void ubus_init_id_tree(struct avl_tree *tree);
13 bool ubus_alloc_id(struct avl_tree *tree, struct ubus_id *id);
14
15 static inline void ubus_free_id(struct avl_tree *tree, struct ubus_id *id)
16 {
17         avl_delete(tree, &id->avl);
18 }
19
20 static inline struct ubus_id *ubus_find_id(struct avl_tree *tree, uint32_t id)
21 {
22         struct avl_node *avl;
23
24         avl = avl_find(tree, &id);
25         if (!avl)
26                 return NULL;
27
28         return container_of(avl, struct ubus_id, avl);
29 }
30
31 #endif