chiark / gitweb /
add api for choose the id name for a service
[elogind.git] / unit.c
diff --git a/unit.c b/unit.c
index c8a6f669615f309506574d21d9c89181b0dc9aba..dbdd7e663e5783c020f0638071a5d13ad8fa4033 100644 (file)
--- a/unit.c
+++ b/unit.c
@@ -155,6 +155,21 @@ int unit_add_name(Unit *u, const char *text) {
         return 0;
 }
 
+int unit_choose_id(Unit *u, const char *name) {
+        char *s;
+
+        assert(u);
+        assert(name);
+
+        /* Selects one of the names of this unit as the id */
+
+        if (!(s = set_get(u->meta.names, (char*) name)))
+                return -ENOENT;
+
+        u->meta.id = s;
+        return 0;
+}
+
 void unit_add_to_load_queue(Unit *u) {
         assert(u);