strv.h revision bcd8e6d1bd3f434af894faeb400fee0e99445a7f
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering This file is part of systemd.
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering Copyright 2010 Lennart Poettering
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering systemd is free software; you can redistribute it and/or modify it
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering under the terms of the GNU Lesser General Public License as published by
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering the Free Software Foundation; either version 2.1 of the License, or
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering (at your option) any later version.
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering systemd is distributed in the hope that it will be useful, but
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering WITHOUT ANY WARRANTY; without even the implied warranty of
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering Lesser General Public License for more details.
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering You should have received a copy of the GNU Lesser General Public License
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering along with systemd; If not, see <http://www.gnu.org/licenses/>.
3ffd4af22052963e7a29431721ee204e634bea75Lennart Poetteringchar *strv_find(char **l, const char *name) _pure_;
96aad8d15a324d0e956a4e5653a11a67b209b41aLennart Poetteringchar *strv_find_prefix(char **l, const char *name) _pure_;
23c80348e656a4e6fd9ba8f17523a65b6fa349a0Kay Sieversvoid strv_free(char **l);
3ffd4af22052963e7a29431721ee204e634bea75Lennart Poetteringstatic inline void strv_freep(char ***l) {
3ffd4af22052963e7a29431721ee204e634bea75Lennart Poettering#define _cleanup_strv_free_ _cleanup_(strv_freep)
4cee5eede280b7fd48c18a1942616c4ac896a554Lennart Poetteringchar **strv_copy(char * const *l);
c335068380fe8c9d843cdb2cf8a00f822cfabed3Lennart Poetteringunsigned strv_length(char * const *l) _pure_;
3ffd4af22052963e7a29431721ee204e634bea75Lennart Poetteringchar **strv_merge(char **a, char **b);
15a5e95075a7f6007dd97b2a165c8ed16fe683dfLennart Poetteringchar **strv_merge_concat(char **a, char **b, const char *suffix);
3ffd4af22052963e7a29431721ee204e634bea75Lennart Poetteringchar **strv_append(char **l, const char *s);
3ffd4af22052963e7a29431721ee204e634bea75Lennart Poetteringint strv_extend(char ***l, const char *value);
160e3793adf2da2bd9ae3fe6b8881bb937e6e71bLennart Poetteringchar **strv_remove(char **l, const char *s);
160e3793adf2da2bd9ae3fe6b8881bb937e6e71bLennart Poetteringchar **strv_remove_prefix(char **l, const char *s);
160e3793adf2da2bd9ae3fe6b8881bb937e6e71bLennart Poetteringchar **strv_uniq(char **l);
160e3793adf2da2bd9ae3fe6b8881bb937e6e71bLennart Poettering#define strv_contains(l, s) (!!strv_find((l), (s)))
160e3793adf2da2bd9ae3fe6b8881bb937e6e71bLennart Poetteringchar **strv_new(const char *x, ...) _sentinel_;
160e3793adf2da2bd9ae3fe6b8881bb937e6e71bLennart Poetteringchar **strv_new_ap(const char *x, va_list ap);
160e3793adf2da2bd9ae3fe6b8881bb937e6e71bLennart Poetteringstatic inline const char* STRV_IFNOTNULL(const char *x) {
160e3793adf2da2bd9ae3fe6b8881bb937e6e71bLennart Poettering return x ? x : (const char *) -1;
160e3793adf2da2bd9ae3fe6b8881bb937e6e71bLennart Poetteringstatic inline bool strv_isempty(char * const *l) {
160e3793adf2da2bd9ae3fe6b8881bb937e6e71bLennart Poettering return !l || !*l;
160e3793adf2da2bd9ae3fe6b8881bb937e6e71bLennart Poetteringchar **strv_split(const char *s, const char *separator);
160e3793adf2da2bd9ae3fe6b8881bb937e6e71bLennart Poetteringchar **strv_split_quoted(const char *s);
160e3793adf2da2bd9ae3fe6b8881bb937e6e71bLennart Poetteringchar **strv_split_newlines(const char *s);
160e3793adf2da2bd9ae3fe6b8881bb937e6e71bLennart Poetteringchar *strv_join(char **l, const char *separator);
160e3793adf2da2bd9ae3fe6b8881bb937e6e71bLennart Poetteringchar **strv_parse_nulstr(const char *s, size_t l);
160e3793adf2da2bd9ae3fe6b8881bb937e6e71bLennart Poetteringchar **strv_split_nulstr(const char *s);
160e3793adf2da2bd9ae3fe6b8881bb937e6e71bLennart Poetteringbool strv_overlap(char **a, char **b) _pure_;
160e3793adf2da2bd9ae3fe6b8881bb937e6e71bLennart Poettering for ((s) = (l); (s) && *(s); (s)++)
160e3793adf2da2bd9ae3fe6b8881bb937e6e71bLennart Poettering for (; (l) && ((s) >= (l)); (s)--)
160e3793adf2da2bd9ae3fe6b8881bb937e6e71bLennart Poettering#define STRV_FOREACH_PAIR(x, y, l) \
160e3793adf2da2bd9ae3fe6b8881bb937e6e71bLennart Poettering for ((x) = (l), (y) = (x+1); (x) && *(x) && *(y); (x) += 2, (y) = (x + 1))
5bcd08db289cd02aad8a89b37b2a46244a7bd473Lennart Poetteringchar **strv_sort(char **l);