diff options
author | Andrew Gregory <andrew.gregory.8@gmail.com> | 2021-04-25 20:03:54 +0200 |
---|---|---|
committer | Allan McRae <allan@archlinux.org> | 2021-05-01 04:08:14 +0200 |
commit | e7fa35baa22bf6710a904815456d3ff679005fc7 (patch) | |
tree | c988537bbc720da5fce7de30c39e73f6e67a16a0 /src/pacman/conf.c | |
parent | 523c393e9e6175e632d355c9440abb0be164a362 (diff) | |
download | pacman-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 'src/pacman/conf.c')
-rw-r--r-- | src/pacman/conf.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/pacman/conf.c b/src/pacman/conf.c index 0f0c2cfb..12fee64c 100644 --- a/src/pacman/conf.c +++ b/src/pacman/conf.c @@ -278,8 +278,8 @@ static int systemvp(const char *file, char *const argv[]) } /** External fetch callback */ -static int download_with_xfercommand(const char *url, const char *localpath, - int force) +static int download_with_xfercommand(void *ctx, const char *url, + const char *localpath, int force) { int ret = 0, retval; int usepart = 0; @@ -289,6 +289,8 @@ static int download_with_xfercommand(const char *url, const char *localpath, const char **argv; size_t i; + (void)ctx; + if(!config->xfercommand_argv) { return -1; } @@ -843,11 +845,11 @@ static int setup_libalpm(void) } config->handle = handle; - alpm_option_set_logcb(handle, cb_log); - alpm_option_set_dlcb(handle, cb_download); - alpm_option_set_eventcb(handle, cb_event); - alpm_option_set_questioncb(handle, cb_question); - alpm_option_set_progresscb(handle, cb_progress); + alpm_option_set_logcb(handle, cb_log, NULL); + alpm_option_set_dlcb(handle, cb_download, NULL); + alpm_option_set_eventcb(handle, cb_event, NULL); + alpm_option_set_questioncb(handle, cb_question, NULL); + alpm_option_set_progresscb(handle, cb_progress, NULL); if(config->op == PM_OP_FILES) { alpm_option_set_dbext(handle, ".files"); @@ -894,7 +896,7 @@ static int setup_libalpm(void) } if(config->xfercommand) { - alpm_option_set_fetchcb(handle, download_with_xfercommand); + alpm_option_set_fetchcb(handle, download_with_xfercommand, NULL); } else if(!(alpm_capabilities() & ALPM_CAPABILITY_DOWNLOADER)) { pm_printf(ALPM_LOG_WARNING, _("no '%s' configured\n"), "XferCommand"); } |