/* * arngment - random music generator * * Written in 2020 by Lucas * * To the extent possible under law, the author(s) have dedicated all * copyright and related and neighboring rights to this software to the * public domain worldwide. This software is distributed without any * warranty. * * You should have received a copy of the CC0 Public Domain Dedication * along with this software. If not, see * . */ #include #include #include #include #include #include "err.h" void err(int eval, const char *fmt, ...) { va_list ap; int saved_errno = errno; fprintf(stderr, "%s: ", __progname); if (fmt != NULL) { va_start(ap, fmt); vfprintf(stderr, fmt, ap); va_end(ap); fprintf(stderr, ": "); } fprintf(stderr, "%s\n", strerror(saved_errno)); exit(eval); } void errx(int eval, const char *fmt, ...) { va_list ap; fprintf(stderr, "%s: ", __progname); if (fmt != NULL) { va_start(ap, fmt); vfprintf(stderr, fmt, ap); va_end(ap); } fprintf(stderr, "\n"); exit(eval); } void warn(const char *fmt, ...) { va_list ap; int saved_errno = errno; fprintf(stderr, "%s: ", __progname); if (fmt != NULL) { va_start(ap, fmt); vfprintf(stderr, fmt, ap); va_end(ap); fprintf(stderr, ": "); } fprintf(stderr, "%s\n", strerror(saved_errno)); } void warnx(const char *fmt, ...) { va_list ap; fprintf(stderr, "%s: ", __progname); if (fmt != NULL) { va_start(ap, fmt); vfprintf(stderr, fmt, ap); va_end(ap); } fprintf(stderr, "\n"); }