uint32_t TDNFQueryTermsHelper( HyPackageList hAccumPkgList, HyQuery hQuery, int nKeyId, const char* pszMatch ) { HyPackageList hPkgList = NULL; HyPackage hPkg = NULL; uint32_t unError = 0; int nIndex = 0; if(!hAccumPkgList || !hQuery || !pszMatch) { unError = ERROR_TDNF_INVALID_PARAMETER; goto error; } unError = hy_query_filter( hQuery, nKeyId, HY_GLOB | HY_ICASE, pszMatch); BAIL_ON_TDNF_HAWKEY_ERROR(unError); hPkgList = hy_query_run(hQuery); if(!hPkgList) { unError = HY_E_IO; BAIL_ON_TDNF_HAWKEY_ERROR(unError); } FOR_PACKAGELIST(hPkg, hPkgList, nIndex) { if (!hy_packagelist_has(hAccumPkgList, hPkg)) { hy_packagelist_push(hAccumPkgList, hy_package_link(hPkg)); } } cleanup: if (hPkgList != NULL) { hy_packagelist_free(hPkgList); } if (hQuery != NULL) { hy_query_clear(hQuery); } return unError; error: goto cleanup; }
static int solution_cb(HyGoal goal, void *data) { struct Solutions *solutions = (struct Solutions*)data; solutions->solutions++; HyPackageList new_installs = hy_goal_list_installs(goal); HyPackage pkg; int i; FOR_PACKAGELIST(pkg, new_installs, i) if (!hy_packagelist_has(solutions->installs, pkg)) hy_packagelist_push(solutions->installs, hy_package_link(pkg)); hy_packagelist_free(new_installs); return 0; }
static int solution_cb(HyGoal goal, void *data) { struct Solutions *solutions = (struct Solutions*)data; solutions->solutions++; GPtrArray *new_installs = hy_goal_list_installs(goal, NULL); DnfPackage *pkg; guint i; for(i = 0; i < new_installs->len; i++) { pkg = g_ptr_array_index (new_installs, i); if (!hy_packagelist_has(solutions->installs, pkg)) g_ptr_array_add(solutions->installs, g_object_ref(pkg)); } g_ptr_array_unref(new_installs); return 0; }