summaryrefslogtreecommitdiff
path: root/lib/libalpm
diff options
context:
space:
mode:
authorAurelien Foret <aurelien@archlinux.org>2005-05-04 19:55:23 +0000
committerAurelien Foret <aurelien@archlinux.org>2005-05-04 19:55:23 +0000
commita26095f8fc27eb564fd5b49c0d99e7821c21e2e8 (patch)
treee9491a2171abd4414e4a2b59ebdaec6edb85e59c /lib/libalpm
parent14c8583ccbb9f3ff218611ca3d54d93b394b41b5 (diff)
event transaction callback rework to prepare the introduction of a conversation callback
Diffstat (limited to 'lib/libalpm')
-rw-r--r--lib/libalpm/add.c16
-rw-r--r--lib/libalpm/alpm.c4
-rw-r--r--lib/libalpm/alpm.h7
-rw-r--r--lib/libalpm/remove.c8
-rw-r--r--lib/libalpm/sync.c12
-rw-r--r--lib/libalpm/trans.c6
-rw-r--r--lib/libalpm/trans.h10
7 files changed, 33 insertions, 30 deletions
diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c
index d0adb10b..31df759a 100644
--- a/lib/libalpm/add.c
+++ b/lib/libalpm/add.c
@@ -200,7 +200,7 @@ int add_prepare(pmtrans_t *trans, pmdb_t *db, PMList **data)
if(!(trans->flags & PM_TRANS_FLAG_NODEPS)) {
PMList *i;
- TRANS_CB(trans, PM_TRANS_EVT_CHECKDEPS_START, NULL, NULL);
+ EVENT(trans, PM_TRANS_EVT_CHECKDEPS_START, NULL, NULL);
_alpm_log(PM_LOG_FLOW1, "looking for conflicts or unsatisfied dependencies");
lp = checkdeps(db, trans->type, trans->packages);
@@ -257,13 +257,13 @@ int add_prepare(pmtrans_t *trans, pmdb_t *db, PMList **data)
FREELISTPTR(trans->packages);
trans->packages = lp;
- TRANS_CB(trans, PM_TRANS_EVT_CHECKDEPS_DONE, NULL, NULL);
+ EVENT(trans, PM_TRANS_EVT_CHECKDEPS_DONE, NULL, NULL);
}
/* Check for file conflicts
*/
if(!(trans->flags & PM_TRANS_FLAG_FORCE)) {
- TRANS_CB(trans, PM_TRANS_EVT_FILECONFLICTS_START, NULL, NULL);
+ EVENT(trans, PM_TRANS_EVT_FILECONFLICTS_START, NULL, NULL);
_alpm_log(PM_LOG_FLOW1, "looking for file conflicts");
lp = db_find_conflicts(db, trans->packages, handle->root);
@@ -272,7 +272,7 @@ int add_prepare(pmtrans_t *trans, pmdb_t *db, PMList **data)
RET_ERR(PM_ERR_FILE_CONFLICTS, -1);
}
- TRANS_CB(trans, PM_TRANS_EVT_FILECONFLICTS_DONE, NULL, NULL);
+ EVENT(trans, PM_TRANS_EVT_FILECONFLICTS_DONE, NULL, NULL);
}
return(0);
@@ -312,7 +312,7 @@ int add_commit(pmtrans_t *trans, pmdb_t *db)
if(pmo_upgrade) {
pmpkg_t *local = db_get_pkgfromcache(db, info->name);
if(local) {
- TRANS_CB(trans, PM_TRANS_EVT_UPGRADE_START, info, NULL);
+ EVENT(trans, PM_TRANS_EVT_UPGRADE_START, info, NULL);
_alpm_log(PM_LOG_FLOW1, "upgrading package %s-%s", info->name, info->version);
/* we'll need to save some record for backup checks later */
@@ -360,7 +360,7 @@ int add_commit(pmtrans_t *trans, pmdb_t *db)
}
}
if(!pmo_upgrade) {
- TRANS_CB(trans, PM_TRANS_EVT_ADD_START, info, NULL);
+ EVENT(trans, PM_TRANS_EVT_ADD_START, info, NULL);
_alpm_log(PM_LOG_FLOW1, "adding package %s-%s", info->name, info->version);
/* pre_install scriptlet */
@@ -656,11 +656,11 @@ int add_commit(pmtrans_t *trans, pmdb_t *db)
}
if(pmo_upgrade) {
- TRANS_CB(trans, PM_TRANS_EVT_UPGRADE_DONE, info, NULL);
+ EVENT(trans, PM_TRANS_EVT_UPGRADE_DONE, info, NULL);
alpm_logaction("upgraded %s (%s -> %s)", info->name,
oldpkg ? oldpkg->version : NULL, info->version);
} else {
- TRANS_CB(trans, PM_TRANS_EVT_ADD_DONE, info, NULL);
+ EVENT(trans, PM_TRANS_EVT_ADD_DONE, info, NULL);
alpm_logaction("installed %s (%s)", info->name, info->version);
}
diff --git a/lib/libalpm/alpm.c b/lib/libalpm/alpm.c
index 691b478c..a91323b3 100644
--- a/lib/libalpm/alpm.c
+++ b/lib/libalpm/alpm.c
@@ -541,7 +541,7 @@ void *alpm_trans_getinfo(unsigned char parm)
return(data);
}
-int alpm_trans_init(unsigned char type, unsigned char flags, alpm_trans_cb cb)
+int alpm_trans_init(unsigned char type, unsigned char flags, alpm_trans_cb_event event)
{
/* Sanity checks */
ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1));
@@ -553,7 +553,7 @@ int alpm_trans_init(unsigned char type, unsigned char flags, alpm_trans_cb cb)
RET_ERR(PM_ERR_MEMORY, -1);
}
- return(trans_init(handle->trans, type, flags, cb));
+ return(trans_init(handle->trans, type, flags, event));
}
int alpm_trans_sysupgrade()
diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h
index 79eb9d20..989bca25 100644
--- a/lib/libalpm/alpm.h
+++ b/lib/libalpm/alpm.h
@@ -229,7 +229,10 @@ enum {
};
/* Event callback */
-typedef void (*alpm_trans_cb)(unsigned short, void *, void *);
+typedef void (*alpm_trans_cb_event)(unsigned char, void *, void *);
+
+/* Conversation callback */
+typedef void (*alpm_trans_cb_conv)(unsigned char, void *, void *);
/* Info parameters */
enum {
@@ -240,7 +243,7 @@ enum {
};
void *alpm_trans_getinfo(unsigned char parm);
-int alpm_trans_init(unsigned char type, unsigned char flags, alpm_trans_cb cb);
+int alpm_trans_init(unsigned char type, unsigned char flags, alpm_trans_cb_event cb_event);
int alpm_trans_sysupgrade();
int alpm_trans_addtarget(char *target);
int alpm_trans_prepare(PM_LIST **data);
diff --git a/lib/libalpm/remove.c b/lib/libalpm/remove.c
index 38dfb299..181f4ddd 100644
--- a/lib/libalpm/remove.c
+++ b/lib/libalpm/remove.c
@@ -81,7 +81,7 @@ int remove_prepare(pmtrans_t *trans, pmdb_t *db, PMList **data)
ASSERT(data != NULL, RET_ERR(PM_ERR_WRONG_ARGS, -1));
if(!(trans->flags & (PM_TRANS_FLAG_NODEPS)) && (trans->type != PM_TRANS_TYPE_UPGRADE)) {
- TRANS_CB(trans, PM_TRANS_EVT_CHECKDEPS_START, NULL, NULL);
+ EVENT(trans, PM_TRANS_EVT_CHECKDEPS_START, NULL, NULL);
_alpm_log(PM_LOG_FLOW1, "looking for unsatisfied dependencies");
if((lp = checkdeps(db, trans->type, trans->packages)) != NULL) {
@@ -119,7 +119,7 @@ int remove_prepare(pmtrans_t *trans, pmdb_t *db, PMList **data)
FREELISTPTR(trans->packages);
trans->packages = lp;
- TRANS_CB(trans, PM_TRANS_EVT_CHECKDEPS_DONE, NULL, NULL);
+ EVENT(trans, PM_TRANS_EVT_CHECKDEPS_DONE, NULL, NULL);
}
return(0);
@@ -147,7 +147,7 @@ int remove_commit(pmtrans_t *trans, pmdb_t *db)
info = (pmpkg_t*)targ->data;
if(trans->type != PM_TRANS_TYPE_UPGRADE) {
- TRANS_CB(trans, PM_TRANS_EVT_REMOVE_START, info, NULL);
+ EVENT(trans, PM_TRANS_EVT_REMOVE_START, info, NULL);
_alpm_log(PM_LOG_FLOW1, "removing package %s-%s", info->name, info->version);
/* run the pre-remove scriptlet if it exists */
@@ -273,7 +273,7 @@ int remove_commit(pmtrans_t *trans, pmdb_t *db)
}
if(trans->type != PM_TRANS_TYPE_UPGRADE) {
- TRANS_CB(trans, PM_TRANS_EVT_REMOVE_DONE, info, NULL);
+ EVENT(trans, PM_TRANS_EVT_REMOVE_DONE, info, NULL);
alpm_logaction("removed %s (%s)", info->name, info->version);
}
}
diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c
index 15ea7789..be7f7385 100644
--- a/lib/libalpm/sync.c
+++ b/lib/libalpm/sync.c
@@ -344,7 +344,7 @@ int sync_prepare(pmtrans_t *trans, pmdb_t *db_local, PMList *dbs_sync, PMList **
trail = pm_list_new();
/* Resolve targets dependencies */
- TRANS_CB(trans, PM_TRANS_EVT_RESOLVEDEPS_START, NULL, NULL);
+ EVENT(trans, PM_TRANS_EVT_RESOLVEDEPS_START, NULL, NULL);
_alpm_log(PM_LOG_FLOW1, "resolving targets dependencies");
for(i = trans->packages; i; i = i->next) {
pmsyncpkg_t *sync = i->data;
@@ -362,10 +362,10 @@ int sync_prepare(pmtrans_t *trans, pmdb_t *db_local, PMList *dbs_sync, PMList **
trans->packages = pm_list_add(trans->packages, sync);
}
}
- TRANS_CB(trans, PM_TRANS_EVT_RESOLVEDEPS_DONE, NULL, NULL);
+ EVENT(trans, PM_TRANS_EVT_RESOLVEDEPS_DONE, NULL, NULL);
/* check for inter-conflicts and whatnot */
- TRANS_CB(trans, PM_TRANS_EVT_INTERCONFLICTS_START, NULL, NULL);
+ EVENT(trans, PM_TRANS_EVT_INTERCONFLICTS_START, NULL, NULL);
deps = checkdeps(db_local, PM_TRANS_TYPE_UPGRADE, list);
if(deps) {
int found;
@@ -431,7 +431,7 @@ int sync_prepare(pmtrans_t *trans, pmdb_t *db_local, PMList *dbs_sync, PMList **
RET_ERR(PM_ERR_CONFLICTING_DEPS, -1);
}
}
- TRANS_CB(trans, PM_TRANS_EVT_INTERCONFLICTS_DONE, NULL, NULL);
+ EVENT(trans, PM_TRANS_EVT_INTERCONFLICTS_DONE, NULL, NULL);
FREELISTPTR(list);
FREELISTPTR(trail);
@@ -511,7 +511,7 @@ int sync_commit(pmtrans_t *trans, pmdb_t *db_local)
goto error;
}
/* we want the frontend to be aware of commit details */
- tr->cb = trans->cb;
+ tr->cb_event = trans->cb_event;
if(trans_commit(tr) == -1) {
_alpm_log(PM_LOG_ERROR, "could not commit removal transaction");
pm_errno = PM_ERR_XXX;
@@ -558,7 +558,7 @@ int sync_commit(pmtrans_t *trans, pmdb_t *db_local)
goto error;
}
/* we want the frontend to be aware of commit details */
- tr->cb = trans->cb;
+ tr->cb_event = trans->cb_event;
if(trans_commit(tr) == -1) {
_alpm_log(PM_LOG_ERROR, "could not commit transaction");
pm_errno = PM_ERR_XXX;
diff --git a/lib/libalpm/trans.c b/lib/libalpm/trans.c
index 7f33f13d..c7c4448f 100644
--- a/lib/libalpm/trans.c
+++ b/lib/libalpm/trans.c
@@ -48,7 +48,7 @@ pmtrans_t *trans_new()
trans->packages = NULL;
trans->type = 0;
trans->flags = 0;
- trans->cb = NULL;
+ trans->cb_event = NULL;
trans->state = STATE_IDLE;
return(trans);
@@ -75,7 +75,7 @@ void trans_free(pmtrans_t *trans)
free(trans);
}
-int trans_init(pmtrans_t *trans, unsigned char type, unsigned char flags, alpm_trans_cb cb)
+int trans_init(pmtrans_t *trans, unsigned char type, unsigned char flags, alpm_trans_cb_event event)
{
/* Sanity checks */
if(trans == NULL) {
@@ -88,7 +88,7 @@ int trans_init(pmtrans_t *trans, unsigned char type, unsigned char flags, alpm_t
trans->type = type;
trans->flags = flags;
- trans->cb = cb;
+ trans->cb_event = event;
trans->state = STATE_INITIALIZED;
return(0);
diff --git a/lib/libalpm/trans.h b/lib/libalpm/trans.h
index 403cf116..96b9083b 100644
--- a/lib/libalpm/trans.h
+++ b/lib/libalpm/trans.h
@@ -36,7 +36,7 @@ typedef struct __pmtrans_t {
unsigned char state;
PMList *targets; /* PMList of (char *) */
PMList *packages; /* PMList of (pmpkg_t *) or (pmsyncpkg_t *) */
- alpm_trans_cb cb;
+ alpm_trans_cb_event cb_event;
} pmtrans_t;
#define FREETRANS(p) \
@@ -46,16 +46,16 @@ do { \
p = NULL; \
} \
} while (0)
-#define TRANS_CB(t, e, d1, d2) \
+#define EVENT(t, e, d1, d2) \
do { \
- if((t) && (t)->cb) { \
- (t)->cb(e, d1, d2); \
+ if((t) && (t)->cb_event) { \
+ (t)->cb_event(e, d1, d2); \
} \
} while(0)
pmtrans_t *trans_new();
void trans_free(pmtrans_t *trans);
-int trans_init(pmtrans_t *trans, unsigned char type, unsigned char flags, alpm_trans_cb cb);
+int trans_init(pmtrans_t *trans, unsigned char type, unsigned char flags, alpm_trans_cb_event event);
int trans_sysupgrade(pmtrans_t *trans);
int trans_addtarget(pmtrans_t *trans, char *target);
int trans_prepare(pmtrans_t *trans, PMList **data);