2010-12-06 03:51:58 +01:00
|
|
|
#ifndef __UBUSD_ID_H
|
|
|
|
#define __UBUSD_ID_H
|
|
|
|
|
|
|
|
#include <libubox/avl.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
struct ubus_id {
|
|
|
|
struct avl_node avl;
|
|
|
|
uint32_t id;
|
|
|
|
};
|
|
|
|
|
|
|
|
void ubus_init_id_tree(struct avl_tree *tree);
|
2011-02-05 01:29:52 +01:00
|
|
|
void ubus_init_string_tree(struct avl_tree *tree, bool dup);
|
2011-02-05 00:21:27 +01:00
|
|
|
bool ubus_alloc_id(struct avl_tree *tree, struct ubus_id *id, uint32_t val);
|
2010-12-06 03:51:58 +01:00
|
|
|
|
|
|
|
static inline void ubus_free_id(struct avl_tree *tree, struct ubus_id *id)
|
|
|
|
{
|
|
|
|
avl_delete(tree, &id->avl);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline struct ubus_id *ubus_find_id(struct avl_tree *tree, uint32_t id)
|
|
|
|
{
|
|
|
|
struct avl_node *avl;
|
|
|
|
|
|
|
|
avl = avl_find(tree, &id);
|
|
|
|
if (!avl)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return container_of(avl, struct ubus_id, avl);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|