strv.h revision e21fea24ae2a7a04f6d5c9d2bbbaf5833d248952
813e3a6ffcd094696001716480bbd68008cc54c8Patrik Flykt/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
813e3a6ffcd094696001716480bbd68008cc54c8Patrik Flykt This file is part of systemd.
813e3a6ffcd094696001716480bbd68008cc54c8Patrik Flykt Copyright 2010 Lennart Poettering
813e3a6ffcd094696001716480bbd68008cc54c8Patrik Flykt systemd is free software; you can redistribute it and/or modify it
813e3a6ffcd094696001716480bbd68008cc54c8Patrik Flykt under the terms of the GNU Lesser General Public License as published by
813e3a6ffcd094696001716480bbd68008cc54c8Patrik Flykt the Free Software Foundation; either version 2.1 of the License, or
813e3a6ffcd094696001716480bbd68008cc54c8Patrik Flykt (at your option) any later version.
813e3a6ffcd094696001716480bbd68008cc54c8Patrik Flykt systemd is distributed in the hope that it will be useful, but
813e3a6ffcd094696001716480bbd68008cc54c8Patrik Flykt WITHOUT ANY WARRANTY; without even the implied warranty of
813e3a6ffcd094696001716480bbd68008cc54c8Patrik Flykt MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
813e3a6ffcd094696001716480bbd68008cc54c8Patrik Flykt Lesser General Public License for more details.
813e3a6ffcd094696001716480bbd68008cc54c8Patrik Flykt You should have received a copy of the GNU Lesser General Public License
813e3a6ffcd094696001716480bbd68008cc54c8Patrik Flykt along with systemd; If not, see <http://www.gnu.org/licenses/>.
2ea8857effb833615b16d10fc7a19a7104c19e13Patrik Flyktchar *strv_find(char **l, const char *name) _pure_;
813e3a6ffcd094696001716480bbd68008cc54c8Patrik Flyktchar *strv_find_prefix(char **l, const char *name) _pure_;
813e3a6ffcd094696001716480bbd68008cc54c8Patrik Flyktvoid strv_free(char **l);
2ea8857effb833615b16d10fc7a19a7104c19e13Patrik Flyktstatic inline void strv_freep(char ***l) {
f12ed3bf0b315fc88d5fbdf5bdca14b218c86e0cPatrik Flykt#define _cleanup_strv_free_ _cleanup_(strv_freep)
813e3a6ffcd094696001716480bbd68008cc54c8Patrik Flyktchar **strv_copy(char * const *l);
813e3a6ffcd094696001716480bbd68008cc54c8Patrik Flyktchar **strv_merge(char **a, char **b);
813e3a6ffcd094696001716480bbd68008cc54c8Patrik Flyktchar **strv_merge_concat(char **a, char **b, const char *suffix);
813e3a6ffcd094696001716480bbd68008cc54c8Patrik Flyktchar **strv_append(char **l, const char *s);
813e3a6ffcd094696001716480bbd68008cc54c8Patrik Flyktchar **strv_appendf(char **l, const char *format, ...) _printf_attr_(2, 3);
5e256ea7d3d556b3a1fb5c1faa94ec6a8833e53ePatrik Flyktchar **strv_remove(char **l, const char *s);
5e256ea7d3d556b3a1fb5c1faa94ec6a8833e53ePatrik Flyktchar **strv_remove_prefix(char **l, const char *s);
5e256ea7d3d556b3a1fb5c1faa94ec6a8833e53ePatrik Flyktchar **strv_uniq(char **l);
813e3a6ffcd094696001716480bbd68008cc54c8Patrik Flykt#define strv_contains(l, s) (!!strv_find((l), (s)))
813e3a6ffcd094696001716480bbd68008cc54c8Patrik Flyktstatic inline const char* STRV_IFNOTNULL(const char *x) {
813e3a6ffcd094696001716480bbd68008cc54c8Patrik Flykt return x ? x : (const char *) -1;
813e3a6ffcd094696001716480bbd68008cc54c8Patrik Flyktstatic inline bool strv_isempty(char * const *l) {
813e3a6ffcd094696001716480bbd68008cc54c8Patrik Flykt return !l || !*l;
813e3a6ffcd094696001716480bbd68008cc54c8Patrik Flyktchar **strv_split(const char *s, const char *separator);
813e3a6ffcd094696001716480bbd68008cc54c8Patrik Flyktchar **strv_split_quoted(const char *s);
813e3a6ffcd094696001716480bbd68008cc54c8Patrik Flyktchar **strv_split_newlines(const char *s);
813e3a6ffcd094696001716480bbd68008cc54c8Patrik Flyktchar *strv_join(char **l, const char *separator);
da6fe470e17fa02f3adedc779585caf8669252bdPatrik Flyktchar **strv_parse_nulstr(const char *s, size_t l);
da6fe470e17fa02f3adedc779585caf8669252bdPatrik Flyktchar **strv_split_nulstr(const char *s);
da6fe470e17fa02f3adedc779585caf8669252bdPatrik Flykt#define STRV_FOREACH(s, l) \
813e3a6ffcd094696001716480bbd68008cc54c8Patrik Flykt for ((s) = (l); (s) && *(s); (s)++)
813e3a6ffcd094696001716480bbd68008cc54c8Patrik Flykt for (; (l) && ((s) >= (l)); (s)--)
813e3a6ffcd094696001716480bbd68008cc54c8Patrik Flykt#define STRV_FOREACH_PAIR(x, y, l) \
813e3a6ffcd094696001716480bbd68008cc54c8Patrik Flykt for ((x) = (l), (y) = (x+1); (x) && *(x) && *(y); (x) += 2, (y) = (x + 1))
f12ed3bf0b315fc88d5fbdf5bdca14b218c86e0cPatrik Flyktchar **strv_sort(char **l);
f12ed3bf0b315fc88d5fbdf5bdca14b218c86e0cPatrik Flyktvoid strv_print(char **l);