// alpm_log.h is the C half of libalpm's log callback (ui.v holds the V // half). the callback takes a va_list, which V cannot receive portably — // a pointer on x86_64, a struct on aarch64 — so the line is formatted here, // with vsnprintf, and handed over whole. only ERROR and WARNING pass, the // levels pacman's cb_log prints by default: alpm_loglevel_t is bit flags #ifndef VPAC_ALPM_LOG_H #define VPAC_ALPM_LOG_H #include #include #include // vpac_log_line is exported by ui.v void vpac_log_line(void *ctx, int level, char *text); static void vpac_alpm_log(void *ctx, alpm_loglevel_t level, const char *fmt, va_list args) { if(!(level & (ALPM_LOG_ERROR | ALPM_LOG_WARNING)) || fmt == NULL || fmt[0] == '\0') { return; } char line[4096]; vsnprintf(line, sizeof line, fmt, args); vpac_log_line(ctx, (int)level, line); } // vpac_set_alpm_log installs the callback, ctx being the run's TransUI static int vpac_set_alpm_log(alpm_handle_t *handle, void *ctx) { return alpm_option_set_logcb(handle, vpac_alpm_log, ctx); } #endif