summaryrefslogtreecommitdiffstats
path: root/lib/libalpm/handle.h
diff options
context:
space:
mode:
authorAndrew Gregory <andrew.gregory.8@gmail.com>2021-04-25 20:03:54 +0200
committerAllan McRae <allan@archlinux.org>2021-05-01 04:08:14 +0200
commite7fa35baa22bf6710a904815456d3ff679005fc7 (patch)
treec988537bbc720da5fce7de30c39e73f6e67a16a0 /lib/libalpm/handle.h
parent523c393e9e6175e632d355c9440abb0be164a362 (diff)
downloadpacman-e7fa35baa22bf6710a904815456d3ff679005fc7.tar.gz
pacman-e7fa35baa22bf6710a904815456d3ff679005fc7.tar.xz
add front-end provided context to callbacks
Our callbacks require front-ends to maintain state in order to provide reasonable output. The new download callback in particular requires much more complex state information to be saved. Without the ability to provide context, state must be saved globally, which may not be possible for all front-ends. Scripting language bindings in particular have no way to register per-handle callbacks without some form of context. Implements: FS#12721 Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Diffstat (limited to 'lib/libalpm/handle.h')
-rw-r--r--lib/libalpm/handle.h12
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/libalpm/handle.h b/lib/libalpm/handle.h
index 52dc2125..b1526c67 100644
--- a/lib/libalpm/handle.h
+++ b/lib/libalpm/handle.h
@@ -34,19 +34,19 @@
#define EVENT(h, e) \
do { \
if((h)->eventcb) { \
- (h)->eventcb((alpm_event_t *) (e)); \
+ (h)->eventcb((h)->eventcb_ctx, (alpm_event_t *) (e)); \
} \
} while(0)
#define QUESTION(h, q) \
do { \
if((h)->questioncb) { \
- (h)->questioncb((alpm_question_t *) (q)); \
+ (h)->questioncb((h)->questioncb_ctx, (alpm_question_t *) (q)); \
} \
} while(0)
#define PROGRESS(h, e, p, per, n, r) \
do { \
if((h)->progresscb) { \
- (h)->progresscb(e, p, per, n, r); \
+ (h)->progresscb((h)->progresscb_ctx, e, p, per, n, r); \
} \
} while(0)
@@ -72,11 +72,17 @@ struct __alpm_handle_t {
/* callback functions */
alpm_cb_log logcb; /* Log callback function */
+ void *logcb_ctx;
alpm_cb_download dlcb; /* Download callback function */
+ void *dlcb_ctx;
alpm_cb_fetch fetchcb; /* Download file callback function */
+ void *fetchcb_ctx;
alpm_cb_event eventcb;
+ void *eventcb_ctx;
alpm_cb_question questioncb;
+ void *questioncb_ctx;
alpm_cb_progress progresscb;
+ void *progresscb_ctx;
/* filesystem paths */
char *root; /* Root path, default '/' */