summaryrefslogtreecommitdiff
path: root/src/shared/unit-name.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2012-06-06 16:56:18 +0200
committerLennart Poettering <lennart@poettering.net>2012-07-10 16:48:08 +0200
commit0a9f8ed00c8f323d5bf24a9a11149a9342c0e1aa (patch)
tree42ecd46d4d40a9c3eb0043b591a79b9968807704 /src/shared/unit-name.c
parentc66d36e5b5ae81f3c5297d6dacadc13c88c530f6 (diff)
unit: Move UnitType definitions from core/unit.c to shared/unit-name.c
This makes it possible to use them from systemctl without linking against the core. A string->enum lookup table is added.
Diffstat (limited to 'src/shared/unit-name.c')
-rw-r--r--src/shared/unit-name.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/shared/unit-name.c b/src/shared/unit-name.c
index 4b52f7bc53..67a760ace6 100644
--- a/src/shared/unit-name.c
+++ b/src/shared/unit-name.c
@@ -33,6 +33,21 @@
"ABCDEFGHIJKLMNOPQRSTUVWXYZ" \
":-_.\\"
+static const char* const unit_type_table[_UNIT_TYPE_MAX] = {
+ [UNIT_SERVICE] = "service",
+ [UNIT_SOCKET] = "socket",
+ [UNIT_TARGET] = "target",
+ [UNIT_DEVICE] = "device",
+ [UNIT_MOUNT] = "mount",
+ [UNIT_AUTOMOUNT] = "automount",
+ [UNIT_SNAPSHOT] = "snapshot",
+ [UNIT_TIMER] = "timer",
+ [UNIT_SWAP] = "swap",
+ [UNIT_PATH] = "path",
+};
+
+DEFINE_STRING_TABLE_LOOKUP(unit_type, UnitType);
+
bool unit_name_is_valid_no_type(const char *n, bool template_ok) {
const char *e, *i, *at;