diff options
Diffstat (limited to 'common.h')
-rw-r--r-- | common.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/common.h b/common.h new file mode 100644 index 0000000..82a6328 --- /dev/null +++ b/common.h @@ -0,0 +1,24 @@ +#ifndef NQ_COMMON_H +#define NQ_COMMON_H + +#include <errno.h> +#include <stdio.h> + +extern const char *progname; + +#define ERROR(...) \ + do { \ + fprintf(stderr, "%s: ", progname); \ + fprintf(stderr, __VA_ARGS__); \ + fprintf(stderr, "\n"); \ + } while (0) + +#define PERROR(str) \ + do { \ + int err = errno; \ + fprintf(stderr, "%s: ", progname); \ + errno = err; \ + perror(str); \ + } while (0) + +#endif |