summaryrefslogtreecommitdiffstats
path: root/lib/libalpm/deps.c
diff options
context:
space:
mode:
authorOlivier Brunel <jjk@jjacky.com>2014-06-15 19:42:40 +0200
committerAllan McRae <allan@archlinux.org>2014-06-24 05:52:15 +0200
commitf1fadecfb34555cfac1c47f217253a535d64a28b (patch)
tree4221201d464af1d0ca234ef05cfd629c00a466e8 /lib/libalpm/deps.c
parentd06d993d56bda499be31042bd39aaea9b8b11e3d (diff)
downloadpacman-f1fadecfb34555cfac1c47f217253a535d64a28b.tar.gz
pacman-f1fadecfb34555cfac1c47f217253a535d64a28b.tar.xz
Update the question callback
Much like with events, instead of using a bunch of void* arguments for all questions, we now send one pointer to an alpm_question_t union. This contains the type of question that was triggered. With this information, a question-specific struct can be accessed in order to get additional arguments. Signed-off-by: Olivier Brunel <jjk@jjacky.com> Signed-off-by: Allan McRae <allan@archlinux.org>
Diffstat (limited to 'lib/libalpm/deps.c')
-rw-r--r--lib/libalpm/deps.c38
1 files changed, 24 insertions, 14 deletions
diff --git a/lib/libalpm/deps.c b/lib/libalpm/deps.c
index b3de1b00..1cbbc5f6 100644
--- a/lib/libalpm/deps.c
+++ b/lib/libalpm/deps.c
@@ -640,15 +640,18 @@ static alpm_pkg_t *resolvedep(alpm_handle_t *handle, alpm_depend_t *dep,
if(pkg && _alpm_depcmp_literal(pkg, dep)
&& !alpm_pkg_find(excluding, pkg->name)) {
if(alpm_pkg_should_ignore(handle, pkg)) {
- int install = 0;
+ alpm_question_install_ignorepkg_t question = {
+ .type = ALPM_QUESTION_INSTALL_IGNOREPKG,
+ .install = 0,
+ .pkg = pkg
+ };
if(prompt) {
- QUESTION(handle, ALPM_QUESTION_INSTALL_IGNOREPKG, pkg,
- NULL, NULL, &install);
+ QUESTION(handle, &question);
} else {
_alpm_log(handle, ALPM_LOG_WARNING, _("ignoring package %s-%s\n"),
pkg->name, pkg->version);
}
- if(!install) {
+ if(!question.install) {
ignored = 1;
continue;
}
@@ -669,15 +672,18 @@ static alpm_pkg_t *resolvedep(alpm_handle_t *handle, alpm_depend_t *dep,
if(pkg->name_hash != dep->name_hash && _alpm_depcmp(pkg, dep)
&& !alpm_pkg_find(excluding, pkg->name)) {
if(alpm_pkg_should_ignore(handle, pkg)) {
- int install = 0;
+ alpm_question_install_ignorepkg_t question = {
+ .type = ALPM_QUESTION_INSTALL_IGNOREPKG,
+ .install = 0,
+ .pkg = pkg
+ };
if(prompt) {
- QUESTION(handle, ALPM_QUESTION_INSTALL_IGNOREPKG,
- pkg, NULL, NULL, &install);
+ QUESTION(handle, &question);
} else {
_alpm_log(handle, ALPM_LOG_WARNING, _("ignoring package %s-%s\n"),
pkg->name, pkg->version);
}
- if(!install) {
+ if(!question.install) {
ignored = 1;
continue;
}
@@ -700,15 +706,19 @@ static alpm_pkg_t *resolvedep(alpm_handle_t *handle, alpm_depend_t *dep,
}
count = alpm_list_count(providers);
if(count >= 1) {
- /* default to first provider if there is no QUESTION callback */
- int idx = 0;
+ alpm_question_select_provider_t question = {
+ .type = ALPM_QUESTION_SELECT_PROVIDER,
+ /* default to first provider if there is no QUESTION callback */
+ .use_index = 0,
+ .providers = providers,
+ .depend = dep
+ };
if(count > 1) {
/* if there is more than one provider, we ask the user */
- QUESTION(handle, ALPM_QUESTION_SELECT_PROVIDER,
- providers, dep, NULL, &idx);
+ QUESTION(handle, &question);
}
- if(idx >= 0 && idx < count) {
- alpm_list_t *nth = alpm_list_nth(providers, idx);
+ if(question.use_index >= 0 && question.use_index < count) {
+ alpm_list_t *nth = alpm_list_nth(providers, question.use_index);
alpm_pkg_t *pkg = nth->data;
alpm_list_free(providers);
return pkg;