src/basic/locale-util.h \
src/basic/signal-util.c \
src/basic/signal-util.h \
+ src/basic/string-table.c \
+ src/basic/string-table.h \
src/basic/mempool.c \
src/basic/mempool.h \
src/basic/hashmap.c \
#include "process-util.h"
#include "set.h"
#include "special.h"
+#include "string-table.h"
#include "string-util.h"
#include "unit-name.h"
#include "user-util.h"
#include "locale-util.h"
#include "path-util.h"
#include "set.h"
+#include "string-table.h"
#include "string-util.h"
#include "strv.h"
#include "utf8.h"
#include "process-util.h"
#include "signal-util.h"
#include "socket-util.h"
+#include "string-table.h"
#include "string-util.h"
#include "terminal-util.h"
#include "util.h"
#include "missing.h"
#include "rlimit-util.h"
+#include "string-table.h"
#include "util.h"
int setrlimit_closest(int resource, const struct rlimit *rlim) {
#include "parse-util.h"
#include "signal-util.h"
+#include "string-table.h"
#include "string-util.h"
#include "util.h"
#include "path-util.h"
#include "process-util.h"
#include "smack-util.h"
+#include "string-table.h"
#include "util.h"
#include "xattr-util.h"
#include "parse-util.h"
#include "path-util.h"
#include "socket-util.h"
+#include "string-table.h"
#include "string-util.h"
#include "util.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 "string-table.h"
+
+ssize_t string_table_lookup(const char * const *table, size_t len, const char *key) {
+ size_t i;
+
+ if (!key)
+ return -1;
+
+ for (i = 0; i < len; ++i)
+ if (streq_ptr(table[i], key))
+ return (ssize_t) i;
+
+ return -1;
+}
--- /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 <stddef.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/types.h>
+
+#include "macro.h"
+#include "parse-util.h"
+#include "string-util.h"
+
+ssize_t string_table_lookup(const char * const *table, size_t len, const char *key);
+
+/* For basic lookup tables with strictly enumerated entries */
+#define _DEFINE_STRING_TABLE_LOOKUP_TO_STRING(name,type,scope) \
+ scope const char *name##_to_string(type i) { \
+ if (i < 0 || i >= (type) ELEMENTSOF(name##_table)) \
+ return NULL; \
+ return name##_table[i]; \
+ }
+
+#define _DEFINE_STRING_TABLE_LOOKUP_FROM_STRING(name,type,scope) \
+ scope type name##_from_string(const char *s) { \
+ return (type) string_table_lookup(name##_table, ELEMENTSOF(name##_table), s); \
+ }
+
+#define _DEFINE_STRING_TABLE_LOOKUP(name,type,scope) \
+ _DEFINE_STRING_TABLE_LOOKUP_TO_STRING(name,type,scope) \
+ _DEFINE_STRING_TABLE_LOOKUP_FROM_STRING(name,type,scope) \
+ struct __useless_struct_to_allow_trailing_semicolon__
+
+#define DEFINE_STRING_TABLE_LOOKUP(name,type) _DEFINE_STRING_TABLE_LOOKUP(name,type,)
+#define DEFINE_PRIVATE_STRING_TABLE_LOOKUP(name,type) _DEFINE_STRING_TABLE_LOOKUP(name,type,static)
+#define DEFINE_PRIVATE_STRING_TABLE_LOOKUP_TO_STRING(name,type) _DEFINE_STRING_TABLE_LOOKUP_TO_STRING(name,type,static)
+#define DEFINE_PRIVATE_STRING_TABLE_LOOKUP_FROM_STRING(name,type) _DEFINE_STRING_TABLE_LOOKUP_FROM_STRING(name,type,static)
+
+/* For string conversions where numbers are also acceptable */
+#define DEFINE_STRING_TABLE_LOOKUP_WITH_FALLBACK(name,type,max) \
+ int name##_to_string_alloc(type i, char **str) { \
+ char *s; \
+ if (i < 0 || i > max) \
+ return -ERANGE; \
+ if (i < (type) ELEMENTSOF(name##_table)) { \
+ s = strdup(name##_table[i]); \
+ if (!s) \
+ return -ENOMEM; \
+ } else { \
+ if (asprintf(&s, "%i", i) < 0) \
+ return -ENOMEM; \
+ } \
+ *str = s; \
+ return 0; \
+ } \
+ type name##_from_string(const char *s) { \
+ type i; \
+ unsigned u = 0; \
+ if (!s) \
+ return (type) -1; \
+ for (i = 0; i < (type) ELEMENTSOF(name##_table); i++) \
+ if (streq_ptr(name##_table[i], s)) \
+ return i; \
+ if (safe_atou(s, &u) >= 0 && u <= max) \
+ return (type) u; \
+ return (type) -1; \
+ } \
+ struct __useless_struct_to_allow_trailing_semicolon__
#include "bus-label.h"
#include "def.h"
+#include "hexdecoct.h"
#include "path-util.h"
+#include "string-table.h"
#include "string-util.h"
#include "strv.h"
-#include "util.h"
#include "unit-name.h"
-#include "hexdecoct.h"
+#include "util.h"
#define VALID_CHARS \
DIGITS LETTERS \
#include "random-util.h"
#include "signal-util.h"
#include "sparse-endian.h"
+#include "string-table.h"
#include "string-util.h"
#include "strv.h"
#include "terminal-util.h"
return 1;
}
-ssize_t string_table_lookup(const char * const *table, size_t len, const char *key) {
- size_t i;
-
- if (!key)
- return -1;
-
- for (i = 0; i < len; ++i)
- if (streq_ptr(table[i], key))
- return (ssize_t) i;
-
- return -1;
-}
-
int version(void) {
puts(PACKAGE_STRING "\n"
SYSTEMD_FEATURES);
return b ? "1" : "0";
}
-/* For basic lookup tables with strictly enumerated entries */
-#define _DEFINE_STRING_TABLE_LOOKUP_TO_STRING(name,type,scope) \
- scope const char *name##_to_string(type i) { \
- if (i < 0 || i >= (type) ELEMENTSOF(name##_table)) \
- return NULL; \
- return name##_table[i]; \
- }
-
-ssize_t string_table_lookup(const char * const *table, size_t len, const char *key);
-
-#define _DEFINE_STRING_TABLE_LOOKUP_FROM_STRING(name,type,scope) \
- scope type name##_from_string(const char *s) { \
- return (type) string_table_lookup(name##_table, ELEMENTSOF(name##_table), s); \
- }
-
-#define _DEFINE_STRING_TABLE_LOOKUP(name,type,scope) \
- _DEFINE_STRING_TABLE_LOOKUP_TO_STRING(name,type,scope) \
- _DEFINE_STRING_TABLE_LOOKUP_FROM_STRING(name,type,scope) \
- struct __useless_struct_to_allow_trailing_semicolon__
-
-#define DEFINE_STRING_TABLE_LOOKUP(name,type) _DEFINE_STRING_TABLE_LOOKUP(name,type,)
-#define DEFINE_PRIVATE_STRING_TABLE_LOOKUP(name,type) _DEFINE_STRING_TABLE_LOOKUP(name,type,static)
-#define DEFINE_PRIVATE_STRING_TABLE_LOOKUP_TO_STRING(name,type) _DEFINE_STRING_TABLE_LOOKUP_TO_STRING(name,type,static)
-#define DEFINE_PRIVATE_STRING_TABLE_LOOKUP_FROM_STRING(name,type) _DEFINE_STRING_TABLE_LOOKUP_FROM_STRING(name,type,static)
-
-/* For string conversions where numbers are also acceptable */
-#define DEFINE_STRING_TABLE_LOOKUP_WITH_FALLBACK(name,type,max) \
- int name##_to_string_alloc(type i, char **str) { \
- char *s; \
- if (i < 0 || i > max) \
- return -ERANGE; \
- if (i < (type) ELEMENTSOF(name##_table)) { \
- s = strdup(name##_table[i]); \
- if (!s) \
- return -ENOMEM; \
- } else { \
- if (asprintf(&s, "%i", i) < 0) \
- return -ENOMEM; \
- } \
- *str = s; \
- return 0; \
- } \
- type name##_from_string(const char *s) { \
- type i; \
- unsigned u = 0; \
- if (!s) \
- return (type) -1; \
- for (i = 0; i < (type) ELEMENTSOF(name##_table); i++) \
- if (streq_ptr(name##_table[i], s)) \
- return i; \
- if (safe_atou(s, &u) >= 0 && u <= max) \
- return (type) u; \
- return (type) -1; \
- } \
- struct __useless_struct_to_allow_trailing_semicolon__
-
bool fstype_is_network(const char *fstype);
#define xsprintf(buf, fmt, ...) \
#include "fileio.h"
#include "process-util.h"
+#include "string-table.h"
#include "string-util.h"
#include "util.h"
#include "virt.h"
#include "fileio.h"
#include "formats-util.h"
#include "set.h"
+#include "string-table.h"
#include "string-util.h"
#include "strv.h"
#include "user-util.h"
#include "path-util.h"
#include "process-util.h"
#include "special.h"
+#include "string-table.h"
#include "string-util.h"
#include "unit-name.h"
#include "unit.h"
#include "bus-kernel.h"
#include "bus-policy.h"
#include "kdbus.h"
+#include "string-table.h"
#include "user-util.h"
#include "util.h"
#include "service.h"
#include "signal-util.h"
#include "special.h"
+#include "string-table.h"
#include "string-util.h"
static const UnitActiveState state_translation_table[_BUSNAME_STATE_MAX] = {
#include "path-util.h"
#include "process-util.h"
#include "special.h"
+#include "string-table.h"
#include "string-util.h"
#define CGROUP_CPU_QUOTA_PERIOD_USEC ((usec_t) 100 * USEC_PER_MSEC)
#include "selinux-util.h"
#include "signal-util.h"
#include "smack-util.h"
+#include "string-table.h"
#include "string-util.h"
#include "strv.h"
#include "terminal-util.h"
#include <sys/reboot.h>
#include <linux/reboot.h>
-#include "bus-util.h"
#include "bus-error.h"
-#include "special.h"
+#include "bus-util.h"
#include "failure-action.h"
+#include "special.h"
+#include "string-table.h"
#include "terminal-util.h"
static void log_and_status(Manager *m, const char *message) {
#include "parse-util.h"
#include "set.h"
#include "special.h"
+#include "string-table.h"
#include "string-util.h"
#include "strv.h"
#include "terminal-util.h"
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include "util.h"
-#include "signal-util.h"
#include "kill.h"
+#include "signal-util.h"
+#include "string-table.h"
+#include "util.h"
void kill_context_init(KillContext *c) {
assert(c);
#include "signal-util.h"
#include "special.h"
#include "stat-util.h"
+#include "string-table.h"
#include "string-util.h"
#include "strv.h"
#include "terminal-util.h"
#include "smack-util.h"
#include "special.h"
#include "string-util.h"
+#include "string-table.h"
#include "strv.h"
#include "unit-name.h"
#include "unit.h"
#include "path-util.h"
#include "selinux-util.h"
#include "socket-util.h"
+#include "string-table.h"
#include "string-util.h"
#include "strv.h"
#include "util.h"
#include "path.h"
#include "special.h"
#include "stat-util.h"
+#include "string-table.h"
#include "string-util.h"
#include "unit-name.h"
#include "unit.h"
#include "load-dropin.h"
#include "log.h"
#include "special.h"
+#include "string-table.h"
#include "string-util.h"
#include "strv.h"
#include "unit-name.h"
#include "service.h"
#include "signal-util.h"
#include "special.h"
+#include "string-table.h"
#include "string-util.h"
#include "strv.h"
#include "unit-name.h"
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
+#include "fd-util.h"
#include "parse-util.h"
#include "show-status.h"
#include "string-util.h"
+#include "terminal-util.h"
#include "util.h"
int parse_show_status(const char *v, ShowStatus *ret) {
#include "smack-util.h"
#include "socket.h"
#include "special.h"
+#include "string-table.h"
#include "string-util.h"
#include "strv.h"
#include "unit-name.h"
#include "parse-util.h"
#include "path-util.h"
#include "special.h"
+#include "string-table.h"
#include "string-util.h"
#include "swap.h"
#include "udev-util.h"
#include "fs-util.h"
#include "parse-util.h"
#include "special.h"
+#include "string-table.h"
#include "string-util.h"
#include "timer.h"
#include "unit-name.h"
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include "util.h"
#include "import-compress.h"
+#include "string-table.h"
+#include "util.h"
void import_compress_free(ImportCompress *c) {
assert(c);
#include "process-util.h"
#include "signal-util.h"
#include "socket-util.h"
+#include "string-table.h"
#include "strv.h"
#include "util.h"
#include "signal-util.h"
#include "socket-util.h"
#include "stat-util.h"
+#include "string-table.h"
#include "string-util.h"
#include "strv.h"
#include "journal-def.h"
#include "macro.h"
#include "sparse-endian.h"
+#include "string-table.h"
#include "string-util.h"
#include "util.h"
#include "process-util.h"
#include "special.h"
#include "stacktrace.h"
+#include "string-table.h"
#include "string-util.h"
#include "strv.h"
#include "user-util.h"
#include "selinux-util.h"
#include "signal-util.h"
#include "socket-util.h"
+#include "string-table.h"
#include "string-util.h"
#define USER_JOURNALS_MAX 1024
#include "fd-util.h"
#include "network-internal.h"
#include "random-util.h"
+#include "string-table.h"
#include "util.h"
#define MAX_MAC_ADDR_LEN INFINIBAND_ALEN
#include "path-util.h"
#include "refcnt.h"
#include "set.h"
+#include "string-table.h"
#include "string-util.h"
#include "strv.h"
#include "strxcpyx.h"
#include <linux/if_bridge.h>
#include <linux/if_addr.h>
#include <linux/if.h>
-
#include <linux/ip.h>
#include <linux/if_link.h>
#include <linux/if_tunnel.h>
#include "macro.h"
-#include "util.h"
-
-#include "netlink-types.h"
#include "missing.h"
+#include "netlink-types.h"
+#include "string-table.h"
+#include "util.h"
/* Maximum ARP IP target defined in kernel */
#define BOND_MAX_ARP_TARGETS 16
#include <unistd.h>
-#include "conf-parser.h"
-#include "special.h"
-#include "sleep-config.h"
-#include "bus-util.h"
#include "bus-error.h"
-#include "logind-action.h"
+#include "bus-util.h"
+#include "conf-parser.h"
#include "formats-util.h"
+#include "logind-action.h"
#include "process-util.h"
+#include "sleep-config.h"
+#include "special.h"
+#include "string-table.h"
#include "terminal-util.h"
#include "user-util.h"
#include "logind-inhibit.h"
#include "mkdir.h"
#include "parse-util.h"
+#include "string-table.h"
#include "string-util.h"
#include "user-util.h"
#include "util.h"
#include "mkdir.h"
#include "parse-util.h"
#include "path-util.h"
+#include "string-table.h"
#include "terminal-util.h"
#include "user-util.h"
#include "util.h"
#include "rm-rf.h"
#include "smack-util.h"
#include "special.h"
+#include "string-table.h"
#include "unit-name.h"
#include "util.h"
#include "mkdir.h"
#include "parse-util.h"
#include "special.h"
+#include "string-table.h"
#include "terminal-util.h"
#include "unit-name.h"
#include "util.h"
#include "parse-util.h"
#include "socket-util.h"
#include "string-util.h"
+#include "string-table.h"
#include "strv.h"
#include "terminal-util.h"
#include "util.h"
#include "networkd-netdev.h"
#include "set.h"
#include "socket-util.h"
+#include "string-table.h"
#include "udev-util.h"
#include "util.h"
#include "virt.h"
#include "conf-parser.h"
#include "missing.h"
-#include "string-util.h"
#include "networkd-netdev-bond.h"
+#include "string-util.h"
+#include "string-table.h"
/*
* Number of seconds between instances where the bonding
#include <net/if.h>
-#include "networkd-netdev-ipvlan.h"
#include "conf-parser.h"
+#include "networkd-netdev-ipvlan.h"
+#include "string-table.h"
static const char* const ipvlan_mode_table[_NETDEV_IPVLAN_MODE_MAX] = {
[NETDEV_IPVLAN_MODE_L2] = "L2",
#include <net/if.h>
-#include "networkd-netdev-macvlan.h"
#include "conf-parser.h"
+#include "networkd-netdev-macvlan.h"
+#include "string-table.h"
static const char* const macvlan_mode_table[_NETDEV_MACVLAN_MODE_MAX] = {
[NETDEV_MACVLAN_MODE_PRIVATE] = "private",
#include "networkd-link.h"
#include "networkd-netdev-tunnel.h"
#include "parse-util.h"
+#include "string-table.h"
#include "string-util.h"
#include "util.h"
#include "networkd.h"
#include "siphash24.h"
#include "stat-util.h"
+#include "string-table.h"
#include "string-util.h"
const NetDevVTable * const netdev_vtable[_NETDEV_KIND_MAX] = {
#include "networkd.h"
#include "parse-util.h"
#include "stat-util.h"
+#include "string-table.h"
#include "string-util.h"
#include "util.h"
#include "conf-parser.h"
#include "networkd-util.h"
#include "parse-util.h"
+#include "string-table.h"
#include "string-util.h"
#include "util.h"
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include "utf8.h"
-#include "util.h"
-#include "strv.h"
-#include "unaligned.h"
#include "dns-domain.h"
#include "resolved-dns-packet.h"
+#include "string-table.h"
+#include "strv.h"
+#include "unaligned.h"
+#include "utf8.h"
+#include "util.h"
int dns_packet_new(DnsPacket **ret, DnsProtocol protocol, size_t mtu) {
DnsPacket *p;
#include "random-util.h"
#include "resolved-dns-transaction.h"
#include "resolved-llmnr.h"
+#include "string-table.h"
DnsTransaction* dns_transaction_free(DnsTransaction *t) {
DnsQuery *q;
#include "resolved-llmnr.h"
#include "resolved-manager.h"
#include "socket-util.h"
+#include "string-table.h"
#include "string-util.h"
#include "utf8.h"
#include "io-util.h"
#include "mkdir.h"
#include "parse-util.h"
+#include "string-table.h"
#include "string-util.h"
#include "udev-util.h"
#include "util.h"
#include <sys/utsname.h>
+#include "string-table.h"
#include "string-util.h"
#include "architecture.h"
#include "selinux-util.h"
#include "smack-util.h"
#include "stat-util.h"
+#include "string-table.h"
#include "string-util.h"
#include "util.h"
#include "virt.h"
#include "btrfs-util.h"
#include "import-util.h"
#include "path-util.h"
+#include "string-table.h"
#include "string-util.h"
#include "util.h"
#include "set.h"
#include "special.h"
#include "stat-util.h"
+#include "string-table.h"
#include "string-util.h"
#include "strv.h"
#include "unit-name.h"
#include "logs-show.h"
#include "parse-util.h"
#include "process-util.h"
+#include "string-table.h"
#include "string-util.h"
#include "terminal-util.h"
#include "utf8.h"
#include "mkdir.h"
#include "path-util.h"
#include "rm-rf.h"
+#include "string-table.h"
#include "string-util.h"
#include "strv.h"
#include "utf8.h"
#include "set.h"
#include "specifier.h"
#include "stat-util.h"
+#include "string-table.h"
#include "string-util.h"
#include "strv.h"
#include "user-util.h"
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include <sys/ioctl.h>
#include <net/if.h>
+#include <sys/ioctl.h>
#include <linux/ethtool.h>
#include <linux/sockios.h>
+#include "conf-parser.h"
#include "ethtool-util.h"
-
+#include "log.h"
+#include "string-table.h"
#include "strxcpyx.h"
#include "util.h"
-#include "log.h"
-#include "conf-parser.h"
static const char* const duplex_table[_DUP_MAX] = {
[DUP_FULL] = "full",
#include "path-util.h"
#include "random-util.h"
#include "stat-util.h"
+#include "string-table.h"
#include "string-util.h"
#include "strv.h"
#include "util.h"