From 3e68e19f056aa97f40dce239f0475bebc88441d7 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Thu, 6 Nov 2003 21:31:24 +0000 Subject: * bsdlib.cc (_vwarnx): New function. (vwarn): Ditto. (vwarnx): Ditto. (warn): Ditto. (warnx): Ditto. (verr): Ditto. (verrx): Ditto. (err): Ditto. (errx): Ditto. * cygwin.din: Export above functions. * include/err.h: New file. * include/cygwin/version.h: Bump API minor number. --- winsup/cygwin/libc/bsdlib.cc | 73 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) (limited to 'winsup/cygwin/libc') diff --git a/winsup/cygwin/libc/bsdlib.cc b/winsup/cygwin/libc/bsdlib.cc index acf43adbf..6d2375331 100644 --- a/winsup/cygwin/libc/bsdlib.cc +++ b/winsup/cygwin/libc/bsdlib.cc @@ -31,7 +31,9 @@ */ #include "winsup.h" +#include #include +#include #include #include #include @@ -163,3 +165,74 @@ forkpty (int *amaster, char *name, struct termios *termp, struct winsize *winp) return pid; } +extern "C" char *__progname; + +static void +_vwarnx (const char *fmt, va_list ap) +{ + fprintf (stderr, "%s: ", __progname); + vfprintf (stderr, fmt, ap); +} + +extern "C" void +vwarn (const char *fmt, va_list ap) +{ + _vwarnx (fmt, ap); + fprintf (stderr, ": %s", strerror (get_errno ())); + fputc ('\n', stderr); +} + +extern "C" void +vwarnx (const char *fmt, va_list ap) +{ + _vwarnx (fmt, ap); + fputc ('\n', stderr); +} + +extern "C" void +warn (const char *fmt, ...) +{ + va_list ap; + va_start (ap, fmt); + vwarn (fmt, ap); +} + +extern "C" void +warnx (const char *fmt, ...) +{ + va_list ap; + va_start (ap, fmt); + vwarnx (fmt, ap); +} + +extern "C" void +verr (int eval, const char *fmt, va_list ap) +{ + vwarn (fmt, ap); + exit (eval); +} + +extern "C" void +verrx (int eval, const char *fmt, va_list ap) +{ + vwarnx (fmt, ap); + exit (eval); +} + +extern "C" void +err (int eval, const char *fmt, ...) +{ + va_list ap; + va_start (ap, fmt); + vwarn (fmt, ap); + exit (eval); +} + +extern "C" void +errx (int eval, const char *fmt, ...) +{ + va_list ap; + va_start (ap, fmt); + vwarnx (fmt, ap); + exit (eval); +} -- cgit v1.2.3