From: Michael Tremer Date: Tue, 17 Oct 2023 09:43:54 +0000 (+0000) Subject: libpakfire: Add scaffolding for connecting to the build service X-Git-Tag: 0.9.30~1468 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=931d97a00dd84ad3926585e18a2dc4685e8ce1bc;p=pakfire.git libpakfire: Add scaffolding for connecting to the build service Signed-off-by: Michael Tremer --- diff --git a/Makefile.am b/Makefile.am index 78f414af7..2a37a6635 100644 --- a/Makefile.am +++ b/Makefile.am @@ -214,6 +214,7 @@ libpakfire_la_SOURCES = \ src/libpakfire/arch.c \ src/libpakfire/archive.c \ src/libpakfire/build.c \ + src/libpakfire/buildservice.c \ src/libpakfire/cgroup.c \ src/libpakfire/compress.c \ src/libpakfire/config.c \ @@ -255,6 +256,7 @@ pkginclude_HEADERS += \ src/libpakfire/include/pakfire/arch.h \ src/libpakfire/include/pakfire/archive.h \ src/libpakfire/include/pakfire/build.h \ + src/libpakfire/include/pakfire/buildservice.h \ src/libpakfire/include/pakfire/cgroup.h \ src/libpakfire/include/pakfire/compress.h \ src/libpakfire/include/pakfire/config.h \ diff --git a/src/libpakfire/buildservice.c b/src/libpakfire/buildservice.c new file mode 100644 index 000000000..a26076ee7 --- /dev/null +++ b/src/libpakfire/buildservice.c @@ -0,0 +1,75 @@ +/*############################################################################# +# # +# 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 . # +# # +#############################################################################*/ + +#include +#include + +#include +#include +#include + +struct pakfire_buildservice { + struct pakfire_ctx* ctx; + int nrefs; +}; + +static void pakfire_buildservice_free(struct pakfire_buildservice* service) { + if (service->ctx) + pakfire_ctx_unref(service->ctx); + + free(service); +} + +PAKFIRE_EXPORT int pakfire_buildservice_create( + struct pakfire_buildservice** service, struct pakfire_ctx* ctx) { + struct pakfire_buildservice* s = NULL; + + // Allocate some memory + s = calloc(1, sizeof(*s)); + if (!s) + return -errno; + + // Store a reference to the context + s->ctx = pakfire_ctx_ref(ctx); + + // Initialize the reference counter + s->nrefs = 1; + + // Return the pointer + *service = s; + + return 0; +} + +PAKFIRE_EXPORT struct pakfire_buildservice* pakfire_buildservice_ref( + struct pakfire_buildservice* service) { + ++service->nrefs; + + return service; +} + +PAKFIRE_EXPORT struct pakfire_buildservice* pakfire_buildservice_unref( + struct pakfire_buildservice* service) { + if (--service->nrefs > 0) + return service; + + pakfire_buildservice_free(service); + return NULL; +} diff --git a/src/libpakfire/include/pakfire/buildservice.h b/src/libpakfire/include/pakfire/buildservice.h new file mode 100644 index 000000000..3104097b1 --- /dev/null +++ b/src/libpakfire/include/pakfire/buildservice.h @@ -0,0 +1,33 @@ +/*############################################################################# +# # +# 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 . # +# # +#############################################################################*/ + +#ifndef PAKFIRE_BUILDSERVICE_H +#define PAKFIRE_BUILDSERVICE_H + +struct pakfire_buildservice; + +#include + +int pakfire_buildservice_create(struct pakfire_buildservice** service, struct pakfire_ctx* ctx); + +struct pakfire_buildservice* pakfire_buildservice_ref(struct pakfire_buildservice* service); +struct pakfire_buildservice* pakfire_buildservice_unref(struct pakfire_buildservice* service); + +#endif /* PAKFIRE_BUILDSERVICE_H */ diff --git a/src/libpakfire/libpakfire.sym b/src/libpakfire/libpakfire.sym index 6727e8354..12812182b 100644 --- a/src/libpakfire/libpakfire.sym +++ b/src/libpakfire/libpakfire.sym @@ -82,6 +82,11 @@ global: pakfire_build_unref; pakfire_shell; + # buildservice + pakfire_buildservice_create; + pakfire_buildservice_ref; + pakfire_buildservice_unref; + # dependencies pakfire_static_version_compare;