Mercurial > repos > blastem
comparison 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 |
comparison
equal
deleted
inserted
replaced
793:9aff36a172b2 | 794:792be135d3af |
---|---|
114 } | 114 } |
115 va_end(args); | 115 va_end(args); |
116 exit(1); | 116 exit(1); |
117 } | 117 } |
118 | 118 |
119 void info_message(char *format, ...) | 119 void warning(char *format, ...) |
120 { | 120 { |
121 va_list args; | 121 va_list args; |
122 va_start(args, format); | 122 va_start(args, format); |
123 #ifndef _WIN32 | 123 #ifndef _WIN32 |
124 if (headless || (isatty(STDOUT_FILENO) && isatty(STDIN_FILENO))) { | 124 if (headless || (isatty(STDERR_FILENO) && isatty(STDIN_FILENO))) { |
125 vprintf(format, args); | 125 vfprintf(stderr, format, args); |
126 } else { | 126 } else { |
127 #endif | 127 #endif |
128 size_t size = strlen(format) * 2; | 128 size_t size = strlen(format) * 2; |
129 char *buf = malloc(size); | 129 char *buf = malloc(size); |
130 size_t actual = vsnprintf(buf, size, format, args); | 130 size_t actual = vsnprintf(buf, size, format, args); |
134 buf = malloc(actual); | 134 buf = malloc(actual); |
135 va_end(args); | 135 va_end(args); |
136 va_start(args, format); | 136 va_start(args, format); |
137 vsnprintf(buf, actual, format, args); | 137 vsnprintf(buf, actual, format, args); |
138 } | 138 } |
139 fputs(buf, stderr); | |
140 render_infobox("BlastEm Info", buf); | |
141 free(buf); | |
142 #ifndef _WIN32 | |
143 } | |
144 #endif | |
145 va_end(args); | |
146 } | |
147 | |
148 void info_message(char *format, ...) | |
149 { | |
150 va_list args; | |
151 va_start(args, format); | |
152 #ifndef _WIN32 | |
153 if (headless || (isatty(STDOUT_FILENO) && isatty(STDIN_FILENO))) { | |
154 vprintf(format, args); | |
155 } else { | |
156 #endif | |
157 size_t size = strlen(format) * 2; | |
158 char *buf = malloc(size); | |
159 size_t actual = vsnprintf(buf, size, format, args); | |
160 if (actual >= size) { | |
161 actual++; | |
162 free(buf); | |
163 buf = malloc(actual); | |
164 va_end(args); | |
165 va_start(args, format); | |
166 vsnprintf(buf, actual, format, args); | |
167 } | |
139 fputs(buf, stdout); | 168 fputs(buf, stdout); |
140 render_infobox("BlastEm Info", buf); | 169 render_infobox("BlastEm Info", buf); |
141 free(buf); | 170 free(buf); |
142 #ifndef _WIN32 | 171 #ifndef _WIN32 |
143 } | 172 } |