Factor out usage_exit into into tools/common.h
This commit is contained in:
@@ -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)
|
||||
|
Reference in New Issue
Block a user