summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/pacman/callback.c36
-rw-r--r--src/pacman/callback.h4
-rw-r--r--src/pacman/conf.c1
-rw-r--r--src/util/cleanupdelta.c14
-rw-r--r--src/util/testdb.c14
-rw-r--r--src/util/testpkg.c14
6 files changed, 41 insertions, 42 deletions
diff --git a/src/pacman/callback.c b/src/pacman/callback.c
index 1d68db4c..4993382d 100644
--- a/src/pacman/callback.c
+++ b/src/pacman/callback.c
@@ -281,24 +281,6 @@ void cb_event(alpm_event_t *event)
event->database_missing.dbname);
}
break;
- case ALPM_EVENT_LOG:
- {
- alpm_event_log_t *e = &event->log;
- if(!e->fmt || strlen(e->fmt) == 0) {
- break;
- }
-
- if(on_progress) {
- char *string = NULL;
- pm_vasprintf(&string, e->level, e->fmt, e->args);
- if(string != NULL) {
- output = alpm_list_add(output, string);
- }
- } else {
- pm_vfprintf(stderr, e->level, e->fmt, e->args);
- }
- }
- break;
case ALPM_EVENT_PACNEW_CREATED:
{
alpm_event_pacnew_created_t *e = &event->pacnew_created;
@@ -862,4 +844,22 @@ void cb_dl_progress(const char *filename, off_t file_xfered, off_t file_total)
return;
}
+/* Callback to handle notifications from the library */
+void cb_log(alpm_loglevel_t level, const char *fmt, va_list args)
+{
+ if(!fmt || strlen(fmt) == 0) {
+ return;
+ }
+
+ if(on_progress) {
+ char *string = NULL;
+ pm_vasprintf(&string, level, fmt, args);
+ if(string != NULL) {
+ output = alpm_list_add(output, string);
+ }
+ } else {
+ pm_vfprintf(stderr, level, fmt, args);
+ }
+}
+
/* vim: set noet: */
diff --git a/src/pacman/callback.h b/src/pacman/callback.h
index e4941fc7..5480c73d 100644
--- a/src/pacman/callback.h
+++ b/src/pacman/callback.h
@@ -39,6 +39,10 @@ void cb_dl_total(off_t total);
/* callback to handle display of download progress */
void cb_dl_progress(const char *filename, off_t file_xfered, off_t file_total);
+/* callback to handle messages/notifications from pacman library */
+__attribute__((format(printf, 2, 0)))
+void cb_log(alpm_loglevel_t level, const char *fmt, va_list args);
+
#endif /* _PM_CALLBACK_H */
/* vim: set noet: */
diff --git a/src/pacman/conf.c b/src/pacman/conf.c
index 0e483f77..8b298ccf 100644
--- a/src/pacman/conf.c
+++ b/src/pacman/conf.c
@@ -684,6 +684,7 @@ static int setup_libalpm(void)
}
config->handle = handle;
+ alpm_option_set_logcb(handle, cb_log);
alpm_option_set_dlcb(handle, cb_dl_progress);
alpm_option_set_eventcb(handle, cb_event);
alpm_option_set_questioncb(handle, cb_question);
diff --git a/src/util/cleanupdelta.c b/src/util/cleanupdelta.c
index 190e2c70..4a67fc38 100644
--- a/src/util/cleanupdelta.c
+++ b/src/util/cleanupdelta.c
@@ -35,19 +35,17 @@ static void cleanup(int signum)
exit(signum);
}
-static void output_cb(alpm_event_log_t *event)
+__attribute__((format(printf, 2, 0)))
+static void output_cb(alpm_loglevel_t level, const char *fmt, va_list args)
{
- if(event->type != ALPM_EVENT_LOG) {
- return;
- }
- if(strlen(event->fmt)) {
- switch(event->level) {
+ if(strlen(fmt)) {
+ switch(level) {
case ALPM_LOG_ERROR: printf("error: "); break;
case ALPM_LOG_WARNING: printf("warning: "); break;
/* case ALPM_LOG_DEBUG: printf("debug: "); break; */
default: return;
}
- vprintf(event->fmt, event->args);
+ vprintf(fmt, args);
}
}
@@ -128,7 +126,7 @@ int main(int argc, char *argv[])
}
/* let us get log messages from libalpm */
- alpm_option_set_eventcb(handle, (alpm_cb_event) output_cb);
+ alpm_option_set_logcb(handle, output_cb);
checkdbs(dbnames);
alpm_list_free(dbnames);
diff --git a/src/util/testdb.c b/src/util/testdb.c
index 4d1fd4c8..e3b331ab 100644
--- a/src/util/testdb.c
+++ b/src/util/testdb.c
@@ -39,18 +39,16 @@ static void cleanup(int signum)
exit(signum);
}
-static void output_cb(alpm_event_log_t *event)
+__attribute__((format(printf, 2, 0)))
+static void output_cb(alpm_loglevel_t level, const char *fmt, va_list args)
{
- if(event->type != ALPM_EVENT_LOG) {
- return;
- }
- if(strlen(event->fmt)) {
- switch(event->level) {
+ if(strlen(fmt)) {
+ switch(level) {
case ALPM_LOG_ERROR: printf("error: "); break;
case ALPM_LOG_WARNING: printf("warning: "); break;
default: return;
}
- vprintf(event->fmt, event->args);
+ vprintf(fmt, args);
}
}
@@ -284,7 +282,7 @@ int main(int argc, char *argv[])
}
/* let us get log messages from libalpm */
- alpm_option_set_eventcb(handle, (alpm_cb_event) output_cb);
+ alpm_option_set_logcb(handle, output_cb);
if(!dbnames) {
errors = check_localdb();
diff --git a/src/util/testpkg.c b/src/util/testpkg.c
index 39807feb..cc7d9c2b 100644
--- a/src/util/testpkg.c
+++ b/src/util/testpkg.c
@@ -23,20 +23,18 @@
#include <alpm.h>
-static void output_cb(alpm_event_log_t *event)
+__attribute__((format(printf, 2, 0)))
+static void output_cb(alpm_loglevel_t level, const char *fmt, va_list args)
{
- if(event->type != ALPM_EVENT_LOG) {
+ if(fmt[0] == '\0') {
return;
}
- if(event->fmt[0] == '\0') {
- return;
- }
- switch(event->level) {
+ switch(level) {
case ALPM_LOG_ERROR: printf("error: "); break;
case ALPM_LOG_WARNING: printf("warning: "); break;
default: return; /* skip other messages */
}
- vprintf(event->fmt, event->args);
+ vprintf(fmt, args);
}
int main(int argc, char *argv[])
@@ -61,7 +59,7 @@ int main(int argc, char *argv[])
}
/* let us get log messages from libalpm */
- alpm_option_set_eventcb(handle, (alpm_cb_event) output_cb);
+ alpm_option_set_logcb(handle, output_cb);
/* set gpgdir to default */
alpm_option_set_gpgdir(handle, GPGDIR);