From bee8b42029900ca034675c54d98813a61ca4407a Mon Sep 17 00:00:00 2001 From: Michael Pavone Date: Sun, 26 Jul 2015 01:11:04 -0700 Subject: Spawn a terminal for the debugger when needed if we are not already attached to one --- util.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'util.c') diff --git a/util.c b/util.c index 3ad290d..c0131b2 100644 --- a/util.c +++ b/util.c @@ -116,6 +116,35 @@ void fatal_error(char *format, ...) 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; -- cgit v1.2.3