diff options
author | Rich Felker <dalias@aerifal.cx> | 2011-04-05 11:16:49 -0400 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2011-04-05 11:16:49 -0400 |
commit | 39e48531eff4e3c3e3e6d1339ff6085f1e2f69bc (patch) | |
tree | 904d053864371a3dd3ffd88c5635d1cf539d3ccb /src/linux | |
parent | 25ce7621e0cbbbc7d31f016f0840a07b12e68912 (diff) | |
download | musl-39e48531eff4e3c3e3e6d1339ff6085f1e2f69bc.tar.gz musl-39e48531eff4e3c3e3e6d1339ff6085f1e2f69bc.tar.bz2 musl-39e48531eff4e3c3e3e6d1339ff6085f1e2f69bc.tar.xz musl-39e48531eff4e3c3e3e6d1339ff6085f1e2f69bc.zip |
support the nonstandard err.h interfaces
note that unlike the originals, these do not print the program
name/argv[0] because we have not saved it anywhere. this could be
changed in __libc_start_main if desired.
Diffstat (limited to 'src/linux')
-rw-r--r-- | src/linux/err.c | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/src/linux/err.c b/src/linux/err.c new file mode 100644 index 00000000..abc26806 --- /dev/null +++ b/src/linux/err.c @@ -0,0 +1,60 @@ +#include <err.h> +#include <stdio.h> +#include <stdarg.h> +#include <stdlib.h> + +void vwarn(const char *fmt, va_list ap) +{ + vfprintf(stderr, fmt, ap); + perror(""); +} + +void vwarnx(const char *fmt, va_list ap) +{ + vfprintf(stderr, fmt, ap); + putc('\n', stderr); +} + +void verr(int status, const char *fmt, va_list ap) +{ + vwarn(fmt, ap); + exit(status); +} + +void verrx(int status, const char *fmt, va_list ap) +{ + vwarnx(fmt, ap); + exit(status); +} + +void warn(const char *fmt, ...) +{ + va_list ap; + va_start(ap, fmt); + vwarn(fmt, ap); + va_end(ap); +} + +void warnx(const char *fmt, ...) +{ + va_list ap; + va_start(ap, fmt); + vwarnx(fmt, ap); + va_end(ap); +} + +void err(int status, const char *fmt, ...) +{ + va_list ap; + va_start(ap, fmt); + verr(status, fmt, ap); + va_end(ap); +} + +void errx(int status, const char *fmt, ...) +{ + va_list ap; + va_start(ap, fmt); + verrx(status, fmt, ap); + va_end(ap); +} |