basic/ordered-set: export networkd function to print string sets

Tests are added.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2019-02-21 12:00:05 +01:00
parent ef79eae09a
commit 53ae3f6467
4 changed files with 34 additions and 20 deletions
+17
View File
@@ -1,5 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1+ */
#include "fileio.h"
#include "ordered-set.h"
#include "strv.h"
@@ -63,3 +64,19 @@ int ordered_set_put_string_set(OrderedSet *s, OrderedSet *l) {
return n;
}
void ordered_set_print(FILE *f, const char *field, OrderedSet *s) {
bool space = false;
Iterator i;
char *p;
if (ordered_set_isempty(s))
return;
fputs(field, f);
ORDERED_SET_FOREACH(p, s, i)
fputs_with_space(f, p, NULL, &space);
fputc('\n', f);
}