-static int bus_parse_unit_info(sd_bus_message *message, struct unit_info *u) {
- int r = 0;
-
- assert(message);
- assert(u);
-
- r = sd_bus_message_read(message, "(ssssssouso)", &u->id,
- &u->description,
- &u->load_state,
- &u->active_state,
- &u->sub_state,
- &u->following,
- &u->unit_path,
- &u->job_id,
- &u->job_type,
- &u->job_path);
- if (r < 0) {
- log_error("Failed to parse message as unit_info.");
- return -EIO;
- }
-
- return r;
-}
-
-static int bus_get_unit_property_strv(sd_bus *bus, const char *unit_path, const char *prop, char ***strv) {
- _cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
- _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
- int r;
- const char *s;
-
- r = sd_bus_get_property(
- bus,
- "org.freedesktop.systemd1",
- unit_path,
- "org.freedesktop.systemd1.Unit",
- prop,
- &error,
- &reply,
- "as");
- if (r < 0) {
- log_error("Failed to get unit property: %s %s", prop, bus_error_message(&error, -r));
- return r;
- }
-
- r = sd_bus_message_enter_container(reply, SD_BUS_TYPE_ARRAY, "s");
- if (r < 0)
- return r;
-
- while ((r = sd_bus_message_read(reply, "s", &s)) > 0) {
- r = strv_extend(strv, s);
- if (r < 0) {
- log_oom();
- return r;
- }
- }
-
- return r;
-}
-