#ifdef PAKFIRE_PRIVATE
-
#include <pakfire/request.h>
int pakfire_problem_create(struct pakfire_problem** problem, struct pakfire* pakfire,
struct pakfire* pakfire_problem_get_pakfire(struct pakfire_problem* problem);
Id pakfire_problem_get_id(struct pakfire_problem* problem);
+int pakfire_problem_next_solution(
+ struct pakfire_problem* problem, struct pakfire_solution** solution);
+
#endif
#endif /* PAKFIRE_PROBLEM_H */
Solver* pakfire_request_get_solver(struct pakfire_request* request);
+int pakfire_request_next_problem(
+ struct pakfire_request* request, struct pakfire_problem** problem);
+
#endif
#endif /* PAKFIRE_REQUEST_H */
# #
#############################################################################*/
+#include <errno.h>
#include <stdlib.h>
#include <pakfire/constants.h>
return r;
}
+
+int pakfire_problem_next_solution(
+ struct pakfire_problem* problem, struct pakfire_solution** solution) {
+ Solver* solver = pakfire_request_get_solver(problem->request);
+ Id id = 0;
+
+ // Check input
+ if (!solution) {
+ errno = EINVAL;
+ return 1;
+ }
+
+ // Fetch the ID of the previous solution
+ if (*solution) {
+ id = pakfire_solution_get_id(*solution);
+
+ // Free the previous solution
+ pakfire_solution_unref(*solution);
+ *solution = NULL;
+ }
+
+ // Fetch the ID of the next problem
+ id = solver_next_solution(solver, problem->id, id);
+ if (!id)
+ return 0;
+
+ // Create solution
+ return pakfire_solution_create(solution, problem, id);
+}
return 0;
}
+int pakfire_request_next_problem(
+ struct pakfire_request* request, struct pakfire_problem** problem) {
+ Id id = 0;
+
+ // Check input
+ if (!problem) {
+ errno = EINVAL;
+ return 1;
+ }
+
+ // Fetch the ID of the previous problem
+ if (*problem) {
+ id = pakfire_problem_get_id(*problem);
+
+ // Free the previous problem
+ pakfire_problem_unref(*problem);
+ *problem = NULL;
+ }
+
+ // Fetch the ID of the next problem
+ id = solver_next_problem(request->solver, id);
+ if (!id)
+ return 0;
+
+ // Create problem
+ return pakfire_problem_create(problem, request->pakfire, request, id);
+}
+
PAKFIRE_EXPORT int pakfire_request_take_solution(struct pakfire_request* request,
struct pakfire_solution* solution) {
struct pakfire_problem* problem = pakfire_solution_get_problem(solution);