src/basic/mount-util.h \
src/basic/hexdecoct.c \
src/basic/hexdecoct.h \
+ src/basic/glob-util.h \
+ src/basic/glob-util.c \
src/basic/extract-word.c \
src/basic/extract-word.h \
src/basic/escape.c \
#include "analyze-verify.h"
#include "bus-error.h"
#include "bus-util.h"
+#include "glob-util.h"
#include "hashmap.h"
#include "locale-util.h"
#include "log.h"
--- /dev/null
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
+
+/***
+ This file is part of systemd.
+
+ Copyright 2010 Lennart Poettering
+
+ systemd is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 2.1 of the License, or
+ (at your option) any later version.
+
+ systemd is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#include <glob.h>
+
+#include "glob-util.h"
+#include "strv.h"
+#include "util.h"
+
+int glob_exists(const char *path) {
+ _cleanup_globfree_ glob_t g = {};
+ int k;
+
+ assert(path);
+
+ errno = 0;
+ k = glob(path, GLOB_NOSORT|GLOB_BRACE, NULL, &g);
+
+ if (k == GLOB_NOMATCH)
+ return 0;
+ if (k == GLOB_NOSPACE)
+ return -ENOMEM;
+ if (k != 0)
+ return errno ? -errno : -EIO;
+
+ return !strv_isempty(g.gl_pathv);
+}
+
+int glob_extend(char ***strv, const char *path) {
+ _cleanup_globfree_ glob_t g = {};
+ int k;
+ char **p;
+
+ errno = 0;
+ k = glob(path, GLOB_NOSORT|GLOB_BRACE, NULL, &g);
+
+ if (k == GLOB_NOMATCH)
+ return -ENOENT;
+ if (k == GLOB_NOSPACE)
+ return -ENOMEM;
+ if (k != 0)
+ return errno ? -errno : -EIO;
+ if (strv_isempty(g.gl_pathv))
+ return -ENOENT;
+
+ STRV_FOREACH(p, g.gl_pathv) {
+ k = strv_extend(strv, *p);
+ if (k < 0)
+ return k;
+ }
+
+ return 0;
+}
--- /dev/null
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
+
+#pragma once
+
+/***
+ This file is part of systemd.
+
+ Copyright 2010 Lennart Poettering
+
+ systemd is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 2.1 of the License, or
+ (at your option) any later version.
+
+ systemd is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#include <string.h>
+
+#include "macro.h"
+#include "util.h"
+
+int glob_exists(const char *path);
+int glob_extend(char ***strv, const char *path);
+
+#define _cleanup_globfree_ _cleanup_(globfree)
+
+_pure_ static inline bool string_is_glob(const char *p) {
+ /* Check if a string contains any glob patterns. */
+ return !!strpbrk(p, GLOB_CHARS);
+}
#define PTR_TO_SIZE(p) ((size_t) ((uintptr_t) (p)))
#define SIZE_TO_PTR(u) ((void *) ((uintptr_t) (u)))
-#define memzero(x,l) (memset((x), 0, (l)))
-#define zero(x) (memzero(&(x), sizeof(x)))
-
#define CHAR_TO_STR(x) ((char[2]) { x, 0 })
#define char_array_0(x) x[sizeof(x)-1] = 0;
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
-#include <glob.h>
#include <grp.h>
#include <langinfo.h>
#include <libintl.h>
return 0;
}
-int glob_exists(const char *path) {
- _cleanup_globfree_ glob_t g = {};
- int k;
-
- assert(path);
-
- errno = 0;
- k = glob(path, GLOB_NOSORT|GLOB_BRACE, NULL, &g);
-
- if (k == GLOB_NOMATCH)
- return 0;
- else if (k == GLOB_NOSPACE)
- return -ENOMEM;
- else if (k == 0)
- return !strv_isempty(g.gl_pathv);
- else
- return errno ? -errno : -EIO;
-}
-
-int glob_extend(char ***strv, const char *path) {
- _cleanup_globfree_ glob_t g = {};
- int k;
- char **p;
-
- errno = 0;
- k = glob(path, GLOB_NOSORT|GLOB_BRACE, NULL, &g);
-
- if (k == GLOB_NOMATCH)
- return -ENOENT;
- else if (k == GLOB_NOSPACE)
- return -ENOMEM;
- else if (k != 0 || strv_isempty(g.gl_pathv))
- return errno ? -errno : -EIO;
-
- STRV_FOREACH(p, g.gl_pathv) {
- k = strv_extend(strv, *p);
- if (k < 0)
- break;
- }
-
- return k;
-}
-
int block_get_whole_disk(dev_t d, dev_t *ret) {
char *p, *s;
int r;
bool display_is_local(const char *display) _pure_;
int socket_from_display(const char *display, char **path);
-int glob_exists(const char *path);
-int glob_extend(char ***strv, const char *path);
-
int block_get_whole_disk(dev_t d, dev_t *ret);
#define NULSTR_FOREACH(i, l) \
}
#define _cleanup_free_ _cleanup_(freep)
-#define _cleanup_globfree_ _cleanup_(globfree)
_malloc_ _alloc_(1, 2) static inline void *malloc_multiply(size_t a, size_t b) {
if (_unlikely_(b != 0 && a > ((size_t) -1) / b))
return memdup(p, a * b);
}
-/**
- * Check if a string contains any glob patterns.
- */
-_pure_ static inline bool string_is_glob(const char *p) {
- return !!strpbrk(p, GLOB_CHARS);
-}
-
void *xbsearch_r(const void *key, const void *base, size_t nmemb, size_t size,
int (*compar) (const void *, const void *, void *),
void *arg);
return (uint8_t*)s + n;
}
+#define memzero(x,l) (memset((x), 0, (l)))
+#define zero(x) (memzero(&(x), sizeof(x)))
+
void* greedy_realloc(void **p, size_t *allocated, size_t need, size_t size);
void* greedy_realloc0(void **p, size_t *allocated, size_t need, size_t size);
#define GREEDY_REALLOC(array, allocated, need) \
#include "fileio.h"
#include "formats-util.h"
#include "fs-util.h"
+#include "glob-util.h"
#include "io-util.h"
#include "ioprio.h"
#include "log.h"
#include "bus-util.h"
#include "dbus-path.h"
#include "fd-util.h"
+#include "glob-util.h"
#include "macro.h"
#include "mkdir.h"
#include "path.h"
#include "fd-util.h"
#include "fileio.h"
#include "formats-util.h"
+#include "glob-util.h"
#include "journal-upload.h"
#include "log.h"
#include "mkdir.h"
#include <inttypes.h>
#include "macro.h"
+#include "util.h"
#ifdef __cplusplus
extern "C" {
#include "fileio.h"
#include "fs-util.h"
#include "fsprg.h"
+#include "glob-util.h"
#include "hostname-util.h"
#include "io-util.h"
#include "journal-def.h"
#include "condition.h"
#include "extract-word.h"
#include "fd-util.h"
+#include "glob-util.h"
#include "hostname-util.h"
#include "ima-util.h"
#include "mount-util.h"
#include "fileio.h"
#include "formats-util.h"
#include "fs-util.h"
+#include "glob-util.h"
#include "hostname-util.h"
#include "initreq.h"
#include "install.h"
#include "fileio.h"
#include "fs-util.h"
#include "fstab-util.h"
+#include "glob-util.h"
#include "hexdecoct.h"
#include "io-util.h"
#include "mkdir.h"
#include "user-util.h"
#include "util.h"
#include "virt.h"
-#include "xattr-util.h"
#include "web-util.h"
+#include "xattr-util.h"
static void test_streq_ptr(void) {
assert_se(streq_ptr(NULL, NULL));
#include "fileio.h"
#include "formats-util.h"
#include "fs-util.h"
+#include "glob-util.h"
#include "io-util.h"
#include "label.h"
#include "log.h"
#include "conf-files.h"
#include "escape.h"
#include "fd-util.h"
+#include "glob-util.h"
#include "path-util.h"
#include "stat-util.h"
#include "strbuf.h"