summaryrefslogtreecommitdiffstats
path: root/src/basic/runtime-scope.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2023-03-10 09:47:10 +0100
committerLennart Poettering <lennart@poettering.net>2023-03-10 09:47:39 +0100
commit4870133bfaaf97189a970a29bf47e0e38fa721aa (patch)
treed2fa9a5699a8b4c948179afabf3da2f9da322ce5 /src/basic/runtime-scope.c
parentsocket-util: fix socket_get_family() (diff)
downloadsystemd-4870133bfaaf97189a970a29bf47e0e38fa721aa.tar.xz
systemd-4870133bfaaf97189a970a29bf47e0e38fa721aa.zip
basic: add RuntimeScope enum
In various tools and services we have a per-system and per-user concept. So far we sometimes used a boolean indicating whether we are in system mode, or a reversed boolean indicating whether we are in user mode, or the LookupScope enum used by the lookup path logic. Let's address that, in introduce a common enum for this, we can use all across the board. This is mostly just search/replace, no actual code changes.
Diffstat (limited to 'src/basic/runtime-scope.c')
-rw-r--r--src/basic/runtime-scope.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/basic/runtime-scope.c b/src/basic/runtime-scope.c
new file mode 100644
index 0000000000..88afb53d0b
--- /dev/null
+++ b/src/basic/runtime-scope.c
@@ -0,0 +1,12 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+
+#include "runtime-scope.h"
+#include "string-table.h"
+
+static const char* const runtime_scope_table[_RUNTIME_SCOPE_MAX] = {
+ [RUNTIME_SCOPE_SYSTEM] = "system",
+ [RUNTIME_SCOPE_USER] = "user",
+ [RUNTIME_SCOPE_GLOBAL] = "global",
+};
+
+DEFINE_STRING_TABLE_LOOKUP(runtime_scope, RuntimeScope);