]> git.ipfire.org Git - pakfire.git/commitdiff
request: Implement taking a solution
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 3 Jul 2021 12:46:13 +0000 (12:46 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 3 Jul 2021 12:46:13 +0000 (12:46 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/include/pakfire/solution.h
src/libpakfire/libpakfire.sym
src/libpakfire/request.c
src/libpakfire/solution.c

index bf26dc633dd6b2480f3697c988cbf83e87d1e943..bdb8a683fda186c1038d61101a48e279ca0d566f 100644 (file)
@@ -34,4 +34,11 @@ struct pakfire_solution* pakfire_solution_unref(struct pakfire_solution* solutio
 
 const char* pakfire_solution_to_string(struct pakfire_solution* solution);
 
+#ifdef PAKFIRE_PRIVATE
+
+struct pakfire_problem* pakfire_solution_get_problem(struct pakfire_solution* solution);
+Id pakfire_solution_get_id(struct pakfire_solution* solution);
+
+#endif /* PAKFIRE_PRIVATE */
+
 #endif /* PAKFIRE_SOLUTION_H */
index e6351e98c5fad86848df5e1b82bdb30e248cf7c5..2137a859edbe446f0dbb00377ebabfae7bdc75f8 100644 (file)
@@ -291,6 +291,7 @@ global:
        pakfire_request_ref;
        pakfire_request_solve;
        pakfire_request_sync;
+       pakfire_request_take_solution;
        pakfire_request_upgrade;
        pakfire_request_upgrade_all;
        pakfire_request_upgrade_package;
index 6767ca7038cb0cac81a68ed8195dafe10f1fccc5..b736184ba2af5a2ff24cf3b55fc66accecd697f5 100644 (file)
@@ -572,3 +572,18 @@ PAKFIRE_EXPORT int pakfire_request_verify(struct pakfire_request* request, int f
 
        return 0;
 }
+
+PAKFIRE_EXPORT int pakfire_request_take_solution(struct pakfire_request* request,
+               struct pakfire_solution* solution) {
+       struct pakfire_problem* problem = pakfire_solution_get_problem(solution);
+
+       // Fetch IDs
+       Id problem_id = pakfire_problem_get_id(problem);
+       Id solution_id = pakfire_solution_get_id(solution);
+
+       // Feed the solution into the solver
+       solver_take_solution(request->solver, problem_id, solution_id, &request->jobs);
+
+       pakfire_problem_unref(problem);
+       return 0;
+}
index d9d530fa8a37b51e82c2e2963294fd08477aace9..9a2f9c4a67453db88db0062c690e8def07389300 100644 (file)
@@ -84,6 +84,14 @@ PAKFIRE_EXPORT struct pakfire_solution* pakfire_solution_unref(struct pakfire_so
        return NULL;
 }
 
+struct pakfire_problem* pakfire_solution_get_problem(struct pakfire_solution* solution) {
+       return pakfire_problem_ref(solution->problem);
+}
+
+Id pakfire_solution_get_id(struct pakfire_solution* solution) {
+       return solution->id;
+}
+
 static char* pakfire_solution_make_string(struct pakfire_solution* solution) {
        struct pakfire_request* request = pakfire_problem_get_request(solution->problem);
        Solver* solver = pakfire_request_get_solver(request);