]> git.ipfire.org Git - pakfire.git/commitdiff
log file: Create its own type
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 27 Jun 2025 14:21:19 +0000 (14:21 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 27 Jun 2025 14:21:19 +0000 (14:21 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/cli/lib/build.c
src/pakfire/job.c
src/pakfire/log_file.c
src/pakfire/log_file.h
tests/libpakfire/log_file.c

index ea6d3f68f95c9812d199d4011f1b953904c85e38..cdc3153eee48be9b001148a3e2d67e85df4401b1 100644 (file)
@@ -49,7 +49,7 @@ struct cli_local_args {
        } flags;
 
        // Log file
-       struct pakfire_log_file* log_file;
+       pakfire_log_file* log_file;
        const char* log_path;
 
        // Makefiles
index 1c29287914c3c7ccadfb7de83ea98617e8c51235..b499a5bd3de523b900378162d980f6f27aff9915 100644 (file)
@@ -93,7 +93,7 @@ struct pakfire_job {
        // Logging
        struct {
                // File
-               struct pakfire_log_file* file;
+               pakfire_log_file* file;
 
                // Buffer
                pakfire_log_buffer* buffer;
index 92776be1c6435e8223067919ecb70ffc1679e8e3..0795d1a674aee1a6981b2a86a9fd2f841287b3d8 100644 (file)
@@ -51,7 +51,7 @@ struct pakfire_log_file {
        FILE* f;
 };
 
-static void pakfire_log_file_free(struct pakfire_log_file* self) {
+static void pakfire_log_file_free(pakfire_log_file* self) {
        // Close the log file
        pakfire_log_file_close(self);
 
@@ -66,9 +66,9 @@ static void pakfire_log_file_free(struct pakfire_log_file* self) {
        free(self);
 }
 
-int pakfire_log_file_create(struct pakfire_log_file** file, pakfire_ctx* ctx,
+int pakfire_log_file_create(pakfire_log_file** file, pakfire_ctx* ctx,
                const char* path, const char* filename, int flags) {
-       struct pakfire_log_file* self = NULL;
+       pakfire_log_file* self = NULL;
        int r;
 
        // Allocate some memory
@@ -148,13 +148,13 @@ ERROR:
        return r;
 }
 
-struct pakfire_log_file* pakfire_log_file_ref(struct pakfire_log_file* self) {
+pakfire_log_file* pakfire_log_file_ref(pakfire_log_file* self) {
        self->nrefs++;
 
        return self;
 }
 
-struct pakfire_log_file* pakfire_log_file_unref(struct pakfire_log_file* self) {
+pakfire_log_file* pakfire_log_file_unref(pakfire_log_file* self) {
        if (--self->nrefs > 0)
                return self;
 
@@ -162,15 +162,15 @@ struct pakfire_log_file* pakfire_log_file_unref(struct pakfire_log_file* self) {
        return NULL;
 }
 
-const char* pakfire_log_file_filename(struct pakfire_log_file* self) {
+const char* pakfire_log_file_filename(pakfire_log_file* self) {
        return self->filename;
 }
 
-const char* pakfire_log_file_path(struct pakfire_log_file* self) {
+const char* pakfire_log_file_path(pakfire_log_file* self) {
        return self->path;
 }
 
-int pakfire_log_file_close(struct pakfire_log_file* self) {
+int pakfire_log_file_close(pakfire_log_file* self) {
        int r;
 
        if (self->f) {
@@ -188,7 +188,7 @@ int pakfire_log_file_close(struct pakfire_log_file* self) {
        return 0;
 }
 
-int pakfire_log_file_write(struct pakfire_log_file* self, int priority, const char* buffer, ssize_t length) {
+int pakfire_log_file_write(pakfire_log_file* self, int priority, const char* buffer, ssize_t length) {
        int r;
 
        // Check inputs
index b930ac064c9b7deabafaa150989a4460a847caaa..bc9183fe8052feb6c02fa61292f0e148853a4175 100644 (file)
        Writes the log into a compressed file
 */
 
-struct pakfire_log_file;
+typedef struct pakfire_log_file pakfire_log_file;
 
 enum pakfire_log_file_flags {
        PAKFIRE_LOG_FILE_COMPRESS = (1 << 0),
 };
 
-int pakfire_log_file_create(struct pakfire_log_file** file,
+int pakfire_log_file_create(pakfire_log_file** file,
        pakfire_ctx* ctx, const char* path, const char* filename, int flags);
-struct pakfire_log_file* pakfire_log_file_ref(struct pakfire_log_file* self);
-struct pakfire_log_file* pakfire_log_file_unref(struct pakfire_log_file* self);
+pakfire_log_file* pakfire_log_file_ref(pakfire_log_file* self);
+pakfire_log_file* pakfire_log_file_unref(pakfire_log_file* self);
 
-const char* pakfire_log_file_filename(struct pakfire_log_file* self);
-const char* pakfire_log_file_path(struct pakfire_log_file* self);
+const char* pakfire_log_file_filename(pakfire_log_file* self);
+const char* pakfire_log_file_path(pakfire_log_file* self);
 
-int pakfire_log_file_close(struct pakfire_log_file* self);
+int pakfire_log_file_close(pakfire_log_file* self);
 
-int pakfire_log_file_write(struct pakfire_log_file* self,
+int pakfire_log_file_write(pakfire_log_file* self,
        int priority, const char* buffer, ssize_t length);
 
 #endif /* PAKFIRE_LOG_FILE_H */
index baebaff2f48a0b7f95f6ebf7a2b9d0983df80780..8c3af2a8edf4c17445e4ee182aa9aae0fbd4413d 100644 (file)
@@ -26,7 +26,7 @@
 #include "../testsuite.h"
 
 static int __test_simple(const struct test* t, int flags) {
-       struct pakfire_log_file* file = NULL;
+       pakfire_log_file* file = NULL;
        char path[PATH_MAX] = "";
        int r = EXIT_FAILURE;