#include "io.h" const int COLOR_RED = 31; const int COLOR_GREEN = 32; const int COLOR_YELLOW = 33; static void colored_print (gint color, const gchar *fmt, va_list args) { gchar *s; s = g_strdup_vprintf (fmt, args); g_print ("%c[%d;%dm%s%c[%dm", 0x1B, 1, color, s, 0x1b, 0); g_free (s); } void warn (const gchar *fmt, ...) { va_list args; va_start (args, fmt); colored_print (COLOR_YELLOW, fmt, args); va_end (args); } void err (const gchar *fmt, ...) { va_list args; va_start (args, fmt); colored_print (COLOR_RED, fmt, args); va_end (args); } void info (const gchar *fmt, ...) { va_list args; gchar *s; va_start (args, fmt); g_print ("%c[%d;%dm>%c[%dm ", 0x1B, 1, COLOR_GREEN, 0x1b, 0); s = g_strdup_vprintf (fmt, args); g_print ("%s", s); va_end (args); g_free (s); }