src/libpakfire/key.c \
src/libpakfire/logging.c \
src/libpakfire/package.c \
+ src/libpakfire/packager.c \
src/libpakfire/packagelist.c \
src/libpakfire/pakfire.c \
src/libpakfire/parser.c \
src/libpakfire/include/pakfire/key.h \
src/libpakfire/include/pakfire/logging.h \
src/libpakfire/include/pakfire/package.h \
+ src/libpakfire/include/pakfire/packager.h \
src/libpakfire/include/pakfire/packagelist.h \
src/libpakfire/include/pakfire/pakfire.h \
src/libpakfire/include/pakfire/parser.h \
--- /dev/null
+/*#############################################################################
+# #
+# Pakfire - The IPFire package management system #
+# Copyright (C) 2021 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 <http://www.gnu.org/licenses/>. #
+# #
+#############################################################################*/
+
+#ifndef PAKFIRE_PACKAGER_H
+#define PAKFIRE_PACKAGER_H
+
+#include <pakfire/types.h>
+
+struct pakfire_packager;
+
+int pakfire_packager_create(struct pakfire_packager** packager, PakfirePackage pkg);
+
+struct pakfire_packager* pakfire_packager_ref(struct pakfire_packager* packager);
+struct pakfire_packager* pakfire_packager_unref(struct pakfire_packager* packager);
+
+#endif /* PAKFIRE_PACKAGER_H */
pakfire_packagelist_sort;
pakfire_packagelist_unref;
+ # packager
+
+ pakfire_packager_create;
+ pakfire_packager_ref;
+ pakfire_packager_unref;
+
# parser
pakfire_parser_append;
pakfire_parser_create;
--- /dev/null
+/*#############################################################################
+# #
+# Pakfire - The IPFire package management system #
+# Copyright (C) 2021 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 <http://www.gnu.org/licenses/>. #
+# #
+#############################################################################*/
+
+#include <errno.h>
+#include <stdlib.h>
+
+#include <pakfire/package.h>
+#include <pakfire/packager.h>
+#include <pakfire/pakfire.h>
+#include <pakfire/private.h>
+#include <pakfire/types.h>
+
+struct pakfire_packager {
+ Pakfire pakfire;
+ int nrefs;
+
+ PakfirePackage pkg;
+};
+
+PAKFIRE_EXPORT int pakfire_packager_create(struct pakfire_packager** packager,
+ PakfirePackage pkg) {
+ struct pakfire_packager* p = calloc(1, sizeof(*p));
+ if (!p)
+ return ENOMEM;
+
+ // Initialize reference counting
+ p->nrefs = 1;
+
+ // Store a reference to Pakfire
+ p->pakfire = pakfire_package_get_pakfire(pkg);
+
+ // Store a reference to the package
+ p->pkg = pakfire_package_ref(pkg);
+
+ *packager = p;
+
+ return 0;
+}
+
+static void pakfire_packager_free(struct pakfire_packager* packager) {
+ pakfire_package_unref(packager->pkg);
+ pakfire_unref(packager->pakfire);
+}
+
+PAKFIRE_EXPORT struct pakfire_packager* pakfire_packager_ref(
+ struct pakfire_packager* packager) {
+ ++packager->nrefs;
+
+ return packager;
+}
+
+PAKFIRE_EXPORT struct pakfire_packager* pakfire_packager_unref(
+ struct pakfire_packager* packager) {
+ if (--packager->nrefs > 0)
+ return packager;
+
+ pakfire_packager_free(packager);
+
+ return NULL;
+}