]> err.no Git - systemd/commitdiff
libudev: make list_node functions available
authorKay Sievers <kay.sievers@vrfy.org>
Fri, 17 Oct 2008 16:59:08 +0000 (18:59 +0200)
committerKay Sievers <kay.sievers@vrfy.org>
Fri, 17 Oct 2008 16:59:08 +0000 (18:59 +0200)
udev/lib/libudev-list.c
udev/lib/libudev-private.h

index 76c2f7e93bd1847ded8fb4eb3250b02cd656b063..606e3d5d630833c5b9e20b2e91ded0fcdcde5443 100644 (file)
@@ -43,14 +43,14 @@ void udev_list_init(struct udev_list_node *list)
        list->prev = list;
 }
 
-static int udev_list_is_empty(struct udev_list_node *list)
+int udev_list_is_empty(struct udev_list_node *list)
 {
        return list->next == list;
 }
 
 static void udev_list_node_insert_between(struct udev_list_node *new,
-                                    struct udev_list_node *prev,
-                                    struct udev_list_node *next)
+                                         struct udev_list_node *prev,
+                                         struct udev_list_node *next)
 {
        next->prev = new;
        new->next = next;
@@ -58,7 +58,12 @@ static void udev_list_node_insert_between(struct udev_list_node *new,
        prev->next = new;
 }
 
-static void udev_list_node_remove(struct udev_list_node *entry)
+void udev_list_node_append(struct udev_list_node *new, struct udev_list_node *list)
+{
+       udev_list_node_insert_between(new, list->prev, list);
+}
+
+void udev_list_node_remove(struct udev_list_node *entry)
 {
        struct udev_list_node *prev = entry->prev;
        struct udev_list_node *next = entry->next;
index 50c96571c537b8a182cf68d5098f4f7e6678d069..07f14917732c89c7288b10b92bf97da178806e50 100644 (file)
@@ -124,19 +124,29 @@ struct udev_list_node {
        struct udev_list_node *next, *prev;
 };
 extern void udev_list_init(struct udev_list_node *list);
-extern void udev_list_cleanup(struct udev *udev, struct udev_list_node *name_list);
+extern int udev_list_is_empty(struct udev_list_node *list);
+extern void udev_list_node_append(struct udev_list_node *new, struct udev_list_node *list);
+extern void udev_list_node_remove(struct udev_list_node *entry);
+#define udev_list_node_foreach(node, list) \
+       for (node = (list)->next; \
+            node != list; \
+            node = (node)->next)
+#define udev_list_node_foreach_safe(node, tmp, list) \
+       for (node = (list)->next, tmp = (node)->next; \
+            node != list; \
+            node = tmp, tmp = (tmp)->next)
 extern struct udev_list_entry *udev_list_entry_add(struct udev *udev, struct udev_list_node *list,
                                                   const char *name, const char *value,
                                                   int unique, int sort);
 extern void udev_list_entry_remove(struct udev_list_entry *entry);
+extern void udev_list_cleanup(struct udev *udev, struct udev_list_node *name_list);
 extern struct udev_list_entry *udev_list_get_entry(struct udev_list_node *list);
 extern void udev_list_entry_move_to_end(struct udev_list_entry *list_entry);
 extern void udev_list_entry_move_before(struct udev_list_entry *list_entry, struct udev_list_entry *entry);
 extern int udev_list_entry_get_flag(struct udev_list_entry *list_entry);
 extern void udev_list_entry_set_flag(struct udev_list_entry *list_entry, int flag);
 #define udev_list_entry_foreach_safe(entry, tmp, first) \
-       for (entry = first, \
-            tmp = udev_list_entry_get_next(entry); \
+       for (entry = first, tmp = udev_list_entry_get_next(entry); \
             entry != NULL; \
             entry = tmp, tmp = udev_list_entry_get_next(tmp))