lua: add a prototype for luaopen_ubus so that -Wmissing-declarations can be enabled
[project/ubus.git] / ubusd_id.c
index 44b509e..5c152cd 100644 (file)
@@ -1,3 +1,16 @@
+/*
+ * Copyright (C) 2011 Felix Fietkau <nbd@openwrt.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 2.1
+ * as published by the Free Software Foundation
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -18,6 +31,16 @@ static int ubus_cmp_id(const void *k1, const void *k2, void *ptr)
                return *id1 > *id2;
 }
 
+static int ubus_cmp_str(const void *k1, const void *k2, void *ptr)
+{
+       return strcmp(k1, k2);
+}
+
+void ubus_init_string_tree(struct avl_tree *tree, bool dup)
+{
+       avl_init(tree, ubus_cmp_str, dup, NULL);
+}
+
 void ubus_init_id_tree(struct avl_tree *tree)
 {
        if (random_fd < 0) {