From: Michael Tremer Date: Fri, 27 Jun 2025 10:44:25 +0000 (+0000) Subject: daemon: Create its own type X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7e84f972c9e3a22d79def189b76af4a2989e07c8;p=pakfire.git daemon: Create its own type Signed-off-by: Michael Tremer --- diff --git a/src/cli/lib/daemon.c b/src/cli/lib/daemon.c index e0894f5b..be91ebf3 100644 --- a/src/cli/lib/daemon.c +++ b/src/cli/lib/daemon.c @@ -24,7 +24,7 @@ #include "daemon.h" int cli_daemon_main(pakfire_ctx* ctx) { - struct pakfire_daemon* daemon = NULL; + pakfire_daemon* daemon = NULL; int r; // Create the daemon diff --git a/src/pakfire/daemon.c b/src/pakfire/daemon.c index f8b127bd..327f5303 100644 --- a/src/pakfire/daemon.c +++ b/src/pakfire/daemon.c @@ -64,7 +64,7 @@ struct pakfire_daemon { static int pakfire_daemon_terminate(sd_event_source* source, const struct signalfd_siginfo* si, void* data) { - struct pakfire_daemon* self = data; + pakfire_daemon* self = data; DEBUG(self->ctx, "Received signal to terminate...\n"); @@ -77,7 +77,7 @@ static int pakfire_daemon_terminate(sd_event_source* source, /* * Prevents that the system can be shut down when there are jobs running... */ -static int pakfire_daemon_inhibit_shutdown(struct pakfire_daemon* self) { +static int pakfire_daemon_inhibit_shutdown(pakfire_daemon* self) { sd_bus_error error = SD_BUS_ERROR_NULL; sd_bus_message* reply = NULL; int r; @@ -133,7 +133,7 @@ ERROR: return r; } -static int pakfire_daemon_release_inhibit_shutdown(struct pakfire_daemon* self) { +static int pakfire_daemon_release_inhibit_shutdown(pakfire_daemon* self) { // If we don't hold the lock, we cannot release it if (self->inhibitfd >= 0) { close(self->inhibitfd); @@ -149,7 +149,7 @@ static int pakfire_daemon_release_inhibit_shutdown(struct pakfire_daemon* self) Called when the client is ready and we can start making connections... */ static int pakfire_daemon_ready(pakfire_client* client, void* data) { - struct pakfire_daemon* self = data; + pakfire_daemon* self = data; // Connect the control connection return pakfire_builder_connect(self->builder); @@ -162,7 +162,7 @@ static int pakfire_daemon_SIGCHLD(sd_event_source* s, const struct signalfd_sigi static int pakfire_daemon_prepare_for_shutdown( sd_bus_message* message, void* data, sd_bus_error* error) { - struct pakfire_daemon* self = data; + pakfire_daemon* self = data; int shutdown; int r; @@ -188,7 +188,7 @@ static int pakfire_daemon_prepare_for_shutdown( return 0; } -static int pakfire_daemon_setup_bus(struct pakfire_daemon* self) { +static int pakfire_daemon_setup_bus(pakfire_daemon* self) { int r; // Connect to the system bus @@ -228,7 +228,7 @@ static int pakfire_daemon_setup_bus(struct pakfire_daemon* self) { return 0; } -static int pakfire_daemon_setup_loop(struct pakfire_daemon* self) { +static int pakfire_daemon_setup_loop(pakfire_daemon* self) { int r; // Fetch a reference to the context's event loop @@ -272,7 +272,7 @@ static int pakfire_daemon_setup_loop(struct pakfire_daemon* self) { return 0; } -static int pakfire_daemon_setup_client(struct pakfire_daemon* self) { +static int pakfire_daemon_setup_client(pakfire_daemon* self) { pakfire_config* config = NULL; const char* url = NULL; int r; @@ -303,7 +303,7 @@ ERROR: return r; } -static void pakfire_daemon_free(struct pakfire_daemon* self) { +static void pakfire_daemon_free(pakfire_daemon* self) { // Release shutdown inhibition pakfire_daemon_release_inhibit_shutdown(self); @@ -332,8 +332,8 @@ static void pakfire_daemon_free(struct pakfire_daemon* self) { free(self); } -int pakfire_daemon_create(struct pakfire_daemon** daemon, pakfire_ctx* ctx) { - struct pakfire_daemon* self = NULL; +int pakfire_daemon_create(pakfire_daemon** daemon, pakfire_ctx* ctx) { + pakfire_daemon* self = NULL; int r; // Allocate some memory @@ -386,13 +386,13 @@ ERROR: return r; } -struct pakfire_daemon* pakfire_daemon_ref(struct pakfire_daemon* self) { +pakfire_daemon* pakfire_daemon_ref(pakfire_daemon* self) { ++self->nrefs; return self; } -struct pakfire_daemon* pakfire_daemon_unref(struct pakfire_daemon* self) { +pakfire_daemon* pakfire_daemon_unref(pakfire_daemon* self) { if (--self->nrefs > 0) return self; @@ -400,7 +400,7 @@ struct pakfire_daemon* pakfire_daemon_unref(struct pakfire_daemon* self) { return NULL; } -int pakfire_daemon_main(struct pakfire_daemon* self) { +int pakfire_daemon_main(pakfire_daemon* self) { int r; // We are now ready diff --git a/src/pakfire/daemon.h b/src/pakfire/daemon.h index 36941222..21d3852d 100644 --- a/src/pakfire/daemon.h +++ b/src/pakfire/daemon.h @@ -21,15 +21,15 @@ #ifndef PAKFIRE_DAEMON_H #define PAKFIRE_DAEMON_H -struct pakfire_daemon; +typedef struct pakfire_daemon pakfire_daemon; #include -int pakfire_daemon_create(struct pakfire_daemon** daemon, pakfire_ctx* ctx); +int pakfire_daemon_create(pakfire_daemon** daemon, pakfire_ctx* ctx); -struct pakfire_daemon* pakfire_daemon_ref(struct pakfire_daemon* self); -struct pakfire_daemon* pakfire_daemon_unref(struct pakfire_daemon* self); +pakfire_daemon* pakfire_daemon_ref(pakfire_daemon* self); +pakfire_daemon* pakfire_daemon_unref(pakfire_daemon* self); -int pakfire_daemon_main(struct pakfire_daemon* self); +int pakfire_daemon_main(pakfire_daemon* self); #endif /* PAKFIRE_DAEMON_H */ diff --git a/tests/libpakfire/daemon.c b/tests/libpakfire/daemon.c index 90afe90c..e03d5873 100644 --- a/tests/libpakfire/daemon.c +++ b/tests/libpakfire/daemon.c @@ -23,7 +23,7 @@ #include "../testsuite.h" static int test_daemon(const struct test* t) { - struct pakfire_daemon* daemon = NULL; + pakfire_daemon* daemon = NULL; int r = EXIT_FAILURE; // We can only create the daemon