From: Michael Tremer Date: Fri, 27 Jun 2025 14:27:59 +0000 (+0000) Subject: packager: Create its own type X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=544e66b789272c08f2e215880e2e6ab5ed511e5e;p=pakfire.git packager: Create its own type Signed-off-by: Michael Tremer --- diff --git a/src/pakfire/build.c b/src/pakfire/build.c index d19ba7a8..37bc5bd8 100644 --- a/src/pakfire/build.c +++ b/src/pakfire/build.c @@ -955,7 +955,7 @@ ERROR: static int pakfire_build_package_add_files(pakfire_build* build, struct pakfire_parser* makefile, const char* buildroot, const char* namespace, - struct pakfire_package* pkg, struct pakfire_packager* packager) { + struct pakfire_package* pkg, pakfire_packager* packager) { pakfire_filelist* filelist = NULL; char** includes = NULL; char** excludes = NULL; @@ -1140,7 +1140,7 @@ static int pakfire_build_add_scriptlet_requires(pakfire_build* build, } static int pakfire_build_package_add_scriptlet(pakfire_build* build, - struct pakfire_package* pkg, struct pakfire_packager* packager, + struct pakfire_package* pkg, pakfire_packager* packager, const char* type, const char* data) { struct pakfire_scriptlet* scriptlet = NULL; char* shell = NULL; @@ -1184,7 +1184,7 @@ ERROR: static int pakfire_build_package_add_scriptlets(pakfire_build* build, struct pakfire_parser* makefile, const char* namespace, - struct pakfire_package* pkg, struct pakfire_packager* packager) { + struct pakfire_package* pkg, pakfire_packager* packager) { char name[NAME_MAX]; int r; @@ -1215,7 +1215,7 @@ static int pakfire_build_package(pakfire_build* build, struct pakfire_parser* ma const char* buildroot, const char* namespace) { pakfire_archive* archive = NULL; struct pakfire_package* pkg = NULL; - struct pakfire_packager* packager = NULL; + pakfire_packager* packager = NULL; int r = 1; diff --git a/src/pakfire/dist.c b/src/pakfire/dist.c index d3979deb..59b6b4f0 100644 --- a/src/pakfire/dist.c +++ b/src/pakfire/dist.c @@ -324,7 +324,7 @@ ERROR: return r; } -static int pakfire_dist_add_source(struct pakfire* pakfire, struct pakfire_packager* packager, +static int pakfire_dist_add_source(struct pakfire* pakfire, pakfire_packager* packager, struct pakfire_package* pkg, pakfire_ctx* ctx, pakfire_mirrorlist* mirrorlist, const char* filename) { char archive_path[PATH_MAX]; @@ -352,7 +352,7 @@ static int pakfire_dist_add_source(struct pakfire* pakfire, struct pakfire_packa } static int pakfire_dist_add_sources(pakfire_ctx* ctx, struct pakfire* pakfire, - struct pakfire_packager* packager, struct pakfire_package* pkg, struct pakfire_parser* makefile) { + pakfire_packager* packager, struct pakfire_package* pkg, struct pakfire_parser* makefile) { pakfire_mirrorlist* mirrorlist = NULL; char* sources = NULL; char* p = NULL; @@ -413,7 +413,7 @@ static int __pakfire_dist_find_root(char* root, const size_t length, const char* } static int pakfire_dist_add_files(pakfire_ctx* ctx, struct pakfire* pakfire, - struct pakfire_packager* packager, const char* file) { + pakfire_packager* packager, const char* file) { pakfire_filelist* filelist = NULL; char root[PATH_MAX]; int r; @@ -452,7 +452,7 @@ ERROR: int pakfire_dist(struct pakfire* pakfire, const char* path, pakfire_archive** archive) { - struct pakfire_packager* packager = NULL; + pakfire_packager* packager = NULL; struct pakfire_package* pkg = NULL; struct pakfire_parser* makefile = NULL; struct pakfire_parser_error* error = NULL; diff --git a/src/pakfire/packager.c b/src/pakfire/packager.c index 4035d948..125a3311 100644 --- a/src/pakfire/packager.c +++ b/src/pakfire/packager.c @@ -69,7 +69,7 @@ struct pakfire_packager { unsigned int digests; }; -static void pakfire_packager_free(struct pakfire_packager* packager) { +static void pakfire_packager_free(pakfire_packager* packager) { if (packager->reader) archive_read_free(packager->reader); @@ -91,9 +91,9 @@ static void pakfire_packager_free(struct pakfire_packager* packager) { free(packager); } -int pakfire_packager_create(struct pakfire_packager** packager, +int pakfire_packager_create(pakfire_packager** packager, struct pakfire* pakfire, struct pakfire_package* pkg) { - struct pakfire_packager* p = NULL; + pakfire_packager* p = NULL; char hostname[HOST_NAME_MAX]; int r = 1; @@ -204,15 +204,15 @@ ERROR: return r; } -struct pakfire_packager* pakfire_packager_ref( - struct pakfire_packager* packager) { +pakfire_packager* pakfire_packager_ref( + pakfire_packager* packager) { ++packager->nrefs; return packager; } -struct pakfire_packager* pakfire_packager_unref( - struct pakfire_packager* packager) { +pakfire_packager* pakfire_packager_unref( + pakfire_packager* packager) { if (--packager->nrefs > 0) return packager; @@ -220,7 +220,7 @@ struct pakfire_packager* pakfire_packager_unref( return NULL; } -static int pakfire_packager_write_format(struct pakfire_packager* packager, +static int pakfire_packager_write_format(pakfire_packager* packager, pakfire_archive_writer* writer) { const char format[] = TO_STRING(PACKAGE_FORMAT) "\n"; int r; @@ -244,7 +244,7 @@ static int pakfire_packager_write_format(struct pakfire_packager* packager, return 0; } -static int pakfire_packager_write_metadata(struct pakfire_packager* packager, +static int pakfire_packager_write_metadata(pakfire_packager* packager, pakfire_archive_writer* writer) { struct json_object* md = NULL; int r; @@ -270,7 +270,7 @@ ERROR: return r; } -static int pakfire_packager_write_scriptlet(struct pakfire_packager* packager, +static int pakfire_packager_write_scriptlet(pakfire_packager* packager, pakfire_archive_writer* writer, struct pakfire_scriptlet* scriptlet) { char filename[PATH_MAX]; size_t size; @@ -298,7 +298,7 @@ static int pakfire_packager_write_scriptlet(struct pakfire_packager* packager, It will create a new archive and write the package to the given file descriptor. */ -int pakfire_packager_finish(struct pakfire_packager* packager, FILE* f) { +int pakfire_packager_finish(pakfire_packager* packager, FILE* f) { pakfire_archive_writer* writer = NULL; int r; @@ -375,7 +375,7 @@ ERROR: return r; } -int pakfire_packager_write_archive(struct pakfire_packager* self, +int pakfire_packager_write_archive(pakfire_packager* self, pakfire_archive** archive) { FILE* f = NULL; char path[PATH_MAX]; @@ -425,7 +425,7 @@ ERROR: return r; } -int pakfire_packager_add_file(struct pakfire_packager* packager, pakfire_file* file) { +int pakfire_packager_add_file(pakfire_packager* packager, pakfire_file* file) { int r; // Check input @@ -487,7 +487,7 @@ int pakfire_packager_add_file(struct pakfire_packager* packager, pakfire_file* f return pakfire_filelist_add(packager->filelist, file); } -int pakfire_packager_add(struct pakfire_packager* packager, +int pakfire_packager_add(pakfire_packager* packager, const char* sourcepath, const char* path) { struct archive_entry* entry = NULL; pakfire_file* file = NULL; @@ -538,18 +538,18 @@ ERROR: static int __pakfire_packager_add_files( pakfire_ctx* ctx, pakfire_file* file, void* data) { - struct pakfire_packager* packager = data; + pakfire_packager* packager = data; return pakfire_packager_add_file(packager, file); } int pakfire_packager_add_files( - struct pakfire_packager* packager, pakfire_filelist* filelist) { + pakfire_packager* packager, pakfire_filelist* filelist) { // Add all files on the filelist return pakfire_filelist_walk(filelist, __pakfire_packager_add_files, packager, 0, NULL); } -int pakfire_packager_add_scriptlet(struct pakfire_packager* packager, +int pakfire_packager_add_scriptlet(pakfire_packager* packager, struct pakfire_scriptlet* scriptlet) { if (!scriptlet) return -EINVAL; @@ -569,7 +569,7 @@ int pakfire_packager_add_scriptlet(struct pakfire_packager* packager, /* Removes all files on the filelist */ -int pakfire_packager_cleanup(struct pakfire_packager* packager) { +int pakfire_packager_cleanup(pakfire_packager* packager) { // Delete all files on the filelist return pakfire_filelist_cleanup(packager->filelist, PAKFIRE_FILE_CLEANUP_TIDY); } diff --git a/src/pakfire/packager.h b/src/pakfire/packager.h index 965d11a1..f064055d 100644 --- a/src/pakfire/packager.h +++ b/src/pakfire/packager.h @@ -29,29 +29,29 @@ #define PAKFIRE_PACKAGER_HASHES (PAKFIRE_HASH_SHA3_512|PAKFIRE_HASH_BLAKE2B512) -struct pakfire_packager; +typedef struct pakfire_packager pakfire_packager; -int pakfire_packager_create(struct pakfire_packager** packager, +int pakfire_packager_create(pakfire_packager** packager, struct pakfire* pakfire, struct pakfire_package* pkg); -struct pakfire_packager* pakfire_packager_ref(struct pakfire_packager* packager); -struct pakfire_packager* pakfire_packager_unref(struct pakfire_packager* packager); +pakfire_packager* pakfire_packager_ref(pakfire_packager* packager); +pakfire_packager* pakfire_packager_unref(pakfire_packager* packager); -int pakfire_packager_write_archive(struct pakfire_packager* self, +int pakfire_packager_write_archive(pakfire_packager* self, pakfire_archive** archive); -int pakfire_packager_finish(struct pakfire_packager* packager, FILE* f); +int pakfire_packager_finish(pakfire_packager* packager, FILE* f); int pakfire_packager_add_file( - struct pakfire_packager* packager, pakfire_file* file); -int pakfire_packager_add_files(struct pakfire_packager* packager, + pakfire_packager* packager, pakfire_file* file); +int pakfire_packager_add_files(pakfire_packager* packager, pakfire_filelist* filelist); -int pakfire_packager_add(struct pakfire_packager* packager, +int pakfire_packager_add(pakfire_packager* packager, const char* sourcepath, const char* path); -int pakfire_packager_add_scriptlet(struct pakfire_packager* packager, +int pakfire_packager_add_scriptlet(pakfire_packager* packager, struct pakfire_scriptlet* scriptlet); -int pakfire_packager_cleanup(struct pakfire_packager* packager); +int pakfire_packager_cleanup(pakfire_packager* packager); #endif /* PAKFIRE_PACKAGER_H */ diff --git a/tests/libpakfire/packager.c b/tests/libpakfire/packager.c index b712bf99..5e6ad34c 100644 --- a/tests/libpakfire/packager.c +++ b/tests/libpakfire/packager.c @@ -28,7 +28,7 @@ #include "../testsuite.h" static int test_create(const struct test* t) { - struct pakfire_packager* packager = NULL; + pakfire_packager* packager = NULL; struct pakfire_package* pkg = NULL; struct pakfire_repo* repo = NULL; int r = EXIT_FAILURE; @@ -68,7 +68,7 @@ static int test_compare_metadata(const struct test* t) { pakfire_archive* archive = NULL; struct pakfire_package* pkg1 = NULL; struct pakfire_package* pkg2 = NULL; - struct pakfire_packager* packager = NULL; + pakfire_packager* packager = NULL; char* path = NULL; const char* s = NULL; int r = EXIT_FAILURE;