diff options
Diffstat (limited to 'libvpx/tools_common.c')
-rw-r--r-- | libvpx/tools_common.c | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/libvpx/tools_common.c b/libvpx/tools_common.c index 92de794..44b2a3f 100644 --- a/libvpx/tools_common.c +++ b/libvpx/tools_common.c @@ -7,8 +7,11 @@ * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ -#include <stdio.h> #include "tools_common.h" + +#include <stdarg.h> +#include <stdlib.h> + #if defined(_WIN32) || defined(__OS2__) #include <io.h> #include <fcntl.h> @@ -20,6 +23,18 @@ #endif #endif +#define LOG_ERROR(label) do {\ + const char *l = label;\ + va_list ap;\ + va_start(ap, fmt);\ + if (l)\ + fprintf(stderr, "%s: ", l);\ + vfprintf(stderr, fmt, ap);\ + fprintf(stderr, "\n");\ + va_end(ap);\ +} while (0) + + FILE *set_binary_mode(FILE *stream) { (void)stream; #if defined(_WIN32) || defined(__OS2__) @@ -27,3 +42,17 @@ FILE *set_binary_mode(FILE *stream) { #endif return stream; } + +void die(const char *fmt, ...) { + LOG_ERROR(NULL); + usage_exit(); +} + +void fatal(const char *fmt, ...) { + LOG_ERROR("Fatal"); + exit(EXIT_FAILURE); +} + +void warn(const char *fmt, ...) { + LOG_ERROR("Warning"); +} |