static PyObject* Pakfire_whatprovides(PakfireObject* self, PyObject* args) {
const char* provides = NULL;
struct pakfire_packagelist* list = NULL;
+ PyObject* ret = NULL;
+ int r;
if (!PyArg_ParseTuple(args, "s", &provides))
return NULL;
- int r = pakfire_whatprovides(self->pakfire, provides, 0, &list);
+ // Create a new list
+ r = pakfire_packagelist_create(&list, self->pakfire);
if (r) {
PyErr_SetFromErrno(PyExc_OSError);
- return NULL;
+ goto ERROR;
}
- PyObject* obj = PyList_FromPackageList(list);
- pakfire_packagelist_unref(list);
+ r = pakfire_whatprovides(self->pakfire, provides, 0, list);
+ if (r) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ goto ERROR;
+ }
- return obj;
+ // Create a Python list from the package list
+ ret = PyList_FromPackageList(list);
+
+ERROR:
+ if (list)
+ pakfire_packagelist_unref(list);
+
+ return ret;
}
static PyObject* Pakfire_whatrequires(PakfireObject* self, PyObject* args) {
const char* requires = NULL;
struct pakfire_packagelist* list = NULL;
+ PyObject* ret = NULL;
+ int r;
if (!PyArg_ParseTuple(args, "s", &requires))
return NULL;
- int r = pakfire_whatrequires(self->pakfire, requires, 0, &list);
+ // Create a new list
+ r = pakfire_packagelist_create(&list, self->pakfire);
if (r) {
PyErr_SetFromErrno(PyExc_OSError);
- return NULL;
+ goto ERROR;
}
- PyObject* obj = PyList_FromPackageList(list);
- pakfire_packagelist_unref(list);
+ r = pakfire_whatprovides(self->pakfire, requires, 0, list);
+ if (r) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ goto ERROR;
+ }
- return obj;
+ // Create a Python list from the package list
+ ret = PyList_FromPackageList(list);
+
+ERROR:
+ if (list)
+ pakfire_packagelist_unref(list);
+
+ return ret;
}
static PyObject* Pakfire_search(PakfireObject* self, PyObject* args, PyObject* kwds) {
struct pakfire_repo* pakfire_get_repo(struct pakfire* pakfire, const char* name);
int pakfire_whatprovides(struct pakfire* pakfire, const char* what, int flags,
- struct pakfire_packagelist** list);
+ struct pakfire_packagelist* list);
int pakfire_whatrequires(struct pakfire* pakfire, const char* what, int flags,
- struct pakfire_packagelist** list);
+ struct pakfire_packagelist* list);
// Search
}
static int pakfire_search_dep(struct pakfire* pakfire, Id type, const char* what, int flags,
- struct pakfire_packagelist** list) {
+ struct pakfire_packagelist* list) {
int r;
// Get the pool ready
return 1;
}
- // Reset pointer
- *list = NULL;
-
Queue matches;
queue_init(&matches);
// Search for anything that matches
pool_whatmatchesdep(pakfire->pool, type, dep, &matches, 0);
- // Create a packagelist
- r = pakfire_packagelist_create_from_queue(list, pakfire, &matches);
+ // Add the result to the packagelist
+ r = pakfire_packagelist_import_solvables(list, &matches);
if (r)
goto ERROR;
- // Sort the list
- pakfire_packagelist_sort(*list);
-
ERROR:
queue_free(&matches);
}
PAKFIRE_EXPORT int pakfire_whatprovides(struct pakfire* pakfire, const char* what, int flags,
- struct pakfire_packagelist** list) {
+ struct pakfire_packagelist* list) {
return pakfire_search_dep(pakfire, SOLVABLE_PROVIDES, what, flags, list);
}
PAKFIRE_EXPORT int pakfire_whatrequires(struct pakfire* pakfire, const char* what, int flags,
- struct pakfire_packagelist** list) {
+ struct pakfire_packagelist* list) {
return pakfire_search_dep(pakfire, SOLVABLE_REQUIRES, what, flags, list);
}