summaryrefslogtreecommitdiffstats
path: root/ui.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2021-12-31 23:20:41 +0100
committerMattias Andrée <maandree@kth.se>2021-12-31 23:20:41 +0100
commit8f2a555f900228b531edba5e44e2e0cd7e8fe61e (patch)
tree51dd5bada07ce28f9022a6410fadcb74a3362310 /ui.c
downloadmakel-8f2a555f900228b531edba5e44e2e0cd7e8fe61e.tar.gz
makel-8f2a555f900228b531edba5e44e2e0cd7e8fe61e.tar.bz2
makel-8f2a555f900228b531edba5e44e2e0cd7e8fe61e.tar.xz
First commit
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r--ui.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/ui.c b/ui.c
new file mode 100644
index 0000000..e23916e
--- /dev/null
+++ b/ui.c
@@ -0,0 +1,47 @@
+/* See LICENSE file for copyright and license details. */
+#include "common.h"
+
+
+struct warning_class_data warning_classes[] = {
+#define X(ENUM, NAME, ACTION) {NAME, ACTION},
+ LIST_WARNING_CLASSES(X)
+#undef X
+ {NULL, 0}
+};
+
+
+static void
+vxprintwarningf(enum warning_class class, int severity, const char *fmt, va_list ap)
+{
+ if (warning_classes[class].action != IGNORE) {
+ fprintf(stderr, "%s: [%s] ", argv0,
+ warning_classes[class].action == INFORM ? "info" : "warn");
+ vfprintf(stderr, fmt, ap);
+ fprintf(stderr, " (-w%s)\n", warning_classes[class].name);
+ if (warning_classes[class].action != INFORM)
+ exit_status = MAX(exit_status, severity);
+ }
+}
+
+
+void
+xprintwarningf(enum warning_class class, int severity, const char *fmt, ...)
+{
+ va_list ap;
+ va_start(ap, fmt);
+ vxprintwarningf(class, severity, fmt, ap);
+ va_end(ap);
+}
+
+
+void
+printerrorf(const char *fmt, ...)
+{
+ va_list ap;
+ va_start(ap, fmt);
+ fprintf(stderr, "%s: [error] ", argv0);
+ vfprintf(stderr, fmt, ap);
+ fprintf(stderr, "\n");
+ va_end(ap);
+ exit(EXIT_CRITICAL);
+}