From: Michael Tremer Date: Wed, 10 Mar 2021 15:09:31 +0000 (+0000) Subject: libpakfire: Add scaffolding for downloader X-Git-Tag: 0.9.28~1285^2~577 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ba26680ee35e2f3d8793ea83cbeb2f56bbe248e4;p=pakfire.git libpakfire: Add scaffolding for downloader Signed-off-by: Michael Tremer --- diff --git a/Makefile.am b/Makefile.am index 3a8ff8e59..801fa517f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -261,6 +261,7 @@ libpakfire_la_SOURCES = \ src/libpakfire/archive.c \ src/libpakfire/db.c \ src/libpakfire/dist.c \ + src/libpakfire/downloader.c \ src/libpakfire/errno.c \ src/libpakfire/execute.c \ src/libpakfire/file.c \ @@ -292,6 +293,7 @@ pkginclude_HEADERS += \ src/libpakfire/include/pakfire/constants.h \ src/libpakfire/include/pakfire/db.h \ src/libpakfire/include/pakfire/dist.h \ + src/libpakfire/include/pakfire/downloader.h \ src/libpakfire/include/pakfire/errno.h \ src/libpakfire/include/pakfire/execute.h \ src/libpakfire/include/pakfire/file.h \ diff --git a/src/libpakfire/downloader.c b/src/libpakfire/downloader.c new file mode 100644 index 000000000..a158fac5d --- /dev/null +++ b/src/libpakfire/downloader.c @@ -0,0 +1,74 @@ +/*############################################################################# +# # +# 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_downloader { + Pakfire pakfire; + int nrefs; +}; + +static void pakfire_downloader_free(struct pakfire_downloader* downloader) { + pakfire_unref(downloader->pakfire); + free(downloader); +} + +int pakfire_downloader_create(struct pakfire_downloader** downloader, Pakfire pakfire) { + struct pakfire_downloader* d = calloc(1, sizeof(*d)); + if (!d) + return ENOMEM; + + // Store reference to Pakfire + d->pakfire = pakfire_ref(pakfire); + + // Initialize reference counting + d->nrefs = 1; + + *downloader = d; + + return 0; +} + +struct pakfire_downloader* pakfire_downloader_ref(struct pakfire_downloader* downloader) { + ++downloader->nrefs; + + return downloader; +} + +struct pakfire_downloader* pakfire_downloader_unref(struct pakfire_downloader* downloader) { + if (--downloader->nrefs > 0) + return downloader; + + pakfire_downloader_free(downloader); + return NULL; +} + +int pakfire_downloader_add(struct pakfire_downloader* downloader, const char* url) { + return 0; +} + +int pakfire_downloader_run(struct pakfire_downloader* downloader) { + return 0; +} diff --git a/src/libpakfire/include/pakfire/downloader.h b/src/libpakfire/include/pakfire/downloader.h new file mode 100644 index 000000000..88d02f9c7 --- /dev/null +++ b/src/libpakfire/include/pakfire/downloader.h @@ -0,0 +1,41 @@ +/*############################################################################# +# # +# 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 . # +# # +#############################################################################*/ + +#ifndef PAKFIRE_DOWNLOADER_H +#define PAKFIRE_DOWNLOADER_H + +#ifdef PAKFIRE_PRIVATE + +#include + +struct pakfire_downloader; + +int pakfire_downloader_create(struct pakfire_downloader** downloader, Pakfire pakfire); + +struct pakfire_downloader* pakfire_downloader_ref(struct pakfire_downloader* downloader); +struct pakfire_downloader* pakfire_downloader_unref(struct pakfire_downloader* downloader); + +int pakfire_downloader_add(struct pakfire_downloader* downloader, const char* url); + +int pakfire_downloader_run(struct pakfire_downloader* downloader); + +#endif + +#endif /* PAKFIRE_DOWNLOADER_H */