]> git.ipfire.org Git - pakfire.git/commitdiff
daemon: Create its own type
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 27 Jun 2025 10:44:25 +0000 (10:44 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 27 Jun 2025 10:44:25 +0000 (10:44 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/cli/lib/daemon.c
src/pakfire/daemon.c
src/pakfire/daemon.h
tests/libpakfire/daemon.c

index e0894f5bb980ac60933d417830ebd0f8df0e99c6..be91ebf397f821692d637c8ac5df25f8689ac22b 100644 (file)
@@ -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
index f8b127bd3e5421b27c2b25b0b3a068c04dd48ea4..327f530366e362d4890e6cbdf7e929feff782fd2 100644 (file)
@@ -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
index 369412223bf176a920bebd42a5a4a113adaafb49..21d3852dd91d3fa683f02426f147dbdfc07425fe 100644 (file)
 #ifndef PAKFIRE_DAEMON_H
 #define PAKFIRE_DAEMON_H
 
-struct pakfire_daemon;
+typedef struct pakfire_daemon pakfire_daemon;
 
 #include <pakfire/ctx.h>
 
-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 */
index 90afe90c4832c5313bf8fb982981a5947373ec02..e03d5873918128f9e0ee4ad7795bf413959f2bb9 100644 (file)
@@ -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