From 9f953e68ebbc433105fe55c538cb69582b22cfff Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Thu, 30 Nov 2017 18:44:20 +0100 Subject: [PATCH] libpakfire: Hide all symbols by default and only export what we want Signed-off-by: Michael Tremer --- Makefile.am | 11 +- src/libpakfire/archive.c | 36 +++--- src/libpakfire/cache.c | 19 +-- src/libpakfire/errno.c | 4 +- src/libpakfire/file.c | 73 +++++------ src/libpakfire/filelist.c | 9 +- src/libpakfire/filter.c | 5 +- src/libpakfire/include/pakfire/private.h | 28 ++++ src/libpakfire/key.c | 39 +++--- src/libpakfire/logging.c | 15 ++- src/libpakfire/package.c | 155 ++++++++++++----------- src/libpakfire/packagecache.c | 11 +- src/libpakfire/packagelist.c | 21 +-- src/libpakfire/pakfire.c | 15 ++- src/libpakfire/pool.c | 33 ++--- src/libpakfire/problem.c | 15 ++- src/libpakfire/relation.c | 15 ++- src/libpakfire/relationlist.c | 15 ++- src/libpakfire/repo.c | 45 +++---- src/libpakfire/repocache.c | 17 +-- src/libpakfire/request.c | 45 +++---- src/libpakfire/selector.c | 11 +- src/libpakfire/solution.c | 13 +- src/libpakfire/step.c | 19 +-- src/libpakfire/transaction.c | 19 +-- src/libpakfire/util.c | 7 +- 26 files changed, 377 insertions(+), 318 deletions(-) create mode 100644 src/libpakfire/include/pakfire/private.h diff --git a/Makefile.am b/Makefile.am index 77d7c6d79..2bec4f4f5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -54,8 +54,13 @@ AM_CPPFLAGS = \ -I $(top_srcdir)/include \ $(OUR_CPPFLAGS) -AM_CFLAGS = $(OUR_CFLAGS) -AM_LDFLAGS = $(OUR_LDFLAGS) +AM_CFLAGS = $(OUR_CFLAGS) \ + -ffunction-sections \ + -fdata-sections + +AM_LDFLAGS = $(OUR_LDFLAGS) \ + -Wl,--gc-sections \ + -Wl,--as-needed PAKFIRE_CPPFLAGS = -I$(top_srcdir)/src/libpakfire/include PAKFIRE_LIBS = libpakfire.la @@ -283,6 +288,7 @@ pkginclude_HEADERS += \ src/libpakfire/include/pakfire/packagelist.h \ src/libpakfire/include/pakfire/pakfire.h \ src/libpakfire/include/pakfire/pool.h \ + src/libpakfire/include/pakfire/private.h \ src/libpakfire/include/pakfire/problem.h \ src/libpakfire/include/pakfire/relation.h \ src/libpakfire/include/pakfire/relationlist.h \ @@ -299,6 +305,7 @@ pkginclude_HEADERS += \ libpakfire_la_CFLAGS = \ $(AM_CFLAGS) \ + -fvisibility=hidden \ $(LIBGCRYPT_CFLAGS) libpakfire_la_CPPFLAGS = \ diff --git a/src/libpakfire/archive.c b/src/libpakfire/archive.c index 41fe39e02..02e2b2802 100644 --- a/src/libpakfire/archive.c +++ b/src/libpakfire/archive.c @@ -41,6 +41,7 @@ #include #include #include +#include #include static void configure_archive(struct archive* a) { @@ -207,20 +208,20 @@ static void pakfire_archive_signature_free(PakfireArchiveSignature signature) { pakfire_free(signature); } -PakfireArchiveSignature pakfire_archive_signature_ref(PakfireArchiveSignature signature) { +PAKFIRE_EXPORT PakfireArchiveSignature pakfire_archive_signature_ref(PakfireArchiveSignature signature) { ++signature->nrefs; return signature; } -void pakfire_archive_signature_unref(PakfireArchiveSignature signature) { +PAKFIRE_EXPORT void pakfire_archive_signature_unref(PakfireArchiveSignature signature) { if (--signature->nrefs > 0) return; pakfire_archive_signature_free(signature); } -size_t _pakfire_archive_count_signatures(const PakfireArchiveSignature* signatures) { +static size_t _pakfire_archive_count_signatures(const PakfireArchiveSignature* signatures) { size_t i = 0; while (signatures && *signatures++) { @@ -230,13 +231,13 @@ size_t _pakfire_archive_count_signatures(const PakfireArchiveSignature* signatur return i; } -size_t pakfire_archive_count_signatures(PakfireArchive archive) { +PAKFIRE_EXPORT size_t pakfire_archive_count_signatures(PakfireArchive archive) { PakfireArchiveSignature* signatures = pakfire_archive_get_signatures(archive); return _pakfire_archive_count_signatures(signatures); } -PakfireArchive pakfire_archive_create(Pakfire pakfire) { +PAKFIRE_EXPORT PakfireArchive pakfire_archive_create(Pakfire pakfire) { PakfireArchive archive = pakfire_calloc(1, sizeof(*archive)); if (archive) { DEBUG("Allocated new archive at %p\n", archive); @@ -251,7 +252,7 @@ PakfireArchive pakfire_archive_create(Pakfire pakfire) { return archive; } -PakfireArchive pakfire_archive_ref(PakfireArchive archive) { +PAKFIRE_EXPORT PakfireArchive pakfire_archive_ref(PakfireArchive archive) { ++archive->nrefs; return archive; @@ -281,7 +282,7 @@ static void pakfire_archive_free(PakfireArchive archive) { pakfire_free(archive); } -void pakfire_archive_unref(PakfireArchive archive) { +PAKFIRE_EXPORT void pakfire_archive_unref(PakfireArchive archive) { if (--archive->nrefs > 0) return; @@ -577,8 +578,7 @@ out: return r; } - -PakfireArchive pakfire_archive_open(Pakfire pakfire, const char* path) { +PAKFIRE_EXPORT PakfireArchive pakfire_archive_open(Pakfire pakfire, const char* path) { PakfireArchive archive = pakfire_archive_create(pakfire); archive->path = pakfire_strdup(path); @@ -628,7 +628,7 @@ static struct archive* archive_open_payload(struct archive* a) { return payload_archive; } -int pakfire_archive_read(PakfireArchive archive, const char* filename, +PAKFIRE_EXPORT int pakfire_archive_read(PakfireArchive archive, const char* filename, void** data, size_t* data_size, int flags) { struct archive* a; struct archive* pa = NULL; @@ -667,7 +667,7 @@ out: return r; } -int pakfire_archive_extract(PakfireArchive archive, const char* prefix, int flags) { +PAKFIRE_EXPORT int pakfire_archive_extract(PakfireArchive archive, const char* prefix, int flags) { struct archive* a; struct archive* pa = NULL; @@ -693,19 +693,19 @@ int pakfire_archive_extract(PakfireArchive archive, const char* prefix, int flag return r; } -const char* pakfire_archive_get_path(PakfireArchive archive) { +PAKFIRE_EXPORT const char* pakfire_archive_get_path(PakfireArchive archive) { return archive->path; } -unsigned int pakfire_archive_get_format(PakfireArchive archive) { +PAKFIRE_EXPORT unsigned int pakfire_archive_get_format(PakfireArchive archive) { return archive->format; } -PakfireFile pakfire_archive_get_filelist(PakfireArchive archive) { +PAKFIRE_EXPORT PakfireFile pakfire_archive_get_filelist(PakfireArchive archive) { return archive->filelist; } -const char* pakfire_archive_signature_get_data(PakfireArchiveSignature signature) { +PAKFIRE_EXPORT const char* pakfire_archive_signature_get_data(PakfireArchiveSignature signature) { return signature->sigdata; } @@ -766,7 +766,7 @@ static int pakfire_archive_load_signatures(PakfireArchive archive) { return pakfire_archive_walk(archive, pakfire_archive_read_signature_entry); } -PakfireArchiveSignature* pakfire_archive_get_signatures(PakfireArchive archive) { +PAKFIRE_EXPORT PakfireArchiveSignature* pakfire_archive_get_signatures(PakfireArchive archive) { if (!archive->signatures_loaded++) pakfire_archive_load_signatures(archive); @@ -947,7 +947,7 @@ FAIL: return status; } -pakfire_archive_verify_status_t pakfire_archive_verify(PakfireArchive archive) { +PAKFIRE_EXPORT pakfire_archive_verify_status_t pakfire_archive_verify(PakfireArchive archive) { // Verify that checksums file is signed with a valid key pakfire_archive_verify_status_t status = pakfire_archive_verify_checksums(archive); if (status) @@ -985,7 +985,7 @@ END: return status; } -const char* pakfire_archive_verify_strerror(pakfire_archive_verify_status_t status) { +PAKFIRE_EXPORT const char* pakfire_archive_verify_strerror(pakfire_archive_verify_status_t status) { switch (status) { case PAKFIRE_ARCHIVE_VERIFY_OK: return _("Verify OK"); diff --git a/src/libpakfire/cache.c b/src/libpakfire/cache.c index 5b99c1a2a..6c7a744b0 100644 --- a/src/libpakfire/cache.c +++ b/src/libpakfire/cache.c @@ -29,10 +29,11 @@ #include #include #include +#include #include #include -PakfireCache pakfire_cache_create(PakfirePool pool, const char* path) { +PAKFIRE_EXPORT PakfireCache pakfire_cache_create(PakfirePool pool, const char* path) { PakfireCache cache = pakfire_calloc(1, sizeof(*cache)); cache->pool = pool; @@ -41,16 +42,16 @@ PakfireCache pakfire_cache_create(PakfirePool pool, const char* path) { return cache; } -void pakfire_cache_free(PakfireCache cache) { +PAKFIRE_EXPORT void pakfire_cache_free(PakfireCache cache) { pakfire_free(cache->path); pakfire_free(cache); } -const char* pakfire_cache_get_path(PakfireCache cache) { +PAKFIRE_EXPORT const char* pakfire_cache_get_path(PakfireCache cache) { return cache->path; } -char* pakfire_cache_get_full_path(PakfireCache cache, const char* path) { +PAKFIRE_EXPORT char* pakfire_cache_get_full_path(PakfireCache cache, const char* path) { const char* cache_path = pakfire_cache_get_path(cache); return pakfire_path_join(cache_path, path); @@ -65,7 +66,7 @@ static int pakfire_cache_stat(PakfireCache cache, const char* filename, struct s return r; } -int pakfire_cache_has_file(PakfireCache cache, const char* filename) { +PAKFIRE_EXPORT int pakfire_cache_has_file(PakfireCache cache, const char* filename) { struct stat buf; int r = pakfire_cache_stat(cache, filename, &buf); @@ -73,7 +74,7 @@ int pakfire_cache_has_file(PakfireCache cache, const char* filename) { return (r == 0); } -char* pakfire_cache_get_package_path(PakfireCache cache, PakfirePackage pkg) { +PAKFIRE_EXPORT char* pakfire_cache_get_package_path(PakfireCache cache, PakfirePackage pkg) { char buffer[STRING_SIZE] = ""; const char* filename = pakfire_package_get_filename(pkg); @@ -88,7 +89,7 @@ char* pakfire_cache_get_package_path(PakfireCache cache, PakfirePackage pkg) { return pakfire_strdup(buffer); } -int pakfire_cache_has_package(PakfireCache cache, PakfirePackage pkg) { +PAKFIRE_EXPORT int pakfire_cache_has_package(PakfireCache cache, PakfirePackage pkg) { char* filename = pakfire_cache_get_package_path(cache, pkg); int r = pakfire_cache_has_file(cache, filename); @@ -97,7 +98,7 @@ int pakfire_cache_has_package(PakfireCache cache, PakfirePackage pkg) { return r; } -int pakfire_cache_age(PakfireCache cache, const char* filename) { +PAKFIRE_EXPORT int pakfire_cache_age(PakfireCache cache, const char* filename) { struct stat buf; int r = pakfire_cache_stat(cache, filename, &buf); @@ -146,7 +147,7 @@ static int pakfire_cache_mkdir(PakfireCache cache, const char* path, mode_t mode return r; } -FILE* pakfire_cache_open(PakfireCache cache, const char* filename, const char* flags) { +PAKFIRE_EXPORT FILE* pakfire_cache_open(PakfireCache cache, const char* filename, const char* flags) { assert(filename); char* cache_filename = pakfire_cache_get_full_path(cache, filename); diff --git a/src/libpakfire/errno.c b/src/libpakfire/errno.c index 1f34a8416..a43284b8f 100644 --- a/src/libpakfire/errno.c +++ b/src/libpakfire/errno.c @@ -20,8 +20,10 @@ #include "errno.h" +#include + __thread int pakfire_errno = 0; -int pakfire_get_errno(void) { +PAKFIRE_EXPORT int pakfire_get_errno(void) { return pakfire_errno; } diff --git a/src/libpakfire/file.c b/src/libpakfire/file.c index a2382f6f2..9cc563897 100644 --- a/src/libpakfire/file.c +++ b/src/libpakfire/file.c @@ -29,9 +29,10 @@ #include #include +#include #include -PakfireFile pakfire_file_create() { +PAKFIRE_EXPORT PakfireFile pakfire_file_create() { PakfireFile file = pakfire_calloc(1, sizeof(*file)); if (file) { file->name = NULL; @@ -43,7 +44,7 @@ PakfireFile pakfire_file_create() { return file; } -void pakfire_file_free(PakfireFile file) { +PAKFIRE_EXPORT void pakfire_file_free(PakfireFile file) { if (file->name) pakfire_free(file->name); @@ -61,7 +62,7 @@ void pakfire_file_free(PakfireFile file) { pakfire_free(file); } -void pakfire_file_free_all(PakfireFile file) { +PAKFIRE_EXPORT void pakfire_file_free_all(PakfireFile file) { file = pakfire_file_get_first(file); while (file) { @@ -72,14 +73,14 @@ void pakfire_file_free_all(PakfireFile file) { } } -int pakfire_file_cmp(PakfireFile file1, PakfireFile file2) { +PAKFIRE_EXPORT int pakfire_file_cmp(PakfireFile file1, PakfireFile file2) { const char* name1 = pakfire_file_get_name(file1); const char* name2 = pakfire_file_get_name(file2); return strcmp(name1, name2); } -void pakfire_file_swap(PakfireFile file1, PakfireFile file2) { +PAKFIRE_EXPORT void pakfire_file_swap(PakfireFile file1, PakfireFile file2) { PakfireFile file_prev = file1->prev; PakfireFile file_next = file2->next; @@ -95,7 +96,7 @@ void pakfire_file_swap(PakfireFile file1, PakfireFile file2) { file1->prev = file2; } -PakfireFile pakfire_file_sort(PakfireFile head) { +PAKFIRE_EXPORT PakfireFile pakfire_file_sort(PakfireFile head) { unsigned int count = pakfire_file_count(head); for (unsigned int i = 0; i < count; i++) { @@ -118,22 +119,22 @@ PakfireFile pakfire_file_sort(PakfireFile head) { return head; } -PakfireFile pakfire_file_get_prev(PakfireFile file) { +PAKFIRE_EXPORT PakfireFile pakfire_file_get_prev(PakfireFile file) { return file->prev; } -PakfireFile pakfire_file_get_next(PakfireFile file) { +PAKFIRE_EXPORT PakfireFile pakfire_file_get_next(PakfireFile file) { return file->next; } -PakfireFile pakfire_file_get_first(PakfireFile file) { +PAKFIRE_EXPORT PakfireFile pakfire_file_get_first(PakfireFile file) { if (file->prev) return pakfire_file_get_first(file->prev); return file; } -PakfireFile pakfire_file_get_last(PakfireFile file) { +PAKFIRE_EXPORT PakfireFile pakfire_file_get_last(PakfireFile file) { if (file->next) return pakfire_file_get_last(file->next); @@ -151,14 +152,14 @@ static PakfireFile __pakfire_file_append(PakfireFile file, PakfireFile appended_ return appended_file; } -PakfireFile pakfire_file_append(PakfireFile file) { +PAKFIRE_EXPORT PakfireFile pakfire_file_append(PakfireFile file) { // Create a new file object. PakfireFile appended_file = pakfire_file_create(); return __pakfire_file_append(file, appended_file); } -unsigned int pakfire_file_count(PakfireFile file) { +PAKFIRE_EXPORT unsigned int pakfire_file_count(PakfireFile file) { unsigned int counter = 0; while (file) { @@ -213,7 +214,7 @@ static char* pakfire_file_format_mtime(PakfireFile file) { return pakfire_strdup(buffer); } -void pakfire_file_sprintf(PakfireFile file, char* str, size_t len) { +PAKFIRE_EXPORT void pakfire_file_sprintf(PakfireFile file, char* str, size_t len) { const char* name = pakfire_file_get_name(file); ssize_t size = pakfire_file_get_size(file); @@ -230,11 +231,11 @@ void pakfire_file_sprintf(PakfireFile file, char* str, size_t len) { pakfire_free(mtime); } -const char* pakfire_file_get_name(PakfireFile file) { +PAKFIRE_EXPORT const char* pakfire_file_get_name(PakfireFile file) { return file->name; } -void pakfire_file_set_name(PakfireFile file, const char* name) { +PAKFIRE_EXPORT void pakfire_file_set_name(PakfireFile file, const char* name) { if (file->name) pakfire_free(file->name); @@ -245,83 +246,83 @@ void pakfire_file_set_name(PakfireFile file, const char* name) { } } -char pakfire_file_get_type(PakfireFile file) { +PAKFIRE_EXPORT char pakfire_file_get_type(PakfireFile file) { return file->type; } -void pakfire_file_set_type(PakfireFile file, char type) { +PAKFIRE_EXPORT void pakfire_file_set_type(PakfireFile file, char type) { file->type = type; } -int pakfire_file_is_file(PakfireFile file) { +PAKFIRE_EXPORT int pakfire_file_is_file(PakfireFile file) { return (file->type == REGTYPE) || (file->type == AREGTYPE); } -int pakfire_file_is_link(PakfireFile file) { +PAKFIRE_EXPORT int pakfire_file_is_link(PakfireFile file) { return (file->type == LNKTYPE); } -int pakfire_file_is_symlink(PakfireFile file) { +PAKFIRE_EXPORT int pakfire_file_is_symlink(PakfireFile file) { return (file->type == SYMTYPE); } -int pakfire_file_is_char(PakfireFile file) { +PAKFIRE_EXPORT int pakfire_file_is_char(PakfireFile file) { return (file->type == CHRTYPE); } -int pakfire_file_is_block(PakfireFile file) { +PAKFIRE_EXPORT int pakfire_file_is_block(PakfireFile file) { return (file->type == BLKTYPE); } -int pakfire_file_is_dir(PakfireFile file) { +PAKFIRE_EXPORT int pakfire_file_is_dir(PakfireFile file) { return (file->type == DIRTYPE); } -ssize_t pakfire_file_get_size(PakfireFile file) { +PAKFIRE_EXPORT ssize_t pakfire_file_get_size(PakfireFile file) { return file->size; } -void pakfire_file_set_size(PakfireFile file, ssize_t size) { +PAKFIRE_EXPORT void pakfire_file_set_size(PakfireFile file, ssize_t size) { file->size = size; } -const char* pakfire_file_get_user(PakfireFile file) { +PAKFIRE_EXPORT const char* pakfire_file_get_user(PakfireFile file) { return file->user; } -void pakfire_file_set_user(PakfireFile file, const char* user) { +PAKFIRE_EXPORT void pakfire_file_set_user(PakfireFile file, const char* user) { file->user = pakfire_strdup(user); } -const char* pakfire_file_get_group(PakfireFile file) { +PAKFIRE_EXPORT const char* pakfire_file_get_group(PakfireFile file) { return file->group; } -void pakfire_file_set_group(PakfireFile file, const char* group) { +PAKFIRE_EXPORT void pakfire_file_set_group(PakfireFile file, const char* group) { file->group = pakfire_strdup(group); } -mode_t pakfire_file_get_mode(PakfireFile file) { +PAKFIRE_EXPORT mode_t pakfire_file_get_mode(PakfireFile file) { return file->mode; } -void pakfire_file_set_mode(PakfireFile file, mode_t mode) { +PAKFIRE_EXPORT void pakfire_file_set_mode(PakfireFile file, mode_t mode) { file->mode = mode; } -time_t pakfire_file_get_time(PakfireFile file) { +PAKFIRE_EXPORT time_t pakfire_file_get_time(PakfireFile file) { return file->time; } -void pakfire_file_set_time(PakfireFile file, time_t time) { +PAKFIRE_EXPORT void pakfire_file_set_time(PakfireFile file, time_t time) { file->time = time; } -const char* pakfire_file_get_chksum(PakfireFile file) { +PAKFIRE_EXPORT const char* pakfire_file_get_chksum(PakfireFile file) { return file->chksum; } -void pakfire_file_set_chksum(PakfireFile file, const char* chksum) { +PAKFIRE_EXPORT void pakfire_file_set_chksum(PakfireFile file, const char* chksum) { file->chksum = pakfire_strdup(chksum); } @@ -444,7 +445,7 @@ static PakfireFile pakfire_file_parse_line(char* line, unsigned int format) { return file; } -PakfireFile pakfire_file_parse_from_file(const char* list, unsigned int format) { +PAKFIRE_EXPORT PakfireFile pakfire_file_parse_from_file(const char* list, unsigned int format) { PakfireFile head = NULL; char* plist = (char *)list; diff --git a/src/libpakfire/filelist.c b/src/libpakfire/filelist.c index 56c799d30..8d0e2f915 100644 --- a/src/libpakfire/filelist.c +++ b/src/libpakfire/filelist.c @@ -20,9 +20,10 @@ #include #include +#include #include -PakfireFilelist pakfire_filelist_create(PakfirePackage pkg) { +PAKFIRE_EXPORT PakfireFilelist pakfire_filelist_create(PakfirePackage pkg) { PakfireFilelist list = pakfire_calloc(1, sizeof(*list)); if (list) { list->pkg = pkg; @@ -34,7 +35,7 @@ PakfireFilelist pakfire_filelist_create(PakfirePackage pkg) { return list; } -void pakfire_filelist_free(PakfireFilelist list) { +PAKFIRE_EXPORT void pakfire_filelist_free(PakfireFilelist list) { pakfire_filelist_remove_all(); pakfire_free(list); } @@ -51,13 +52,13 @@ static void pakfire_filelist_remove_first(PakfireFilelist list) { pakfire_file_free(file); } -void pakfire_filelist_remove_all(PakfireFilelist list) { +PAKFIRE_EXPORT void pakfire_filelist_remove_all(PakfireFilelist list) { while (list->first) { pakfire_filelist_remove_first(list); } } -void pakfire_filelist_append(PakfireFilelist list, PakfireFile file) { +PAKFIRE_EXPORT void pakfire_filelist_append(PakfireFilelist list, PakfireFile file) { if (list->first && list->last) { list->last->next = file; list->last = file; diff --git a/src/libpakfire/filter.c b/src/libpakfire/filter.c index 95dbd2dc8..0be50e1c8 100644 --- a/src/libpakfire/filter.c +++ b/src/libpakfire/filter.c @@ -19,16 +19,17 @@ #############################################################################*/ #include +#include #include #include -PakfireFilter pakfire_filter_create(void) { +PAKFIRE_EXPORT PakfireFilter pakfire_filter_create(void) { PakfireFilter filter = pakfire_calloc(1, sizeof(*filter)); return filter; } -void pakfire_filter_free(PakfireFilter filter) { +PAKFIRE_EXPORT void pakfire_filter_free(PakfireFilter filter) { pakfire_free(filter->match); pakfire_free(filter); } diff --git a/src/libpakfire/include/pakfire/private.h b/src/libpakfire/include/pakfire/private.h new file mode 100644 index 000000000..d0de1e905 --- /dev/null +++ b/src/libpakfire/include/pakfire/private.h @@ -0,0 +1,28 @@ +/*############################################################################# +# # +# Pakfire - The IPFire package management system # +# Copyright (C) 2013 Pakfire development team # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +#############################################################################*/ + +#ifndef PAKFIRE_PRIVATE_H +#define PAKFIRE_PRIVATE_H + +#ifdef PAKFIRE_PRIVATE +#define PAKFIRE_EXPORT __attribute__ ((visibility("default"))) +#endif + +#endif /* PAKFIRE_PRIVATE_H */ diff --git a/src/libpakfire/key.c b/src/libpakfire/key.c index 92126f359..db9b050f3 100644 --- a/src/libpakfire/key.c +++ b/src/libpakfire/key.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #define DEFAULT_KEY_SIZE "rsa4096" @@ -121,7 +122,7 @@ static size_t pakfire_count_keys(Pakfire pakfire) { return count; } -PakfireKey* pakfire_key_list(Pakfire pakfire) { +PAKFIRE_EXPORT PakfireKey* pakfire_key_list(Pakfire pakfire) { size_t count = pakfire_count_keys(pakfire); if (count == 0) return NULL; @@ -152,7 +153,7 @@ PakfireKey* pakfire_key_list(Pakfire pakfire) { return first; } -PakfireKey pakfire_key_create(Pakfire pakfire, gpgme_key_t gpgkey) { +PAKFIRE_EXPORT PakfireKey pakfire_key_create(Pakfire pakfire, gpgme_key_t gpgkey) { PakfireKey key = pakfire_calloc(1, sizeof(*key)); if (key) { @@ -173,13 +174,13 @@ static void pakfire_key_free(PakfireKey key) { pakfire_free(key); } -PakfireKey pakfire_key_ref(PakfireKey key) { +PAKFIRE_EXPORT PakfireKey pakfire_key_ref(PakfireKey key) { ++key->nrefs; return key; } -void pakfire_key_unref(PakfireKey key) { +PAKFIRE_EXPORT void pakfire_key_unref(PakfireKey key) { if (--key->nrefs > 0) return; @@ -211,7 +212,7 @@ static PakfireKey __pakfire_get_key(Pakfire pakfire, gpgme_ctx_t gpgctx, const c return key; } -PakfireKey pakfire_key_get(Pakfire pakfire, const char* fingerprint) { +PAKFIRE_EXPORT PakfireKey pakfire_key_get(Pakfire pakfire, const char* fingerprint) { gpgme_ctx_t gpgctx = pakfire_get_gpgctx(pakfire); PakfireKey key = __pakfire_get_key(pakfire, gpgctx, fingerprint); @@ -220,7 +221,7 @@ PakfireKey pakfire_key_get(Pakfire pakfire, const char* fingerprint) { return key; } -int pakfire_key_delete(PakfireKey key) { +PAKFIRE_EXPORT int pakfire_key_delete(PakfireKey key) { gpgme_ctx_t gpgctx = pakfire_get_gpgctx(key->pakfire); int r = 0; @@ -233,23 +234,23 @@ int pakfire_key_delete(PakfireKey key) { return r; } -const char* pakfire_key_get_fingerprint(PakfireKey key) { +PAKFIRE_EXPORT const char* pakfire_key_get_fingerprint(PakfireKey key) { return key->gpgkey->fpr; } -const char* pakfire_key_get_uid(PakfireKey key) { +PAKFIRE_EXPORT const char* pakfire_key_get_uid(PakfireKey key) { return key->gpgkey->uids->uid; } -const char* pakfire_key_get_name(PakfireKey key) { +PAKFIRE_EXPORT const char* pakfire_key_get_name(PakfireKey key) { return key->gpgkey->uids->name; } -const char* pakfire_key_get_email(PakfireKey key) { +PAKFIRE_EXPORT const char* pakfire_key_get_email(PakfireKey key) { return key->gpgkey->uids->email; } -const char* pakfire_key_get_pubkey_algo(PakfireKey key) { +PAKFIRE_EXPORT const char* pakfire_key_get_pubkey_algo(PakfireKey key) { switch (key->gpgkey->subkeys->pubkey_algo) { case GPGME_PK_RSA: case GPGME_PK_RSA_E: @@ -279,23 +280,23 @@ const char* pakfire_key_get_pubkey_algo(PakfireKey key) { return NULL; } -size_t pakfire_key_get_pubkey_length(PakfireKey key) { +PAKFIRE_EXPORT size_t pakfire_key_get_pubkey_length(PakfireKey key) { return key->gpgkey->subkeys->length; } -time_t pakfire_key_get_created(PakfireKey key) { +PAKFIRE_EXPORT time_t pakfire_key_get_created(PakfireKey key) { return key->gpgkey->subkeys->timestamp; } -time_t pakfire_key_get_expires(PakfireKey key) { +PAKFIRE_EXPORT time_t pakfire_key_get_expires(PakfireKey key) { return key->gpgkey->subkeys->expires; } -int pakfire_key_is_revoked(PakfireKey key) { +PAKFIRE_EXPORT int pakfire_key_is_revoked(PakfireKey key) { return key->gpgkey->subkeys->revoked; } -PakfireKey pakfire_key_generate(Pakfire pakfire, const char* userid) { +PAKFIRE_EXPORT PakfireKey pakfire_key_generate(Pakfire pakfire, const char* userid) { gpgme_ctx_t gpgctx = pakfire_get_gpgctx(pakfire); unsigned int flags = 0; @@ -326,7 +327,7 @@ PakfireKey pakfire_key_generate(Pakfire pakfire, const char* userid) { return pakfire_key_get(pakfire, result->fpr); } -char* pakfire_key_export(PakfireKey key, pakfire_key_export_mode_t mode) { +PAKFIRE_EXPORT char* pakfire_key_export(PakfireKey key, pakfire_key_export_mode_t mode) { gpgme_ctx_t gpgctx = pakfire_get_gpgctx(key->pakfire); gpgme_export_mode_t gpgmode = 0; @@ -380,7 +381,7 @@ FAIL: return NULL; } -PakfireKey* pakfire_key_import(Pakfire pakfire, const char* data) { +PAKFIRE_EXPORT PakfireKey* pakfire_key_import(Pakfire pakfire, const char* data) { gpgme_error_t error; gpgme_data_t keydata; @@ -452,7 +453,7 @@ FAIL: return NULL; } -char* pakfire_key_dump(PakfireKey key) { +PAKFIRE_EXPORT char* pakfire_key_dump(PakfireKey key) { char* s = ""; time_t created = pakfire_key_get_created(key); diff --git a/src/libpakfire/logging.c b/src/libpakfire/logging.c index 344172ecc..d83ee2f30 100644 --- a/src/libpakfire/logging.c +++ b/src/libpakfire/logging.c @@ -28,6 +28,7 @@ #include #include +#include static pakfire_logging_config_t conf = { .function = pakfire_log_syslog, @@ -59,23 +60,23 @@ void pakfire_setup_logging() { pakfire_log_set_priority(log_priority(priority)); } -pakfire_log_function_t pakfire_log_get_function() { +PAKFIRE_EXPORT pakfire_log_function_t pakfire_log_get_function() { return conf.function; } -void pakfire_log_set_function(pakfire_log_function_t func) { +PAKFIRE_EXPORT void pakfire_log_set_function(pakfire_log_function_t func) { conf.function = func; } -int pakfire_log_get_priority() { +PAKFIRE_EXPORT int pakfire_log_get_priority() { return conf.priority; } -void pakfire_log_set_priority(int priority) { +PAKFIRE_EXPORT void pakfire_log_set_priority(int priority) { conf.priority = priority; } -void pakfire_log(int priority, const char* file, int line, +PAKFIRE_EXPORT void pakfire_log(int priority, const char* file, int line, const char* fn, const char* format, ...) { va_list args; @@ -90,13 +91,13 @@ void pakfire_log(int priority, const char* file, int line, errno = saved_errno; } -void pakfire_log_stderr(int priority, const char* file, +PAKFIRE_EXPORT void pakfire_log_stderr(int priority, const char* file, int line, const char* fn, const char* format, va_list args) { fprintf(stderr, "pakfire: %s: ", fn); vfprintf(stderr, format, args); } -void pakfire_log_syslog(int priority, const char* file, +PAKFIRE_EXPORT void pakfire_log_syslog(int priority, const char* file, int line, const char* fn, const char* format, va_list args) { openlog("pakfire", LOG_PID, LOG_DAEMON); vsyslog(priority | LOG_DAEMON, format, args); diff --git a/src/libpakfire/package.c b/src/libpakfire/package.c index 38771d3be..c0afc72da 100644 --- a/src/libpakfire/package.c +++ b/src/libpakfire/package.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -63,7 +64,7 @@ static void pakfire_package_add_self_provides(PakfirePool pool, PakfirePackage p #endif } -PakfirePackage pakfire_package_create(PakfirePool pool, Id id) { +PAKFIRE_EXPORT PakfirePackage pakfire_package_create(PakfirePool pool, Id id) { PakfirePackage pkg = pakfire_calloc(1, sizeof(*pkg)); if (pkg) { @@ -77,7 +78,7 @@ PakfirePackage pakfire_package_create(PakfirePool pool, Id id) { return pkg; } -PakfirePackage pakfire_package_create2(PakfirePool pool, PakfireRepo repo, const char* name, const char* evr, const char* arch) { +PAKFIRE_EXPORT PakfirePackage pakfire_package_create2(PakfirePool pool, PakfireRepo repo, const char* name, const char* evr, const char* arch) { PakfirePackage pkg = pakfire_repo_add_package(repo); pakfire_package_set_name(pkg, name); @@ -89,7 +90,7 @@ PakfirePackage pakfire_package_create2(PakfirePool pool, PakfireRepo repo, const return pkg; } -void pakfire_package_free(PakfirePackage pkg) { +PAKFIRE_EXPORT void pakfire_package_free(PakfirePackage pkg) { if (--pkg->nrefs > 0) return; @@ -116,11 +117,11 @@ static Id pakfire_package_get_handle(PakfirePackage pkg) { return s - pool->solvables; } -int pakfire_package_identical(PakfirePackage pkg1, PakfirePackage pkg2) { +PAKFIRE_EXPORT int pakfire_package_identical(PakfirePackage pkg1, PakfirePackage pkg2) { return pkg1->id == pkg2->id; } -int pakfire_package_cmp(PakfirePackage pkg1, PakfirePackage pkg2) { +PAKFIRE_EXPORT int pakfire_package_cmp(PakfirePackage pkg1, PakfirePackage pkg2) { Pool* pool = pakfire_package_solv_pool(pkg1); Solvable* s1 = get_solvable(pkg1); @@ -160,7 +161,7 @@ int pakfire_package_cmp(PakfirePackage pkg1, PakfirePackage pkg2) { return strcmp(str1, str2); } -int pakfire_package_evr_cmp(PakfirePackage pkg1, PakfirePackage pkg2) { +PAKFIRE_EXPORT int pakfire_package_evr_cmp(PakfirePackage pkg1, PakfirePackage pkg2) { Pool* pool = pakfire_package_solv_pool(pkg1); Solvable* s1 = get_solvable(pkg1); @@ -169,11 +170,11 @@ int pakfire_package_evr_cmp(PakfirePackage pkg1, PakfirePackage pkg2) { return pool_evrcmp(pool, s1->evr, s2->evr, EVRCMP_COMPARE); } -Id pakfire_package_id(PakfirePackage pkg) { +PAKFIRE_EXPORT Id pakfire_package_id(PakfirePackage pkg) { return pkg->id; } -char* pakfire_package_get_nevra(PakfirePackage pkg) { +PAKFIRE_EXPORT char* pakfire_package_get_nevra(PakfirePackage pkg) { Pool* pool = pakfire_package_solv_pool(pkg); Solvable* s = get_solvable(pkg); @@ -182,28 +183,28 @@ char* pakfire_package_get_nevra(PakfirePackage pkg) { return pakfire_strdup(nevra); } -const char* pakfire_package_get_name(PakfirePackage pkg) { +PAKFIRE_EXPORT const char* pakfire_package_get_name(PakfirePackage pkg) { Pool* pool = pakfire_package_solv_pool(pkg); Solvable* s = get_solvable(pkg); return pool_id2str(pool, s->name); } -void pakfire_package_set_name(PakfirePackage pkg, const char* name) { +PAKFIRE_EXPORT void pakfire_package_set_name(PakfirePackage pkg, const char* name) { Pool* pool = pakfire_package_solv_pool(pkg); Solvable* s = get_solvable(pkg); s->name = pool_str2id(pool, name, 1); } -const char* pakfire_package_get_evr(PakfirePackage pkg) { +PAKFIRE_EXPORT const char* pakfire_package_get_evr(PakfirePackage pkg) { Pool* pool = pakfire_package_solv_pool(pkg); Solvable* s = get_solvable(pkg); return pool_id2str(pool, s->evr); } -void pakfire_package_set_evr(PakfirePackage pkg, const char* evr) { +PAKFIRE_EXPORT void pakfire_package_set_evr(PakfirePackage pkg, const char* evr) { Pool* pool = pakfire_package_solv_pool(pkg); Solvable* s = get_solvable(pkg); @@ -237,7 +238,7 @@ static void split_evr(Pool* pool, const char* evr_c, char** epoch, char** versio *release = r; } -unsigned long pakfire_package_get_epoch(PakfirePackage pkg) { +PAKFIRE_EXPORT unsigned long pakfire_package_get_epoch(PakfirePackage pkg) { Pool* pool = pakfire_package_solv_pool(pkg); char *e, *v, *r, *endptr; @@ -255,7 +256,7 @@ unsigned long pakfire_package_get_epoch(PakfirePackage pkg) { return epoch; } -const char* pakfire_package_get_version(PakfirePackage pkg) { +PAKFIRE_EXPORT const char* pakfire_package_get_version(PakfirePackage pkg) { Pool* pool = pakfire_package_solv_pool(pkg); char *e, *v, *r; @@ -263,7 +264,7 @@ const char* pakfire_package_get_version(PakfirePackage pkg) { return pakfire_strdup(v); } -const char* pakfire_package_get_release(PakfirePackage pkg) { +PAKFIRE_EXPORT const char* pakfire_package_get_release(PakfirePackage pkg) { Pool* pool = pakfire_package_solv_pool(pkg); char *e, *v, *r; @@ -271,14 +272,14 @@ const char* pakfire_package_get_release(PakfirePackage pkg) { return pakfire_strdup(r); } -const char* pakfire_package_get_arch(PakfirePackage pkg) { +PAKFIRE_EXPORT const char* pakfire_package_get_arch(PakfirePackage pkg) { Pool* pool = pakfire_package_solv_pool(pkg); Solvable* s = get_solvable(pkg); return pool_id2str(pool, s->arch); } -void pakfire_package_set_arch(PakfirePackage pkg, const char* arch) { +PAKFIRE_EXPORT void pakfire_package_set_arch(PakfirePackage pkg, const char* arch) { Pool* pool = pakfire_package_solv_pool(pkg); Solvable* s = get_solvable(pkg); @@ -317,57 +318,57 @@ static void pakfire_package_set_string(PakfirePackage pkg, int key, const char* solvable_set_str(s, key, value); } -const char* pakfire_package_get_uuid(PakfirePackage pkg) { +PAKFIRE_EXPORT const char* pakfire_package_get_uuid(PakfirePackage pkg) { return pakfire_package_get_string(pkg, SOLVABLE_PKGID); } -void pakfire_package_set_uuid(PakfirePackage pkg, const char* uuid) { +PAKFIRE_EXPORT void pakfire_package_set_uuid(PakfirePackage pkg, const char* uuid) { pakfire_package_set_string(pkg, SOLVABLE_PKGID, uuid); } -const char* pakfire_package_get_checksum(PakfirePackage pkg) { +PAKFIRE_EXPORT const char* pakfire_package_get_checksum(PakfirePackage pkg) { return pakfire_package_get_string(pkg, SOLVABLE_CHECKSUM); } -void pakfire_package_set_checksum(PakfirePackage pkg, const char* checksum) { +PAKFIRE_EXPORT void pakfire_package_set_checksum(PakfirePackage pkg, const char* checksum) { pakfire_package_set_string(pkg, SOLVABLE_CHECKSUM, checksum); } -const char* pakfire_package_get_summary(PakfirePackage pkg) { +PAKFIRE_EXPORT const char* pakfire_package_get_summary(PakfirePackage pkg) { return pakfire_package_get_string(pkg, SOLVABLE_SUMMARY); } -void pakfire_package_set_summary(PakfirePackage pkg, const char* summary) { +PAKFIRE_EXPORT void pakfire_package_set_summary(PakfirePackage pkg, const char* summary) { pakfire_package_set_string(pkg, SOLVABLE_SUMMARY, summary); } -const char* pakfire_package_get_description(PakfirePackage pkg) { +PAKFIRE_EXPORT const char* pakfire_package_get_description(PakfirePackage pkg) { return pakfire_package_get_string(pkg, SOLVABLE_DESCRIPTION); } -void pakfire_package_set_description(PakfirePackage pkg, const char* description) { +PAKFIRE_EXPORT void pakfire_package_set_description(PakfirePackage pkg, const char* description) { pakfire_package_set_string(pkg, SOLVABLE_DESCRIPTION, description); } -const char* pakfire_package_get_license(PakfirePackage pkg) { +PAKFIRE_EXPORT const char* pakfire_package_get_license(PakfirePackage pkg) { return pakfire_package_get_string(pkg, SOLVABLE_LICENSE); } -void pakfire_package_set_license(PakfirePackage pkg, const char* license) { +PAKFIRE_EXPORT void pakfire_package_set_license(PakfirePackage pkg, const char* license) { pakfire_package_set_string(pkg, SOLVABLE_LICENSE, license); } -const char* pakfire_package_get_url(PakfirePackage pkg) { +PAKFIRE_EXPORT const char* pakfire_package_get_url(PakfirePackage pkg) { return pakfire_package_get_string(pkg, SOLVABLE_URL); } -void pakfire_package_set_url(PakfirePackage pkg, const char* url) { +PAKFIRE_EXPORT void pakfire_package_set_url(PakfirePackage pkg, const char* url) { pakfire_package_set_string(pkg, SOLVABLE_URL, url); } #warning the groups functions need to be refactored -const char** pakfire_package_get_groups(PakfirePackage pkg) { +PAKFIRE_EXPORT const char** pakfire_package_get_groups(PakfirePackage pkg) { const char* groups = pakfire_package_get_string(pkg, SOLVABLE_GROUP); const char** grouplist = NULL; @@ -386,7 +387,7 @@ const char** pakfire_package_get_groups(PakfirePackage pkg) { return grouplist; } -void pakfire_package_set_groups(PakfirePackage pkg, const char** grouplist) { +PAKFIRE_EXPORT void pakfire_package_set_groups(PakfirePackage pkg, const char** grouplist) { char groups[2048] = ""; if (grouplist) { @@ -404,31 +405,31 @@ void pakfire_package_set_groups(PakfirePackage pkg, const char** grouplist) { pakfire_package_set_string(pkg, SOLVABLE_GROUP, (const char *)&groups); } -const char* pakfire_package_get_vendor(PakfirePackage pkg) { +PAKFIRE_EXPORT const char* pakfire_package_get_vendor(PakfirePackage pkg) { return pakfire_package_get_string(pkg, SOLVABLE_VENDOR); } -void pakfire_package_set_vendor(PakfirePackage pkg, const char* vendor) { +PAKFIRE_EXPORT void pakfire_package_set_vendor(PakfirePackage pkg, const char* vendor) { pakfire_package_set_string(pkg, SOLVABLE_VENDOR, vendor); } -const char* pakfire_package_get_maintainer(PakfirePackage pkg) { +PAKFIRE_EXPORT const char* pakfire_package_get_maintainer(PakfirePackage pkg) { return pakfire_package_get_string(pkg, SOLVABLE_PACKAGER); } -void pakfire_package_set_maintainer(PakfirePackage pkg, const char* maintainer) { +PAKFIRE_EXPORT void pakfire_package_set_maintainer(PakfirePackage pkg, const char* maintainer) { pakfire_package_set_string(pkg, SOLVABLE_PACKAGER, maintainer); } -const char* pakfire_package_get_filename(PakfirePackage pkg) { +PAKFIRE_EXPORT const char* pakfire_package_get_filename(PakfirePackage pkg) { return pakfire_package_get_string(pkg, SOLVABLE_MEDIAFILE); } -void pakfire_package_set_filename(PakfirePackage pkg, const char* filename) { +PAKFIRE_EXPORT void pakfire_package_set_filename(PakfirePackage pkg, const char* filename) { pakfire_package_set_string(pkg, SOLVABLE_MEDIAFILE, filename); } -int pakfire_package_is_installed(PakfirePackage pkg) { +PAKFIRE_EXPORT int pakfire_package_is_installed(PakfirePackage pkg) { Pool* pool = pakfire_package_solv_pool(pkg); Solvable* s = get_solvable(pkg); @@ -448,46 +449,46 @@ static void pakfire_package_set_num(PakfirePackage pkg, Id type, unsigned long l solvable_set_num(s, type, value); } -unsigned long long pakfire_package_get_downloadsize(PakfirePackage pkg) { +PAKFIRE_EXPORT unsigned long long pakfire_package_get_downloadsize(PakfirePackage pkg) { return pakfire_package_get_num(pkg, SOLVABLE_DOWNLOADSIZE); } -void pakfire_package_set_downloadsize(PakfirePackage pkg, unsigned long long downloadsize) { +PAKFIRE_EXPORT void pakfire_package_set_downloadsize(PakfirePackage pkg, unsigned long long downloadsize) { return pakfire_package_set_num(pkg, SOLVABLE_DOWNLOADSIZE, downloadsize); } -unsigned long long pakfire_package_get_installsize(PakfirePackage pkg) { +PAKFIRE_EXPORT unsigned long long pakfire_package_get_installsize(PakfirePackage pkg) { return pakfire_package_get_num(pkg, SOLVABLE_INSTALLSIZE); } -void pakfire_package_set_installsize(PakfirePackage pkg, unsigned long long installsize) { +PAKFIRE_EXPORT void pakfire_package_set_installsize(PakfirePackage pkg, unsigned long long installsize) { return pakfire_package_set_num(pkg, SOLVABLE_INSTALLSIZE, installsize); } -unsigned long long pakfire_package_get_size(PakfirePackage pkg) { +PAKFIRE_EXPORT unsigned long long pakfire_package_get_size(PakfirePackage pkg) { if (pakfire_package_is_installed(pkg)) return pakfire_package_get_installsize(pkg); return pakfire_package_get_downloadsize(pkg); } -const char* pakfire_package_get_buildhost(PakfirePackage pkg) { +PAKFIRE_EXPORT const char* pakfire_package_get_buildhost(PakfirePackage pkg) { return pakfire_package_get_string(pkg, SOLVABLE_BUILDHOST); } -void pakfire_package_set_buildhost(PakfirePackage pkg, const char* buildhost) { +PAKFIRE_EXPORT void pakfire_package_set_buildhost(PakfirePackage pkg, const char* buildhost) { pakfire_package_set_string(pkg, SOLVABLE_BUILDHOST, buildhost); } -unsigned long long pakfire_package_get_buildtime(PakfirePackage pkg) { +PAKFIRE_EXPORT unsigned long long pakfire_package_get_buildtime(PakfirePackage pkg) { return pakfire_package_get_num(pkg, SOLVABLE_BUILDTIME); } -void pakfire_package_set_buildtime(PakfirePackage pkg, unsigned long long buildtime) { +PAKFIRE_EXPORT void pakfire_package_set_buildtime(PakfirePackage pkg, unsigned long long buildtime) { pakfire_package_set_num(pkg, SOLVABLE_BUILDTIME, buildtime); } -unsigned long long pakfire_package_get_installtime(PakfirePackage pkg) { +PAKFIRE_EXPORT unsigned long long pakfire_package_get_installtime(PakfirePackage pkg) { return pakfire_package_get_num(pkg, SOLVABLE_INSTALLTIME); } @@ -536,96 +537,96 @@ static void pakfire_package_add_relation(PakfirePackage pkg, Id type, PakfireRel solvable_add_idarray(s, type, relation->id); } -PakfireRelationList pakfire_package_get_provides(PakfirePackage pkg) { +PAKFIRE_EXPORT PakfireRelationList pakfire_package_get_provides(PakfirePackage pkg) { return pakfire_package_get_relationlist(pkg, SOLVABLE_PROVIDES); } -void pakfire_package_set_provides(PakfirePackage pkg, PakfireRelationList relationlist) { +PAKFIRE_EXPORT void pakfire_package_set_provides(PakfirePackage pkg, PakfireRelationList relationlist) { pakfire_package_set_relationlist(pkg, SOLVABLE_PROVIDES, relationlist); } -void pakfire_package_add_provides(PakfirePackage pkg, PakfireRelation relation) { +PAKFIRE_EXPORT void pakfire_package_add_provides(PakfirePackage pkg, PakfireRelation relation) { pakfire_package_add_relation(pkg, SOLVABLE_PROVIDES, relation); } -PakfireRelationList pakfire_package_get_prerequires(PakfirePackage pkg) { +PAKFIRE_EXPORT PakfireRelationList pakfire_package_get_prerequires(PakfirePackage pkg) { #warning TODO return NULL; } -PakfireRelationList pakfire_package_get_requires(PakfirePackage pkg) { +PAKFIRE_EXPORT PakfireRelationList pakfire_package_get_requires(PakfirePackage pkg) { return pakfire_package_get_relationlist(pkg, SOLVABLE_REQUIRES); } -void pakfire_package_set_requires(PakfirePackage pkg, PakfireRelationList relationlist) { +PAKFIRE_EXPORT void pakfire_package_set_requires(PakfirePackage pkg, PakfireRelationList relationlist) { pakfire_package_set_relationlist(pkg, SOLVABLE_REQUIRES, relationlist); } -void pakfire_package_add_requires(PakfirePackage pkg, PakfireRelation relation) { +PAKFIRE_EXPORT void pakfire_package_add_requires(PakfirePackage pkg, PakfireRelation relation) { pakfire_package_add_relation(pkg, SOLVABLE_REQUIRES, relation); } -PakfireRelationList pakfire_package_get_conflicts(PakfirePackage pkg) { +PAKFIRE_EXPORT PakfireRelationList pakfire_package_get_conflicts(PakfirePackage pkg) { return pakfire_package_get_relationlist(pkg, SOLVABLE_CONFLICTS); } -void pakfire_package_set_conflicts(PakfirePackage pkg, PakfireRelationList relationlist) { +PAKFIRE_EXPORT void pakfire_package_set_conflicts(PakfirePackage pkg, PakfireRelationList relationlist) { pakfire_package_set_relationlist(pkg, SOLVABLE_CONFLICTS, relationlist); } -void pakfire_package_add_conflicts(PakfirePackage pkg, PakfireRelation relation) { +PAKFIRE_EXPORT void pakfire_package_add_conflicts(PakfirePackage pkg, PakfireRelation relation) { pakfire_package_add_relation(pkg, SOLVABLE_CONFLICTS, relation); } -PakfireRelationList pakfire_package_get_obsoletes(PakfirePackage pkg) { +PAKFIRE_EXPORT PakfireRelationList pakfire_package_get_obsoletes(PakfirePackage pkg) { return pakfire_package_get_relationlist(pkg, SOLVABLE_OBSOLETES); } -void pakfire_package_set_obsoletes(PakfirePackage pkg, PakfireRelationList relationlist) { +PAKFIRE_EXPORT void pakfire_package_set_obsoletes(PakfirePackage pkg, PakfireRelationList relationlist) { pakfire_package_set_relationlist(pkg, SOLVABLE_OBSOLETES, relationlist); } -void pakfire_package_add_obsoletes(PakfirePackage pkg, PakfireRelation relation) { +PAKFIRE_EXPORT void pakfire_package_add_obsoletes(PakfirePackage pkg, PakfireRelation relation) { pakfire_package_add_relation(pkg, SOLVABLE_OBSOLETES, relation); } -PakfireRelationList pakfire_package_get_recommends(PakfirePackage pkg) { +PAKFIRE_EXPORT PakfireRelationList pakfire_package_get_recommends(PakfirePackage pkg) { return pakfire_package_get_relationlist(pkg, SOLVABLE_RECOMMENDS); } -void pakfire_package_set_recommends(PakfirePackage pkg, PakfireRelationList relationlist) { +PAKFIRE_EXPORT void pakfire_package_set_recommends(PakfirePackage pkg, PakfireRelationList relationlist) { pakfire_package_set_relationlist(pkg, SOLVABLE_RECOMMENDS, relationlist); } -void pakfire_package_add_recommends(PakfirePackage pkg, PakfireRelation relation) { +PAKFIRE_EXPORT void pakfire_package_add_recommends(PakfirePackage pkg, PakfireRelation relation) { pakfire_package_add_relation(pkg, SOLVABLE_RECOMMENDS, relation); } -PakfireRelationList pakfire_package_get_suggests(PakfirePackage pkg) { +PAKFIRE_EXPORT PakfireRelationList pakfire_package_get_suggests(PakfirePackage pkg) { return pakfire_package_get_relationlist(pkg, SOLVABLE_SUGGESTS); } -void pakfire_package_set_suggests(PakfirePackage pkg, PakfireRelationList relationlist) { +PAKFIRE_EXPORT void pakfire_package_set_suggests(PakfirePackage pkg, PakfireRelationList relationlist) { pakfire_package_set_relationlist(pkg, SOLVABLE_SUGGESTS, relationlist); } -void pakfire_package_add_suggests(PakfirePackage pkg, PakfireRelation relation) { +PAKFIRE_EXPORT void pakfire_package_add_suggests(PakfirePackage pkg, PakfireRelation relation) { pakfire_package_add_relation(pkg, SOLVABLE_SUGGESTS, relation); } -PakfireRepo pakfire_package_get_repo(PakfirePackage pkg) { +PAKFIRE_EXPORT PakfireRepo pakfire_package_get_repo(PakfirePackage pkg) { Solvable* s = get_solvable(pkg); return pakfire_repo_create_from_repo(pkg->pool, s->repo); } -void pakfire_package_set_repo(PakfirePackage pkg, PakfireRepo repo) { +PAKFIRE_EXPORT void pakfire_package_set_repo(PakfirePackage pkg, PakfireRepo repo) { Solvable* s = get_solvable(pkg); s->repo = pakfire_repo_get_solv_repo(repo); } -char* pakfire_package_get_location(PakfirePackage pkg) { +PAKFIRE_EXPORT char* pakfire_package_get_location(PakfirePackage pkg) { pakfire_package_internalize_repo(pkg); Solvable* s = get_solvable(pkg); @@ -703,7 +704,7 @@ static void pakfire_package_dump_add_line_size(char** str, const char* key, unsi } } -char* pakfire_package_dump(PakfirePackage pkg, int flags) { +PAKFIRE_EXPORT char* pakfire_package_dump(PakfirePackage pkg, int flags) { char* string = ""; // Name @@ -836,7 +837,7 @@ char* pakfire_package_dump(PakfirePackage pkg, int flags) { return string; } -int pakfire_package_is_cached(PakfirePackage pkg) { +PAKFIRE_EXPORT int pakfire_package_is_cached(PakfirePackage pkg) { PakfireCache cache = pakfire_pool_get_cache(pkg->pool); if (!cache) return 1; @@ -844,7 +845,7 @@ int pakfire_package_is_cached(PakfirePackage pkg) { return pakfire_cache_has_package(cache, pkg); } -char* pakfire_package_get_cache_path(PakfirePackage pkg) { +PAKFIRE_EXPORT char* pakfire_package_get_cache_path(PakfirePackage pkg) { PakfireCache cache = pakfire_pool_get_cache(pkg->pool); if (!cache) return NULL; @@ -852,7 +853,7 @@ char* pakfire_package_get_cache_path(PakfirePackage pkg) { return pakfire_cache_get_package_path(cache, pkg); } -char* pakfire_package_get_cache_full_path(PakfirePackage pkg) { +PAKFIRE_EXPORT char* pakfire_package_get_cache_full_path(PakfirePackage pkg) { char* cache_path = NULL; char* pkg_cache_path = pakfire_package_get_cache_path(pkg); @@ -955,7 +956,7 @@ static PakfireFile pakfire_package_fetch_filelist(PakfirePackage pkg) { return file; } -PakfireFile pakfire_package_get_filelist(PakfirePackage pkg) { +PAKFIRE_EXPORT PakfireFile pakfire_package_get_filelist(PakfirePackage pkg) { if (!pkg->filelist) { pkg->filelist = pakfire_package_fetch_filelist(pkg); } @@ -963,7 +964,7 @@ PakfireFile pakfire_package_get_filelist(PakfirePackage pkg) { return pkg->filelist; } -PakfireFile pakfire_package_filelist_append(PakfirePackage pkg, const char* filename) { +PAKFIRE_EXPORT PakfireFile pakfire_package_filelist_append(PakfirePackage pkg, const char* filename) { PakfireRepo repo = pakfire_package_get_repo(pkg); Id handle = pakfire_package_get_handle(pkg); @@ -994,7 +995,7 @@ PakfireFile pakfire_package_filelist_append(PakfirePackage pkg) { } #endif -void pakfire_package_filelist_remove(PakfirePackage pkg) { +PAKFIRE_EXPORT void pakfire_package_filelist_remove(PakfirePackage pkg) { if (pkg->filelist) pakfire_file_free_all(pkg->filelist); } diff --git a/src/libpakfire/packagecache.c b/src/libpakfire/packagecache.c index 14b0616a1..5391147e4 100644 --- a/src/libpakfire/packagecache.c +++ b/src/libpakfire/packagecache.c @@ -23,10 +23,11 @@ #include #include #include +#include #include #include -PakfirePackageCache pakfire_packagecache_create(PakfirePool pool, const char* path) { +PAKFIRE_EXPORT PakfirePackageCache pakfire_packagecache_create(PakfirePool pool, const char* path) { PakfirePackageCache cache = pakfire_calloc(1, sizeof(*cache)); cache->pool = pool; @@ -35,16 +36,16 @@ PakfirePackageCache pakfire_packagecache_create(PakfirePool pool, const char* pa return cache; } -void pakfire_packagecache_free(PakfirePackageCache cache) { +PAKFIRE_EXPORT void pakfire_packagecache_free(PakfirePackageCache cache) { pakfire_free(cache->path); pakfire_free(cache); } -const char* pakfire_packagecache_get_path(PakfirePackageCache cache) { +PAKFIRE_EXPORT const char* pakfire_packagecache_get_path(PakfirePackageCache cache) { return cache->path; } -char* pakfire_packagecache_get_package_path(PakfirePackageCache cache, PakfirePackage pkg) { +PAKFIRE_EXPORT char* pakfire_packagecache_get_package_path(PakfirePackageCache cache, PakfirePackage pkg) { char buffer[STRING_SIZE] = ""; const char* filename = pakfire_package_get_filename(pkg); @@ -59,7 +60,7 @@ char* pakfire_packagecache_get_package_path(PakfirePackageCache cache, PakfirePa return pakfire_strdup(buffer); } -int pakfire_packagecache_has_package(PakfirePackageCache cache, PakfirePackage pkg) { +PAKFIRE_EXPORT int pakfire_packagecache_has_package(PakfirePackageCache cache, PakfirePackage pkg) { char* filename = pakfire_packagecache_get_package_path(cache, pkg); // Check if stat() is successful. diff --git a/src/libpakfire/packagelist.c b/src/libpakfire/packagelist.c index ed6b9c6a1..a604e6787 100644 --- a/src/libpakfire/packagelist.c +++ b/src/libpakfire/packagelist.c @@ -27,18 +27,19 @@ #include #include +#include #include #include #define BLOCK_SIZE 31 -PakfirePackageList pakfire_packagelist_create(void) { +PAKFIRE_EXPORT PakfirePackageList pakfire_packagelist_create(void) { PakfirePackageList list = pakfire_calloc(1, sizeof(*list)); return list; } -void pakfire_packagelist_free(PakfirePackageList list) { +PAKFIRE_EXPORT void pakfire_packagelist_free(PakfirePackageList list) { for (int i = 0; i < list->count; i++) { PakfirePackage pkg = list->elements[i]; pakfire_package_free(pkg); @@ -48,26 +49,26 @@ void pakfire_packagelist_free(PakfirePackageList list) { pakfire_free(list); } -int pakfire_packagelist_count(PakfirePackageList list) { +PAKFIRE_EXPORT int pakfire_packagelist_count(PakfirePackageList list) { return list->count; } -int _packagelist_cmp(const void* pkg1, const void* pkg2) { +PAKFIRE_EXPORT int _packagelist_cmp(const void* pkg1, const void* pkg2) { return pakfire_package_cmp(*(PakfirePackage*)pkg1, *(PakfirePackage*)pkg2); } -void pakfire_packagelist_sort(PakfirePackageList list) { +PAKFIRE_EXPORT void pakfire_packagelist_sort(PakfirePackageList list) { qsort(list->elements, list->count, sizeof(*list->elements), _packagelist_cmp); } -PakfirePackage pakfire_packagelist_get(PakfirePackageList list, int index) { +PAKFIRE_EXPORT PakfirePackage pakfire_packagelist_get(PakfirePackageList list, int index) { if (index < list->count) return list->elements[index]; return NULL; } -int pakfire_packagelist_has(PakfirePackageList list, PakfirePackage pkg) { +PAKFIRE_EXPORT int pakfire_packagelist_has(PakfirePackageList list, PakfirePackage pkg) { for (int i = 0; i < list->count; i++) { PakfirePackage _pkg = list->elements[i]; @@ -78,19 +79,19 @@ int pakfire_packagelist_has(PakfirePackageList list, PakfirePackage pkg) { return 0; } -void pakfire_packagelist_push(PakfirePackageList list, PakfirePackage pkg) { +PAKFIRE_EXPORT void pakfire_packagelist_push(PakfirePackageList list, PakfirePackage pkg) { list->elements = solv_extend(list->elements, list->count, 1, sizeof(pkg), BLOCK_SIZE); list->elements[list->count++] = pkg; } -void pakfire_packagelist_push_if_not_exists(PakfirePackageList list, PakfirePackage pkg) { +PAKFIRE_EXPORT void pakfire_packagelist_push_if_not_exists(PakfirePackageList list, PakfirePackage pkg) { if (pakfire_packagelist_has(list, pkg)) return; pakfire_packagelist_push(list, pkg); } -PakfirePackageList pakfire_packagelist_from_queue(PakfirePool _pool, Queue* q) { +PAKFIRE_EXPORT PakfirePackageList pakfire_packagelist_from_queue(PakfirePool _pool, Queue* q) { PakfirePackageList list = pakfire_packagelist_create(); Pool* pool = _pool->pool; diff --git a/src/libpakfire/pakfire.c b/src/libpakfire/pakfire.c index c23cf0e4f..362c1136d 100644 --- a/src/libpakfire/pakfire.c +++ b/src/libpakfire/pakfire.c @@ -20,18 +20,19 @@ #include #include +#include #include #include #include -int pakfire_init() { +PAKFIRE_EXPORT int pakfire_init() { // Setup logging pakfire_setup_logging(); return 0; } -Pakfire pakfire_create(const char* path, const char* arch) { +PAKFIRE_EXPORT Pakfire pakfire_create(const char* path, const char* arch) { Pakfire pakfire = pakfire_calloc(1, sizeof(*pakfire)); if (pakfire) { pakfire->nrefs = 1; @@ -52,13 +53,13 @@ Pakfire pakfire_create(const char* path, const char* arch) { return pakfire; } -Pakfire pakfire_ref(Pakfire pakfire) { +PAKFIRE_EXPORT Pakfire pakfire_ref(Pakfire pakfire) { ++pakfire->nrefs; return pakfire; } -void pakfire_unref(Pakfire pakfire) { +PAKFIRE_EXPORT void pakfire_unref(Pakfire pakfire) { if (--pakfire->nrefs > 0) return; @@ -71,14 +72,14 @@ void pakfire_unref(Pakfire pakfire) { pakfire_free(pakfire); } -const char* pakfire_get_path(Pakfire pakfire) { +PAKFIRE_EXPORT const char* pakfire_get_path(Pakfire pakfire) { return pakfire->path; } -const char* pakfire_get_arch(Pakfire pakfire) { +PAKFIRE_EXPORT const char* pakfire_get_arch(Pakfire pakfire) { return pakfire->arch; } -PakfirePool pakfire_get_pool(Pakfire pakfire) { +PAKFIRE_EXPORT PakfirePool pakfire_get_pool(Pakfire pakfire) { return pakfire_pool_ref(pakfire->pool); } diff --git a/src/libpakfire/pool.c b/src/libpakfire/pool.c index 6edf8c34d..0b4bf2acf 100644 --- a/src/libpakfire/pool.c +++ b/src/libpakfire/pool.c @@ -31,11 +31,12 @@ #include #include #include +#include #include #include #include -PakfirePool pakfire_pool_create(Pakfire pakfire) { +PAKFIRE_EXPORT PakfirePool pakfire_pool_create(Pakfire pakfire) { PakfirePool pool = pakfire_calloc(1, sizeof(*pool)); if (pool) { pool->nrefs = 1; @@ -74,24 +75,24 @@ static void pakfire_pool_free(PakfirePool pool) { pakfire_free(pool); } -PakfirePool pakfire_pool_ref(PakfirePool pool) { +PAKFIRE_EXPORT PakfirePool pakfire_pool_ref(PakfirePool pool) { ++pool->nrefs; return pool; } -void pakfire_pool_unref(PakfirePool pool) { +PAKFIRE_EXPORT void pakfire_pool_unref(PakfirePool pool) { if (--pool->nrefs > 0) return; pakfire_pool_free(pool); } -int pakfire_pool_version_compare(PakfirePool pool, const char* evr1, const char* evr2) { +PAKFIRE_EXPORT int pakfire_pool_version_compare(PakfirePool pool, const char* evr1, const char* evr2) { return pool_evrcmp_str(pool->pool, evr1, evr2, EVRCMP_COMPARE); } -int pakfire_pool_count(PakfirePool pool) { +PAKFIRE_EXPORT int pakfire_pool_count(PakfirePool pool) { int cnt = 0; for (int i = 2; i < pool->pool->nsolvables; i++) { @@ -103,7 +104,7 @@ int pakfire_pool_count(PakfirePool pool) { return cnt; } -void pakfire_pool_make_provides_ready(PakfirePool pool) { +PAKFIRE_EXPORT void pakfire_pool_make_provides_ready(PakfirePool pool) { if (!pool->provides_ready) { pool_addfileprovides(pool->pool); pool_createwhatprovides(pool->pool); @@ -111,7 +112,7 @@ void pakfire_pool_make_provides_ready(PakfirePool pool) { } } -PakfireRepo pakfire_pool_get_installed_repo(PakfirePool pool) { +PAKFIRE_EXPORT PakfireRepo pakfire_pool_get_installed_repo(PakfirePool pool) { Pool* p = pool->pool; if (!p->installed) @@ -120,7 +121,7 @@ PakfireRepo pakfire_pool_get_installed_repo(PakfirePool pool) { return pakfire_repo_create_from_repo(pool, p->installed); } -void pakfire_pool_set_installed_repo(PakfirePool pool, PakfireRepo repo) { +PAKFIRE_EXPORT void pakfire_pool_set_installed_repo(PakfirePool pool, PakfireRepo repo) { if (!repo) { pool_set_installed(pool->pool, NULL); return; @@ -130,7 +131,7 @@ void pakfire_pool_set_installed_repo(PakfirePool pool, PakfireRepo repo) { pool_set_installed(pool->pool, repo->repo); } -const char** pakfire_pool_get_installonly(PakfirePool pool) { +PAKFIRE_EXPORT const char** pakfire_pool_get_installonly(PakfirePool pool) { Queue q; queue_init_clone(&q, &pool->installonly); @@ -147,7 +148,7 @@ const char** pakfire_pool_get_installonly(PakfirePool pool) { return installonly; } -void pakfire_pool_set_installonly(PakfirePool pool, const char** installonly) { +PAKFIRE_EXPORT void pakfire_pool_set_installonly(PakfirePool pool, const char** installonly) { queue_empty(&pool->installonly); if (installonly == NULL) @@ -158,21 +159,21 @@ void pakfire_pool_set_installonly(PakfirePool pool, const char** installonly) { queue_pushunique(&pool->installonly, pool_str2id(pool->pool, name, 1)); } -const char* pakfire_pool_get_cache_path(PakfirePool pool) { +PAKFIRE_EXPORT const char* pakfire_pool_get_cache_path(PakfirePool pool) { if (!pool->cache) return NULL; return pakfire_cache_get_path(pool->cache); } -void pakfire_pool_set_cache_path(PakfirePool pool, const char* path) { +PAKFIRE_EXPORT void pakfire_pool_set_cache_path(PakfirePool pool, const char* path) { if (pool->cache) pakfire_cache_free(pool->cache); pool->cache = pakfire_cache_create(pool, path); } -PakfireCache pakfire_pool_get_cache(PakfirePool pool) { +PAKFIRE_EXPORT PakfireCache pakfire_pool_get_cache(PakfirePool pool) { if (pool->cache) return pool->cache; @@ -253,7 +254,7 @@ static PakfirePackageList pakfire_pool_search_provides(PakfirePool _pool, const return pakfire_pool_dataiterator(_pool, provides, SOLVABLE_PROVIDES, flags); } -PakfirePackageList pakfire_pool_whatprovides(PakfirePool pool, const char* what, int flags) { +PAKFIRE_EXPORT PakfirePackageList pakfire_pool_whatprovides(PakfirePool pool, const char* what, int flags) { assert((flags & ~(PAKFIRE_ICASE|PAKFIRE_NAME_ONLY|PAKFIRE_GLOB)) == 0); if (flags & PAKFIRE_NAME_ONLY) { @@ -265,11 +266,11 @@ PakfirePackageList pakfire_pool_whatprovides(PakfirePool pool, const char* what, } } -PakfirePackageList pakfire_pool_search(PakfirePool pool, const char* what, int flags) { +PAKFIRE_EXPORT PakfirePackageList pakfire_pool_search(PakfirePool pool, const char* what, int flags) { return pakfire_pool_dataiterator(pool, what, 0, PAKFIRE_SUBSTRING); } -char* pakfire_pool_tmpdup(Pool* pool, const char* s) { +PAKFIRE_EXPORT char* pakfire_pool_tmpdup(Pool* pool, const char* s) { char* dup = pool_alloctmpspace(pool, strlen(s) + 1); return strcpy(dup, s); diff --git a/src/libpakfire/problem.c b/src/libpakfire/problem.c index be1d0557b..7cfec1a05 100644 --- a/src/libpakfire/problem.c +++ b/src/libpakfire/problem.c @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -188,7 +189,7 @@ static char* to_string(PakfireProblem problem) { return pakfire_strdup(s); } -PakfireProblem pakfire_problem_create(PakfireRequest request, Id id) { +PAKFIRE_EXPORT PakfireProblem pakfire_problem_create(PakfireRequest request, Id id) { PakfireProblem problem = pakfire_calloc(1, sizeof(*problem)); problem->request = pakfire_request_ref(request); @@ -204,13 +205,13 @@ PakfireProblem pakfire_problem_create(PakfireRequest request, Id id) { return problem; } -PakfireProblem pakfire_problem_ref(PakfireProblem problem) { +PAKFIRE_EXPORT PakfireProblem pakfire_problem_ref(PakfireProblem problem) { problem->nrefs++; return problem; } -void pakfire_problem_free(PakfireProblem problem) { +PAKFIRE_EXPORT void pakfire_problem_free(PakfireProblem problem) { if (--problem->nrefs > 0) return; @@ -225,11 +226,11 @@ void pakfire_problem_free(PakfireProblem problem) { pakfire_free(problem); } -PakfireProblem pakfire_problem_next(PakfireProblem problem) { +PAKFIRE_EXPORT PakfireProblem pakfire_problem_next(PakfireProblem problem) { return problem->next; } -void pakfire_problem_append(PakfireProblem problem, PakfireProblem new_problem) { +PAKFIRE_EXPORT void pakfire_problem_append(PakfireProblem problem, PakfireProblem new_problem) { PakfireProblem next; // Go to last problem in list @@ -240,11 +241,11 @@ void pakfire_problem_append(PakfireProblem problem, PakfireProblem new_problem) problem->next = pakfire_problem_ref(new_problem); } -const char* pakfire_problem_to_string(PakfireProblem problem) { +PAKFIRE_EXPORT const char* pakfire_problem_to_string(PakfireProblem problem) { return problem->string; } -PakfireSolution pakfire_problem_get_solutions(PakfireProblem problem) { +PAKFIRE_EXPORT PakfireSolution pakfire_problem_get_solutions(PakfireProblem problem) { PakfireSolution ret = NULL; Id solution = 0; diff --git a/src/libpakfire/relation.c b/src/libpakfire/relation.c index e38069201..09c2eeff4 100644 --- a/src/libpakfire/relation.c +++ b/src/libpakfire/relation.c @@ -26,6 +26,7 @@ #include #include +#include #include #include #include @@ -43,7 +44,7 @@ static int cmptype2relflags(int type) { return flags; } -PakfireRelation pakfire_relation_create(PakfirePool pool, const char* name, int cmp_type, const char* evr) { +PAKFIRE_EXPORT PakfireRelation pakfire_relation_create(PakfirePool pool, const char* name, int cmp_type, const char* evr) { Pool* p = pool->pool; Id id = pool_str2id(p, name, 1); @@ -62,7 +63,7 @@ PakfireRelation pakfire_relation_create(PakfirePool pool, const char* name, int return pakfire_relation_create_from_id(pool, id); } -PakfireRelation pakfire_relation_create_from_id(PakfirePool pool, Id id) { +PAKFIRE_EXPORT PakfireRelation pakfire_relation_create_from_id(PakfirePool pool, Id id) { PakfireRelation relation = pakfire_calloc(1, sizeof(*relation)); relation->pool = pool; @@ -71,15 +72,15 @@ PakfireRelation pakfire_relation_create_from_id(PakfirePool pool, Id id) { return relation; } -void pakfire_relation_free(PakfireRelation relation) { +PAKFIRE_EXPORT void pakfire_relation_free(PakfireRelation relation) { pakfire_free(relation); } -Id pakfire_relation_id(PakfireRelation relation) { +PAKFIRE_EXPORT Id pakfire_relation_id(PakfireRelation relation) { return relation->id; } -char* pakfire_relation_str(PakfireRelation relation) { +PAKFIRE_EXPORT char* pakfire_relation_str(PakfireRelation relation) { Pool* pool = pakfire_relation_solv_pool(relation); const char* str = pool_dep2str(pool, relation->id); @@ -87,13 +88,13 @@ char* pakfire_relation_str(PakfireRelation relation) { return pakfire_strdup(str); } -int pakfire_relation2queue(const PakfireRelation relation, Queue* queue, int solver_action) { +PAKFIRE_EXPORT int pakfire_relation2queue(const PakfireRelation relation, Queue* queue, int solver_action) { queue_push2(queue, SOLVER_SOLVABLE_PROVIDES|solver_action, relation->id); return 0; } -PakfirePackageList pakfire_relation_providers(PakfireRelation relation) { +PAKFIRE_EXPORT PakfirePackageList pakfire_relation_providers(PakfireRelation relation) { Queue q; queue_init(&q); diff --git a/src/libpakfire/relationlist.c b/src/libpakfire/relationlist.c index fbf214d9d..278ac394f 100644 --- a/src/libpakfire/relationlist.c +++ b/src/libpakfire/relationlist.c @@ -22,12 +22,13 @@ #include #include +#include #include #include #include #include -PakfireRelationList pakfire_relationlist_create(PakfirePool pool) { +PAKFIRE_EXPORT PakfireRelationList pakfire_relationlist_create(PakfirePool pool) { PakfireRelationList relationlist = pakfire_calloc(1, sizeof(*relationlist)); if (relationlist) { relationlist->pool = pool; @@ -37,20 +38,20 @@ PakfireRelationList pakfire_relationlist_create(PakfirePool pool) { return relationlist; } -void pakfire_relationlist_free(PakfireRelationList relationlist) { +PAKFIRE_EXPORT void pakfire_relationlist_free(PakfireRelationList relationlist) { queue_free(&relationlist->queue); pakfire_free(relationlist); } -void pakfire_relationlist_add(PakfireRelationList relationlist, PakfireRelation relation) { +PAKFIRE_EXPORT void pakfire_relationlist_add(PakfireRelationList relationlist, PakfireRelation relation) { queue_push(&relationlist->queue, relation->id); } -int pakfire_relationlist_count(PakfireRelationList relationlist) { +PAKFIRE_EXPORT int pakfire_relationlist_count(PakfireRelationList relationlist) { return relationlist->queue.count; } -PakfireRelationList pakfire_relationlist_from_queue(PakfirePool pool, Queue q) { +PAKFIRE_EXPORT PakfireRelationList pakfire_relationlist_from_queue(PakfirePool pool, Queue q) { PakfireRelationList relationlist = pakfire_calloc(1, sizeof(*relationlist)); if (relationlist) { relationlist->pool = pool; @@ -60,12 +61,12 @@ PakfireRelationList pakfire_relationlist_from_queue(PakfirePool pool, Queue q) { return relationlist; } -PakfireRelation pakfire_relationlist_get_clone(PakfireRelationList relationlist, int index) { +PAKFIRE_EXPORT PakfireRelation pakfire_relationlist_get_clone(PakfireRelationList relationlist, int index) { Id id = relationlist->queue.elements[index]; return pakfire_relation_create_from_id(relationlist->pool, id); } -void pakfire_relationlist_clone_to_queue(PakfireRelationList relationlist, Queue* q) { +PAKFIRE_EXPORT void pakfire_relationlist_clone_to_queue(PakfireRelationList relationlist, Queue* q) { queue_init_clone(q, &relationlist->queue); } diff --git a/src/libpakfire/repo.c b/src/libpakfire/repo.c index 5d36eddfa..9d4281cbe 100644 --- a/src/libpakfire/repo.c +++ b/src/libpakfire/repo.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -62,7 +63,7 @@ static PakfireRepo get_pakfire_repo_by_name(PakfirePool pool, const char* name) return NULL; } -PakfireRepo pakfire_repo_create(PakfirePool pool, const char* name) { +PAKFIRE_EXPORT PakfireRepo pakfire_repo_create(PakfirePool pool, const char* name) { PakfireRepo repo = get_pakfire_repo_by_name(pool, name); if (repo) { repo->nrefs++; @@ -76,7 +77,7 @@ PakfireRepo pakfire_repo_create(PakfirePool pool, const char* name) { return pakfire_repo_create_from_repo(pool, r); } -PakfireRepo pakfire_repo_create_from_repo(PakfirePool pool, Repo* r) { +PAKFIRE_EXPORT PakfireRepo pakfire_repo_create_from_repo(PakfirePool pool, Repo* r) { PakfireRepo repo; if (r->appdata) { @@ -102,7 +103,7 @@ PakfireRepo pakfire_repo_create_from_repo(PakfirePool pool, Repo* r) { return repo; } -void pakfire_repo_free(PakfireRepo repo) { +PAKFIRE_EXPORT void pakfire_repo_free(PakfireRepo repo) { if (--repo->nrefs > 0) return; @@ -115,18 +116,18 @@ void pakfire_repo_free(PakfireRepo repo) { pakfire_free(repo); } -PakfirePool pakfire_repo_pool(PakfireRepo repo) { +PAKFIRE_EXPORT PakfirePool pakfire_repo_pool(PakfireRepo repo) { return repo->pool; } -int pakfire_repo_identical(PakfireRepo repo1, PakfireRepo repo2) { +PAKFIRE_EXPORT int pakfire_repo_identical(PakfireRepo repo1, PakfireRepo repo2) { Repo* r1 = repo1->repo; Repo* r2 = repo2->repo; return strcmp(r1->name, r2->name); } -int pakfire_repo_cmp(PakfireRepo repo1, PakfireRepo repo2) { +PAKFIRE_EXPORT int pakfire_repo_cmp(PakfireRepo repo1, PakfireRepo repo2) { Repo* r1 = repo1->repo; Repo* r2 = repo2->repo; @@ -139,7 +140,7 @@ int pakfire_repo_cmp(PakfireRepo repo1, PakfireRepo repo2) { return strcmp(r1->name, r2->name); } -int pakfire_repo_count(PakfireRepo repo) { +PAKFIRE_EXPORT int pakfire_repo_count(PakfireRepo repo) { Pool* pool = pakfire_repo_solv_pool(repo); int cnt = 0; @@ -152,38 +153,38 @@ int pakfire_repo_count(PakfireRepo repo) { return cnt; } -void pakfire_repo_internalize(PakfireRepo repo) { +PAKFIRE_EXPORT void pakfire_repo_internalize(PakfireRepo repo) { repo_internalize(repo->repo); } -const char* pakfire_repo_get_name(PakfireRepo repo) { +PAKFIRE_EXPORT const char* pakfire_repo_get_name(PakfireRepo repo) { return repo->repo->name; } -void pakfire_repo_set_name(PakfireRepo repo, const char* name) { +PAKFIRE_EXPORT void pakfire_repo_set_name(PakfireRepo repo, const char* name) { repo->repo->name = pakfire_strdup(name); } -int pakfire_repo_get_enabled(PakfireRepo repo) { +PAKFIRE_EXPORT int pakfire_repo_get_enabled(PakfireRepo repo) { return !repo->repo->disabled; } -void pakfire_repo_set_enabled(PakfireRepo repo, int enabled) { +PAKFIRE_EXPORT void pakfire_repo_set_enabled(PakfireRepo repo, int enabled) { repo->repo->disabled = !enabled; PakfirePool pool = pakfire_repo_pool(repo); pool->provides_ready = 0; } -int pakfire_repo_get_priority(PakfireRepo repo) { +PAKFIRE_EXPORT int pakfire_repo_get_priority(PakfireRepo repo) { return repo->repo->priority; } -void pakfire_repo_set_priority(PakfireRepo repo, int priority) { +PAKFIRE_EXPORT void pakfire_repo_set_priority(PakfireRepo repo, int priority) { repo->repo->priority = priority; } -int pakfire_repo_is_installed_repo(PakfireRepo repo) { +PAKFIRE_EXPORT int pakfire_repo_is_installed_repo(PakfireRepo repo) { PakfirePool pool = pakfire_repo_pool(repo); PakfireRepo installed_repo = pakfire_pool_get_installed_repo(pool); @@ -191,7 +192,7 @@ int pakfire_repo_is_installed_repo(PakfireRepo repo) { return pakfire_repo_identical(repo, installed_repo); } -int pakfire_repo_read_solv(PakfireRepo repo, const char* filename, int flags) { +PAKFIRE_EXPORT int pakfire_repo_read_solv(PakfireRepo repo, const char* filename, int flags) { FILE* f = fopen(filename, "rb"); if (!f) { return PAKFIRE_E_IO; @@ -320,7 +321,7 @@ UNCOMPRESSED: return f; } -int pakfire_repo_read_solv_fp(PakfireRepo repo, FILE *f, int flags) { +PAKFIRE_EXPORT int pakfire_repo_read_solv_fp(PakfireRepo repo, FILE *f, int flags) { f = decompression_proxy(f); int ret = repo_add_solv(repo->repo, f, flags); @@ -355,7 +356,7 @@ int pakfire_repo_read_solv_fp(PakfireRepo repo, FILE *f, int flags) { return ret; } -int pakfire_repo_write_solv(PakfireRepo repo, const char* filename, int flags) { +PAKFIRE_EXPORT int pakfire_repo_write_solv(PakfireRepo repo, const char* filename, int flags) { FILE* f = fopen(filename, "wb"); if (!f) { return PAKFIRE_E_IO; @@ -367,25 +368,25 @@ int pakfire_repo_write_solv(PakfireRepo repo, const char* filename, int flags) { return ret; } -int pakfire_repo_write_solv_fp(PakfireRepo repo, FILE *f, int flags) { +PAKFIRE_EXPORT int pakfire_repo_write_solv_fp(PakfireRepo repo, FILE *f, int flags) { pakfire_repo_internalize(repo); return repo_write(repo->repo, f); } -PakfirePackage pakfire_repo_add_package(PakfireRepo repo) { +PAKFIRE_EXPORT PakfirePackage pakfire_repo_add_package(PakfireRepo repo) { Id id = repo_add_solvable(repo->repo); return pakfire_package_create(repo->pool, id); } -PakfireRepoCache pakfire_repo_get_cache(PakfireRepo repo) { +PAKFIRE_EXPORT PakfireRepoCache pakfire_repo_get_cache(PakfireRepo repo) { assert(repo); return repo->cache; } -int pakfire_repo_clean(PakfireRepo repo) { +PAKFIRE_EXPORT int pakfire_repo_clean(PakfireRepo repo) { PakfireRepoCache cache = pakfire_repo_get_cache(repo); if (cache) diff --git a/src/libpakfire/repocache.c b/src/libpakfire/repocache.c index 95865b6cf..5795a443d 100644 --- a/src/libpakfire/repocache.c +++ b/src/libpakfire/repocache.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -40,7 +41,7 @@ static char* pakfire_repocache_prefix(PakfireRepoCache repo_cache) { return pakfire_strdup(buffer); } -PakfireRepoCache pakfire_repocache_create(PakfireRepo repo) { +PAKFIRE_EXPORT PakfireRepoCache pakfire_repocache_create(PakfireRepo repo) { PakfireRepoCache repo_cache = pakfire_calloc(1, sizeof(*repo_cache)); repo_cache->repo = repo; @@ -49,16 +50,16 @@ PakfireRepoCache pakfire_repocache_create(PakfireRepo repo) { return repo_cache; } -void pakfire_repocache_free(PakfireRepoCache repo_cache) { +PAKFIRE_EXPORT void pakfire_repocache_free(PakfireRepoCache repo_cache) { pakfire_free(repo_cache->prefix); pakfire_free(repo_cache); } -char* pakfire_repocache_get_cache_path(PakfireRepoCache repo_cache, const char* path) { +PAKFIRE_EXPORT char* pakfire_repocache_get_cache_path(PakfireRepoCache repo_cache, const char* path) { return pakfire_path_join(repo_cache->prefix, path); } -char* pakfire_repocache_get_full_path(PakfireRepoCache repo_cache, const char* path) { +PAKFIRE_EXPORT char* pakfire_repocache_get_full_path(PakfireRepoCache repo_cache, const char* path) { char* cache_path = pakfire_repocache_get_cache_path(repo_cache, path); PakfireCache cache = pakfire_repocache_cache(repo_cache); @@ -69,7 +70,7 @@ char* pakfire_repocache_get_full_path(PakfireRepoCache repo_cache, const char* p return full_path; } -int pakfire_repocache_has_file(PakfireRepoCache repo_cache, const char* filename) { +PAKFIRE_EXPORT int pakfire_repocache_has_file(PakfireRepoCache repo_cache, const char* filename) { char* cache_filename = pakfire_repocache_get_cache_path(repo_cache, filename); PakfireCache cache = pakfire_repocache_cache(repo_cache); @@ -79,7 +80,7 @@ int pakfire_repocache_has_file(PakfireRepoCache repo_cache, const char* filename return r; } -int pakfire_repocache_age(PakfireRepoCache repo_cache, const char* filename) { +PAKFIRE_EXPORT int pakfire_repocache_age(PakfireRepoCache repo_cache, const char* filename) { char* cache_filename = pakfire_repocache_get_cache_path(repo_cache, filename); PakfireCache cache = pakfire_repocache_cache(repo_cache); @@ -89,7 +90,7 @@ int pakfire_repocache_age(PakfireRepoCache repo_cache, const char* filename) { return age; } -FILE* pakfire_repocache_open(PakfireRepoCache repo_cache, const char* filename, const char* flags) { +PAKFIRE_EXPORT FILE* pakfire_repocache_open(PakfireRepoCache repo_cache, const char* filename, const char* flags) { char* cache_filename = pakfire_repocache_get_cache_path(repo_cache, filename); PakfireCache cache = pakfire_repocache_cache(repo_cache); @@ -103,7 +104,7 @@ static int _unlink(const char* path, const struct stat* stat, int typeflag, stru return remove(path); } -int pakfire_repocache_destroy(PakfireRepoCache repo_cache) { +PAKFIRE_EXPORT int pakfire_repocache_destroy(PakfireRepoCache repo_cache) { // Completely delete the tree of files return nftw(repo_cache->prefix, _unlink, 64, FTW_DEPTH|FTW_PHYS); } diff --git a/src/libpakfire/request.c b/src/libpakfire/request.c index f43211983..c87878c36 100644 --- a/src/libpakfire/request.c +++ b/src/libpakfire/request.c @@ -27,6 +27,7 @@ #endif #include +#include #include #include #include @@ -34,7 +35,7 @@ #include #include -PakfireRequest pakfire_request_create(PakfirePool pool) { +PAKFIRE_EXPORT PakfireRequest pakfire_request_create(PakfirePool pool) { PakfireRequest request = pakfire_calloc(1, sizeof(*request)); request->pool = pool; @@ -46,13 +47,13 @@ PakfireRequest pakfire_request_create(PakfirePool pool) { return request; } -PakfireRequest pakfire_request_ref(PakfireRequest request) { +PAKFIRE_EXPORT PakfireRequest pakfire_request_ref(PakfireRequest request) { request->nrefs++; return request; } -void pakfire_request_free(PakfireRequest request) { +PAKFIRE_EXPORT void pakfire_request_free(PakfireRequest request) { if (--request->nrefs > 0) return; @@ -67,7 +68,7 @@ void pakfire_request_free(PakfireRequest request) { pakfire_free(request); } -PakfirePool pakfire_request_pool(PakfireRequest request) { +PAKFIRE_EXPORT PakfirePool pakfire_request_pool(PakfireRequest request) { return request->pool; } @@ -128,7 +129,7 @@ static int solve(PakfireRequest request, Queue* queue) { return 0; } -int pakfire_request_solve(PakfireRequest request, int flags) { +PAKFIRE_EXPORT int pakfire_request_solve(PakfireRequest request, int flags) { init_solver(request, flags); Queue queue; @@ -156,7 +157,7 @@ int pakfire_request_solve(PakfireRequest request, int flags) { return ret; } -PakfireProblem pakfire_request_get_problems(PakfireRequest request) { +PAKFIRE_EXPORT PakfireProblem pakfire_request_get_problems(PakfireRequest request) { Id problem = 0; PakfireProblem ret = NULL; @@ -172,24 +173,24 @@ PakfireProblem pakfire_request_get_problems(PakfireRequest request) { return ret; } -PakfireTransaction pakfire_request_get_transaction(PakfireRequest request) { +PAKFIRE_EXPORT PakfireTransaction pakfire_request_get_transaction(PakfireRequest request) { if (!request->transaction) return NULL; return pakfire_transaction_create(request->pool, request->transaction); } -int pakfire_request_install(PakfireRequest request, PakfirePackage package) { +PAKFIRE_EXPORT int pakfire_request_install(PakfireRequest request, PakfirePackage package) { queue_push2(&request->queue, SOLVER_SOLVABLE|SOLVER_INSTALL, pakfire_package_id(package)); return 0; } -int pakfire_request_install_relation(PakfireRequest request, PakfireRelation relation) { +PAKFIRE_EXPORT int pakfire_request_install_relation(PakfireRequest request, PakfireRelation relation) { return pakfire_relation2queue(relation, &request->queue, SOLVER_INSTALL); } -int pakfire_request_install_selector(PakfireRequest request, PakfireSelector selector) { +PAKFIRE_EXPORT int pakfire_request_install_selector(PakfireRequest request, PakfireSelector selector) { return pakfire_selector2queue(selector, &request->queue, SOLVER_INSTALL); } @@ -202,64 +203,64 @@ static int erase_flags(int flags) { return additional; } -int pakfire_request_erase(PakfireRequest request, PakfirePackage package, int flags) { +PAKFIRE_EXPORT int pakfire_request_erase(PakfireRequest request, PakfirePackage package, int flags) { int additional = erase_flags(flags); queue_push2(&request->queue, SOLVER_SOLVABLE|SOLVER_ERASE|additional, pakfire_package_id(package)); return 0; } -int pakfire_request_erase_relation(PakfireRequest request, PakfireRelation relation, int flags) { +PAKFIRE_EXPORT int pakfire_request_erase_relation(PakfireRequest request, PakfireRelation relation, int flags) { int additional = erase_flags(flags); return pakfire_relation2queue(relation, &request->queue, SOLVER_ERASE|additional); } -int pakfire_request_erase_selector(PakfireRequest request, PakfireSelector selector, int flags) { +PAKFIRE_EXPORT int pakfire_request_erase_selector(PakfireRequest request, PakfireSelector selector, int flags) { int additional = erase_flags(flags); return pakfire_selector2queue(selector, &request->queue, SOLVER_ERASE|additional); } -int pakfire_request_upgrade(PakfireRequest request, PakfirePackage package) { +PAKFIRE_EXPORT int pakfire_request_upgrade(PakfireRequest request, PakfirePackage package) { return pakfire_request_install(request, package); } -int pakfire_request_upgrade_relation(PakfireRequest request, PakfireRelation relation) { +PAKFIRE_EXPORT int pakfire_request_upgrade_relation(PakfireRequest request, PakfireRelation relation) { return pakfire_relation2queue(relation, &request->queue, SOLVER_UPDATE); } -int pakfire_request_upgrade_selector(PakfireRequest request, PakfireSelector selector) { +PAKFIRE_EXPORT int pakfire_request_upgrade_selector(PakfireRequest request, PakfireSelector selector) { return pakfire_selector2queue(selector, &request->queue, SOLVER_UPDATE); } -int pakfire_request_upgrade_all(PakfireRequest request) { +PAKFIRE_EXPORT int pakfire_request_upgrade_all(PakfireRequest request) { queue_push2(&request->queue, SOLVER_UPDATE|SOLVER_SOLVABLE_ALL, 0); return 0; } -int pakfire_request_distupgrade(PakfireRequest request) { +PAKFIRE_EXPORT int pakfire_request_distupgrade(PakfireRequest request) { queue_push2(&request->queue, SOLVER_DISTUPGRADE|SOLVER_SOLVABLE_ALL, 0); return 0; } -int pakfire_request_lock(PakfireRequest request, PakfirePackage package) { +PAKFIRE_EXPORT int pakfire_request_lock(PakfireRequest request, PakfirePackage package) { queue_push2(&request->queue, SOLVER_SOLVABLE|SOLVER_LOCK, pakfire_package_id(package)); return 0; } -int pakfire_request_lock_relation(PakfireRequest request, PakfireRelation relation) { +PAKFIRE_EXPORT int pakfire_request_lock_relation(PakfireRequest request, PakfireRelation relation) { return pakfire_relation2queue(relation, &request->queue, SOLVER_LOCK); } -int pakfire_request_lock_selector(PakfireRequest request, PakfireSelector selector) { +PAKFIRE_EXPORT int pakfire_request_lock_selector(PakfireRequest request, PakfireSelector selector) { return pakfire_selector2queue(selector, &request->queue, SOLVER_LOCK); } -int pakfire_request_verify(PakfireRequest request) { +PAKFIRE_EXPORT int pakfire_request_verify(PakfireRequest request) { queue_push2(&request->queue, SOLVER_VERIFY|SOLVER_SOLVABLE_ALL, 0); return 0; diff --git a/src/libpakfire/selector.c b/src/libpakfire/selector.c index a2b0ff759..f0120c64f 100644 --- a/src/libpakfire/selector.c +++ b/src/libpakfire/selector.c @@ -29,11 +29,12 @@ #include #include #include +#include #include #include #include -PakfireSelector pakfire_selector_create(PakfirePool pool) { +PAKFIRE_EXPORT PakfireSelector pakfire_selector_create(PakfirePool pool) { PakfireSelector selector = pakfire_calloc(1, sizeof(*selector)); selector->pool = pool; @@ -45,7 +46,7 @@ PakfireSelector pakfire_selector_create(PakfirePool pool) { return selector; } -void pakfire_selector_free(PakfireSelector selector) { +PAKFIRE_EXPORT void pakfire_selector_free(PakfireSelector selector) { pakfire_free(selector); } @@ -78,7 +79,7 @@ static void pakfire_selector_replace_filter(PakfireFilter* filter, int keyname, *filter = f; } -int pakfire_selector_set(PakfireSelector selector, int keyname, int cmp_type, const char* match) { +PAKFIRE_EXPORT int pakfire_selector_set(PakfireSelector selector, int keyname, int cmp_type, const char* match) { if (!pakfire_selector_valid_setting(keyname, cmp_type)) return PAKFIRE_E_SELECTOR; @@ -119,7 +120,7 @@ int pakfire_selector_set(PakfireSelector selector, int keyname, int cmp_type, co return 0; } -PakfirePackageList pakfire_selector_providers(PakfireSelector selector) { +PAKFIRE_EXPORT PakfirePackageList pakfire_selector_providers(PakfireSelector selector) { Queue q; queue_init(&q); @@ -257,7 +258,7 @@ static int filter_provides2queue(PakfirePool pool, const PakfireFilter f, Queue* return 0; } -int pakfire_selector2queue(const PakfireSelector selector, Queue* queue, int solver_action) { +PAKFIRE_EXPORT int pakfire_selector2queue(const PakfireSelector selector, Queue* queue, int solver_action) { PakfirePool pool = selector->pool; int ret = 0; diff --git a/src/libpakfire/solution.c b/src/libpakfire/solution.c index fbbc41424..269dfd137 100644 --- a/src/libpakfire/solution.c +++ b/src/libpakfire/solution.c @@ -24,6 +24,7 @@ #include #include +#include #include #include #include @@ -102,7 +103,7 @@ static void import_elements(PakfireSolution solution) { *elements = NULL; } -PakfireSolution pakfire_solution_create(PakfireProblem problem, Id id) { +PAKFIRE_EXPORT PakfireSolution pakfire_solution_create(PakfireProblem problem, Id id) { PakfireSolution solution = pakfire_calloc(1, sizeof(*solution)); solution->problem = pakfire_problem_ref(problem); @@ -118,13 +119,13 @@ PakfireSolution pakfire_solution_create(PakfireProblem problem, Id id) { return solution; } -PakfireSolution pakfire_solution_ref(PakfireSolution solution) { +PAKFIRE_EXPORT PakfireSolution pakfire_solution_ref(PakfireSolution solution) { solution->nrefs++; return solution; } -void pakfire_solution_free(PakfireSolution solution) { +PAKFIRE_EXPORT void pakfire_solution_free(PakfireSolution solution) { if (--solution->nrefs > 0) return; @@ -140,11 +141,11 @@ void pakfire_solution_free(PakfireSolution solution) { pakfire_free(solution); } -PakfireSolution pakfire_solution_next(PakfireSolution solution) { +PAKFIRE_EXPORT PakfireSolution pakfire_solution_next(PakfireSolution solution) { return solution->next; } -void pakfire_solution_append(PakfireSolution solution, PakfireSolution new_solution) { +PAKFIRE_EXPORT void pakfire_solution_append(PakfireSolution solution, PakfireSolution new_solution) { PakfireSolution next; // Go to last problem in list @@ -166,7 +167,7 @@ static size_t count_elements_length(PakfireSolution solution) { return length; } -char* pakfire_solution_to_string(PakfireSolution solution) { +PAKFIRE_EXPORT char* pakfire_solution_to_string(PakfireSolution solution) { // Determine length of output string size_t length = count_elements_length(solution); diff --git a/src/libpakfire/step.c b/src/libpakfire/step.c index 452b5d95a..dfd1388b0 100644 --- a/src/libpakfire/step.c +++ b/src/libpakfire/step.c @@ -26,13 +26,14 @@ #include #include #include +#include #include #include #include #include #include -PakfireStep pakfire_step_create(PakfireTransaction transaction, Id id) { +PAKFIRE_EXPORT PakfireStep pakfire_step_create(PakfireTransaction transaction, Id id) { PakfireStep step = pakfire_calloc(1, sizeof(*step)); step->pool = pakfire_transaction_pool(transaction); @@ -42,15 +43,15 @@ PakfireStep pakfire_step_create(PakfireTransaction transaction, Id id) { return step; } -void pakfire_step_free(PakfireStep step) { +PAKFIRE_EXPORT void pakfire_step_free(PakfireStep step) { pakfire_free(step); } -PakfirePackage pakfire_step_get_package(PakfireStep step) { +PAKFIRE_EXPORT PakfirePackage pakfire_step_get_package(PakfireStep step) { return pakfire_package_create(step->pool, step->id); } -pakfire_step_type pakfire_step_get_type(PakfireStep step) { +PAKFIRE_EXPORT pakfire_step_type pakfire_step_get_type(PakfireStep step) { Transaction* trans = step->transaction->transaction; int type = transaction_type(trans, step->id, @@ -87,7 +88,7 @@ pakfire_step_type pakfire_step_get_type(PakfireStep step) { } } -const char* pakfire_step_get_type_string(PakfireStep step) { +PAKFIRE_EXPORT const char* pakfire_step_get_type_string(PakfireStep step) { pakfire_step_type type = pakfire_step_get_type(step); switch(type) { @@ -132,7 +133,7 @@ static int pakfire_step_get_downloadtype(PakfireStep step) { return 0; } -unsigned long long pakfire_step_get_downloadsize(PakfireStep step) { +PAKFIRE_EXPORT unsigned long long pakfire_step_get_downloadsize(PakfireStep step) { PakfirePackage pkg = NULL; int downloadsize = 0; @@ -147,7 +148,7 @@ unsigned long long pakfire_step_get_downloadsize(PakfireStep step) { return downloadsize; } -long pakfire_step_get_installsizechange(PakfireStep step) { +PAKFIRE_EXPORT long pakfire_step_get_installsizechange(PakfireStep step) { PakfirePackage pkg = pakfire_step_get_package(step); int installsize = pakfire_package_get_installsize(pkg); @@ -168,7 +169,7 @@ long pakfire_step_get_installsizechange(PakfireStep step) { return installsize; } -int pakfire_step_needs_download(PakfireStep step) { +PAKFIRE_EXPORT int pakfire_step_needs_download(PakfireStep step) { PakfirePackage pkg = NULL; int ret = true; @@ -220,7 +221,7 @@ static int pakfire_step_erase(PakfireStep step) { return 0; // TODO } -int pakfire_step_run(PakfireStep step, const pakfire_action_type action) { +PAKFIRE_EXPORT int pakfire_step_run(PakfireStep step, const pakfire_action_type action) { pakfire_step_type type = pakfire_step_get_type(step); // Get the package diff --git a/src/libpakfire/transaction.c b/src/libpakfire/transaction.c index 8074fe03e..c3767a05e 100644 --- a/src/libpakfire/transaction.c +++ b/src/libpakfire/transaction.c @@ -24,13 +24,14 @@ #include #include #include +#include #include #include #include #include #include -PakfireTransaction pakfire_transaction_create(PakfirePool pool, Transaction* trans) { +PAKFIRE_EXPORT PakfireTransaction pakfire_transaction_create(PakfirePool pool, Transaction* trans) { PakfireTransaction transaction = pakfire_calloc(1, sizeof(*transaction)); transaction->pool = pool; @@ -45,23 +46,23 @@ PakfireTransaction pakfire_transaction_create(PakfirePool pool, Transaction* tra return transaction; } -void pakfire_transaction_free(PakfireTransaction transaction) { +PAKFIRE_EXPORT void pakfire_transaction_free(PakfireTransaction transaction) { transaction_free(transaction->transaction); pakfire_free(transaction); } -size_t pakfire_transaction_count(PakfireTransaction transaction) { +PAKFIRE_EXPORT size_t pakfire_transaction_count(PakfireTransaction transaction) { return transaction->transaction->steps.count; } -ssize_t pakfire_transaction_installsizechange(PakfireTransaction transaction) { +PAKFIRE_EXPORT ssize_t pakfire_transaction_installsizechange(PakfireTransaction transaction) { ssize_t sizechange = transaction_calc_installsizechange(transaction->transaction); // Convert from kbytes to bytes return sizechange * 1024; } -ssize_t pakfire_transaction_downloadsize(PakfireTransaction transaction) { +PAKFIRE_EXPORT ssize_t pakfire_transaction_downloadsize(PakfireTransaction transaction) { PakfirePool pool = pakfire_transaction_pool(transaction); ssize_t size = 0; @@ -89,7 +90,7 @@ ssize_t pakfire_transaction_downloadsize(PakfireTransaction transaction) { return size; } -PakfireStep pakfire_transaction_get_step(PakfireTransaction transaction, int index) { +PAKFIRE_EXPORT PakfireStep pakfire_transaction_get_step(PakfireTransaction transaction, int index) { Transaction* trans = transaction->transaction; if (index >= trans->steps.count) @@ -98,7 +99,7 @@ PakfireStep pakfire_transaction_get_step(PakfireTransaction transaction, int ind return pakfire_step_create(transaction, trans->steps.elements[index]); } -PakfirePackageList pakfire_transaction_get_packages(PakfireTransaction transaction, int type) { +PAKFIRE_EXPORT PakfirePackageList pakfire_transaction_get_packages(PakfireTransaction transaction, int type) { PakfirePool pool = pakfire_transaction_pool(transaction); PakfirePackageList packagelist = pakfire_packagelist_create(); @@ -205,7 +206,7 @@ static void pakfire_transaction_add_usage_line(char** str, size_t width, const c pakfire_free(s); } -char* pakfire_transaction_dump(PakfireTransaction transaction, size_t width) { +PAKFIRE_EXPORT char* pakfire_transaction_dump(PakfireTransaction transaction, size_t width) { char* string = ""; // Header @@ -287,7 +288,7 @@ static int pakfire_transaction_run_steps(PakfireTransaction transaction, const p return r; } -int pakfire_transaction_run(PakfireTransaction transaction) { +PAKFIRE_EXPORT int pakfire_transaction_run(PakfireTransaction transaction) { int r = 0; // Verify steps diff --git a/src/libpakfire/util.c b/src/libpakfire/util.c index ed783e825..6f373ebb0 100644 --- a/src/libpakfire/util.c +++ b/src/libpakfire/util.c @@ -34,6 +34,7 @@ #include #include +#include void pakfire_oom(size_t num, size_t len) { if (num) @@ -75,7 +76,7 @@ void* pakfire_realloc(void* ptr, size_t size) { return ptr; } -void* pakfire_free(void* mem) { +PAKFIRE_EXPORT void* pakfire_free(void* mem) { if (mem) free(mem); @@ -124,7 +125,7 @@ char* pakfire_format_date(time_t t) { return pakfire_strftime("%Y-%m-%d", t); } -char* pakfire_path_join(const char* first, const char* second) { +PAKFIRE_EXPORT char* pakfire_path_join(const char* first, const char* second) { char* buffer; if (!second) @@ -150,7 +151,7 @@ char* pakfire_dirname(const char* path) { return dirname(parent); } -int pakfire_access(const char* dir, const char* file, int mode) { +PAKFIRE_EXPORT int pakfire_access(const char* dir, const char* file, int mode) { char* path = pakfire_path_join(dir, file); int r = access(path, mode); -- 2.39.5