From 6bedfcbb2970e06a4d3280c8fb62083d252ede73 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 26 Oct 2015 16:18:16 +0100 Subject: [PATCH] util-lib: split string parsing related calls from util.[ch] into parse-util.[ch] --- Makefile.am | 2 + src/analyze/analyze.c | 1 + src/backlight/backlight.c | 1 + src/basic/audit.c | 1 + src/basic/cap-list.c | 3 +- src/basic/capability.c | 1 + src/basic/cgroup-util.c | 1 + src/basic/cpu-set-util.c | 3 +- src/basic/fd-util.c | 1 + src/basic/fdset.c | 1 + src/basic/log.c | 1 + src/basic/parse-util.c | 408 ++++++++++++++++++++ src/basic/parse-util.h | 88 +++++ src/basic/path-util.c | 1 + src/basic/signal-util.c | 8 +- src/basic/signal-util.h | 2 + src/basic/socket-util.c | 1 + src/basic/terminal-util.c | 1 + src/basic/user-util.c | 7 +- src/basic/util.c | 388 +------------------ src/basic/util.h | 66 ---- src/bootchart/bootchart.c | 1 + src/bootchart/store.c | 1 + src/cgtop/cgtop.c | 1 + src/core/automount.c | 1 + src/core/busname.c | 1 + src/core/cgroup.c | 1 + src/core/dbus-execute.c | 6 +- src/core/device.c | 3 +- src/core/execute.c | 1 + src/core/job.c | 3 +- src/core/killall.c | 1 + src/core/load-fragment.c | 1 + src/core/main.c | 1 + src/core/manager.c | 1 + src/core/mount.c | 1 + src/core/service.c | 1 + src/core/show-status.c | 3 +- src/core/shutdown.c | 1 + src/core/snapshot.c | 4 +- src/core/snapshot.h | 2 + src/core/socket.c | 1 + src/core/swap.c | 1 + src/core/timer.c | 1 + src/core/unit.c | 1 + src/cryptsetup/cryptsetup-generator.c | 1 + src/cryptsetup/cryptsetup.c | 1 + src/debug-generator/debug-generator.c | 1 + src/delta/delta.c | 1 + src/firstboot/firstboot.c | 5 +- src/fsck/fsck.c | 1 + src/fstab-generator/fstab-generator.c | 1 + src/gpt-auto-generator/gpt-auto-generator.c | 1 + src/hostname/hostnamed.c | 13 +- src/import/importd.c | 1 + src/import/pull-job.c | 1 + src/import/pull.c | 1 + src/journal-remote/journal-gatewayd.c | 1 + src/journal-remote/journal-remote-parse.c | 1 + src/journal-remote/journal-remote.c | 1 + src/journal-remote/journal-upload.c | 1 + src/journal/cat.c | 1 + src/journal/coredump.c | 1 + src/journal/coredumpctl.c | 3 +- src/journal/journal-file.c | 1 + src/journal/journal-vacuum.c | 1 + src/journal/journalctl.c | 1 + src/journal/journald-console.c | 7 +- src/journal/journald-kmsg.c | 1 + src/journal/journald-native.c | 1 + src/journal/journald-server.c | 1 + src/journal/journald-stream.c | 1 + src/journal/test-compress-benchmark.c | 1 + src/journal/test-journal-init.c | 1 + src/journal/test-journal-interleaving.c | 4 +- src/journal/test-journal-stream.c | 10 +- src/libsystemd-network/network-internal.c | 3 +- src/libsystemd-network/sd-dhcp-lease.c | 1 + src/libsystemd-network/test-ipv4ll-manual.c | 1 + src/libsystemd/sd-bus/bus-creds.c | 1 + src/libsystemd/sd-bus/bus-kernel.c | 1 + src/libsystemd/sd-bus/busctl.c | 1 + src/libsystemd/sd-bus/sd-bus.c | 1 + src/libsystemd/sd-daemon/sd-daemon.c | 1 + src/libsystemd/sd-device/device-private.c | 1 + src/libsystemd/sd-device/sd-device.c | 1 + src/libsystemd/sd-login/sd-login.c | 1 + src/libsystemd/sd-network/sd-network.c | 1 + src/libudev/libudev-device.c | 1 + src/login/loginctl.c | 1 + src/login/logind-inhibit.c | 1 + src/login/logind-seat.c | 1 + src/login/logind-session.c | 1 + src/login/logind-user.c | 1 + src/login/pam_systemd.c | 1 + src/machine/machine.c | 1 + src/machine/machinectl.c | 1 + src/network/networkctl.c | 1 + src/network/networkd-address.c | 3 +- src/network/networkd-link-bus.c | 3 +- src/network/networkd-netdev-tunnel.c | 3 +- src/network/networkd-network.c | 1 + src/network/networkd-route.c | 3 +- src/network/networkd-util.c | 1 + src/notify/notify.c | 1 + src/nspawn/nspawn-expose-ports.c | 1 + src/nspawn/nspawn-mount.c | 3 +- src/nspawn/nspawn.c | 1 + src/resolve-host/resolve-host.c | 1 + src/resolve/resolved-conf.c | 3 +- src/resolve/resolved-link.c | 1 + src/resolve/resolved-manager.c | 1 + src/rfkill/rfkill.c | 1 + src/run/run.c | 1 + src/shared/apparmor-util.c | 6 +- src/shared/bus-util.c | 1 + src/shared/condition.c | 1 + src/shared/conf-parser.c | 5 +- src/shared/dns-domain.c | 3 +- src/shared/efivars.c | 1 + src/shared/fstab-util.c | 3 +- src/shared/logs-show.c | 1 + src/shared/machine-pool.c | 1 + src/shared/sleep-config.c | 1 + src/systemctl/systemctl.c | 1 + src/test/test-btrfs.c | 1 + src/test/test-cap-list.c | 8 +- src/test/test-cgroup-util.c | 1 + src/test/test-fileio.c | 1 + src/test/test-util.c | 3 +- src/timedate/timedatectl.c | 1 + src/tmpfiles/tmpfiles.c | 1 + src/udev/net/link-config.c | 1 + src/udev/udev-builtin-keyboard.c | 1 + src/udev/udevadm-settle.c | 1 + src/udev/udevd.c | 1 + 136 files changed, 686 insertions(+), 502 deletions(-) create mode 100644 src/basic/parse-util.c create mode 100644 src/basic/parse-util.h diff --git a/Makefile.am b/Makefile.am index 2e960623a53..189d9c99ac6 100644 --- a/Makefile.am +++ b/Makefile.am @@ -787,6 +787,8 @@ libbasic_la_SOURCES = \ src/basic/string-util.h \ src/basic/fd-util.c \ src/basic/fd-util.h \ + src/basic/parse-util.c \ + src/basic/parse-util.h \ src/basic/user-util.c \ src/basic/user-util.h \ src/basic/extract-word.c \ diff --git a/src/analyze/analyze.c b/src/analyze/analyze.c index 4bf83eb3293..6ba16d8b65e 100644 --- a/src/analyze/analyze.c +++ b/src/analyze/analyze.c @@ -33,6 +33,7 @@ #include "hashmap.h" #include "log.h" #include "pager.h" +#include "parse-util.h" #include "special.h" #include "strv.h" #include "strxcpyx.h" diff --git a/src/backlight/backlight.c b/src/backlight/backlight.c index fc96eee6a92..6a2d04ef13f 100644 --- a/src/backlight/backlight.c +++ b/src/backlight/backlight.c @@ -28,6 +28,7 @@ #include "string-util.h" #include "udev-util.h" #include "util.h" +#include "parse-util.h" static struct udev_device *find_pci_or_platform_parent(struct udev_device *device) { struct udev_device *parent; diff --git a/src/basic/audit.c b/src/basic/audit.c index c9b762151a2..4957fc1bec1 100644 --- a/src/basic/audit.c +++ b/src/basic/audit.c @@ -26,6 +26,7 @@ #include "fd-util.h" #include "fileio.h" #include "macro.h" +#include "parse-util.h" #include "process-util.h" #include "user-util.h" #include "util.h" diff --git a/src/basic/cap-list.c b/src/basic/cap-list.c index bd5bffbfa51..4d391510bc8 100644 --- a/src/basic/cap-list.c +++ b/src/basic/cap-list.c @@ -21,9 +21,10 @@ #include -#include "util.h" #include "cap-list.h" #include "missing.h" +#include "parse-util.h" +#include "util.h" static const struct capability_name* lookup_capability(register const char *str, register unsigned int len); diff --git a/src/basic/capability.c b/src/basic/capability.c index 6f25b5dee94..04c7047a6af 100644 --- a/src/basic/capability.c +++ b/src/basic/capability.c @@ -30,6 +30,7 @@ #include "fileio.h" #include "log.h" #include "macro.h" +#include "parse-util.h" #include "util.h" int have_effective_cap(int value) { diff --git a/src/basic/cgroup-util.c b/src/basic/cgroup-util.c index 4af991200c8..232d6e8fe24 100644 --- a/src/basic/cgroup-util.c +++ b/src/basic/cgroup-util.c @@ -37,6 +37,7 @@ #include "login-util.h" #include "macro.h" #include "mkdir.h" +#include "parse-util.h" #include "path-util.h" #include "process-util.h" #include "set.h" diff --git a/src/basic/cpu-set-util.c b/src/basic/cpu-set-util.c index 5e064d854fa..cbeae0bf20a 100644 --- a/src/basic/cpu-set-util.c +++ b/src/basic/cpu-set-util.c @@ -20,9 +20,10 @@ along with systemd; If not, see . ***/ +#include "cpu-set-util.h" #include "extract-word.h" +#include "parse-util.h" #include "util.h" -#include "cpu-set-util.h" cpu_set_t* cpu_set_malloc(unsigned *ncpus) { cpu_set_t *c; diff --git a/src/basic/fd-util.c b/src/basic/fd-util.c index e54c104597e..76d7e32bfa1 100644 --- a/src/basic/fd-util.c +++ b/src/basic/fd-util.c @@ -20,6 +20,7 @@ ***/ #include "fd-util.h" +#include "parse-util.h" #include "util.h" int close_nointr(int fd) { diff --git a/src/basic/fdset.c b/src/basic/fdset.c index 96691108283..ef60f664313 100644 --- a/src/basic/fdset.c +++ b/src/basic/fdset.c @@ -28,6 +28,7 @@ #include "fd-util.h" #include "fdset.h" #include "macro.h" +#include "parse-util.h" #include "set.h" #include "util.h" diff --git a/src/basic/log.c b/src/basic/log.c index 99dccb1f103..2c0abdc0bdc 100644 --- a/src/basic/log.c +++ b/src/basic/log.c @@ -42,6 +42,7 @@ #include "string-util.h" #include "terminal-util.h" #include "util.h" +#include "parse-util.h" #define SNDBUF_SIZE (8*1024*1024) diff --git a/src/basic/parse-util.c b/src/basic/parse-util.c new file mode 100644 index 00000000000..2437fee60cc --- /dev/null +++ b/src/basic/parse-util.c @@ -0,0 +1,408 @@ +/*-*- 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 . +***/ + +#include "parse-util.h" +#include "string-util.h" +#include "util.h" + +int parse_boolean(const char *v) { + assert(v); + + if (streq(v, "1") || strcaseeq(v, "yes") || strcaseeq(v, "y") || strcaseeq(v, "true") || strcaseeq(v, "t") || strcaseeq(v, "on")) + return 1; + else if (streq(v, "0") || strcaseeq(v, "no") || strcaseeq(v, "n") || strcaseeq(v, "false") || strcaseeq(v, "f") || strcaseeq(v, "off")) + return 0; + + return -EINVAL; +} + +int parse_pid(const char *s, pid_t* ret_pid) { + unsigned long ul = 0; + pid_t pid; + int r; + + assert(s); + assert(ret_pid); + + r = safe_atolu(s, &ul); + if (r < 0) + return r; + + pid = (pid_t) ul; + + if ((unsigned long) pid != ul) + return -ERANGE; + + if (pid <= 0) + return -ERANGE; + + *ret_pid = pid; + return 0; +} + +int parse_mode(const char *s, mode_t *ret) { + char *x; + long l; + + assert(s); + assert(ret); + + errno = 0; + l = strtol(s, &x, 8); + if (errno != 0) + return -errno; + + if (!x || x == s || *x) + return -EINVAL; + if (l < 0 || l > 07777) + return -ERANGE; + + *ret = (mode_t) l; + return 0; +} + +int parse_size(const char *t, uint64_t base, uint64_t *size) { + + /* Soo, sometimes we want to parse IEC binary suffixes, and + * sometimes SI decimal suffixes. This function can parse + * both. Which one is the right way depends on the + * context. Wikipedia suggests that SI is customary for + * hardware metrics and network speeds, while IEC is + * customary for most data sizes used by software and volatile + * (RAM) memory. Hence be careful which one you pick! + * + * In either case we use just K, M, G as suffix, and not Ki, + * Mi, Gi or so (as IEC would suggest). That's because that's + * frickin' ugly. But this means you really need to make sure + * to document which base you are parsing when you use this + * call. */ + + struct table { + const char *suffix; + unsigned long long factor; + }; + + static const struct table iec[] = { + { "E", 1024ULL*1024ULL*1024ULL*1024ULL*1024ULL*1024ULL }, + { "P", 1024ULL*1024ULL*1024ULL*1024ULL*1024ULL }, + { "T", 1024ULL*1024ULL*1024ULL*1024ULL }, + { "G", 1024ULL*1024ULL*1024ULL }, + { "M", 1024ULL*1024ULL }, + { "K", 1024ULL }, + { "B", 1ULL }, + { "", 1ULL }, + }; + + static const struct table si[] = { + { "E", 1000ULL*1000ULL*1000ULL*1000ULL*1000ULL*1000ULL }, + { "P", 1000ULL*1000ULL*1000ULL*1000ULL*1000ULL }, + { "T", 1000ULL*1000ULL*1000ULL*1000ULL }, + { "G", 1000ULL*1000ULL*1000ULL }, + { "M", 1000ULL*1000ULL }, + { "K", 1000ULL }, + { "B", 1ULL }, + { "", 1ULL }, + }; + + const struct table *table; + const char *p; + unsigned long long r = 0; + unsigned n_entries, start_pos = 0; + + assert(t); + assert(base == 1000 || base == 1024); + assert(size); + + if (base == 1000) { + table = si; + n_entries = ELEMENTSOF(si); + } else { + table = iec; + n_entries = ELEMENTSOF(iec); + } + + p = t; + do { + unsigned long long l, tmp; + double frac = 0; + char *e; + unsigned i; + + p += strspn(p, WHITESPACE); + if (*p == '-') + return -ERANGE; + + errno = 0; + l = strtoull(p, &e, 10); + if (errno > 0) + return -errno; + if (e == p) + return -EINVAL; + + if (*e == '.') { + e++; + + /* strtoull() itself would accept space/+/- */ + if (*e >= '0' && *e <= '9') { + unsigned long long l2; + char *e2; + + l2 = strtoull(e, &e2, 10); + if (errno > 0) + return -errno; + + /* Ignore failure. E.g. 10.M is valid */ + frac = l2; + for (; e < e2; e++) + frac /= 10; + } + } + + e += strspn(e, WHITESPACE); + + for (i = start_pos; i < n_entries; i++) + if (startswith(e, table[i].suffix)) + break; + + if (i >= n_entries) + return -EINVAL; + + if (l + (frac > 0) > ULLONG_MAX / table[i].factor) + return -ERANGE; + + tmp = l * table[i].factor + (unsigned long long) (frac * table[i].factor); + if (tmp > ULLONG_MAX - r) + return -ERANGE; + + r += tmp; + if ((unsigned long long) (uint64_t) r != r) + return -ERANGE; + + p = e + strlen(table[i].suffix); + + start_pos = i + 1; + + } while (*p); + + *size = r; + + return 0; +} + +char *format_bytes(char *buf, size_t l, uint64_t t) { + unsigned i; + + /* This only does IEC units so far */ + + static const struct { + const char *suffix; + uint64_t factor; + } table[] = { + { "E", UINT64_C(1024)*UINT64_C(1024)*UINT64_C(1024)*UINT64_C(1024)*UINT64_C(1024)*UINT64_C(1024) }, + { "P", UINT64_C(1024)*UINT64_C(1024)*UINT64_C(1024)*UINT64_C(1024)*UINT64_C(1024) }, + { "T", UINT64_C(1024)*UINT64_C(1024)*UINT64_C(1024)*UINT64_C(1024) }, + { "G", UINT64_C(1024)*UINT64_C(1024)*UINT64_C(1024) }, + { "M", UINT64_C(1024)*UINT64_C(1024) }, + { "K", UINT64_C(1024) }, + }; + + if (t == (uint64_t) -1) + return NULL; + + for (i = 0; i < ELEMENTSOF(table); i++) { + + if (t >= table[i].factor) { + snprintf(buf, l, + "%" PRIu64 ".%" PRIu64 "%s", + t / table[i].factor, + ((t*UINT64_C(10)) / table[i].factor) % UINT64_C(10), + table[i].suffix); + + goto finish; + } + } + + snprintf(buf, l, "%" PRIu64 "B", t); + +finish: + buf[l-1] = 0; + return buf; + +} + +int safe_atou(const char *s, unsigned *ret_u) { + char *x = NULL; + unsigned long l; + + assert(s); + assert(ret_u); + + errno = 0; + l = strtoul(s, &x, 0); + + if (!x || x == s || *x || errno) + return errno > 0 ? -errno : -EINVAL; + + if ((unsigned long) (unsigned) l != l) + return -ERANGE; + + *ret_u = (unsigned) l; + return 0; +} + +int safe_atoi(const char *s, int *ret_i) { + char *x = NULL; + long l; + + assert(s); + assert(ret_i); + + errno = 0; + l = strtol(s, &x, 0); + + if (!x || x == s || *x || errno) + return errno > 0 ? -errno : -EINVAL; + + if ((long) (int) l != l) + return -ERANGE; + + *ret_i = (int) l; + return 0; +} + +int safe_atollu(const char *s, long long unsigned *ret_llu) { + char *x = NULL; + unsigned long long l; + + assert(s); + assert(ret_llu); + + errno = 0; + l = strtoull(s, &x, 0); + + if (!x || x == s || *x || errno) + return errno ? -errno : -EINVAL; + + *ret_llu = l; + return 0; +} + +int safe_atolli(const char *s, long long int *ret_lli) { + char *x = NULL; + long long l; + + assert(s); + assert(ret_lli); + + errno = 0; + l = strtoll(s, &x, 0); + + if (!x || x == s || *x || errno) + return errno ? -errno : -EINVAL; + + *ret_lli = l; + return 0; +} + +int safe_atou8(const char *s, uint8_t *ret) { + char *x = NULL; + unsigned long l; + + assert(s); + assert(ret); + + errno = 0; + l = strtoul(s, &x, 0); + + if (!x || x == s || *x || errno) + return errno > 0 ? -errno : -EINVAL; + + if ((unsigned long) (uint8_t) l != l) + return -ERANGE; + + *ret = (uint8_t) l; + return 0; +} + +int safe_atou16(const char *s, uint16_t *ret) { + char *x = NULL; + unsigned long l; + + assert(s); + assert(ret); + + errno = 0; + l = strtoul(s, &x, 0); + + if (!x || x == s || *x || errno) + return errno > 0 ? -errno : -EINVAL; + + if ((unsigned long) (uint16_t) l != l) + return -ERANGE; + + *ret = (uint16_t) l; + return 0; +} + +int safe_atoi16(const char *s, int16_t *ret) { + char *x = NULL; + long l; + + assert(s); + assert(ret); + + errno = 0; + l = strtol(s, &x, 0); + + if (!x || x == s || *x || errno) + return errno > 0 ? -errno : -EINVAL; + + if ((long) (int16_t) l != l) + return -ERANGE; + + *ret = (int16_t) l; + return 0; +} + +int safe_atod(const char *s, double *ret_d) { + char *x = NULL; + double d = 0; + locale_t loc; + + assert(s); + assert(ret_d); + + loc = newlocale(LC_NUMERIC_MASK, "C", (locale_t) 0); + if (loc == (locale_t) 0) + return -errno; + + errno = 0; + d = strtod_l(s, &x, loc); + + if (!x || x == s || *x || errno) { + freelocale(loc); + return errno ? -errno : -EINVAL; + } + + freelocale(loc); + *ret_d = (double) d; + return 0; +} diff --git a/src/basic/parse-util.h b/src/basic/parse-util.h new file mode 100644 index 00000000000..35b4ba030c2 --- /dev/null +++ b/src/basic/parse-util.h @@ -0,0 +1,88 @@ +/*-*- 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 . +***/ + +#include +#include + +#include "macro.h" + +int parse_boolean(const char *v) _pure_; +int parse_pid(const char *s, pid_t* ret_pid); +int parse_mode(const char *s, mode_t *ret); + +int parse_size(const char *t, uint64_t base, uint64_t *size); + +#define FORMAT_BYTES_MAX 8 +char *format_bytes(char *buf, size_t l, uint64_t t); + +int safe_atou(const char *s, unsigned *ret_u); +int safe_atoi(const char *s, int *ret_i); +int safe_atollu(const char *s, unsigned long long *ret_u); +int safe_atolli(const char *s, long long int *ret_i); + +int safe_atou8(const char *s, uint8_t *ret); + +int safe_atou16(const char *s, uint16_t *ret); +int safe_atoi16(const char *s, int16_t *ret); + +static inline int safe_atou32(const char *s, uint32_t *ret_u) { + assert_cc(sizeof(uint32_t) == sizeof(unsigned)); + return safe_atou(s, (unsigned*) ret_u); +} + +static inline int safe_atoi32(const char *s, int32_t *ret_i) { + assert_cc(sizeof(int32_t) == sizeof(int)); + return safe_atoi(s, (int*) ret_i); +} + +static inline int safe_atou64(const char *s, uint64_t *ret_u) { + assert_cc(sizeof(uint64_t) == sizeof(unsigned long long)); + return safe_atollu(s, (unsigned long long*) ret_u); +} + +static inline int safe_atoi64(const char *s, int64_t *ret_i) { + assert_cc(sizeof(int64_t) == sizeof(long long int)); + return safe_atolli(s, (long long int*) ret_i); +} + +#if LONG_MAX == INT_MAX +static inline int safe_atolu(const char *s, unsigned long *ret_u) { + assert_cc(sizeof(unsigned long) == sizeof(unsigned)); + return safe_atou(s, (unsigned*) ret_u); +} +static inline int safe_atoli(const char *s, long int *ret_u) { + assert_cc(sizeof(long int) == sizeof(int)); + return safe_atoi(s, (int*) ret_u); +} +#else +static inline int safe_atolu(const char *s, unsigned long *ret_u) { + assert_cc(sizeof(unsigned long) == sizeof(unsigned long long)); + return safe_atollu(s, (unsigned long long*) ret_u); +} +static inline int safe_atoli(const char *s, long int *ret_u) { + assert_cc(sizeof(long int) == sizeof(long long int)); + return safe_atolli(s, (long long int*) ret_u); +} +#endif + +int safe_atod(const char *s, double *ret_d); diff --git a/src/basic/path-util.c b/src/basic/path-util.c index e25e50e78a6..0015667ac09 100644 --- a/src/basic/path-util.c +++ b/src/basic/path-util.c @@ -32,6 +32,7 @@ #include "log.h" #include "macro.h" #include "missing.h" +#include "parse-util.h" #include "path-util.h" #include "string-util.h" #include "strv.h" diff --git a/src/basic/signal-util.c b/src/basic/signal-util.c index 730f99e0af4..e5ac6317d40 100644 --- a/src/basic/signal-util.c +++ b/src/basic/signal-util.c @@ -19,11 +19,11 @@ along with systemd; If not, see . ***/ +#include "parse-util.h" +#include "signal-util.h" #include "string-util.h" #include "util.h" -#include "signal-util.h" - int reset_all_signal_handlers(void) { static const struct sigaction sa = { .sa_handler = SIG_DFL, @@ -268,3 +268,7 @@ int signal_from_string_try_harder(const char *s) { return signo; } + +void nop_signal_handler(int sig) { + /* nothing here */ +} diff --git a/src/basic/signal-util.h b/src/basic/signal-util.h index 5e6eb50b07f..e7393e2daca 100644 --- a/src/basic/signal-util.h +++ b/src/basic/signal-util.h @@ -39,3 +39,5 @@ const char *signal_to_string(int i) _const_; int signal_from_string(const char *s) _pure_; int signal_from_string_try_harder(const char *s); + +void nop_signal_handler(int sig); diff --git a/src/basic/socket-util.c b/src/basic/socket-util.c index 684ac765f5a..c4af6aa9410 100644 --- a/src/basic/socket-util.c +++ b/src/basic/socket-util.c @@ -35,6 +35,7 @@ #include "formats-util.h" #include "macro.h" #include "missing.h" +#include "parse-util.h" #include "path-util.h" #include "socket-util.h" #include "string-util.h" diff --git a/src/basic/terminal-util.c b/src/basic/terminal-util.c index 7dfab0af620..2fe5c26a672 100644 --- a/src/basic/terminal-util.c +++ b/src/basic/terminal-util.c @@ -34,6 +34,7 @@ #include "fd-util.h" #include "fileio.h" #include "io-util.h" +#include "parse-util.h" #include "path-util.h" #include "process-util.h" #include "socket-util.h" diff --git a/src/basic/user-util.c b/src/basic/user-util.c index 7e6c4c645da..0b3cf3d733b 100644 --- a/src/basic/user-util.c +++ b/src/basic/user-util.c @@ -22,11 +22,12 @@ #include #include -#include "user-util.h" #include "macro.h" -#include "util.h" -#include "string-util.h" +#include "parse-util.h" #include "path-util.h" +#include "string-util.h" +#include "user-util.h" +#include "util.h" bool uid_is_valid(uid_t uid) { diff --git a/src/basic/util.c b/src/basic/util.c index d5227aa6d0d..66b7978c60b 100644 --- a/src/basic/util.c +++ b/src/basic/util.c @@ -89,6 +89,7 @@ #include "macro.h" #include "missing.h" #include "mkdir.h" +#include "parse-util.h" #include "path-util.h" #include "process-util.h" #include "random-util.h" @@ -133,201 +134,6 @@ int unlink_noerrno(const char *path) { return 0; } -int parse_boolean(const char *v) { - assert(v); - - if (streq(v, "1") || strcaseeq(v, "yes") || strcaseeq(v, "y") || strcaseeq(v, "true") || strcaseeq(v, "t") || strcaseeq(v, "on")) - return 1; - else if (streq(v, "0") || strcaseeq(v, "no") || strcaseeq(v, "n") || strcaseeq(v, "false") || strcaseeq(v, "f") || strcaseeq(v, "off")) - return 0; - - return -EINVAL; -} - -int parse_pid(const char *s, pid_t* ret_pid) { - unsigned long ul = 0; - pid_t pid; - int r; - - assert(s); - assert(ret_pid); - - r = safe_atolu(s, &ul); - if (r < 0) - return r; - - pid = (pid_t) ul; - - if ((unsigned long) pid != ul) - return -ERANGE; - - if (pid <= 0) - return -ERANGE; - - *ret_pid = pid; - return 0; -} - -int safe_atou(const char *s, unsigned *ret_u) { - char *x = NULL; - unsigned long l; - - assert(s); - assert(ret_u); - - errno = 0; - l = strtoul(s, &x, 0); - - if (!x || x == s || *x || errno) - return errno > 0 ? -errno : -EINVAL; - - if ((unsigned long) (unsigned) l != l) - return -ERANGE; - - *ret_u = (unsigned) l; - return 0; -} - -int safe_atoi(const char *s, int *ret_i) { - char *x = NULL; - long l; - - assert(s); - assert(ret_i); - - errno = 0; - l = strtol(s, &x, 0); - - if (!x || x == s || *x || errno) - return errno > 0 ? -errno : -EINVAL; - - if ((long) (int) l != l) - return -ERANGE; - - *ret_i = (int) l; - return 0; -} - -int safe_atou8(const char *s, uint8_t *ret) { - char *x = NULL; - unsigned long l; - - assert(s); - assert(ret); - - errno = 0; - l = strtoul(s, &x, 0); - - if (!x || x == s || *x || errno) - return errno > 0 ? -errno : -EINVAL; - - if ((unsigned long) (uint8_t) l != l) - return -ERANGE; - - *ret = (uint8_t) l; - return 0; -} - -int safe_atou16(const char *s, uint16_t *ret) { - char *x = NULL; - unsigned long l; - - assert(s); - assert(ret); - - errno = 0; - l = strtoul(s, &x, 0); - - if (!x || x == s || *x || errno) - return errno > 0 ? -errno : -EINVAL; - - if ((unsigned long) (uint16_t) l != l) - return -ERANGE; - - *ret = (uint16_t) l; - return 0; -} - -int safe_atoi16(const char *s, int16_t *ret) { - char *x = NULL; - long l; - - assert(s); - assert(ret); - - errno = 0; - l = strtol(s, &x, 0); - - if (!x || x == s || *x || errno) - return errno > 0 ? -errno : -EINVAL; - - if ((long) (int16_t) l != l) - return -ERANGE; - - *ret = (int16_t) l; - return 0; -} - -int safe_atollu(const char *s, long long unsigned *ret_llu) { - char *x = NULL; - unsigned long long l; - - assert(s); - assert(ret_llu); - - errno = 0; - l = strtoull(s, &x, 0); - - if (!x || x == s || *x || errno) - return errno ? -errno : -EINVAL; - - *ret_llu = l; - return 0; -} - -int safe_atolli(const char *s, long long int *ret_lli) { - char *x = NULL; - long long l; - - assert(s); - assert(ret_lli); - - errno = 0; - l = strtoll(s, &x, 0); - - if (!x || x == s || *x || errno) - return errno ? -errno : -EINVAL; - - *ret_lli = l; - return 0; -} - -int safe_atod(const char *s, double *ret_d) { - char *x = NULL; - double d = 0; - locale_t loc; - - assert(s); - assert(ret_d); - - loc = newlocale(LC_NUMERIC_MASK, "C", (locale_t) 0); - if (loc == (locale_t) 0) - return -errno; - - errno = 0; - d = strtod_l(s, &x, loc); - - if (!x || x == s || *x || errno) { - freelocale(loc); - return errno ? -errno : -EINVAL; - } - - freelocale(loc); - *ret_d = (double) d; - return 0; -} - - int fchmod_umask(int fd, mode_t m) { mode_t u; int r; @@ -1195,134 +1001,6 @@ bool fstype_is_network(const char *fstype) { return nulstr_contains(table, fstype); } -int parse_size(const char *t, uint64_t base, uint64_t *size) { - - /* Soo, sometimes we want to parse IEC binary suffixes, and - * sometimes SI decimal suffixes. This function can parse - * both. Which one is the right way depends on the - * context. Wikipedia suggests that SI is customary for - * hardware metrics and network speeds, while IEC is - * customary for most data sizes used by software and volatile - * (RAM) memory. Hence be careful which one you pick! - * - * In either case we use just K, M, G as suffix, and not Ki, - * Mi, Gi or so (as IEC would suggest). That's because that's - * frickin' ugly. But this means you really need to make sure - * to document which base you are parsing when you use this - * call. */ - - struct table { - const char *suffix; - unsigned long long factor; - }; - - static const struct table iec[] = { - { "E", 1024ULL*1024ULL*1024ULL*1024ULL*1024ULL*1024ULL }, - { "P", 1024ULL*1024ULL*1024ULL*1024ULL*1024ULL }, - { "T", 1024ULL*1024ULL*1024ULL*1024ULL }, - { "G", 1024ULL*1024ULL*1024ULL }, - { "M", 1024ULL*1024ULL }, - { "K", 1024ULL }, - { "B", 1ULL }, - { "", 1ULL }, - }; - - static const struct table si[] = { - { "E", 1000ULL*1000ULL*1000ULL*1000ULL*1000ULL*1000ULL }, - { "P", 1000ULL*1000ULL*1000ULL*1000ULL*1000ULL }, - { "T", 1000ULL*1000ULL*1000ULL*1000ULL }, - { "G", 1000ULL*1000ULL*1000ULL }, - { "M", 1000ULL*1000ULL }, - { "K", 1000ULL }, - { "B", 1ULL }, - { "", 1ULL }, - }; - - const struct table *table; - const char *p; - unsigned long long r = 0; - unsigned n_entries, start_pos = 0; - - assert(t); - assert(base == 1000 || base == 1024); - assert(size); - - if (base == 1000) { - table = si; - n_entries = ELEMENTSOF(si); - } else { - table = iec; - n_entries = ELEMENTSOF(iec); - } - - p = t; - do { - unsigned long long l, tmp; - double frac = 0; - char *e; - unsigned i; - - p += strspn(p, WHITESPACE); - if (*p == '-') - return -ERANGE; - - errno = 0; - l = strtoull(p, &e, 10); - if (errno > 0) - return -errno; - if (e == p) - return -EINVAL; - - if (*e == '.') { - e++; - - /* strtoull() itself would accept space/+/- */ - if (*e >= '0' && *e <= '9') { - unsigned long long l2; - char *e2; - - l2 = strtoull(e, &e2, 10); - if (errno > 0) - return -errno; - - /* Ignore failure. E.g. 10.M is valid */ - frac = l2; - for (; e < e2; e++) - frac /= 10; - } - } - - e += strspn(e, WHITESPACE); - - for (i = start_pos; i < n_entries; i++) - if (startswith(e, table[i].suffix)) - break; - - if (i >= n_entries) - return -EINVAL; - - if (l + (frac > 0) > ULLONG_MAX / table[i].factor) - return -ERANGE; - - tmp = l * table[i].factor + (unsigned long long) (frac * table[i].factor); - if (tmp > ULLONG_MAX - r) - return -ERANGE; - - r += tmp; - if ((unsigned long long) (uint64_t) r != r) - return -ERANGE; - - p = e + strlen(table[i].suffix); - - start_pos = i + 1; - - } while (*p); - - *size = r; - - return 0; -} - bool is_device_path(const char *path) { /* Returns true on paths that refer to a device, either in @@ -2300,45 +1978,6 @@ int prot_from_flags(int flags) { } } -char *format_bytes(char *buf, size_t l, uint64_t t) { - unsigned i; - - static const struct { - const char *suffix; - uint64_t factor; - } table[] = { - { "E", UINT64_C(1024)*UINT64_C(1024)*UINT64_C(1024)*UINT64_C(1024)*UINT64_C(1024)*UINT64_C(1024) }, - { "P", UINT64_C(1024)*UINT64_C(1024)*UINT64_C(1024)*UINT64_C(1024)*UINT64_C(1024) }, - { "T", UINT64_C(1024)*UINT64_C(1024)*UINT64_C(1024)*UINT64_C(1024) }, - { "G", UINT64_C(1024)*UINT64_C(1024)*UINT64_C(1024) }, - { "M", UINT64_C(1024)*UINT64_C(1024) }, - { "K", UINT64_C(1024) }, - }; - - if (t == (uint64_t) -1) - return NULL; - - for (i = 0; i < ELEMENTSOF(table); i++) { - - if (t >= table[i].factor) { - snprintf(buf, l, - "%" PRIu64 ".%" PRIu64 "%s", - t / table[i].factor, - ((t*UINT64_C(10)) / table[i].factor) % UINT64_C(10), - table[i].suffix); - - goto finish; - } - } - - snprintf(buf, l, "%" PRIu64 "B", t); - -finish: - buf[l-1] = 0; - return buf; - -} - void* memdup(const void *p, size_t l) { void *r; @@ -4111,27 +3750,6 @@ int rename_noreplace(int olddirfd, const char *oldpath, int newdirfd, const char return 0; } -int parse_mode(const char *s, mode_t *ret) { - char *x; - long l; - - assert(s); - assert(ret); - - errno = 0; - l = strtol(s, &x, 8); - if (errno != 0) - return -errno; - - if (!x || x == s || *x) - return -EINVAL; - if (l < 0 || l > 07777) - return -ERANGE; - - *ret = (mode_t) l; - return 0; -} - int mount_move_root(const char *path) { assert(path); @@ -4220,10 +3838,6 @@ int fgetxattr_malloc(int fd, const char *name, char **value) { } } -void nop_signal_handler(int sig) { - /* nothing here */ -} - int version(void) { puts(PACKAGE_STRING "\n" SYSTEMD_FEATURES); diff --git a/src/basic/util.h b/src/basic/util.h index f32033767ae..d51b824294c 100644 --- a/src/basic/util.h +++ b/src/basic/util.h @@ -53,8 +53,6 @@ #define COMMENTS "#;" #define GLOB_CHARS "*?[" -#define FORMAT_BYTES_MAX 8 - size_t page_size(void) _pure_; #define PAGE_ALIGN(l) ALIGN_TO((l), page_size()) @@ -87,64 +85,6 @@ static inline const char* one_zero(bool b) { return b ? "1" : "0"; } -int parse_size(const char *t, uint64_t base, uint64_t *size); - -int parse_boolean(const char *v) _pure_; -int parse_pid(const char *s, pid_t* ret_pid); - -int safe_atou(const char *s, unsigned *ret_u); -int safe_atoi(const char *s, int *ret_i); - -int safe_atollu(const char *s, unsigned long long *ret_u); -int safe_atolli(const char *s, long long int *ret_i); - -int safe_atod(const char *s, double *ret_d); - -int safe_atou8(const char *s, uint8_t *ret); - -#if LONG_MAX == INT_MAX -static inline int safe_atolu(const char *s, unsigned long *ret_u) { - assert_cc(sizeof(unsigned long) == sizeof(unsigned)); - return safe_atou(s, (unsigned*) ret_u); -} -static inline int safe_atoli(const char *s, long int *ret_u) { - assert_cc(sizeof(long int) == sizeof(int)); - return safe_atoi(s, (int*) ret_u); -} -#else -static inline int safe_atolu(const char *s, unsigned long *ret_u) { - assert_cc(sizeof(unsigned long) == sizeof(unsigned long long)); - return safe_atollu(s, (unsigned long long*) ret_u); -} -static inline int safe_atoli(const char *s, long int *ret_u) { - assert_cc(sizeof(long int) == sizeof(long long int)); - return safe_atolli(s, (long long int*) ret_u); -} -#endif - -static inline int safe_atou32(const char *s, uint32_t *ret_u) { - assert_cc(sizeof(uint32_t) == sizeof(unsigned)); - return safe_atou(s, (unsigned*) ret_u); -} - -static inline int safe_atoi32(const char *s, int32_t *ret_i) { - assert_cc(sizeof(int32_t) == sizeof(int)); - return safe_atoi(s, (int*) ret_i); -} - -static inline int safe_atou64(const char *s, uint64_t *ret_u) { - assert_cc(sizeof(uint64_t) == sizeof(unsigned long long)); - return safe_atollu(s, (unsigned long long*) ret_u); -} - -static inline int safe_atoi64(const char *s, int64_t *ret_i) { - assert_cc(sizeof(int64_t) == sizeof(long long int)); - return safe_atolli(s, (long long int*) ret_i); -} - -int safe_atou16(const char *s, uint16_t *ret); -int safe_atoi16(const char *s, int16_t *ret); - int readlinkat_malloc(int fd, const char *p, char **ret); int readlink_malloc(const char *p, char **r); int readlink_value(const char *p, char **ret); @@ -336,8 +276,6 @@ bool kexec_loaded(void); int prot_from_flags(int flags) _const_; -char *format_bytes(char *buf, size_t l, uint64_t t); - void* memdup(const void *p, size_t l) _alloc_(2); int fork_agent(pid_t *pid, const int except[], unsigned n_except, const char *path, ...); @@ -680,15 +618,11 @@ int syslog_parse_priority(const char **p, int *priority, bool with_facility); int rename_noreplace(int olddirfd, const char *oldpath, int newdirfd, const char *newpath); -int parse_mode(const char *s, mode_t *ret); - int mount_move_root(const char *path); int getxattr_malloc(const char *path, const char *name, char **value, bool allow_symlink); int fgetxattr_malloc(int fd, const char *name, char **value); -void nop_signal_handler(int sig); - int version(void); bool fdname_is_valid(const char *s); diff --git a/src/bootchart/bootchart.c b/src/bootchart/bootchart.c index ef113ed40c3..c0019174ab8 100644 --- a/src/bootchart/bootchart.c +++ b/src/bootchart/bootchart.c @@ -55,6 +55,7 @@ #include "io-util.h" #include "list.h" #include "macro.h" +#include "parse-util.h" #include "path-util.h" #include "store.h" #include "string-util.h" diff --git a/src/bootchart/store.c b/src/bootchart/store.c index 6066e142886..50b69637ef4 100644 --- a/src/bootchart/store.c +++ b/src/bootchart/store.c @@ -35,6 +35,7 @@ #include "cgroup-util.h" #include "fd-util.h" #include "fileio.h" +#include "parse-util.h" #include "store.h" #include "string-util.h" #include "strxcpyx.h" diff --git a/src/cgtop/cgtop.c b/src/cgtop/cgtop.c index 3786dae2d98..43b8af44203 100644 --- a/src/cgtop/cgtop.c +++ b/src/cgtop/cgtop.c @@ -36,6 +36,7 @@ #include "fd-util.h" #include "fileio.h" #include "hashmap.h" +#include "parse-util.h" #include "path-util.h" #include "process-util.h" #include "terminal-util.h" diff --git a/src/core/automount.c b/src/core/automount.c index d362d6579d9..2ee32312fba 100644 --- a/src/core/automount.c +++ b/src/core/automount.c @@ -40,6 +40,7 @@ #include "label.h" #include "mkdir.h" #include "mount.h" +#include "parse-util.h" #include "path-util.h" #include "process-util.h" #include "special.h" diff --git a/src/core/busname.c b/src/core/busname.c index 335a1fdc4c9..df4a8bef52b 100644 --- a/src/core/busname.c +++ b/src/core/busname.c @@ -30,6 +30,7 @@ #include "fd-util.h" #include "formats-util.h" #include "kdbus.h" +#include "parse-util.h" #include "service.h" #include "signal-util.h" #include "special.h" diff --git a/src/core/cgroup.c b/src/core/cgroup.c index 2a2cf02774d..a33eaa8d421 100644 --- a/src/core/cgroup.c +++ b/src/core/cgroup.c @@ -25,6 +25,7 @@ #include "cgroup-util.h" #include "cgroup.h" #include "fd-util.h" +#include "parse-util.h" #include "path-util.h" #include "process-util.h" #include "special.h" diff --git a/src/core/dbus-execute.c b/src/core/dbus-execute.c index 6f1e0dc6ac2..a7fbd711442 100644 --- a/src/core/dbus-execute.c +++ b/src/core/dbus-execute.c @@ -36,13 +36,13 @@ #include "ioprio.h" #include "missing.h" #include "namespace.h" +#include "parse-util.h" #include "path-util.h" -#include "strv.h" -#include "utf8.h" - #ifdef HAVE_SECCOMP #include "seccomp-util.h" #endif +#include "strv.h" +#include "utf8.h" BUS_DEFINE_PROPERTY_GET_ENUM(bus_property_get_exec_output, exec_output, ExecOutput); diff --git a/src/core/device.c b/src/core/device.c index 9127d2d2252..fb467a48765 100644 --- a/src/core/device.c +++ b/src/core/device.c @@ -25,14 +25,15 @@ #include "libudev.h" #include "dbus-device.h" +#include "device.h" #include "log.h" +#include "parse-util.h" #include "path-util.h" #include "string-util.h" #include "swap.h" #include "udev-util.h" #include "unit-name.h" #include "unit.h" -#include "device.h" static const UnitActiveState state_translation_table[_DEVICE_STATE_MAX] = { [DEVICE_DEAD] = UNIT_INACTIVE, diff --git a/src/core/execute.c b/src/core/execute.c index 3f2607ff1a2..24a8e646ad6 100644 --- a/src/core/execute.c +++ b/src/core/execute.c @@ -76,6 +76,7 @@ #include "missing.h" #include "mkdir.h" #include "namespace.h" +#include "parse-util.h" #include "path-util.h" #include "process-util.h" #include "rm-rf.h" diff --git a/src/core/job.c b/src/core/job.c index 8a0e0a0ea41..7fde88f5fe5 100644 --- a/src/core/job.c +++ b/src/core/job.c @@ -28,8 +28,10 @@ #include "dbus-job.h" #include "dbus.h" #include "escape.h" +#include "job.h" #include "log.h" #include "macro.h" +#include "parse-util.h" #include "set.h" #include "special.h" #include "string-util.h" @@ -37,7 +39,6 @@ #include "terminal-util.h" #include "unit.h" #include "virt.h" -#include "job.h" Job* job_new_raw(Unit *unit) { Job *j; diff --git a/src/core/killall.c b/src/core/killall.c index cb119871666..dbfa90ebacb 100644 --- a/src/core/killall.c +++ b/src/core/killall.c @@ -27,6 +27,7 @@ #include "fd-util.h" #include "formats-util.h" #include "killall.h" +#include "parse-util.h" #include "process-util.h" #include "set.h" #include "string-util.h" diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c index 31fdc48823e..f5c28e514f8 100644 --- a/src/core/load-fragment.c +++ b/src/core/load-fragment.c @@ -48,6 +48,7 @@ #include "load-fragment.h" #include "log.h" #include "missing.h" +#include "parse-util.h" #include "path-util.h" #ifdef HAVE_SECCOMP #include "seccomp-util.h" diff --git a/src/core/main.c b/src/core/main.c index b0ca6fa10e0..a8834b6f0b2 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -67,6 +67,7 @@ #include "missing.h" #include "mount-setup.h" #include "pager.h" +#include "parse-util.h" #include "process-util.h" #include "selinux-setup.h" #include "selinux-util.h" diff --git a/src/core/manager.c b/src/core/manager.c index 287676ff270..9ad8a136abb 100644 --- a/src/core/manager.c +++ b/src/core/manager.c @@ -62,6 +62,7 @@ #include "manager.h" #include "missing.h" #include "mkdir.h" +#include "parse-util.h" #include "path-lookup.h" #include "path-util.h" #include "process-util.h" diff --git a/src/core/mount.c b/src/core/mount.c index ebdb3503e9b..59f56bdefa5 100644 --- a/src/core/mount.c +++ b/src/core/mount.c @@ -36,6 +36,7 @@ #include "mkdir.h" #include "mount-setup.h" #include "mount.h" +#include "parse-util.h" #include "path-util.h" #include "smack-util.h" #include "special.h" diff --git a/src/core/service.c b/src/core/service.c index abcbd4954f1..d5bd8869da7 100644 --- a/src/core/service.c +++ b/src/core/service.c @@ -39,6 +39,7 @@ #include "load-fragment.h" #include "log.h" #include "manager.h" +#include "parse-util.h" #include "path-util.h" #include "process-util.h" #include "service.h" diff --git a/src/core/show-status.c b/src/core/show-status.c index 7951ea73038..9e4c9f563ef 100644 --- a/src/core/show-status.c +++ b/src/core/show-status.c @@ -19,9 +19,10 @@ along with systemd; If not, see . ***/ +#include "parse-util.h" +#include "show-status.h" #include "string-util.h" #include "util.h" -#include "show-status.h" int parse_show_status(const char *v, ShowStatus *ret) { int r; diff --git a/src/core/shutdown.c b/src/core/shutdown.c index 33383a4b0bd..93bbc315d36 100644 --- a/src/core/shutdown.c +++ b/src/core/shutdown.c @@ -37,6 +37,7 @@ #include "killall.h" #include "log.h" #include "missing.h" +#include "parse-util.h" #include "process-util.h" #include "string-util.h" #include "switch-root.h" diff --git a/src/core/snapshot.c b/src/core/snapshot.c index 15726c344e5..da1c99ad12e 100644 --- a/src/core/snapshot.c +++ b/src/core/snapshot.c @@ -23,10 +23,12 @@ #include "bus-common-errors.h" #include "dbus-snapshot.h" +#include "parse-util.h" +#include "parse-util.h" +#include "snapshot.h" #include "string-util.h" #include "unit-name.h" #include "unit.h" -#include "snapshot.h" static const UnitActiveState state_translation_table[_SNAPSHOT_STATE_MAX] = { [SNAPSHOT_DEAD] = UNIT_INACTIVE, diff --git a/src/core/snapshot.h b/src/core/snapshot.h index 97747e18bdf..bd52dea408b 100644 --- a/src/core/snapshot.h +++ b/src/core/snapshot.h @@ -23,6 +23,8 @@ typedef struct Snapshot Snapshot; +#include "unit.h" + struct Snapshot { Unit meta; diff --git a/src/core/socket.c b/src/core/socket.c index 7f401025ed5..49cef210dcb 100644 --- a/src/core/socket.c +++ b/src/core/socket.c @@ -43,6 +43,7 @@ #include "log.h" #include "missing.h" #include "mkdir.h" +#include "parse-util.h" #include "path-util.h" #include "selinux-util.h" #include "signal-util.h" diff --git a/src/core/swap.c b/src/core/swap.c index d864c7b3041..c4151c6afde 100644 --- a/src/core/swap.c +++ b/src/core/swap.c @@ -32,6 +32,7 @@ #include "fd-util.h" #include "formats-util.h" #include "fstab-util.h" +#include "parse-util.h" #include "path-util.h" #include "special.h" #include "string-util.h" diff --git a/src/core/timer.c b/src/core/timer.c index 908d45ac739..3ece2e056d1 100644 --- a/src/core/timer.c +++ b/src/core/timer.c @@ -24,6 +24,7 @@ #include "bus-error.h" #include "bus-util.h" #include "dbus-timer.h" +#include "parse-util.h" #include "special.h" #include "string-util.h" #include "timer.h" diff --git a/src/core/unit.c b/src/core/unit.c index 572b1c1b784..17c135cf3f8 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -44,6 +44,7 @@ #include "macro.h" #include "missing.h" #include "mkdir.h" +#include "parse-util.h" #include "path-util.h" #include "process-util.h" #include "set.h" diff --git a/src/cryptsetup/cryptsetup-generator.c b/src/cryptsetup/cryptsetup-generator.c index 78adcf18d6f..51a2c6dfd7b 100644 --- a/src/cryptsetup/cryptsetup-generator.c +++ b/src/cryptsetup/cryptsetup-generator.c @@ -28,6 +28,7 @@ #include "hashmap.h" #include "log.h" #include "mkdir.h" +#include "parse-util.h" #include "path-util.h" #include "string-util.h" #include "strv.h" diff --git a/src/cryptsetup/cryptsetup.c b/src/cryptsetup/cryptsetup.c index f5fb6a09fe0..4c1d8a8e746 100644 --- a/src/cryptsetup/cryptsetup.c +++ b/src/cryptsetup/cryptsetup.c @@ -32,6 +32,7 @@ #include "escape.h" #include "fileio.h" #include "log.h" +#include "parse-util.h" #include "path-util.h" #include "string-util.h" #include "strv.h" diff --git a/src/debug-generator/debug-generator.c b/src/debug-generator/debug-generator.c index 7f26108e9cc..115f99e68ca 100644 --- a/src/debug-generator/debug-generator.c +++ b/src/debug-generator/debug-generator.c @@ -24,6 +24,7 @@ #include "unit-name.h" #include "mkdir.h" #include "string-util.h" +#include "parse-util.h" static const char *arg_dest = "/tmp"; static char **arg_mask = NULL; diff --git a/src/delta/delta.c b/src/delta/delta.c index 5dbd526b9b3..bb2e6195b98 100644 --- a/src/delta/delta.c +++ b/src/delta/delta.c @@ -30,6 +30,7 @@ #include "hashmap.h" #include "log.h" #include "pager.h" +#include "parse-util.h" #include "path-util.h" #include "process-util.h" #include "signal-util.h" diff --git a/src/firstboot/firstboot.c b/src/firstboot/firstboot.c index 5aa247b2ae0..abb5e77966a 100644 --- a/src/firstboot/firstboot.c +++ b/src/firstboot/firstboot.c @@ -26,17 +26,18 @@ #include "ask-password-api.h" #include "copy.h" +#include "fd-util.h" #include "fileio.h" #include "hostname-util.h" #include "locale-util.h" #include "mkdir.h" +#include "parse-util.h" #include "path-util.h" #include "random-util.h" +#include "string-util.h" #include "strv.h" #include "terminal-util.h" #include "time-util.h" -#include "string-util.h" -#include "fd-util.h" static char *arg_root = NULL; static char *arg_locale = NULL; /* $LANG */ diff --git a/src/fsck/fsck.c b/src/fsck/fsck.c index 9c49557787d..7415be1529b 100644 --- a/src/fsck/fsck.c +++ b/src/fsck/fsck.c @@ -37,6 +37,7 @@ #include "bus-util.h" #include "device-util.h" #include "fd-util.h" +#include "parse-util.h" #include "path-util.h" #include "process-util.h" #include "signal-util.h" diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c index 0a3917b7ba3..18baf6cc7d3 100644 --- a/src/fstab-generator/fstab-generator.c +++ b/src/fstab-generator/fstab-generator.c @@ -31,6 +31,7 @@ #include "log.h" #include "mkdir.h" #include "mount-setup.h" +#include "parse-util.h" #include "path-util.h" #include "special.h" #include "string-util.h" diff --git a/src/gpt-auto-generator/gpt-auto-generator.c b/src/gpt-auto-generator/gpt-auto-generator.c index ba97c98d6f2..ac6d731753e 100644 --- a/src/gpt-auto-generator/gpt-auto-generator.c +++ b/src/gpt-auto-generator/gpt-auto-generator.c @@ -37,6 +37,7 @@ #include "gpt.h" #include "missing.h" #include "mkdir.h" +#include "parse-util.h" #include "path-util.h" #include "special.h" #include "string-util.h" diff --git a/src/hostname/hostnamed.c b/src/hostname/hostnamed.c index dd508aefb5f..8bff7d4b39f 100644 --- a/src/hostname/hostnamed.c +++ b/src/hostname/hostnamed.c @@ -24,16 +24,17 @@ #include #include -#include "util.h" -#include "strv.h" +#include "bus-util.h" #include "def.h" -#include "virt.h" #include "env-util.h" -#include "fileio-label.h" -#include "bus-util.h" #include "event-util.h" -#include "selinux-util.h" +#include "fileio-label.h" #include "hostname-util.h" +#include "parse-util.h" +#include "selinux-util.h" +#include "strv.h" +#include "util.h" +#include "virt.h" #define VALID_DEPLOYMENT_CHARS (DIGITS LETTERS "-.:") diff --git a/src/import/importd.c b/src/import/importd.c index b712cedcc6b..975907e3c92 100644 --- a/src/import/importd.c +++ b/src/import/importd.c @@ -32,6 +32,7 @@ #include "machine-pool.h" #include "missing.h" #include "mkdir.h" +#include "parse-util.h" #include "path-util.h" #include "process-util.h" #include "signal-util.h" diff --git a/src/import/pull-job.c b/src/import/pull-job.c index 4736306de22..fd058777050 100644 --- a/src/import/pull-job.c +++ b/src/import/pull-job.c @@ -24,6 +24,7 @@ #include "fd-util.h" #include "io-util.h" #include "machine-pool.h" +#include "parse-util.h" #include "pull-job.h" #include "string-util.h" #include "strv.h" diff --git a/src/import/pull.c b/src/import/pull.c index 73d5f391c25..50299330748 100644 --- a/src/import/pull.c +++ b/src/import/pull.c @@ -27,6 +27,7 @@ #include "hostname-util.h" #include "import-util.h" #include "machine-image.h" +#include "parse-util.h" #include "pull-dkr.h" #include "pull-raw.h" #include "pull-tar.h" diff --git a/src/journal-remote/journal-gatewayd.c b/src/journal-remote/journal-gatewayd.c index 92ef723afff..b8a513bb749 100644 --- a/src/journal-remote/journal-gatewayd.c +++ b/src/journal-remote/journal-gatewayd.c @@ -40,6 +40,7 @@ #include "log.h" #include "logs-show.h" #include "microhttpd-util.h" +#include "parse-util.h" #include "sigbus.h" #include "util.h" diff --git a/src/journal-remote/journal-remote-parse.c b/src/journal-remote/journal-remote-parse.c index bb299e378c6..db1636ac3e6 100644 --- a/src/journal-remote/journal-remote-parse.c +++ b/src/journal-remote/journal-remote-parse.c @@ -22,6 +22,7 @@ #include "fd-util.h" #include "journal-remote-parse.h" #include "journald-native.h" +#include "parse-util.h" #include "string-util.h" #define LINE_CHUNK 8*1024u diff --git a/src/journal-remote/journal-remote.c b/src/journal-remote/journal-remote.c index de207f8d249..01c8e5c37ac 100644 --- a/src/journal-remote/journal-remote.c +++ b/src/journal-remote/journal-remote.c @@ -44,6 +44,7 @@ #include "journal-remote.h" #include "journald-native.h" #include "macro.h" +#include "parse-util.h" #include "signal-util.h" #include "socket-util.h" #include "string-util.h" diff --git a/src/journal-remote/journal-upload.c b/src/journal-remote/journal-upload.c index a945a9971a6..20e2a2f73bd 100644 --- a/src/journal-remote/journal-upload.c +++ b/src/journal-remote/journal-upload.c @@ -34,6 +34,7 @@ #include "journal-upload.h" #include "log.h" #include "mkdir.h" +#include "parse-util.h" #include "sigbus.h" #include "signal-util.h" #include "string-util.h" diff --git a/src/journal/cat.c b/src/journal/cat.c index ff1887604a5..95a1868b939 100644 --- a/src/journal/cat.c +++ b/src/journal/cat.c @@ -29,6 +29,7 @@ #include "sd-journal.h" #include "fd-util.h" +#include "parse-util.h" #include "string-util.h" #include "util.h" diff --git a/src/journal/coredump.c b/src/journal/coredump.c index 7336db219b9..92f598464a3 100644 --- a/src/journal/coredump.c +++ b/src/journal/coredump.c @@ -47,6 +47,7 @@ #include "log.h" #include "macro.h" #include "mkdir.h" +#include "parse-util.h" #include "process-util.h" #include "special.h" #include "stacktrace.h" diff --git a/src/journal/coredumpctl.c b/src/journal/coredumpctl.c index f891ddffc6b..fecccd4eb92 100644 --- a/src/journal/coredumpctl.c +++ b/src/journal/coredumpctl.c @@ -34,6 +34,7 @@ #include "log.h" #include "macro.h" #include "pager.h" +#include "parse-util.h" #include "path-util.h" #include "process-util.h" #include "set.h" @@ -41,8 +42,8 @@ #include "signal-util.h" #include "string-util.h" #include "terminal-util.h" -#include "util.h" #include "user-util.h" +#include "util.h" static enum { ACTION_NONE, diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c index f193cb90ce6..c33e278cbe6 100644 --- a/src/journal/journal-file.c +++ b/src/journal/journal-file.c @@ -35,6 +35,7 @@ #include "journal-def.h" #include "journal-file.h" #include "lookup3.h" +#include "parse-util.h" #include "random-util.h" #include "string-util.h" diff --git a/src/journal/journal-vacuum.c b/src/journal/journal-vacuum.c index dca5bf5000d..026dca49012 100644 --- a/src/journal/journal-vacuum.c +++ b/src/journal/journal-vacuum.c @@ -29,6 +29,7 @@ #include "journal-def.h" #include "journal-file.h" #include "journal-vacuum.h" +#include "parse-util.h" #include "string-util.h" #include "util.h" diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c index 6e452a4d511..c13b674e15d 100644 --- a/src/journal/journalctl.c +++ b/src/journal/journalctl.c @@ -56,6 +56,7 @@ #include "logs-show.h" #include "mkdir.h" #include "pager.h" +#include "parse-util.h" #include "path-util.h" #include "set.h" #include "sigbus.h" diff --git a/src/journal/journald-console.c b/src/journal/journald-console.c index 5f3eb052752..4a5e07ec5df 100644 --- a/src/journal/journald-console.c +++ b/src/journal/journald-console.c @@ -23,13 +23,14 @@ #include #include +#include "fd-util.h" #include "fileio.h" -#include "journald-server.h" -#include "journald-console.h" #include "formats-util.h" +#include "journald-console.h" +#include "journald-server.h" +#include "parse-util.h" #include "process-util.h" #include "terminal-util.h" -#include "fd-util.h" static bool prefix_timestamp(void) { diff --git a/src/journal/journald-kmsg.c b/src/journal/journald-kmsg.c index 5a05632e56e..e680aafafe0 100644 --- a/src/journal/journald-kmsg.c +++ b/src/journal/journald-kmsg.c @@ -34,6 +34,7 @@ #include "journald-kmsg.h" #include "journald-server.h" #include "journald-syslog.h" +#include "parse-util.h" #include "process-util.h" #include "string-util.h" diff --git a/src/journal/journald-native.c b/src/journal/journald-native.c index 7d4aac687e4..ae229ecaf54 100644 --- a/src/journal/journald-native.c +++ b/src/journal/journald-native.c @@ -32,6 +32,7 @@ #include "journald-syslog.h" #include "journald-wall.h" #include "memfd-util.h" +#include "parse-util.h" #include "path-util.h" #include "selinux-util.h" #include "socket-util.h" diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c index 7cefea323e8..f286e3030f7 100644 --- a/src/journal/journald-server.c +++ b/src/journal/journald-server.c @@ -54,6 +54,7 @@ #include "journald-syslog.h" #include "missing.h" #include "mkdir.h" +#include "parse-util.h" #include "process-util.h" #include "rm-rf.h" #include "selinux-util.h" diff --git a/src/journal/journald-stream.c b/src/journal/journald-stream.c index 0dd511519c5..6745864da11 100644 --- a/src/journal/journald-stream.c +++ b/src/journal/journald-stream.c @@ -39,6 +39,7 @@ #include "journald-syslog.h" #include "journald-wall.h" #include "mkdir.h" +#include "parse-util.h" #include "selinux-util.h" #include "socket-util.h" #include "string-util.h" diff --git a/src/journal/test-compress-benchmark.c b/src/journal/test-compress-benchmark.c index 0a9ab7f52ca..5a2f0564ca4 100644 --- a/src/journal/test-compress-benchmark.c +++ b/src/journal/test-compress-benchmark.c @@ -21,6 +21,7 @@ #include "compress.h" #include "macro.h" +#include "parse-util.h" #include "random-util.h" #include "string-util.h" #include "util.h" diff --git a/src/journal/test-journal-init.c b/src/journal/test-journal-init.c index 717b703d191..142da85041f 100644 --- a/src/journal/test-journal-init.c +++ b/src/journal/test-journal-init.c @@ -22,6 +22,7 @@ #include "sd-journal.h" #include "log.h" +#include "parse-util.h" #include "rm-rf.h" #include "util.h" diff --git a/src/journal/test-journal-interleaving.c b/src/journal/test-journal-interleaving.c index 8069339c1f4..3c8b0268a4a 100644 --- a/src/journal/test-journal-interleaving.c +++ b/src/journal/test-journal-interleaving.c @@ -24,11 +24,13 @@ #include #include "sd-journal.h" + #include "journal-file.h" #include "journal-vacuum.h" -#include "util.h" #include "log.h" +#include "parse-util.h" #include "rm-rf.h" +#include "util.h" /* This program tests skipping around in a multi-file journal. */ diff --git a/src/journal/test-journal-stream.c b/src/journal/test-journal-stream.c index b5ecf2f375c..b8482743a2c 100644 --- a/src/journal/test-journal-stream.c +++ b/src/journal/test-journal-stream.c @@ -19,16 +19,18 @@ along with systemd; If not, see . ***/ -#include #include +#include #include "sd-journal.h" -#include "util.h" + +#include "journal-file.h" +#include "journal-internal.h" #include "log.h" #include "macro.h" +#include "parse-util.h" #include "rm-rf.h" -#include "journal-file.h" -#include "journal-internal.h" +#include "util.h" #define N_ENTRIES 200 diff --git a/src/libsystemd-network/network-internal.c b/src/libsystemd-network/network-internal.c index 39551b57616..926ad0b02f3 100644 --- a/src/libsystemd-network/network-internal.c +++ b/src/libsystemd-network/network-internal.c @@ -29,12 +29,13 @@ #include "conf-parser.h" #include "dhcp-lease-internal.h" #include "log.h" +#include "network-internal.h" +#include "parse-util.h" #include "siphash24.h" #include "string-util.h" #include "strv.h" #include "utf8.h" #include "util.h" -#include "network-internal.h" const char *net_get_name(struct udev_device *device) { const char *name, *field; diff --git a/src/libsystemd-network/sd-dhcp-lease.c b/src/libsystemd-network/sd-dhcp-lease.c index d982936a28f..94a276fb289 100644 --- a/src/libsystemd-network/sd-dhcp-lease.c +++ b/src/libsystemd-network/sd-dhcp-lease.c @@ -34,6 +34,7 @@ #include "hostname-util.h" #include "in-addr-util.h" #include "network-internal.h" +#include "parse-util.h" #include "unaligned.h" int sd_dhcp_lease_get_address(sd_dhcp_lease *lease, struct in_addr *addr) { diff --git a/src/libsystemd-network/test-ipv4ll-manual.c b/src/libsystemd-network/test-ipv4ll-manual.c index 08421c35751..9485a7df64a 100644 --- a/src/libsystemd-network/test-ipv4ll-manual.c +++ b/src/libsystemd-network/test-ipv4ll-manual.c @@ -32,6 +32,7 @@ #include "event-util.h" #include "in-addr-util.h" #include "netlink-util.h" +#include "parse-util.h" #include "string-util.h" #include "util.h" diff --git a/src/libsystemd/sd-bus/bus-creds.c b/src/libsystemd/sd-bus/bus-creds.c index d7bff784b8d..eee53b6407d 100644 --- a/src/libsystemd/sd-bus/bus-creds.c +++ b/src/libsystemd/sd-bus/bus-creds.c @@ -32,6 +32,7 @@ #include "fd-util.h" #include "fileio.h" #include "formats-util.h" +#include "parse-util.h" #include "process-util.h" #include "string-util.h" #include "strv.h" diff --git a/src/libsystemd/sd-bus/bus-kernel.c b/src/libsystemd/sd-bus/bus-kernel.c index f311e86d446..6f396b79531 100644 --- a/src/libsystemd/sd-bus/bus-kernel.c +++ b/src/libsystemd/sd-bus/bus-kernel.c @@ -45,6 +45,7 @@ #include "fileio.h" #include "formats-util.h" #include "memfd-util.h" +#include "parse-util.h" #include "string-util.h" #include "strv.h" #include "util.h" diff --git a/src/libsystemd/sd-bus/busctl.c b/src/libsystemd/sd-bus/busctl.c index d3e846db84b..4b121e849ab 100644 --- a/src/libsystemd/sd-bus/busctl.c +++ b/src/libsystemd/sd-bus/busctl.c @@ -33,6 +33,7 @@ #include "fd-util.h" #include "log.h" #include "pager.h" +#include "parse-util.h" #include "path-util.h" #include "set.h" #include "strv.h" diff --git a/src/libsystemd/sd-bus/sd-bus.c b/src/libsystemd/sd-bus/sd-bus.c index 7b91c2583df..36370e79e39 100644 --- a/src/libsystemd/sd-bus/sd-bus.c +++ b/src/libsystemd/sd-bus/sd-bus.c @@ -48,6 +48,7 @@ #include "hostname-util.h" #include "macro.h" #include "missing.h" +#include "parse-util.h" #include "string-util.h" #include "strv.h" #include "util.h" diff --git a/src/libsystemd/sd-daemon/sd-daemon.c b/src/libsystemd/sd-daemon/sd-daemon.c index 85c73722df4..a125be7cb87 100644 --- a/src/libsystemd/sd-daemon/sd-daemon.c +++ b/src/libsystemd/sd-daemon/sd-daemon.c @@ -36,6 +36,7 @@ #include "sd-daemon.h" #include "fd-util.h" +#include "parse-util.h" #include "path-util.h" #include "socket-util.h" #include "strv.h" diff --git a/src/libsystemd/sd-device/device-private.c b/src/libsystemd/sd-device/device-private.c index bcabf9468d4..91690d83f68 100644 --- a/src/libsystemd/sd-device/device-private.c +++ b/src/libsystemd/sd-device/device-private.c @@ -32,6 +32,7 @@ #include "hashmap.h" #include "macro.h" #include "mkdir.h" +#include "parse-util.h" #include "path-util.h" #include "refcnt.h" #include "set.h" diff --git a/src/libsystemd/sd-device/sd-device.c b/src/libsystemd/sd-device/sd-device.c index 593dda52f2a..0e7a26523d4 100644 --- a/src/libsystemd/sd-device/sd-device.c +++ b/src/libsystemd/sd-device/sd-device.c @@ -31,6 +31,7 @@ #include "fileio.h" #include "hashmap.h" #include "macro.h" +#include "parse-util.h" #include "path-util.h" #include "set.h" #include "string-util.h" diff --git a/src/libsystemd/sd-login/sd-login.c b/src/libsystemd/sd-login/sd-login.c index f564d43e06a..05cba9651a5 100644 --- a/src/libsystemd/sd-login/sd-login.c +++ b/src/libsystemd/sd-login/sd-login.c @@ -36,6 +36,7 @@ #include "io-util.h" #include "login-util.h" #include "macro.h" +#include "parse-util.h" #include "socket-util.h" #include "string-util.h" #include "strv.h" diff --git a/src/libsystemd/sd-network/sd-network.c b/src/libsystemd/sd-network/sd-network.c index ad1227264c4..6cc3321f429 100644 --- a/src/libsystemd/sd-network/sd-network.c +++ b/src/libsystemd/sd-network/sd-network.c @@ -33,6 +33,7 @@ #include "strv.h" #include "util.h" #include "fd-util.h" +#include "parse-util.h" _public_ int sd_network_get_operational_state(char **state) { _cleanup_free_ char *s = NULL; diff --git a/src/libudev/libudev-device.c b/src/libudev/libudev-device.c index 1e513f3ff75..bd349e3f640 100644 --- a/src/libudev/libudev-device.c +++ b/src/libudev/libudev-device.c @@ -41,6 +41,7 @@ #include "device-util.h" #include "libudev-device-internal.h" #include "libudev-private.h" +#include "parse-util.h" /** * SECTION:libudev-device diff --git a/src/login/loginctl.c b/src/login/loginctl.c index 1cd186dec3d..92443c81909 100644 --- a/src/login/loginctl.c +++ b/src/login/loginctl.c @@ -35,6 +35,7 @@ #include "logs-show.h" #include "macro.h" #include "pager.h" +#include "parse-util.h" #include "process-util.h" #include "signal-util.h" #include "spawn-polkit-agent.h" diff --git a/src/login/logind-inhibit.c b/src/login/logind-inhibit.c index c4b74eb734f..460c2f0bd8d 100644 --- a/src/login/logind-inhibit.c +++ b/src/login/logind-inhibit.c @@ -30,6 +30,7 @@ #include "formats-util.h" #include "logind-inhibit.h" #include "mkdir.h" +#include "parse-util.h" #include "string-util.h" #include "user-util.h" #include "util.h" diff --git a/src/login/logind-seat.c b/src/login/logind-seat.c index dad552d5f25..2566894d057 100644 --- a/src/login/logind-seat.c +++ b/src/login/logind-seat.c @@ -31,6 +31,7 @@ #include "logind-acl.h" #include "logind-seat.h" #include "mkdir.h" +#include "parse-util.h" #include "string-util.h" #include "terminal-util.h" #include "util.h" diff --git a/src/login/logind-session.c b/src/login/logind-session.c index 714b1cb2997..9651d3e24af 100644 --- a/src/login/logind-session.c +++ b/src/login/logind-session.c @@ -41,6 +41,7 @@ #include "io-util.h" #include "logind-session.h" #include "mkdir.h" +#include "parse-util.h" #include "path-util.h" #include "terminal-util.h" #include "user-util.h" diff --git a/src/login/logind-user.c b/src/login/logind-user.c index 80328068cdd..9f3af59b545 100644 --- a/src/login/logind-user.c +++ b/src/login/logind-user.c @@ -36,6 +36,7 @@ #include "label.h" #include "logind-user.h" #include "mkdir.h" +#include "parse-util.h" #include "path-util.h" #include "rm-rf.h" #include "smack-util.h" diff --git a/src/login/pam_systemd.c b/src/login/pam_systemd.c index dbd055a79a0..464da88bccb 100644 --- a/src/login/pam_systemd.c +++ b/src/login/pam_systemd.c @@ -41,6 +41,7 @@ #include "hostname-util.h" #include "login-util.h" #include "macro.h" +#include "parse-util.h" #include "socket-util.h" #include "strv.h" #include "terminal-util.h" diff --git a/src/machine/machine.c b/src/machine/machine.c index e41f8add986..7aff55b761d 100644 --- a/src/machine/machine.c +++ b/src/machine/machine.c @@ -35,6 +35,7 @@ #include "machine-dbus.h" #include "machine.h" #include "mkdir.h" +#include "parse-util.h" #include "special.h" #include "terminal-util.h" #include "unit-name.h" diff --git a/src/machine/machinectl.c b/src/machine/machinectl.c index 23cc74ab542..274952b8ce2 100644 --- a/src/machine/machinectl.c +++ b/src/machine/machinectl.c @@ -48,6 +48,7 @@ #include "macro.h" #include "mkdir.h" #include "pager.h" +#include "parse-util.h" #include "path-util.h" #include "process-util.h" #include "ptyfwd.h" diff --git a/src/network/networkctl.c b/src/network/networkctl.c index acb6b7ce240..be679acca0e 100644 --- a/src/network/networkctl.c +++ b/src/network/networkctl.c @@ -36,6 +36,7 @@ #include "local-addresses.h" #include "netlink-util.h" #include "pager.h" +#include "parse-util.h" #include "socket-util.h" #include "string-util.h" #include "strv.h" diff --git a/src/network/networkd-address.c b/src/network/networkd-address.c index dcd7b482d38..1beb7ffae48 100644 --- a/src/network/networkd-address.c +++ b/src/network/networkd-address.c @@ -24,12 +24,13 @@ #include "conf-parser.h" #include "firewall-util.h" #include "netlink-util.h" +#include "networkd-address.h" #include "networkd.h" +#include "parse-util.h" #include "set.h" #include "string-util.h" #include "utf8.h" #include "util.h" -#include "networkd-address.h" int address_new(Address **ret) { _cleanup_address_free_ Address *address = NULL; diff --git a/src/network/networkd-link-bus.c b/src/network/networkd-link-bus.c index 1a1524dfb4e..f40a01fd78e 100644 --- a/src/network/networkd-link-bus.c +++ b/src/network/networkd-link-bus.c @@ -22,8 +22,9 @@ #include "bus-util.h" #include "strv.h" -#include "networkd.h" #include "networkd-link.h" +#include "networkd.h" +#include "parse-util.h" static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_operational_state, link_operstate, LinkOperationalState); static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_administrative_state, link_state, LinkState); diff --git a/src/network/networkd-netdev-tunnel.c b/src/network/networkd-netdev-tunnel.c index bbc46062581..2dd16be3817 100644 --- a/src/network/networkd-netdev-tunnel.c +++ b/src/network/networkd-netdev-tunnel.c @@ -30,9 +30,10 @@ #include "conf-parser.h" #include "missing.h" #include "networkd-link.h" +#include "networkd-netdev-tunnel.h" +#include "parse-util.h" #include "string-util.h" #include "util.h" -#include "networkd-netdev-tunnel.h" #define DEFAULT_TNL_HOP_LIMIT 64 #define IP6_FLOWINFO_FLOWLABEL htonl(0x000FFFFF) diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c index 150fd052c25..6cef5fb7aa1 100644 --- a/src/network/networkd-network.c +++ b/src/network/networkd-network.c @@ -30,6 +30,7 @@ #include "network-internal.h" #include "networkd-network.h" #include "networkd.h" +#include "parse-util.h" #include "string-util.h" #include "util.h" diff --git a/src/network/networkd-route.c b/src/network/networkd-route.c index fcca6790936..7ae6ca26005 100644 --- a/src/network/networkd-route.c +++ b/src/network/networkd-route.c @@ -22,10 +22,11 @@ #include "conf-parser.h" #include "in-addr-util.h" #include "netlink-util.h" +#include "networkd-route.h" #include "networkd.h" +#include "parse-util.h" #include "string-util.h" #include "util.h" -#include "networkd-route.h" int route_new(Route **ret) { _cleanup_route_free_ Route *route = NULL; diff --git a/src/network/networkd-util.c b/src/network/networkd-util.c index 4e4a4bbd588..3ada0ce32b2 100644 --- a/src/network/networkd-util.c +++ b/src/network/networkd-util.c @@ -21,6 +21,7 @@ #include "conf-parser.h" #include "networkd-util.h" +#include "parse-util.h" #include "string-util.h" #include "util.h" diff --git a/src/notify/notify.c b/src/notify/notify.c index 288e0a43166..77f017dbac6 100644 --- a/src/notify/notify.c +++ b/src/notify/notify.c @@ -30,6 +30,7 @@ #include "env-util.h" #include "formats-util.h" #include "log.h" +#include "parse-util.h" #include "string-util.h" #include "strv.h" #include "util.h" diff --git a/src/nspawn/nspawn-expose-ports.c b/src/nspawn/nspawn-expose-ports.c index 98e4a7682f2..89c82403992 100644 --- a/src/nspawn/nspawn-expose-ports.c +++ b/src/nspawn/nspawn-expose-ports.c @@ -27,6 +27,7 @@ #include "local-addresses.h" #include "netlink-util.h" #include "nspawn-expose-ports.h" +#include "parse-util.h" #include "socket-util.h" #include "string-util.h" #include "util.h" diff --git a/src/nspawn/nspawn-mount.c b/src/nspawn/nspawn-mount.c index 25457fd62d6..5d8172092a6 100644 --- a/src/nspawn/nspawn-mount.c +++ b/src/nspawn/nspawn-mount.c @@ -26,13 +26,14 @@ #include "escape.h" #include "label.h" #include "mkdir.h" +#include "nspawn-mount.h" +#include "parse-util.h" #include "path-util.h" #include "rm-rf.h" #include "set.h" #include "string-util.h" #include "strv.h" #include "util.h" -#include "nspawn-mount.h" CustomMount* custom_mount_add(CustomMount **l, unsigned *n, CustomMountType t) { CustomMount *c, *ret; diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c index 6502fe1943b..a4eefe5eb88 100644 --- a/src/nspawn/nspawn.c +++ b/src/nspawn/nspawn.c @@ -77,6 +77,7 @@ #include "nspawn-register.h" #include "nspawn-settings.h" #include "nspawn-setuid.h" +#include "parse-util.h" #include "path-util.h" #include "process-util.h" #include "ptyfwd.h" diff --git a/src/resolve-host/resolve-host.c b/src/resolve-host/resolve-host.c index 97516a87a8c..9b808ff110f 100644 --- a/src/resolve-host/resolve-host.c +++ b/src/resolve-host/resolve-host.c @@ -28,6 +28,7 @@ #include "bus-error.h" #include "bus-util.h" #include "in-addr-util.h" +#include "parse-util.h" #include "resolved-def.h" #include "resolved-dns-packet.h" diff --git a/src/resolve/resolved-conf.c b/src/resolve/resolved-conf.c index 22a5c7fdbfb..17eafec2fa6 100644 --- a/src/resolve/resolved-conf.c +++ b/src/resolve/resolved-conf.c @@ -20,9 +20,10 @@ ***/ #include "conf-parser.h" -#include "string-util.h" +#include "parse-util.h" #include "resolved-conf.h" #include "extract-word.h" +#include "string-util.h" int manager_parse_dns_server(Manager *m, DnsServerType type, const char *string) { DnsServer *first; diff --git a/src/resolve/resolved-link.c b/src/resolve/resolved-link.c index 43a3b61b08a..8c88e2dbf11 100644 --- a/src/resolve/resolved-link.c +++ b/src/resolve/resolved-link.c @@ -24,6 +24,7 @@ #include "sd-network.h" #include "missing.h" +#include "parse-util.h" #include "resolved-link.h" #include "string-util.h" #include "strv.h" diff --git a/src/resolve/resolved-manager.c b/src/resolve/resolved-manager.c index 6144eedfeb8..a6aac196dbf 100644 --- a/src/resolve/resolved-manager.c +++ b/src/resolve/resolved-manager.c @@ -33,6 +33,7 @@ #include "netlink-util.h" #include "network-internal.h" #include "ordered-set.h" +#include "parse-util.h" #include "random-util.h" #include "resolved-bus.h" #include "resolved-conf.h" diff --git a/src/rfkill/rfkill.c b/src/rfkill/rfkill.c index 311343e4547..559a1765353 100644 --- a/src/rfkill/rfkill.c +++ b/src/rfkill/rfkill.c @@ -30,6 +30,7 @@ #include "fileio.h" #include "io-util.h" #include "mkdir.h" +#include "parse-util.h" #include "string-util.h" #include "udev-util.h" #include "util.h" diff --git a/src/run/run.c b/src/run/run.c index 36463059619..dbcb29546f5 100644 --- a/src/run/run.c +++ b/src/run/run.c @@ -40,6 +40,7 @@ #include "terminal-util.h" #include "unit-name.h" #include "user-util.h" +#include "parse-util.h" static bool arg_ask_password = true; static bool arg_scope = false; diff --git a/src/shared/apparmor-util.c b/src/shared/apparmor-util.c index c2bbd330bdd..48d0f84995f 100644 --- a/src/shared/apparmor-util.c +++ b/src/shared/apparmor-util.c @@ -19,10 +19,10 @@ along with systemd; If not, see . ***/ - -#include "util.h" -#include "fileio.h" #include "apparmor-util.h" +#include "fileio.h" +#include "parse-util.h" +#include "util.h" bool mac_apparmor_use(void) { static int cached_use = -1; diff --git a/src/shared/bus-util.c b/src/shared/bus-util.c index 604b8f248a2..53b9752af0a 100644 --- a/src/shared/bus-util.c +++ b/src/shared/bus-util.c @@ -37,6 +37,7 @@ #include "fd-util.h" #include "macro.h" #include "missing.h" +#include "parse-util.h" #include "path-util.h" #include "set.h" #include "signal-util.h" diff --git a/src/shared/condition.c b/src/shared/condition.c index b8915dab8a5..145ea410956 100644 --- a/src/shared/condition.c +++ b/src/shared/condition.c @@ -36,6 +36,7 @@ #include "fd-util.h" #include "hostname-util.h" #include "ima-util.h" +#include "parse-util.h" #include "path-util.h" #include "selinux-util.h" #include "smack-util.h" diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c index 1b47c0ab527..8bb33add720 100644 --- a/src/shared/conf-parser.c +++ b/src/shared/conf-parser.c @@ -27,16 +27,17 @@ #include "sd-messages.h" #include "conf-files.h" +#include "conf-parser.h" +#include "fd-util.h" #include "log.h" #include "macro.h" +#include "parse-util.h" #include "path-util.h" #include "signal-util.h" #include "string-util.h" #include "strv.h" #include "utf8.h" #include "util.h" -#include "conf-parser.h" -#include "fd-util.h" int config_item_table_lookup( const void *table, diff --git a/src/shared/dns-domain.c b/src/shared/dns-domain.c index d4df9d2acba..a8176af8404 100644 --- a/src/shared/dns-domain.c +++ b/src/shared/dns-domain.c @@ -24,8 +24,9 @@ #include #endif -#include "string-util.h" #include "dns-domain.h" +#include "parse-util.h" +#include "string-util.h" int dns_label_unescape(const char **name, char *dest, size_t sz) { const char *n; diff --git a/src/shared/efivars.c b/src/shared/efivars.c index 4808ede60c7..771bc9458c6 100644 --- a/src/shared/efivars.c +++ b/src/shared/efivars.c @@ -26,6 +26,7 @@ #include "efivars.h" #include "fd-util.h" #include "io-util.h" +#include "parse-util.h" #include "utf8.h" #include "util.h" #include "virt.h" diff --git a/src/shared/fstab-util.c b/src/shared/fstab-util.c index bdfc13e3cd0..20fb0f5a065 100644 --- a/src/shared/fstab-util.c +++ b/src/shared/fstab-util.c @@ -19,11 +19,12 @@ along with systemd; If not, see . ***/ +#include "fstab-util.h" +#include "parse-util.h" #include "path-util.h" #include "string-util.h" #include "strv.h" #include "util.h" -#include "fstab-util.h" bool fstab_is_mount_point(const char *mount) { _cleanup_endmntent_ FILE *f = NULL; diff --git a/src/shared/logs-show.c b/src/shared/logs-show.c index d8ea4c9f926..3519323b7ae 100644 --- a/src/shared/logs-show.c +++ b/src/shared/logs-show.c @@ -33,6 +33,7 @@ #include "journal-internal.h" #include "log.h" #include "logs-show.h" +#include "parse-util.h" #include "process-util.h" #include "string-util.h" #include "terminal-util.h" diff --git a/src/shared/machine-pool.c b/src/shared/machine-pool.c index a2cb5fc5a01..c576242b599 100644 --- a/src/shared/machine-pool.c +++ b/src/shared/machine-pool.c @@ -29,6 +29,7 @@ #include "lockfile-util.h" #include "machine-pool.h" #include "mkdir.h" +#include "parse-util.h" #include "path-util.h" #include "process-util.h" #include "signal-util.h" diff --git a/src/shared/sleep-config.c b/src/shared/sleep-config.c index b5cb9508bf5..0e232e6aa6f 100644 --- a/src/shared/sleep-config.c +++ b/src/shared/sleep-config.c @@ -29,6 +29,7 @@ #include "string-util.h" #include "strv.h" #include "util.h" +#include "parse-util.h" #define USE(x, y) do{ (x) = (y); (y) = NULL; } while(0) diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c index fe4213c0855..49a4b46fd42 100644 --- a/src/systemctl/systemctl.c +++ b/src/systemctl/systemctl.c @@ -61,6 +61,7 @@ #include "macro.h" #include "mkdir.h" #include "pager.h" +#include "parse-util.h" #include "path-lookup.h" #include "path-util.h" #include "process-util.h" diff --git a/src/test/test-btrfs.c b/src/test/test-btrfs.c index afe3ff8fc2c..33356f8387a 100644 --- a/src/test/test-btrfs.c +++ b/src/test/test-btrfs.c @@ -25,6 +25,7 @@ #include "fd-util.h" #include "fileio.h" #include "log.h" +#include "parse-util.h" #include "string-util.h" #include "util.h" diff --git a/src/test/test-cap-list.c b/src/test/test-cap-list.c index 43a2d35b803..5f178684588 100644 --- a/src/test/test-cap-list.c +++ b/src/test/test-cap-list.c @@ -19,11 +19,13 @@ along with systemd; If not, see . ***/ -#include "util.h" -#include "fileio.h" +#include + #include "cap-list.h" #include "capability.h" -#include +#include "fileio.h" +#include "parse-util.h" +#include "util.h" /* verify the capability parser */ static void test_cap_list(void) { diff --git a/src/test/test-cgroup-util.c b/src/test/test-cgroup-util.c index 7bf59a0aa21..af8d478fa9e 100644 --- a/src/test/test-cgroup-util.c +++ b/src/test/test-cgroup-util.c @@ -22,6 +22,7 @@ #include "cgroup-util.h" #include "fd-util.h" #include "formats-util.h" +#include "parse-util.h" #include "process-util.h" #include "string-util.h" #include "test-helper.h" diff --git a/src/test/test-fileio.c b/src/test/test-fileio.c index a40f013491b..1c1fed4660b 100644 --- a/src/test/test-fileio.c +++ b/src/test/test-fileio.c @@ -28,6 +28,7 @@ #include "env-util.h" #include "fd-util.h" #include "fileio.h" +#include "parse-util.h" #include "process-util.h" #include "string-util.h" #include "strv.h" diff --git a/src/test/test-util.c b/src/test/test-util.c index c1f8a866aff..f42d8f19bb0 100644 --- a/src/test/test-util.c +++ b/src/test/test-util.c @@ -39,14 +39,15 @@ #include "fileio.h" #include "io-util.h" #include "mkdir.h" +#include "parse-util.h" #include "process-util.h" #include "rm-rf.h" #include "signal-util.h" #include "string-util.h" #include "strv.h" +#include "user-util.h" #include "util.h" #include "virt.h" -#include "user-util.h" static void test_streq_ptr(void) { assert_se(streq_ptr(NULL, NULL)); diff --git a/src/timedate/timedatectl.c b/src/timedate/timedatectl.c index 68fbe3f5b85..564d72773a2 100644 --- a/src/timedate/timedatectl.c +++ b/src/timedate/timedatectl.c @@ -30,6 +30,7 @@ #include "bus-error.h" #include "bus-util.h" #include "pager.h" +#include "parse-util.h" #include "spawn-polkit-agent.h" #include "strv.h" #include "terminal-util.h" diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c index 05c4661a2c5..57cca17e807 100644 --- a/src/tmpfiles/tmpfiles.c +++ b/src/tmpfiles/tmpfiles.c @@ -52,6 +52,7 @@ #include "macro.h" #include "missing.h" #include "mkdir.h" +#include "parse-util.h" #include "path-util.h" #include "rm-rf.h" #include "selinux-util.h" diff --git a/src/udev/net/link-config.c b/src/udev/net/link-config.c index e9577930e32..7459ee1fe27 100644 --- a/src/udev/net/link-config.c +++ b/src/udev/net/link-config.c @@ -34,6 +34,7 @@ #include "missing.h" #include "netlink-util.h" #include "network-internal.h" +#include "parse-util.h" #include "path-util.h" #include "random-util.h" #include "string-util.h" diff --git a/src/udev/udev-builtin-keyboard.c b/src/udev/udev-builtin-keyboard.c index 5e97bdd614a..74df4cb0f43 100644 --- a/src/udev/udev-builtin-keyboard.c +++ b/src/udev/udev-builtin-keyboard.c @@ -24,6 +24,7 @@ #include #include "fd-util.h" +#include "parse-util.h" #include "string-util.h" #include "udev.h" diff --git a/src/udev/udevadm-settle.c b/src/udev/udevadm-settle.c index 3d6ca7a9858..c25071b0fee 100644 --- a/src/udev/udevadm-settle.c +++ b/src/udev/udevadm-settle.c @@ -26,6 +26,7 @@ #include #include +#include "parse-util.h" #include "udev.h" #include "util.h" diff --git a/src/udev/udevd.c b/src/udev/udevd.c index df5fd88bff5..f1fc1cd0821 100644 --- a/src/udev/udevd.c +++ b/src/udev/udevd.c @@ -53,6 +53,7 @@ #include "hashmap.h" #include "io-util.h" #include "netlink-util.h" +#include "parse-util.h" #include "process-util.h" #include "selinux-util.h" #include "signal-util.h" -- 2.39.2