diff util.c @ 794:792be135d3af

Spawn a terminal for the debugger when needed if we are not already attached to one
author Michael Pavone <pavone@retrodev.com>
date Sun, 26 Jul 2015 01:11:04 -0700
parents 724bbec47f86
children 0b692b5d154b
line wrap: on
line diff
--- a/util.c	Sun Jul 26 01:09:05 2015 -0700
+++ b/util.c	Sun Jul 26 01:11:04 2015 -0700
@@ -116,6 +116,35 @@
 	exit(1);
 }
 
+void warning(char *format, ...)
+{
+	va_list args;
+	va_start(args, format);
+#ifndef _WIN32
+	if (headless || (isatty(STDERR_FILENO) && isatty(STDIN_FILENO))) {
+		vfprintf(stderr, format, args);
+	} else {
+#endif
+		size_t size = strlen(format) * 2;
+		char *buf = malloc(size);
+		size_t actual = vsnprintf(buf, size, format, args);
+		if (actual >= size) {
+			actual++;
+			free(buf);
+			buf = malloc(actual);
+			va_end(args);
+			va_start(args, format);
+			vsnprintf(buf, actual, format, args);
+		}
+		fputs(buf, stderr);
+		render_infobox("BlastEm Info", buf);
+		free(buf);
+#ifndef _WIN32
+	}
+#endif
+	va_end(args);
+}
+
 void info_message(char *format, ...)
 {
 	va_list args;