diff options
author | jvech <jmvalenciae@unal.edu.co> | 2023-08-16 08:31:33 -0500 |
---|---|---|
committer | jvech <jmvalenciae@unal.edu.co> | 2023-08-16 08:31:33 -0500 |
commit | ba9a7343ad22d507cfaed6b7bb8618a99c2f2976 (patch) | |
tree | 14f5be8b79e89ad3e4aa0a48773a9bf078eb2e0f /src/util.c | |
parent | c888c09e8ecb166efa01929c0f27d5085929a2b2 (diff) |
add: Cli defined
Diffstat (limited to 'src/util.c')
-rw-r--r-- | src/util.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/util.c b/src/util.c new file mode 100644 index 0000000..4a8c3ef --- /dev/null +++ b/src/util.c @@ -0,0 +1,33 @@ +/* See LICENSE file for copyright and license details. */ +#include <string.h> + +#include "util.h" + +void +die(const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + va_end(ap); + + if (fmt[0] && fmt[strlen(fmt)-1] == ':') { + fputc(' ', stderr); + perror(NULL); + } else { + fputc('\n', stderr); + } + + exit(1); +} + +void * +ecalloc(size_t nmemb, size_t size) +{ + void *p; + + if (!(p = calloc(nmemb, size))) + die("calloc:"); + return p; +} |