static PyObject* Pakfire_whatrequires(PakfireObject* self, PyObject* args) {
const char* requires = NULL;
+ struct pakfire_packagelist* list = NULL;
if (!PyArg_ParseTuple(args, "s", &requires))
return NULL;
- struct pakfire_packagelist* list = pakfire_whatrequires(self->pakfire, requires, 0);
+ int r = pakfire_whatrequires(self->pakfire, requires, 0, &list);
+ if (r) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
PyObject* obj = PyList_FromPackageList(list);
pakfire_packagelist_unref(list);
PakfireRepo pakfire_get_repo(Pakfire pakfire, const char* name);
struct pakfire_packagelist* pakfire_whatprovides(Pakfire pakfire, const char* provides, int flags);
-struct pakfire_packagelist* pakfire_whatrequires(Pakfire pakfire, const char* what, int flags);
+int pakfire_whatrequires(Pakfire pakfire, const char* what, int flags,
+ struct pakfire_packagelist** list);
struct pakfire_packagelist* pakfire_search(Pakfire pakfire, const char* what, int flags);
// Logging
}
}
-PAKFIRE_EXPORT struct pakfire_packagelist* pakfire_whatrequires(Pakfire pakfire, const char* what, int flags) {
- struct pakfire_packagelist* list = NULL;
-
+PAKFIRE_EXPORT int pakfire_whatrequires(Pakfire pakfire, const char* what, int flags,
+ struct pakfire_packagelist** list) {
// Refresh repositories
int r = pakfire_refresh(pakfire, 0);
if (r)
- return NULL;
+ return r;
// Get the pool ready
pakfire_pool_apply_changes(pakfire);
Id dep = pakfire_parse_dep(pakfire, what);
if (!dep) {
errno = EINVAL;
- return NULL;
+ return 1;
}
+ // Reset pointer
+ *list = NULL;
+
Queue matches;
queue_init(&matches);
pool_whatmatchesdep(pakfire->pool, SOLVABLE_REQUIRES, dep, &matches, 0);
// Create a packagelist
- r = pakfire_packagelist_create_from_queue(&list, pakfire, &matches);
+ r = pakfire_packagelist_create_from_queue(list, pakfire, &matches);
if (r)
goto ERROR;
// Sort the list
- pakfire_packagelist_sort(list);
+ pakfire_packagelist_sort(*list);
ERROR:
queue_free(&matches);
- return list;
+ return r;
}
PAKFIRE_EXPORT struct pakfire_packagelist* pakfire_search(Pakfire pakfire, const char* what, int flags) {