+/* Helper functions */
+static void message(FILE *output_fd, const char *prefix, const char *fmt, va_list ap)
+{
+ va_list tmp;
+
+ /* Log to standard out */
+ if (output_fd) {
+ va_copy(tmp, ap);
+ fprintf(output_fd, "%s: ", prefix);
+ vfprintf(output_fd, fmt, tmp);
+ fprintf(output_fd, "\n");
+ }
+
+ /* Log to debug file */
+ if (debug_fd) {
+ va_copy(tmp, ap);
+ fprintf(debug_fd, "%s: ", prefix);
+ vfprintf(debug_fd, fmt, tmp);
+ fprintf(debug_fd, "\n");
+ }
+
+ /* Log to status bar */
+ if (stdscr) {
+ va_copy(tmp, ap);
+ mvhline(LINES-2, 0, ACS_HLINE, COLS);
+ move(LINES-1, 0);
+ attron(COLOR_PAIR(COLOR_ERROR));
+ vwprintw(stdscr, fmt, tmp);
+ attroff(COLOR_PAIR(COLOR_ERROR));
+ clrtoeol();
+ }
+}
+