From: Michael Tremer Date: Thu, 24 Jun 2021 21:09:56 +0000 (+0000) Subject: problems: Change type from PakfireProblem* to struct pakfire_problem X-Git-Tag: 0.9.28~1177 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=014e8eb62997bcd8f15e1ad94d38432e715f0bf3;p=pakfire.git problems: Change type from PakfireProblem* to struct pakfire_problem Signed-off-by: Michael Tremer --- diff --git a/src/_pakfire/problem.c b/src/_pakfire/problem.c index f02ae26ae..23f4430f8 100644 --- a/src/_pakfire/problem.c +++ b/src/_pakfire/problem.c @@ -25,7 +25,7 @@ #include "problem.h" #include "solution.h" -static ProblemObject* Problem_new_core(PyTypeObject* type, PakfireProblem problem) { +static ProblemObject* Problem_new_core(PyTypeObject* type, struct pakfire_problem* problem) { ProblemObject* self = (ProblemObject *)type->tp_alloc(type, 0); if (self) { self->problem = problem; @@ -34,7 +34,7 @@ static ProblemObject* Problem_new_core(PyTypeObject* type, PakfireProblem proble return self; } -PyObject* new_problem(PakfireProblem problem) { +PyObject* new_problem(struct pakfire_problem* problem) { ProblemObject* p = Problem_new_core(&ProblemType, problem); return (PyObject*)p; diff --git a/src/_pakfire/problem.h b/src/_pakfire/problem.h index 7146b5c5d..ca581ad5b 100644 --- a/src/_pakfire/problem.h +++ b/src/_pakfire/problem.h @@ -27,11 +27,11 @@ typedef struct { PyObject_HEAD - PakfireProblem problem; + struct pakfire_problem* problem; } ProblemObject; extern PyTypeObject ProblemType; -PyObject* new_problem(PakfireProblem problem); +PyObject* new_problem(struct pakfire_problem* problem); #endif /* PYTHON_PAKFIRE_PROBLEM_H */ diff --git a/src/libpakfire/include/pakfire/problem.h b/src/libpakfire/include/pakfire/problem.h index 76a692122..e96bc4818 100644 --- a/src/libpakfire/include/pakfire/problem.h +++ b/src/libpakfire/include/pakfire/problem.h @@ -25,22 +25,24 @@ #include -PakfireProblem pakfire_problem_create(struct pakfire_request* request, Id id); -PakfireProblem pakfire_problem_ref(PakfireProblem problem); -PakfireProblem pakfire_problem_unref(PakfireProblem problem); +struct pakfire_problem; -PakfireProblem pakfire_problem_next(PakfireProblem problem); -void pakfire_problem_append(PakfireProblem problem, PakfireProblem new_problem); +struct pakfire_problem* pakfire_problem_create(struct pakfire_request* request, Id id); +struct pakfire_problem* pakfire_problem_ref(struct pakfire_problem* problem); +struct pakfire_problem* pakfire_problem_unref(struct pakfire_problem* problem); -const char* pakfire_problem_to_string(PakfireProblem problem); +struct pakfire_problem* pakfire_problem_next(struct pakfire_problem* problem); +void pakfire_problem_append(struct pakfire_problem* problem, struct pakfire_problem* new_problem); -struct pakfire_request* pakfire_problem_get_request(PakfireProblem problem); -PakfireSolution pakfire_problem_get_solutions(PakfireProblem problem); +const char* pakfire_problem_to_string(struct pakfire_problem* problem); + +struct pakfire_request* pakfire_problem_get_request(struct pakfire_problem* problem); +PakfireSolution pakfire_problem_get_solutions(struct pakfire_problem* problem); #ifdef PAKFIRE_PRIVATE -Pakfire pakfire_problem_get_pakfire(PakfireProblem problem); -Id pakfire_problem_get_id(PakfireProblem problem); +Pakfire pakfire_problem_get_pakfire(struct pakfire_problem* problem); +Id pakfire_problem_get_id(struct pakfire_problem* problem); #endif diff --git a/src/libpakfire/include/pakfire/request.h b/src/libpakfire/include/pakfire/request.h index cfafd219d..47dd65e68 100644 --- a/src/libpakfire/include/pakfire/request.h +++ b/src/libpakfire/include/pakfire/request.h @@ -21,6 +21,7 @@ #ifndef PAKFIRE_REQUEST_H #define PAKFIRE_REQUEST_H +#include #include #include @@ -46,7 +47,7 @@ struct pakfire_request* pakfire_request_unref(struct pakfire_request* request); int pakfire_request_solve(struct pakfire_request* request, struct pakfire_transaction** transaction); -PakfireProblem pakfire_request_get_problems(struct pakfire_request* request); +struct pakfire_problem* pakfire_request_get_problems(struct pakfire_request* request); int pakfire_request_install(struct pakfire_request* request, const char* what, int flags); int pakfire_request_install_package(struct pakfire_request* request, PakfirePackage package); diff --git a/src/libpakfire/include/pakfire/solution.h b/src/libpakfire/include/pakfire/solution.h index 026491f4a..1c833a513 100644 --- a/src/libpakfire/include/pakfire/solution.h +++ b/src/libpakfire/include/pakfire/solution.h @@ -21,9 +21,11 @@ #ifndef PAKFIRE_SOLUTION_H #define PAKFIRE_SOLUTION_H +#include + #include -PakfireSolution pakfire_solution_create(PakfireProblem problem, Id id); +PakfireSolution pakfire_solution_create(struct pakfire_problem* problem, Id id); PakfireSolution pakfire_solution_ref(PakfireSolution solution); PakfireSolution pakfire_solution_unref(PakfireSolution solution); diff --git a/src/libpakfire/include/pakfire/types.h b/src/libpakfire/include/pakfire/types.h index d07f11c0d..5335ccefb 100644 --- a/src/libpakfire/include/pakfire/types.h +++ b/src/libpakfire/include/pakfire/types.h @@ -31,7 +31,6 @@ typedef struct _PakfireKey* PakfireKey; typedef struct _PakfirePackage* PakfirePackage; typedef struct _PakfirePackageList* PakfirePackageList; typedef struct _PakfireParser* PakfireParser; -typedef struct _PakfireProblem* PakfireProblem; typedef struct _PakfireRepo* PakfireRepo; typedef struct _PakfireSolution* PakfireSolution; diff --git a/src/libpakfire/problem.c b/src/libpakfire/problem.c index 31f0c9e4c..f8067055d 100644 --- a/src/libpakfire/problem.c +++ b/src/libpakfire/problem.c @@ -30,17 +30,17 @@ #include #include -struct _PakfireProblem { +struct pakfire_problem { Pakfire pakfire; struct pakfire_request* request; Id id; char* string; - PakfireProblem next; + struct pakfire_problem* next; int nrefs; }; -static char* to_string(PakfireProblem problem) { +static char* to_string(struct pakfire_problem* problem) { Solver* solver = pakfire_request_get_solver(problem->request); Pool* pool = solver->pool; @@ -204,10 +204,10 @@ static char* to_string(PakfireProblem problem) { return strdup(s); } -PAKFIRE_EXPORT PakfireProblem pakfire_problem_create(struct pakfire_request* request, Id id) { +PAKFIRE_EXPORT struct pakfire_problem* pakfire_problem_create(struct pakfire_request* request, Id id) { Pakfire pakfire = pakfire_request_get_pakfire(request); - PakfireProblem problem = calloc(1, sizeof(*problem)); + struct pakfire_problem* problem = calloc(1, sizeof(*problem)); if (problem) { problem->pakfire = pakfire_ref(pakfire); problem->nrefs = 1; @@ -224,13 +224,13 @@ PAKFIRE_EXPORT PakfireProblem pakfire_problem_create(struct pakfire_request* req return problem; } -PAKFIRE_EXPORT PakfireProblem pakfire_problem_ref(PakfireProblem problem) { +PAKFIRE_EXPORT struct pakfire_problem* pakfire_problem_ref(struct pakfire_problem* problem) { problem->nrefs++; return problem; } -static void pakfire_problem_free(PakfireProblem problem) { +static void pakfire_problem_free(struct pakfire_problem* problem) { pakfire_problem_unref(problem->next); pakfire_request_unref(problem->request); @@ -241,7 +241,7 @@ static void pakfire_problem_free(PakfireProblem problem) { free(problem); } -PAKFIRE_EXPORT PakfireProblem pakfire_problem_unref(PakfireProblem problem) { +PAKFIRE_EXPORT struct pakfire_problem* pakfire_problem_unref(struct pakfire_problem* problem) { if (!problem) return NULL; @@ -252,16 +252,16 @@ PAKFIRE_EXPORT PakfireProblem pakfire_problem_unref(PakfireProblem problem) { return NULL; } -Pakfire pakfire_problem_get_pakfire(PakfireProblem problem) { +Pakfire pakfire_problem_get_pakfire(struct pakfire_problem* problem) { return pakfire_ref(problem->pakfire); } -PAKFIRE_EXPORT PakfireProblem pakfire_problem_next(PakfireProblem problem) { +PAKFIRE_EXPORT struct pakfire_problem* pakfire_problem_next(struct pakfire_problem* problem) { return problem->next; } -PAKFIRE_EXPORT void pakfire_problem_append(PakfireProblem problem, PakfireProblem new_problem) { - PakfireProblem next; +PAKFIRE_EXPORT void pakfire_problem_append(struct pakfire_problem* problem, struct pakfire_problem* new_problem) { + struct pakfire_problem* next; // Go to last problem in list while ((next = pakfire_problem_next(problem)) != NULL) { @@ -271,19 +271,19 @@ PAKFIRE_EXPORT void pakfire_problem_append(PakfireProblem problem, PakfireProble problem->next = pakfire_problem_ref(new_problem); } -PAKFIRE_EXPORT const char* pakfire_problem_to_string(PakfireProblem problem) { +PAKFIRE_EXPORT const char* pakfire_problem_to_string(struct pakfire_problem* problem) { return problem->string; } -Id pakfire_problem_get_id(PakfireProblem problem) { +Id pakfire_problem_get_id(struct pakfire_problem* problem) { return problem->id; } -PAKFIRE_EXPORT struct pakfire_request* pakfire_problem_get_request(PakfireProblem problem) { +PAKFIRE_EXPORT struct pakfire_request* pakfire_problem_get_request(struct pakfire_problem* problem) { return pakfire_request_ref(problem->request); } -PAKFIRE_EXPORT PakfireSolution pakfire_problem_get_solutions(PakfireProblem problem) { +PAKFIRE_EXPORT PakfireSolution pakfire_problem_get_solutions(struct pakfire_problem* problem) { PakfireSolution ret = NULL; Solver* solver = pakfire_request_get_solver(problem->request); diff --git a/src/libpakfire/request.c b/src/libpakfire/request.c index fafda7e37..4dc98ebf0 100644 --- a/src/libpakfire/request.c +++ b/src/libpakfire/request.c @@ -193,12 +193,12 @@ ERROR: return r; } -PAKFIRE_EXPORT PakfireProblem pakfire_request_get_problems(struct pakfire_request* request) { +PAKFIRE_EXPORT struct pakfire_problem* pakfire_request_get_problems(struct pakfire_request* request) { Id problem = 0; - PakfireProblem ret = NULL; + struct pakfire_problem* ret = NULL; while ((problem = solver_next_problem(request->solver, problem)) != 0) { - PakfireProblem p = pakfire_problem_create(request, problem); + struct pakfire_problem* p = pakfire_problem_create(request, problem); if (ret) pakfire_problem_append(ret, p); diff --git a/src/libpakfire/solution.c b/src/libpakfire/solution.c index ce21c12de..5eead890b 100644 --- a/src/libpakfire/solution.c +++ b/src/libpakfire/solution.c @@ -33,7 +33,7 @@ struct _PakfireSolution { Pakfire pakfire; - PakfireProblem problem; + struct pakfire_problem* problem; Id id; char** elements; @@ -119,7 +119,7 @@ static void import_elements(PakfireSolution solution) { pakfire_request_unref(request); } -PAKFIRE_EXPORT PakfireSolution pakfire_solution_create(PakfireProblem problem, Id id) { +PAKFIRE_EXPORT PakfireSolution pakfire_solution_create(struct pakfire_problem* problem, Id id) { Pakfire pakfire = pakfire_problem_get_pakfire(problem); PakfireSolution solution = calloc(1, sizeof(*solution));