Add errc(3) family.
This commit is contained in:
parent
4890297611
commit
a942b15f91
|
@ -331,13 +331,17 @@ dirent/rewinddir.o \
|
||||||
dirent/scandir.o \
|
dirent/scandir.o \
|
||||||
dlfcn/dlfcn.o \
|
dlfcn/dlfcn.o \
|
||||||
err/err.o \
|
err/err.o \
|
||||||
|
err/errc.o \
|
||||||
err/errx.o \
|
err/errx.o \
|
||||||
error/gnu_error.o \
|
error/gnu_error.o \
|
||||||
err/verr.o \
|
err/verr.o \
|
||||||
|
err/verrc.o \
|
||||||
err/verrx.o \
|
err/verrx.o \
|
||||||
err/vwarn.o \
|
err/vwarn.o \
|
||||||
|
err/vwarnc.o \
|
||||||
err/vwarnx.o \
|
err/vwarnx.o \
|
||||||
err/warn.o \
|
err/warn.o \
|
||||||
|
err/warnc.o \
|
||||||
err/warnx.o \
|
err/warnx.o \
|
||||||
fcntl/creat.o \
|
fcntl/creat.o \
|
||||||
fcntl/fcntl.o \
|
fcntl/fcntl.o \
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2016 Nicholas De Nova.
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*
|
||||||
|
* err/errc.c
|
||||||
|
* Print an error message to stderr.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <err.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
void errc(int exitcode, int errnum, const char* fmt, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, fmt);
|
||||||
|
verrc(exitcode, errnum, fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2016 Nicholas De Nova.
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*
|
||||||
|
* err/verrc.c
|
||||||
|
* Print an error message to stderr.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <err.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
void verrc(int exitcode, int errnum, const char* fmt, va_list ap)
|
||||||
|
{
|
||||||
|
vwarnc(errnum, fmt, ap);
|
||||||
|
exit(exitcode);
|
||||||
|
}
|
|
@ -25,14 +25,5 @@
|
||||||
|
|
||||||
void vwarn(const char* fmt, va_list ap)
|
void vwarn(const char* fmt, va_list ap)
|
||||||
{
|
{
|
||||||
int errnum = errno;
|
vwarnc(errno, fmt, ap);
|
||||||
flockfile(stderr);
|
|
||||||
fprintf_unlocked(stderr, "%s: ", program_invocation_name);
|
|
||||||
if ( fmt )
|
|
||||||
{
|
|
||||||
vfprintf_unlocked(stderr, fmt, ap);
|
|
||||||
fputs_unlocked(": ", stderr);
|
|
||||||
}
|
|
||||||
fprintf_unlocked(stderr, "%s\n", strerror(errnum));
|
|
||||||
funlockfile(stderr);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2016 Jonas 'Sortie' Termansen.
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*
|
||||||
|
* err/vwarnc.c
|
||||||
|
* Print an error message to stderr.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <err.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
void vwarnc(int errnum, const char* fmt, va_list ap)
|
||||||
|
{
|
||||||
|
flockfile(stderr);
|
||||||
|
fprintf_unlocked(stderr, "%s: ", program_invocation_name);
|
||||||
|
if ( fmt )
|
||||||
|
{
|
||||||
|
vfprintf_unlocked(stderr, fmt, ap);
|
||||||
|
fputs_unlocked(": ", stderr);
|
||||||
|
}
|
||||||
|
fprintf_unlocked(stderr, "%s\n", strerror(errnum));
|
||||||
|
funlockfile(stderr);
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2016 Nicholas De Nova.
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*
|
||||||
|
* err/warnc.c
|
||||||
|
* Print an error message to stderr.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <err.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
void warnc(int errnum, const char* fmt, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, fmt);
|
||||||
|
vwarnc(errnum, fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
}
|
|
@ -30,18 +30,26 @@ extern "C" {
|
||||||
|
|
||||||
__attribute__((__noreturn__, __format__(__printf__, 2, 3)))
|
__attribute__((__noreturn__, __format__(__printf__, 2, 3)))
|
||||||
void err(int, const char*, ...);
|
void err(int, const char*, ...);
|
||||||
|
__attribute__((__noreturn__, __format__(__printf__, 3, 4)))
|
||||||
|
void errc(int, int, const char*, ...);
|
||||||
__attribute__((__noreturn__, __format__(__printf__, 2, 3)))
|
__attribute__((__noreturn__, __format__(__printf__, 2, 3)))
|
||||||
void errx(int, const char*, ...);
|
void errx(int, const char*, ...);
|
||||||
__attribute__((__noreturn__, __format__(__printf__, 2, 0)))
|
__attribute__((__noreturn__, __format__(__printf__, 2, 0)))
|
||||||
void verr(int, const char*, va_list);
|
void verr(int, const char*, va_list);
|
||||||
|
__attribute__((__noreturn__, __format__(__printf__, 3, 0)))
|
||||||
|
void verrc(int, int, const char*, va_list);
|
||||||
__attribute__((__noreturn__, __format__(__printf__, 2, 0)))
|
__attribute__((__noreturn__, __format__(__printf__, 2, 0)))
|
||||||
void verrx(int, const char*, va_list);
|
void verrx(int, const char*, va_list);
|
||||||
__attribute__((__format__(__printf__, 1, 2)))
|
__attribute__((__format__(__printf__, 1, 2)))
|
||||||
void warn(const char*, ...);
|
void warn(const char*, ...);
|
||||||
|
__attribute__((__format__(__printf__, 2, 3)))
|
||||||
|
void warnc(int, const char*, ...);
|
||||||
__attribute__((__format__(__printf__, 1, 2)))
|
__attribute__((__format__(__printf__, 1, 2)))
|
||||||
void warnx(const char*, ...);
|
void warnx(const char*, ...);
|
||||||
__attribute__((__format__(__printf__, 1, 0)))
|
__attribute__((__format__(__printf__, 1, 0)))
|
||||||
void vwarn(const char*, va_list);
|
void vwarn(const char*, va_list);
|
||||||
|
__attribute__((__format__(__printf__, 2, 0)))
|
||||||
|
void vwarnc(int, const char*, va_list);
|
||||||
__attribute__((__format__(__printf__, 1, 0)))
|
__attribute__((__format__(__printf__, 1, 0)))
|
||||||
void vwarnx(const char*, va_list);
|
void vwarnx(const char*, va_list);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue