X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fbasic%2Fstrv.c;h=5c8261d9210d240e767c9c0af831c1dec106a2d9;hp=7401c29081b5d98c9ce2bb002ea5ded2821bc360;hb=66ecc207e203db5434610395cd04c40ae8727b58;hpb=eaca07ccfdf5d7dabc50afc7e539c2413dd69d3e diff --git a/src/basic/strv.c b/src/basic/strv.c index 7401c2908..5c8261d92 100644 --- a/src/basic/strv.c +++ b/src/basic/strv.c @@ -1,5 +1,3 @@ -/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ - /*** This file is part of systemd. @@ -20,12 +18,16 @@ ***/ #include +#include #include +#include #include #include #include "alloc-util.h" #include "escape.h" +#include "extract-word.h" +//#include "fileio.h" #include "string-util.h" #include "strv.h" #include "util.h" @@ -200,6 +202,7 @@ char **strv_new(const char *x, ...) { return r; } +#if 0 /// UNNEEDED by elogind int strv_extend_strv(char ***a, char **b, bool filter_duplicates) { char **s, **t; size_t p, q, i = 0, j; @@ -244,8 +247,6 @@ rollback: return -ENOMEM; } -/// UNNEEDED by elogind -#if 0 int strv_extend_strv_concat(char ***a, char **b, const char *suffix) { int r; char **s; @@ -299,8 +300,7 @@ char **strv_split(const char *s, const char *separator) { return r; } -/// UNNEEDED by elogind -#if 0 +#if 0 /// UNNEEDED by elogind char **strv_split_newlines(const char *s) { char **l; unsigned n; @@ -397,8 +397,7 @@ char *strv_join(char **l, const char *separator) { return r; } -/// UNNEEDED by elogind -#if 0 +#if 0 /// UNNEEDED by elogind char *strv_join_quoted(char **l) { char *buf = NULL; char **s; @@ -530,8 +529,7 @@ int strv_consume(char ***l, char *value) { return r; } -/// UNNEEDED by elogind -#if 0 +#if 0 /// UNNEEDED by elogind int strv_consume_pair(char ***l, char *a, char *b) { int r; @@ -580,8 +578,7 @@ char **strv_uniq(char **l) { return l; } -/// UNNEEDED by elogind -#if 0 +#if 0 /// UNNEEDED by elogind bool strv_is_uniq(char **l) { char **i; @@ -676,8 +673,7 @@ char **strv_split_nulstr(const char *s) { return r; } -/// UNNEEDED by elogind -#if 0 +#if 0 /// UNNEEDED by elogind int strv_make_nulstr(char **l, char **p, size_t *q) { size_t n_allocated = 0, n = 0; _cleanup_free_ char *m = NULL; @@ -739,8 +735,7 @@ char **strv_sort(char **l) { return l; } -/// UNNEEDED by elogind -#if 0 +#if 0 /// UNNEEDED by elogind bool strv_equal(char **a, char **b) { if (strv_isempty(a)) @@ -888,4 +883,23 @@ rollback: nl[k] = NULL; return -ENOMEM; } + +int fputstrv(FILE *f, char **l, const char *separator, bool *space) { + bool b = false; + char **s; + int r; + + /* Like fputs(), but for strv, and with a less stupid argument order */ + + if (!space) + space = &b; + + STRV_FOREACH(s, l) { + r = fputs_with_space(f, *s, separator, space); + if (r < 0) + return r; + } + + return 0; +} #endif // 0