summaryrefslogtreecommitdiffstats
path: root/lib/libalpm/remove.c
diff options
context:
space:
mode:
authorOlivier Brunel <jjk@jjacky.com>2014-01-10 16:25:14 +0100
committerAllan McRae <allan@archlinux.org>2014-03-03 02:25:54 +0100
commit28dbd5551ee75e843019e6f067ed069daaabba0b (patch)
tree409a7b18a3363ae9a53da30ee17ce59fbc67dd5b /lib/libalpm/remove.c
parentb6f6a165c4630cac86efb2608b9909b20488a710 (diff)
downloadpacman-28dbd5551ee75e843019e6f067ed069daaabba0b.tar.gz
pacman-28dbd5551ee75e843019e6f067ed069daaabba0b.tar.xz
Update the event callback
Instead of using two void* arguments for all events, we now send one pointer to an alpm_event_t struct. This contains the type of event that was triggered. With this information, the pointer can then be typecasted to the event-specific struct 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/remove.c')
-rw-r--r--lib/libalpm/remove.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/lib/libalpm/remove.c b/lib/libalpm/remove.c
index 6fb82eed..dce55784 100644
--- a/lib/libalpm/remove.c
+++ b/lib/libalpm/remove.c
@@ -179,7 +179,12 @@ static void remove_notify_needed_optdepends(alpm_handle_t *handle, alpm_list_t *
for(j = optdeps; j; j = alpm_list_next(j)) {
alpm_depend_t *optdep = j->data;
if(alpm_pkg_find(lp, optdep->name)) {
- EVENT(handle, ALPM_EVENT_OPTDEP_REMOVAL, pkg, optdep);
+ alpm_event_optdep_removal_t event = {
+ .type = ALPM_EVENT_OPTDEP_REMOVAL,
+ .pkg = pkg,
+ .optdep = optdep
+ };
+ EVENT(handle, &event);
}
}
}
@@ -203,6 +208,7 @@ int _alpm_remove_prepare(alpm_handle_t *handle, alpm_list_t **data)
alpm_list_t *lp;
alpm_trans_t *trans = handle->trans;
alpm_db_t *db = handle->db_local;
+ alpm_event_t event;
if((trans->flags & ALPM_TRANS_FLAG_RECURSE)
&& !(trans->flags & ALPM_TRANS_FLAG_CASCADE)) {
@@ -214,7 +220,8 @@ int _alpm_remove_prepare(alpm_handle_t *handle, alpm_list_t **data)
}
if(!(trans->flags & ALPM_TRANS_FLAG_NODEPS)) {
- EVENT(handle, ALPM_EVENT_CHECKDEPS_START, NULL, NULL);
+ event.type = ALPM_EVENT_CHECKDEPS_START;
+ EVENT(handle, &event);
_alpm_log(handle, ALPM_LOG_DEBUG, "looking for unsatisfied dependencies\n");
lp = alpm_checkdeps(handle, _alpm_db_get_pkgcache(db), trans->remove, NULL, 1);
@@ -255,7 +262,8 @@ int _alpm_remove_prepare(alpm_handle_t *handle, alpm_list_t **data)
remove_notify_needed_optdepends(handle, trans->remove);
if(!(trans->flags & ALPM_TRANS_FLAG_NODEPS)) {
- EVENT(handle, ALPM_EVENT_CHECKDEPS_DONE, NULL, NULL);
+ event.type = ALPM_EVENT_CHECKDEPS_DONE;
+ EVENT(handle, &event);
}
return 0;
@@ -657,12 +665,18 @@ int _alpm_remove_single_package(alpm_handle_t *handle,
{
const char *pkgname = oldpkg->name;
const char *pkgver = oldpkg->version;
+ alpm_event_package_operation_t event = {
+ .type = ALPM_EVENT_PACKAGE_OPERATION_START,
+ .operation = ALPM_PACKAGE_REMOVE,
+ .oldpkg = oldpkg,
+ .newpkg = NULL
+ };
if(newpkg) {
_alpm_log(handle, ALPM_LOG_DEBUG, "removing old package first (%s-%s)\n",
pkgname, pkgver);
} else {
- EVENT(handle, ALPM_EVENT_REMOVE_START, oldpkg, NULL);
+ EVENT(handle, &event);
_alpm_log(handle, ALPM_LOG_DEBUG, "removing package %s-%s\n",
pkgname, pkgver);
@@ -696,7 +710,8 @@ int _alpm_remove_single_package(alpm_handle_t *handle,
}
if(!newpkg) {
- EVENT(handle, ALPM_EVENT_REMOVE_DONE, oldpkg, NULL);
+ event.type = ALPM_EVENT_PACKAGE_OPERATION_DONE;
+ EVENT(handle, &event);
}
/* remove the package from the database */