From: Michael Tremer Date: Fri, 27 Jun 2025 14:21:19 +0000 (+0000) Subject: log file: Create its own type X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=bd7d97a75a02e699154224ac1ee0e4ce284c9593;p=pakfire.git log file: Create its own type Signed-off-by: Michael Tremer --- diff --git a/src/cli/lib/build.c b/src/cli/lib/build.c index ea6d3f68..cdc3153e 100644 --- a/src/cli/lib/build.c +++ b/src/cli/lib/build.c @@ -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 diff --git a/src/pakfire/job.c b/src/pakfire/job.c index 1c292879..b499a5bd 100644 --- a/src/pakfire/job.c +++ b/src/pakfire/job.c @@ -93,7 +93,7 @@ struct pakfire_job { // Logging struct { // File - struct pakfire_log_file* file; + pakfire_log_file* file; // Buffer pakfire_log_buffer* buffer; diff --git a/src/pakfire/log_file.c b/src/pakfire/log_file.c index 92776be1..0795d1a6 100644 --- a/src/pakfire/log_file.c +++ b/src/pakfire/log_file.c @@ -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 diff --git a/src/pakfire/log_file.h b/src/pakfire/log_file.h index b930ac06..bc9183fe 100644 --- a/src/pakfire/log_file.h +++ b/src/pakfire/log_file.h @@ -27,23 +27,23 @@ 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 */ diff --git a/tests/libpakfire/log_file.c b/tests/libpakfire/log_file.c index baebaff2..8c3af2a8 100644 --- a/tests/libpakfire/log_file.c +++ b/tests/libpakfire/log_file.c @@ -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;