diff options
author | David Härdeman <david@hardeman.nu> | 2020-06-22 10:50:15 +0200 |
---|---|---|
committer | David Härdeman <david@hardeman.nu> | 2020-06-22 10:50:15 +0200 |
commit | 31afd2aaaeb76a12e232eab0fb6a550b73948737 (patch) | |
tree | 7125a54d09904eef6c558a682cff0a7976529fad /systemd.c | |
parent | 41dc97f5d0dbcfe4399656c9aabb597f6366ca23 (diff) |
Make struct cfg global and make the corresponding changes throughout
Diffstat (limited to 'systemd.c')
-rw-r--r-- | systemd.c | 35 |
1 files changed, 16 insertions, 19 deletions
@@ -30,13 +30,13 @@ tohex(uint8_t val) * Example: minecraft@world1.service -> minecraft_40world1_2eservice */ char * -systemd_service_object_path(struct cfg *cfg, const char *service) +systemd_object_path(const char *service) { char *r; char *d; const char *s; - assert_return(cfg && service && !empty_str(service), NULL); + assert_return(service && !empty_str(service), NULL); r = zmalloc(strlen(SYSTEMD_DBUS_PATH_PREFIX) + strlen(service) * 3 + 1); if (!r) @@ -63,9 +63,8 @@ systemd_service_object_path(struct cfg *cfg, const char *service) } void -systemd_delete(struct cfg *cfg) +systemd_delete() { - assert_return(cfg); assert_return_silent(cfg->sd_bus); sd_bus_unref(cfg->sd_bus); @@ -73,12 +72,10 @@ systemd_delete(struct cfg *cfg) } static sd_bus * -get_bus(struct cfg *cfg) +get_bus() { int r; - assert_return(cfg, NULL); - if (cfg->sd_bus_failed) return NULL; @@ -106,15 +103,15 @@ get_bus(struct cfg *cfg) * "ActiveState" */ bool -systemd_service_running(struct cfg *cfg, struct server *server) +systemd_service_running(struct server *server) { - sd_bus *bus = get_bus(cfg); + sd_bus *bus = get_bus(); sd_bus_error error = SD_BUS_ERROR_NULL; char *status = NULL; bool running = false; int r; - assert_return(cfg && server && bus && server->systemd_service && server->systemd_obj, false); + assert_return(server && bus && server->systemd_service && server->systemd_obj, false); r = sd_bus_get_property_string(bus, SYSTEMD_DBUS_SERVICE, @@ -144,16 +141,16 @@ out: } static bool -systemd_service_action(struct cfg *cfg, struct server *server, const char *action) +systemd_service_action(struct server *server, const char *action) { sd_bus_error error = SD_BUS_ERROR_NULL; sd_bus_message *m = NULL; - sd_bus *bus = get_bus(cfg); + sd_bus *bus = get_bus(); const char *path; bool performed = false; int r; - assert_return(cfg && server && bus && server->systemd_service && server->systemd_obj && action, false); + assert_return(server && bus && server->systemd_service && server->systemd_obj && action, false); r = sd_bus_call_method(bus, SYSTEMD_DBUS_SERVICE, @@ -196,11 +193,11 @@ out: * --method org.freedesktop.systemd1.Unit.Stop "fail" */ bool -systemd_service_stop(struct cfg *cfg, struct server *server) +systemd_service_stop(struct server *server) { - assert_return(cfg && server, false); + assert_return(server, false); - return systemd_service_action(cfg, server, "Stop"); + return systemd_service_action(server, "Stop"); } /* @@ -213,10 +210,10 @@ systemd_service_stop(struct cfg *cfg, struct server *server) * --method org.freedesktop.systemd1.Unit.Start "fail" */ bool -systemd_service_start(struct cfg *cfg, struct server *server) +systemd_service_start(struct server *server) { - assert_return(cfg && server, false); + assert_return(server, false); - return systemd_service_action(cfg, server, "Start"); + return systemd_service_action(server, "Start"); } |