Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/lib/libalpm/add.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 11:25:54 +1000
commit28dbd5551ee75e843019e6f067ed069daaabba0b (patch)
tree409a7b18a3363ae9a53da30ee17ce59fbc67dd5b /lib/libalpm/add.c
parentb6f6a165c4630cac86efb2608b9909b20488a710 (diff)
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/add.c')
-rw-r--r--lib/libalpm/add.c31
1 files changed, 17 insertions, 14 deletions
diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c
index 1199d300..b0f97d89 100644
--- a/lib/libalpm/add.c
+++ b/lib/libalpm/add.c
@@ -465,7 +465,7 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_t *newpkg,
alpm_db_t *db = handle->db_local;
alpm_trans_t *trans = handle->trans;
alpm_progress_t progress = ALPM_PROGRESS_ADD_START;
- alpm_event_t done = ALPM_EVENT_ADD_DONE, start = ALPM_EVENT_ADD_START;
+ alpm_event_package_operation_t event;
const char *log_msg = "adding";
const char *pkgfile;
@@ -478,18 +478,15 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_t *newpkg,
if(cmp < 0) {
log_msg = "downgrading";
progress = ALPM_PROGRESS_DOWNGRADE_START;
- start = ALPM_EVENT_DOWNGRADE_START;
- done = ALPM_EVENT_DOWNGRADE_DONE;
+ event.operation = ALPM_PACKAGE_DOWNGRADE;
} else if(cmp == 0) {
log_msg = "reinstalling";
progress = ALPM_PROGRESS_REINSTALL_START;
- start = ALPM_EVENT_REINSTALL_START;
- done = ALPM_EVENT_REINSTALL_DONE;
+ event.operation = ALPM_PACKAGE_REINSTALL;
} else {
log_msg = "upgrading";
progress = ALPM_PROGRESS_UPGRADE_START;
- start = ALPM_EVENT_UPGRADE_START;
- done = ALPM_EVENT_UPGRADE_DONE;
+ event.operation = ALPM_PACKAGE_UPGRADE;
}
is_upgrade = 1;
@@ -501,9 +498,14 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_t *newpkg,
/* copy over the install reason */
newpkg->reason = alpm_pkg_get_reason(local);
+ } else {
+ event.operation = ALPM_PACKAGE_INSTALL;
}
- EVENT(handle, start, newpkg, local);
+ event.type = ALPM_EVENT_PACKAGE_OPERATION_START;
+ event.oldpkg = oldpkg;
+ event.newpkg = newpkg;
+ EVENT(handle, &event);
pkgfile = newpkg->origin_data.file;
@@ -654,20 +656,20 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_t *newpkg,
PROGRESS(handle, progress, newpkg->name, 100, pkg_count, pkg_current);
- switch(done) {
- case ALPM_EVENT_ADD_DONE:
+ switch(event.operation) {
+ case ALPM_PACKAGE_INSTALL:
alpm_logaction(handle, ALPM_CALLER_PREFIX, "installed %s (%s)\n",
newpkg->name, newpkg->version);
break;
- case ALPM_EVENT_DOWNGRADE_DONE:
+ case ALPM_PACKAGE_DOWNGRADE:
alpm_logaction(handle, ALPM_CALLER_PREFIX, "downgraded %s (%s -> %s)\n",
newpkg->name, oldpkg->version, newpkg->version);
break;
- case ALPM_EVENT_REINSTALL_DONE:
+ case ALPM_PACKAGE_REINSTALL:
alpm_logaction(handle, ALPM_CALLER_PREFIX, "reinstalled %s (%s)\n",
newpkg->name, newpkg->version);
break;
- case ALPM_EVENT_UPGRADE_DONE:
+ case ALPM_PACKAGE_UPGRADE:
alpm_logaction(handle, ALPM_CALLER_PREFIX, "upgraded %s (%s -> %s)\n",
newpkg->name, oldpkg->version, newpkg->version);
break;
@@ -687,7 +689,8 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_t *newpkg,
free(scriptlet);
}
- EVENT(handle, done, newpkg, oldpkg);
+ event.type = ALPM_EVENT_PACKAGE_OPERATION_DONE;
+ EVENT(handle, &event);
cleanup:
_alpm_pkg_free(oldpkg);