add some stub functionality for the ubus event switch
[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 void ubus_init_string_tree(struct avl_tree *tree, bool dup);
14 bool ubus_alloc_id(struct avl_tree *tree, struct ubus_id *id, uint32_t val);
15
16 static inline void ubus_free_id(struct avl_tree *tree, struct ubus_id *id)
17 {
18 avl_delete(tree, &id->avl);
19 }
20
21 static inline struct ubus_id *ubus_find_id(struct avl_tree *tree, uint32_t id)
22 {
23 struct avl_node *avl;
24
25 avl = avl_find(tree, &id);
26 if (!avl)
27 return NULL;
28
29 return container_of(avl, struct ubus_id, avl);
30 }
31
32 #endif