From: Michael Tremer Date: Thu, 3 Jun 2021 20:05:59 +0000 (+0000) Subject: libpakfire: Move offline switch into flags X-Git-Tag: 0.9.28~1285^2~17 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fb909902872982cbfc50819df6cb5e539c31a8d6;p=pakfire.git libpakfire: Move offline switch into flags Signed-off-by: Michael Tremer --- diff --git a/src/_pakfire/pakfire.c b/src/_pakfire/pakfire.c index 9b49d0bf2..8f27060d5 100644 --- a/src/_pakfire/pakfire.c +++ b/src/_pakfire/pakfire.c @@ -62,6 +62,10 @@ static int Pakfire_init(PakfireObject* self, PyObject* args, PyObject* kwds) { &path, &arch, &offline, &conf)) return -1; + // Enable offline mode + if (offline) + flags |= PAKFIRE_FLAGS_OFFLINE; + // Create a new Pakfire instance int r = pakfire_create(&self->pakfire, path, arch, conf, flags); if (r) { @@ -79,10 +83,6 @@ static int Pakfire_init(PakfireObject* self, PyObject* args, PyObject* kwds) { return -1; } - // Set offline mode if requested - if (offline) - pakfire_set_offline(self->pakfire, 1); - return 0; } @@ -667,21 +667,6 @@ static PyObject* Pakfire_dist(PakfireObject* self, PyObject* args) { Py_RETURN_NONE; } -static PyObject* Pakfire_get_offline(PakfireObject* self) { - int offline = pakfire_get_offline(self->pakfire); - - if (offline) - Py_RETURN_TRUE; - - Py_RETURN_FALSE; -} - -static int Pakfire_set_offline(PakfireObject* self, PyObject* value) { - pakfire_set_offline(self->pakfire, PyObject_IsTrue(value)); - - return 0; -} - static PyObject* Pakfire_bind(PakfireObject* self, PyObject* args) { const char* src = NULL; const char* dst = NULL; @@ -1036,13 +1021,6 @@ static struct PyGetSetDef Pakfire_getsetters[] = { NULL, NULL }, - { - "offline", - (getter)Pakfire_get_offline, - (setter)Pakfire_set_offline, - NULL, - NULL, - }, { "path", (getter)Pakfire_get_path, diff --git a/src/libpakfire/include/pakfire/pakfire.h b/src/libpakfire/include/pakfire/pakfire.h index 17aa78f3b..ef01dd98b 100644 --- a/src/libpakfire/include/pakfire/pakfire.h +++ b/src/libpakfire/include/pakfire/pakfire.h @@ -30,6 +30,10 @@ #include #include +enum pakfire_flags { + PAKFIRE_FLAGS_OFFLINE = (1 << 0), +}; + int pakfire_create(Pakfire* pakfire, const char* path, const char* arch, const char* conf, int flags); @@ -51,9 +55,6 @@ int pakfire_copy_out(Pakfire pakfire, const char* src, const char* dst); const char* pakfire_get_arch(Pakfire pakfire); -int pakfire_get_offline(Pakfire pakfire); -void pakfire_set_offline(Pakfire pakfire, int offline); - const char** pakfire_get_installonly(Pakfire pakfire); void pakfire_set_installonly(Pakfire pakfire, const char** installonly); diff --git a/src/libpakfire/libpakfire.sym b/src/libpakfire/libpakfire.sym index 3ed5620d3..fd490e4c0 100644 --- a/src/libpakfire/libpakfire.sym +++ b/src/libpakfire/libpakfire.sym @@ -32,7 +32,6 @@ global: pakfire_get_arch; pakfire_get_installed_repo; pakfire_get_installonly; - pakfire_get_offline; pakfire_get_path; pakfire_get_pool; pakfire_get_repo; @@ -42,7 +41,6 @@ global: pakfire_ref; pakfire_search; pakfire_set_installonly; - pakfire_set_offline; pakfire_unref; pakfire_version_compare; pakfire_whatprovides; diff --git a/src/libpakfire/pakfire.c b/src/libpakfire/pakfire.c index 739a38b2d..6c092c737 100644 --- a/src/libpakfire/pakfire.c +++ b/src/libpakfire/pakfire.c @@ -1129,14 +1129,6 @@ PAKFIRE_EXPORT const char* pakfire_get_arch(Pakfire pakfire) { return pakfire->arch; } -PAKFIRE_EXPORT int pakfire_get_offline(Pakfire pakfire) { - return pakfire->offline; -} - -PAKFIRE_EXPORT void pakfire_set_offline(Pakfire pakfire, int offline) { - pakfire->offline = offline; -} - PAKFIRE_EXPORT int pakfire_version_compare(Pakfire pakfire, const char* evr1, const char* evr2) { return pool_evrcmp_str(pakfire->pool, evr1, evr2, EVRCMP_COMPARE); }