src/libpakfire/cgroup.c \
src/libpakfire/compress.c \
src/libpakfire/config.c \
+ src/libpakfire/ctx.c \
src/libpakfire/db.c \
src/libpakfire/dependencies.c \
src/libpakfire/digest.c \
src/libpakfire/include/pakfire/compress.h \
src/libpakfire/include/pakfire/config.h \
src/libpakfire/include/pakfire/constants.h \
+ src/libpakfire/include/pakfire/ctx.h \
src/libpakfire/include/pakfire/db.h \
src/libpakfire/include/pakfire/dependencies.h \
src/libpakfire/include/pakfire/digest.h \
--- /dev/null
+/*#############################################################################
+# #
+# Pakfire - The IPFire package management system #
+# Copyright (C) 2023 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/ctx.h>
+#include <pakfire/private.h>
+
+struct pakfire_ctx {
+ // Reference counter
+ int nrefs;
+};
+
+static void pakfire_ctx_free(struct pakfire_ctx* ctx) {
+ free(ctx);
+}
+
+PAKFIRE_EXPORT int pakfire_ctx_create(struct pakfire_ctx** ctx) {
+ struct pakfire_ctx* c = NULL;
+
+ // Allocate the context
+ c = calloc(1, sizeof(*c));
+ if (!c)
+ return -errno;
+
+ // Initialize the reference counter
+ c->nrefs = 1;
+
+ // Return the pointer
+ *ctx = c;
+
+ return 0;
+}
+
+PAKFIRE_EXPORT struct pakfire_ctx* pakfire_ctx_ref(struct pakfire_ctx* ctx) {
+ ctx->nrefs++;
+
+ return ctx;
+}
+
+PAKFIRE_EXPORT struct pakfire_ctx* pakfire_ctx_unref(struct pakfire_ctx* ctx) {
+ if (--ctx->nrefs > 0)
+ return ctx;
+
+ pakfire_ctx_free(ctx);
+ return NULL;
+}
--- /dev/null
+/*#############################################################################
+# #
+# Pakfire - The IPFire package management system #
+# Copyright (C) 2023 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_CTX_H
+#define PAKFIRE_CTX_H
+
+struct pakfire_ctx;
+
+int pakfire_ctx_create(struct pakfire_ctx** ctx);
+
+struct pakfire_ctx* pakfire_ctx_ref(struct pakfire_ctx* ctx);
+struct pakfire_ctx* pakfire_ctx_unref(struct pakfire_ctx* ctx);
+
+#endif /* PAKFIRE_CTX_H */
LIBPAKFIRE_0 {
global:
+ # pakfire ctx
+ pakfire_ctx_create;
+ pakfire_ctx_ref;
+ pakfire_ctx_unref;
+
# pakfire
pakfire_check;
pakfire_clean;