1 #if WIN32
2 #define WIN32_LEAN_AND_MEAN
3 #include <windows.h>
4 #endif
5 
6 #include <stdarg.h>
7 #include <stdio.h>
8 #include <stdlib.h>
9 
10 #include "error.h"
11 
info(const char * format,...)12 void info(const char* format, ...)
13 {
14   va_list args;
15 
16   va_start(args, format);
17 
18   vfprintf(stderr, format, args);
19   fwrite("\n", 1, 1, stderr);
20 }
21 
fatal_error(const char * format,...)22 void fatal_error(const char* format, ...)
23 {
24   va_list args;
25 
26   va_start(args, format);
27 
28 #if WIN32
29   char buf[512];
30 
31   vsnprintf(buf, sizeof(buf), format, args);
32   buf[sizeof(buf) - 1] = 0;
33 
34   MessageBox(0, buf, "Fatal Error", MB_OK | MB_ICONEXCLAMATION);
35 #else
36   vfprintf(stderr, format, args);
37   fwrite("\n", 1, 1, stderr);
38 #endif
39 
40   exit(EXIT_FAILURE);
41 }
42