changeset 675:6d877c46f83d

err: provided by libbsd
author David Demelier <markand@malikania.fr>
date Thu, 24 Mar 2022 07:32:10 +0100
parents 06d62ae43367
children a84f1baeb9e7
files c/err/err.c c/err/err.h
diffstat 2 files changed, 0 insertions(+), 176 deletions(-) [+]
line wrap: on
line diff
--- a/c/err/err.c	Thu Mar 24 07:31:32 2022 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,114 +0,0 @@
-/*
- * err.c -- formtted error messages (portable version)
- *
- * Copyright (c) 2011-2019 David Demelier <markand@malikania.fr>
- *
- * Permission to use, copy, modify, and/or 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.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-#include <errno.h>
-
-#include "err.h"
-
-/*
- * These functions implements at least the same functions that can be found
- * in the NetBSD err(3) man page without printing the programe name due to
- * a portability issue.
- */
-
-void
-err(int val, const char *fmt, ...)
-{
-	va_list ap;
-
-	va_start(ap, fmt);
-	verr(val, fmt, ap);
-	va_end(ap);
-}
-
-void
-verr(int val, const char *fmt, va_list ap)
-{
-	if (fmt) {
-		vfprintf(stderr, fmt, ap);
-		fprintf(stderr, ": ");
-	}
-
-	fprintf(stderr, "%s\n", strerror(errno));
-	exit(val);
-}
-
-void
-errx(int val, const char *fmt, ...)
-{
-	va_list ap;
-
-	va_start(ap, fmt);
-	verrx(val, fmt, ap);
-	va_end(ap);
-}
-
-void
-verrx(int val, const char *fmt, va_list ap)
-{
-	if (fmt)
-		vfprintf(stderr, fmt, ap);
-
-	fprintf(stderr, "\n");
-
-	exit(val);
-}
-
-void
-warn(const char *fmt, ...)
-{
-	va_list ap;
-
-	va_start(ap, fmt);
-	vwarn(fmt, ap);
-	va_end(ap);
-}
-
-void
-vwarn(const char *fmt, va_list ap)
-{
-	if (fmt) {
-		vfprintf(stderr, fmt, ap);
-		fprintf(stderr, ": ");
-	}
-
-	fprintf(stderr, "%s\n", strerror(errno));
-}
-
-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 (fmt)
-		vfprintf(stderr, fmt, ap);
-
-	fprintf(stderr, "\n");
-}
--- a/c/err/err.h	Thu Mar 24 07:31:32 2022 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,62 +0,0 @@
-/*
- * err.h -- formtted error messages (portable version)
- *
- * Copyright (c) 2011-2019 David Demelier <markand@malikania.fr>
- *
- * Permission to use, copy, modify, and/or 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.
- */
-
-#ifndef ERR_H
-#define ERR_H
-
-#include <stdarg.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#if defined(__GNUC__)
-#	define ERR_NORETURN __attribute__ ((noreturn))
-#elif defined(_MSC_VER)
-#	define ERR_NORETURN __declspec(noreturn)
-#endif
-
-void
-err(int, const char *, ...) ERR_NORETURN;
-
-void
-verr(int, const char *, va_list) ERR_NORETURN;
-
-void
-errx(int, const char *, ...) ERR_NORETURN;
-
-void
-verrx(int, const char *, va_list) ERR_NORETURN;
-
-void
-warn(const char *, ...);
-
-void
-vwarn(const char *, va_list);
-
-void
-warnx(const char *, ...);
-
-void
-vwarnx(const char *, va_list);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* ERR_H */