diff options
Diffstat (limited to 'tools/common.h')
-rw-r--r-- | tools/common.h | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/tools/common.h b/tools/common.h index 2010e9e9d..506b483b9 100644 --- a/tools/common.h +++ b/tools/common.h @@ -11,7 +11,19 @@ #include <unistd.h> #include <getopt.h> -#define error_exit(...) exit((fprintf(stderr, __VA_ARGS__), 1)) +#ifndef PROGRAM_NAME +#error Define PROGRAM_NAME before including common.h! +#endif +#ifndef USAGE_OPTS +#error Define USAGE_OPTS before including common.h! +#endif + +#define error_exit(...) exit((fprintf(stderr, PROGRAM_NAME ": " __VA_ARGS__), 1)) + +void usage_exit(int status) { + fprintf(stderr, "Usage: " PROGRAM_NAME " " USAGE_OPTS "\n"); + exit(status); +} int getopt_long_index; #define getopt_long(argc, argv, optstring, longopts) getopt_long(argc, argv, optstring, longopts, &getopt_long_index) |