argh.  good i looked.  same again, inline.

diff -Napru open.orig/include/err.h open/include/err.h
--- open.orig/include/err.h     2014-01-14 12:12:44.000000000 +0100
+++ open/include/err.h  2014-01-14 13:20:36.000000000 +0100
@@ -51,6 +51,10 @@ __dead void  err(int, const char *, ...)
                        __attribute__((__format__ (printf, 2, 3)));
 __dead void    verr(int, const char *, __va_list)
                        __attribute__((__format__ (printf, 2, 0)));
+__dead void    errc(int, int, const char *, ...)
+                       __attribute__((__format__ (printf, 3, 4)));
+__dead void    verrc(int, int, const char *, __va_list)
+                       __attribute__((__format__ (printf, 3, 0)));
 __dead void    errx(int, const char *, ...)
                        __attribute__((__format__ (printf, 2, 3)));
 __dead void    verrx(int, const char *, __va_list)
@@ -59,6 +63,10 @@ void         warn(const char *, ...)
                        __attribute__((__format__ (printf, 1, 2)));
 void           vwarn(const char *, __va_list)
                        __attribute__((__format__ (printf, 1, 0)));
+void           warnc(int, const char *, ...)
+                       __attribute__((__format__ (printf, 2, 3)));
+void           vwarnc(int, const char *, __va_list)
+                       __attribute__((__format__ (printf, 2, 0)));
 void           warnx(const char *, ...)
                        __attribute__((__format__ (printf, 1, 2)));
 void           vwarnx(const char *, __va_list)
@@ -72,6 +80,10 @@ __dead void  _err(int, const char *, ...)
                        __attribute__((__format__ (printf, 2, 3)));
 __dead void    _verr(int, const char *, __va_list)
                        __attribute__((__format__ (printf, 2, 0)));
+__dead void    _errc(int, int, const char *, ...)
+                       __attribute__((__format__ (printf, 3, 4)));
+__dead void    _verrc(int, int, const char *, __va_list)
+                       __attribute__((__format__ (printf, 3, 0)));
 __dead void    _errx(int, const char *, ...)
                        __attribute__((__format__ (printf, 2, 3)));
 __dead void    _verrx(int, const char *, __va_list)
@@ -80,6 +92,10 @@ void         _warn(const char *, ...)
                        __attribute__((__format__ (printf, 1, 2)));
 void           _vwarn(const char *, __va_list)
                        __attribute__((__format__ (printf, 1, 0)));
+void           _warnc(int, const char *, ...)
+                       __attribute__((__format__ (printf, 2, 3)));
+void           _vwarnc(int, const char *, __va_list)
+                       __attribute__((__format__ (printf, 2, 0)));
 void           _warnx(const char *, ...)
                        __attribute__((__format__ (printf, 1, 2)));
 void           _vwarnx(const char *, __va_list)
diff -Napru open.orig/lib/libc/gen/err.3 open/lib/libc/gen/err.3
--- open.orig/lib/libc/gen/err.3        2014-01-14 13:27:46.000000000 +0100
+++ open/lib/libc/gen/err.3     2014-01-14 13:39:05.000000000 +0100
@@ -33,10 +33,14 @@
 .Sh NAME
 .Nm err ,
 .Nm verr ,
+.Nm errc ,
+.Nm verrc ,
 .Nm errx ,
 .Nm verrx ,
 .Nm warn ,
 .Nm vwarn ,
+.Nm warnc ,
+.Nm vwarnc ,
 .Nm warnx ,
 .Nm vwarnx
 .Nd formatted error messages
@@ -47,6 +51,10 @@
 .Ft void
 .Fn verr "int eval" "const char *fmt" "va_list args"
 .Ft void
+.Fn errc "int eval" "int code" "const char *fmt" "..."
+.Ft void
+.Fn verrc "int eval" "int code" "const char *fmt" "va_list args"
+.Ft void
 .Fn errx "int eval" "const char *fmt" "..."
 .Ft void
 .Fn verrx "int eval" "const char *fmt" "va_list args"
@@ -55,6 +63,10 @@
 .Ft void
 .Fn vwarn "const char *fmt" "va_list args"
 .Ft void
+.Fn warnc "int code" "const char *fmt" "..."
+.Ft void
+.Fn vwarnc "int code" "const char *fmt" "va_list args"
+.Ft void
 .Fn warnx "const char *fmt" "..."
 .Ft void
 .Fn vwarnx "const char *fmt" "va_list args"
@@ -97,6 +109,16 @@ preceded by a colon character and a spac
 .Fa fmt
 is not
 .Dv NULL .
+In case of
+.Fn errc ,
+.Fn verrc ,
+.Fn warnc ,
+and
+.Fn vwarnc
+the argument
+.Fa code
+is used instead of the value of the global variable
+.Va errno .
 That is, the output is as follows:
 .Bd -literal -offset indent
 progname: fmt: error message string
@@ -129,6 +151,8 @@ In all cases, the output is followed by 
 The
 .Fn err ,
 .Fn verr ,
+.Fn errc ,
+.Fn verrc ,
 .Fn errx ,
 and
 .Fn verrx
diff -Napru open.orig/lib/libc/gen/errc.c open/lib/libc/gen/errc.c
--- open.orig/lib/libc/gen/errc.c       1970-01-01 01:00:00.000000000 +0100
+++ open/lib/libc/gen/errc.c    2014-01-14 13:40:06.000000000 +0100
@@ -0,0 +1,45 @@
+/*     $OpenBSD$ */
+/*-
+ * Copyright (c) 1993
+ *     The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <err.h>
+#include <stdarg.h>
+
+__dead void
+_errc(int eval, int code, const char *fmt, ...)
+{
+       va_list ap;
+
+       va_start(ap, fmt);
+       _verrc(eval, code, fmt, ap);
+       va_end(ap);
+}
+
+__weak_alias(errc, _errc);
+
diff -Napru open.orig/lib/libc/gen/verrc.c open/lib/libc/gen/verrc.c
--- open.orig/lib/libc/gen/verrc.c      1970-01-01 01:00:00.000000000 +0100
+++ open/lib/libc/gen/verrc.c   2014-01-14 13:29:30.000000000 +0100
@@ -0,0 +1,51 @@
+/*     $OpenBSD$ */
+/*-
+ * Copyright (c) 1993
+ *     The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <err.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+
+extern char *__progname;               /* Program name, from crt0. */
+
+__dead void
+_verrc(int eval, int code, const char *fmt, va_list ap)
+{
+       (void)fprintf(stderr, "%s: ", __progname);
+       if (fmt != NULL) {
+               (void)vfprintf(stderr, fmt, ap);
+               (void)fprintf(stderr, ": ");
+       }
+       (void)fprintf(stderr, "%s\n", strerror(code));
+       exit(eval);
+}
+
+__weak_alias(verrc, _verrc);
+
diff -Napru open.orig/lib/libc/gen/vwarnc.c open/lib/libc/gen/vwarnc.c
--- open.orig/lib/libc/gen/vwarnc.c     1970-01-01 01:00:00.000000000 +0100
+++ open/lib/libc/gen/vwarnc.c  2014-01-14 13:35:44.000000000 +0100
@@ -0,0 +1,49 @@
+/*     $OpenBSD$ */
+/*-
+ * Copyright (c) 1993
+ *     The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <err.h>
+#include <stdio.h>
+#include <stdarg.h>
+
+extern char *__progname;               /* Program name, from crt0. */
+
+void
+_vwarnc(int code, const char *fmt, va_list ap)
+{
+       (void)fprintf(stderr, "%s: ", __progname);
+       if (fmt != NULL) {
+               (void)vfprintf(stderr, fmt, ap);
+               (void)fprintf(stderr, ": ");
+       }
+       (void)fprintf(stderr, "%s\n", strerror(code));
+}
+
+__weak_alias(vwarnc, _vwarnc);
+
diff -Napru open.orig/lib/libc/gen/warnc.c open/lib/libc/gen/warnc.c
--- open.orig/lib/libc/gen/warnc.c      1970-01-01 01:00:00.000000000 +0100
+++ open/lib/libc/gen/warnc.c   2014-01-14 13:40:15.000000000 +0100
@@ -0,0 +1,45 @@
+/*     $OpenBSD$ */
+/*-
+ * Copyright (c) 1993
+ *     The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <err.h>
+#include <stdarg.h>
+
+void
+_warnc(int code, const char *fmt, ...)
+{
+       va_list ap;
+
+       va_start(ap, fmt);
+       _vwarnc(code, fmt, ap);
+       va_end(ap);
+}
+
+__weak_alias(warnc, _warnc);
+

Reply via email to