strv.h revision d7832d2c6e0ef5f2839a2296c1cc2fc85c7d9632
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering#ifndef foostrvhfoo
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering#define foostrvhfoo
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering/***
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering This file is part of systemd.
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering Copyright 2010 Lennart Poettering
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering systemd is free software; you can redistribute it and/or modify it
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering under the terms of the GNU General Public License as published by
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering the Free Software Foundation; either version 2 of the License, or
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering (at your option) any later version.
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering systemd is distributed in the hope that it will be useful, but
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering WITHOUT ANY WARRANTY; without even the implied warranty of
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering General Public License for more details.
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering You should have received a copy of the GNU General Public License
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering along with systemd; If not, see <http://www.gnu.org/licenses/>.
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering***/
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering
1ca208fb4f93e5869704af1812cbff7130a2fc03Zbigniew Jędrzejewski-Szmek#include <stdarg.h>
1ca208fb4f93e5869704af1812cbff7130a2fc03Zbigniew Jędrzejewski-Szmek#include <stdbool.h>
938d2699d2e818bd996614e89ea3d668200ad2a8Zbigniew Jędrzejewski-Szmek
3731acf1acfb4a6eb68374a5b137f3b368f63381Lennart Poettering#include "macro.h"
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poetteringchar *strv_find(char **l, const char *name);
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poetteringchar *strv_find_prefix(char **l, const char *name);
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poetteringvoid strv_free(char **l);
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poetteringchar **strv_copy(char **l) _malloc_;
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poetteringunsigned strv_length(char **l);
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poetteringchar **strv_merge(char **a, char **b);
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poetteringchar **strv_merge_concat(char **a, char **b, const char *suffix);
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poetteringchar **strv_append(char **l, const char *s);
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poetteringchar **strv_remove(char **l, const char *s);
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poetteringchar **strv_uniq(char **l);
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering#define strv_contains(l, s) (!!strv_find((l), (s)))
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poetteringchar **strv_new(const char *x, ...) _sentinel_ _malloc_;
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poetteringchar **strv_new_ap(const char *x, va_list ap) _malloc_;
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poetteringstatic inline bool strv_isempty(char **l) {
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering return !l || !*l;
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering}
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poetteringchar **strv_split(const char *s, const char *separator) _malloc_;
938d2699d2e818bd996614e89ea3d668200ad2a8Zbigniew Jędrzejewski-Szmekchar **strv_split_quoted(const char *s) _malloc_;
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poetteringchar *strv_join(char **l, const char *separator) _malloc_;
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poetteringchar **strv_env_merge(unsigned n_lists, ...);
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poetteringchar **strv_env_delete(char **x, unsigned n_lists, ...);
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poetteringchar **strv_env_set(char **x, const char *p);
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poetteringchar **strv_env_unset(char **l, const char *p);
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poetteringchar *strv_env_get_with_length(char **l, const char *name, size_t k);
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poetteringchar *strv_env_get(char **x, const char *n);
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poetteringchar **strv_env_clean(char **l);
39883f622f392d8579f4428fc5a789a102efbb10Lennart Poettering
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poetteringchar **strv_parse_nulstr(const char *s, size_t l);
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering
938d2699d2e818bd996614e89ea3d668200ad2a8Zbigniew Jędrzejewski-Szmekbool strv_overlap(char **a, char **b);
938d2699d2e818bd996614e89ea3d668200ad2a8Zbigniew Jędrzejewski-Szmek
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering#define STRV_FOREACH(s, l) \
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering for ((s) = (l); (s) && *(s); (s)++)
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering#define STRV_FOREACH_BACKWARDS(s, l) \
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering for (; (l) && ((s) >= (l)); (s)--)
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering#endif
0f4ba83c397e807939a4eb0b2cbd04ad4ab548ccLennart Poettering