diff options
Diffstat (limited to 'common/compat.c')
-rw-r--r-- | common/compat.c | 164 |
1 files changed, 0 insertions, 164 deletions
diff --git a/common/compat.c b/common/compat.c index fe16e07..a22071a 100644 --- a/common/compat.c +++ b/common/compat.c @@ -185,170 +185,6 @@ p11_thread_join (p11_thread_t thread) #endif /* OS_WIN32 */ -#ifndef HAVE_ERR_H - -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <stdarg.h> - -static FILE *err_file; /* file to use for error output */ - -/* - * This is declared to take a `void *' so that the caller is not required - * to include <stdio.h> first. However, it is really a `FILE *', and the - * manual page documents it as such. - */ -void -err_set_file (void *fp) -{ - if (fp) - err_file = fp; - else - err_file = stderr; -} - -void -err (int eval, - const char *fmt, - ...) -{ - va_list ap; - va_start(ap, fmt); - verrc(eval, errno, fmt, ap); - va_end(ap); -} - -void -verr (int eval, - const char *fmt, - va_list ap) -{ - verrc(eval, errno, fmt, ap); -} - -void -errc (int eval, - int code, - const char *fmt, - ...) -{ - va_list ap; - va_start(ap, fmt); - verrc(eval, code, fmt, ap); - va_end(ap); -} - -void -verrc (int eval, - int code, - const char *fmt, - va_list ap) -{ - if (err_file == 0) - err_set_file((FILE *)0); - fprintf(err_file, "%s: ", getprogname ()); - if (fmt != NULL) { - vfprintf(err_file, fmt, ap); - fprintf(err_file, ": "); - } - fprintf(err_file, "%s\n", strerror(code)); - exit(eval); -} - -void -errx (int eval, - const char *fmt, - ...) -{ - va_list ap; - va_start(ap, fmt); - verrx(eval, fmt, ap); - va_end(ap); -} - -void -verrx (int eval, - const char *fmt, - va_list ap) -{ - if (err_file == 0) - err_set_file((FILE *)0); - fprintf(err_file, "%s: ", getprogname ()); - if (fmt != NULL) - vfprintf(err_file, fmt, ap); - fprintf(err_file, "\n"); - exit(eval); -} - -void -warn (const char *fmt, - ...) -{ - va_list ap; - va_start(ap, fmt); - vwarnc(errno, fmt, ap); - va_end(ap); -} - -void -vwarn (const char *fmt, - va_list ap) -{ - vwarnc(errno, fmt, ap); -} - -void -warnc (int code, - const char *fmt, - ...) -{ - va_list ap; - va_start(ap, fmt); - vwarnc(code, fmt, ap); - va_end(ap); -} - -void -vwarnc (int code, - const char *fmt, - va_list ap) -{ - if (err_file == 0) - err_set_file((FILE *)0); - fprintf(err_file, "%s: ", getprogname ()); - if (fmt != NULL) - { - vfprintf(err_file, fmt, ap); - fprintf(err_file, ": "); - } - fprintf(err_file, "%s\n", strerror(code)); -} - -void -warnx (const char *fmt, - ...) -{ - va_list ap; - va_start(ap, fmt); - vwarnx(fmt, ap); - va_end(ap); -} - -void -vwarnx (const char *fmt, - va_list ap) -{ - if(err_file == 0) - err_set_file((FILE*)0); - fprintf(err_file, "%s: ", getprogname ()); - if(fmt != NULL) - vfprintf(err_file, fmt, ap); - fprintf(err_file, "\n"); -} - -#endif /* HAVE_ERR_H */ - #ifndef HAVE_MEMDUP void * |