diff options
author | Alasdair Kergon <agk@redhat.com> | 2004-03-08 15:23:01 +0000 |
---|---|---|
committer | Alasdair Kergon <agk@redhat.com> | 2004-03-08 15:23:01 +0000 |
commit | 5071196631d9f96b977b492558c48f5b66020c8b (patch) | |
tree | b0a4ec25889c56a72b4f0e7899f2620ec9307db8 /lib/datastruct/str_list.c | |
parent | 02cb3ccdc478b88ebb678c379a085b6b7f758c87 (diff) | |
download | lvm2-5071196631d9f96b977b492558c48f5b66020c8b.tar.gz lvm2-5071196631d9f96b977b492558c48f5b66020c8b.tar.xz lvm2-5071196631d9f96b977b492558c48f5b66020c8b.zip |
More str_list fns.
Diffstat (limited to 'lib/datastruct/str_list.c')
-rw-r--r-- | lib/datastruct/str_list.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/lib/datastruct/str_list.c b/lib/datastruct/str_list.c index b414b51e..dc1e59c1 100644 --- a/lib/datastruct/str_list.c +++ b/lib/datastruct/str_list.c @@ -57,6 +57,25 @@ int str_list_del(struct list *sll, const char *str) return 1; } +int str_list_dup(struct pool *mem, struct list *sllnew, struct list *sllold) +{ + struct str_list *sl; + + list_init(sllnew); + + list_iterate_items(sl, sllold) { + if (!str_list_add(mem, sllnew, strdup(sl->str))) { + stack; + return 0; + } + } + + return 1; +} + +/* + * Is item on list? + */ int str_list_match_item(struct list *sll, const char *str) { struct str_list *sl; @@ -68,6 +87,9 @@ int str_list_match_item(struct list *sll, const char *str) return 0; } +/* + * Is at least one item on both lists? + */ int str_list_match_list(struct list *sll, struct list *sll2) { struct str_list *sl; @@ -78,3 +100,20 @@ int str_list_match_list(struct list *sll, struct list *sll2) return 0; } + +/* + * Do both lists contain the same set of items? + */ +int str_list_lists_equal(struct list *sll, struct list *sll2) +{ + struct str_list *sl; + + if (list_size(sll) != list_size(sll2)) + return 0; + + list_iterate_items(sl, sll) + if (!str_list_match_item(sll2, sl->str)) + return 0; + + return 1; +} |