diff options
author | sinanmohd <sinan@firemail.cc> | 2023-05-22 15:25:25 +0530 |
---|---|---|
committer | sinanmohd <sinan@firemail.cc> | 2023-06-26 12:59:10 +0530 |
commit | d7ce046606ce05dd8a37e83fc48667bbe4c20093 (patch) | |
tree | 7e8d44431998e8c9d80f39165b6525866ddb5856 /util.c |
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 22 |
1 files changed, 22 insertions, 0 deletions
@@ -0,0 +1,22 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <stdarg.h> +#include <errno.h> +#include "util.h" + +void die(const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + fprintf(stderr, "error: "); + vfprintf(stderr, fmt, ap); + if (errno) + fprintf(stderr, " (%d): %s\n", errno, strerror(errno)); + else + fputc('\n', stderr);; + va_end(ap); + + exit(errno); +} |