summaryrefslogtreecommitdiffstats
path: root/lib/libalpm/handle.c
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.c
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.c')
-rw-r--r--lib/libalpm/handle.c54
1 files changed, 48 insertions, 6 deletions
diff --git a/lib/libalpm/handle.c b/lib/libalpm/handle.c
index 46224a25..e6b683cb 100644
--- a/lib/libalpm/handle.c
+++ b/lib/libalpm/handle.c
@@ -162,36 +162,72 @@ alpm_cb_log SYMEXPORT alpm_option_get_logcb(alpm_handle_t *handle)
return handle->logcb;
}
+void SYMEXPORT *alpm_option_get_logcb_ctx(alpm_handle_t *handle)
+{
+ CHECK_HANDLE(handle, return NULL);
+ return handle->logcb_ctx;
+}
+
alpm_cb_download SYMEXPORT alpm_option_get_dlcb(alpm_handle_t *handle)
{
CHECK_HANDLE(handle, return NULL);
return handle->dlcb;
}
+void SYMEXPORT *alpm_option_get_dlcb_ctx(alpm_handle_t *handle)
+{
+ CHECK_HANDLE(handle, return NULL);
+ return handle->dlcb_ctx;
+}
+
alpm_cb_fetch SYMEXPORT alpm_option_get_fetchcb(alpm_handle_t *handle)
{
CHECK_HANDLE(handle, return NULL);
return handle->fetchcb;
}
+void SYMEXPORT *alpm_option_get_fetchcb_ctx(alpm_handle_t *handle)
+{
+ CHECK_HANDLE(handle, return NULL);
+ return handle->fetchcb_ctx;
+}
+
alpm_cb_event SYMEXPORT alpm_option_get_eventcb(alpm_handle_t *handle)
{
CHECK_HANDLE(handle, return NULL);
return handle->eventcb;
}
+void SYMEXPORT *alpm_option_get_eventcb_ctx(alpm_handle_t *handle)
+{
+ CHECK_HANDLE(handle, return NULL);
+ return handle->eventcb_ctx;
+}
+
alpm_cb_question SYMEXPORT alpm_option_get_questioncb(alpm_handle_t *handle)
{
CHECK_HANDLE(handle, return NULL);
return handle->questioncb;
}
+void SYMEXPORT *alpm_option_get_questioncb_ctx(alpm_handle_t *handle)
+{
+ CHECK_HANDLE(handle, return NULL);
+ return handle->questioncb_ctx;
+}
+
alpm_cb_progress SYMEXPORT alpm_option_get_progresscb(alpm_handle_t *handle)
{
CHECK_HANDLE(handle, return NULL);
return handle->progresscb;
}
+void SYMEXPORT *alpm_option_get_progresscb_ctx(alpm_handle_t *handle)
+{
+ CHECK_HANDLE(handle, return NULL);
+ return handle->progresscb_ctx;
+}
+
const char SYMEXPORT *alpm_option_get_root(alpm_handle_t *handle)
{
CHECK_HANDLE(handle, return NULL);
@@ -300,45 +336,51 @@ int SYMEXPORT alpm_option_get_parallel_downloads(alpm_handle_t *handle)
return handle->parallel_downloads;
}
-int SYMEXPORT alpm_option_set_logcb(alpm_handle_t *handle, alpm_cb_log cb)
+int SYMEXPORT alpm_option_set_logcb(alpm_handle_t *handle, alpm_cb_log cb, void *ctx)
{
CHECK_HANDLE(handle, return -1);
handle->logcb = cb;
+ handle->logcb_ctx = ctx;
return 0;
}
-int SYMEXPORT alpm_option_set_dlcb(alpm_handle_t *handle, alpm_cb_download cb)
+int SYMEXPORT alpm_option_set_dlcb(alpm_handle_t *handle, alpm_cb_download cb, void *ctx)
{
CHECK_HANDLE(handle, return -1);
handle->dlcb = cb;
+ handle->dlcb_ctx = ctx;
return 0;
}
-int SYMEXPORT alpm_option_set_fetchcb(alpm_handle_t *handle, alpm_cb_fetch cb)
+int SYMEXPORT alpm_option_set_fetchcb(alpm_handle_t *handle, alpm_cb_fetch cb, void *ctx)
{
CHECK_HANDLE(handle, return -1);
handle->fetchcb = cb;
+ handle->fetchcb_ctx = ctx;
return 0;
}
-int SYMEXPORT alpm_option_set_eventcb(alpm_handle_t *handle, alpm_cb_event cb)
+int SYMEXPORT alpm_option_set_eventcb(alpm_handle_t *handle, alpm_cb_event cb, void *ctx)
{
CHECK_HANDLE(handle, return -1);
handle->eventcb = cb;
+ handle->eventcb_ctx = ctx;
return 0;
}
-int SYMEXPORT alpm_option_set_questioncb(alpm_handle_t *handle, alpm_cb_question cb)
+int SYMEXPORT alpm_option_set_questioncb(alpm_handle_t *handle, alpm_cb_question cb, void *ctx)
{
CHECK_HANDLE(handle, return -1);
handle->questioncb = cb;
+ handle->questioncb_ctx = ctx;
return 0;
}
-int SYMEXPORT alpm_option_set_progresscb(alpm_handle_t *handle, alpm_cb_progress cb)
+int SYMEXPORT alpm_option_set_progresscb(alpm_handle_t *handle, alpm_cb_progress cb, void *ctx)
{
CHECK_HANDLE(handle, return -1);
handle->progresscb = cb;
+ handle->progresscb_ctx = ctx;
return 0;
}