The goal is to split execute.c into a more flexible API.
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/execute.c \
src/libpakfire/file.c \
src/libpakfire/filelist.c \
+ src/libpakfire/jail.c \
src/libpakfire/key.c \
src/libpakfire/keystore.c \
src/libpakfire/logging.c \
src/libpakfire/include/pakfire/file.h \
src/libpakfire/include/pakfire/filelist.h \
src/libpakfire/include/pakfire/i18n.h \
+ src/libpakfire/include/pakfire/jail.h \
src/libpakfire/include/pakfire/key.h \
src/libpakfire/include/pakfire/keystore.h \
src/libpakfire/include/pakfire/logging.h \
--- /dev/null
+/*#############################################################################
+# #
+# Pakfire - The IPFire package management system #
+# Copyright (C) 2022 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_JAIL_H
+#define PAKFIRE_JAIL_H
+
+#ifdef PAKFIRE_PRIVATE
+
+#include <pakfire/pakfire.h>
+
+struct pakfire_jail;
+
+int pakfire_jail_create(struct pakfire_jail** jail, struct pakfire* pakfire);
+
+struct pakfire_jail* pakfire_jail_ref(struct pakfire_jail* jail);
+struct pakfire_jail* pakfire_jail_unref(struct pakfire_jail* jail);
+
+#endif
+
+#endif /* PAKFIRE_JAIL_H */
--- /dev/null
+/*#############################################################################
+# #
+# Pakfire - The IPFire package management system #
+# Copyright (C) 2022 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 <pakfire/jail.h>
+#include <pakfire/pakfire.h>
+
+struct pakfire_jail {
+ struct pakfire* pakfire;
+ int nrefs;
+};
+
+int pakfire_jail_create(struct pakfire_jail** jail, struct pakfire* pakfire) {
+ struct pakfire_jail* j = calloc(1, sizeof(*j));
+ if (!j)
+ return 1;
+
+ // Reference Pakfire
+ j->pakfire = pakfire_ref(pakfire);
+
+ // Initialize reference counter
+ j->nrefs = 1;
+
+ // Done
+ *jail = j;
+ return 0;
+}
+
+static void pakfire_jail_free(struct pakfire_jail* jail) {
+ pakfire_unref(jail->pakfire);
+ free(jail);
+}
+
+struct pakfire_jail* pakfire_jail_ref(struct pakfire_jail* jail) {
+ ++jail->nrefs;
+
+ return jail;
+}
+
+struct pakfire_jail* pakfire_jail_unref(struct pakfire_jail* jail) {
+ if (--jail->nrefs > 0)
+ return jail;
+
+ pakfire_jail_free(jail);
+ return NULL;
+}