summaryrefslogtreecommitdiff
path: root/lib/libwrap/diag.c
diff options
context:
space:
mode:
authorJason Downs <downsj@cvs.openbsd.org>1997-02-26 03:07:00 +0000
committerJason Downs <downsj@cvs.openbsd.org>1997-02-26 03:07:00 +0000
commit805f364a7afb206a7c89e333232aca351b6e19e0 (patch)
treeabb8889a3045ea5aa67c32f60cbd18196419b899 /lib/libwrap/diag.c
parent69b5d60558dcb932964f8d6d64517209707041b5 (diff)
Initial integration of a much cleaned up libwrap.
Diffstat (limited to 'lib/libwrap/diag.c')
-rw-r--r--lib/libwrap/diag.c75
1 files changed, 75 insertions, 0 deletions
diff --git a/lib/libwrap/diag.c b/lib/libwrap/diag.c
new file mode 100644
index 00000000000..ed8d064ed56
--- /dev/null
+++ b/lib/libwrap/diag.c
@@ -0,0 +1,75 @@
+/* $OpenBSD: diag.c,v 1.1 1997/02/26 03:06:50 downsj Exp $ */
+
+ /*
+ * Routines to report various classes of problems. Each report is decorated
+ * with the current context (file name and line number), if available.
+ *
+ * tcpd_warn() reports a problem and proceeds.
+ *
+ * tcpd_jump() reports a problem and jumps.
+ *
+ * Author: Wietse Venema, Eindhoven University of Technology, The Netherlands.
+ */
+
+#ifndef lint
+#if 0
+static char sccsid[] = "@(#) diag.c 1.1 94/12/28 17:42:20";
+#else
+static char rcsid[] = "$OpenBSD: diag.c,v 1.1 1997/02/26 03:06:50 downsj Exp $";
+#endif
+#endif
+
+/* System libraries */
+
+#include <syslog.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <setjmp.h>
+
+/* Local stuff */
+
+#include "tcpd.h"
+
+struct tcpd_context tcpd_context;
+jmp_buf tcpd_buf;
+
+/* tcpd_diag - centralize error reporter */
+
+static void tcpd_diag(severity, tag, format, ap)
+int severity;
+char *tag;
+char *format;
+va_list ap;
+{
+ char fmt[BUFSIZ];
+
+ if (tcpd_context.file)
+ sprintf(fmt, "%s: %s, line %d: %s",
+ tag, tcpd_context.file, tcpd_context.line, format);
+ else
+ sprintf(fmt, "%s: %s", tag, format);
+ vsyslog(severity, fmt, ap);
+}
+
+/* tcpd_warn - report problem of some sort and proceed */
+
+void VARARGS(tcpd_warn, char *, format)
+{
+ va_list ap;
+
+ VASTART(ap, char *, format);
+ tcpd_diag(LOG_ERR, "warning", format, ap);
+ VAEND(ap);
+}
+
+/* tcpd_jump - report serious problem and jump */
+
+void VARARGS(tcpd_jump, char *, format)
+{
+ va_list ap;
+
+ VASTART(ap, char *, format);
+ tcpd_diag(LOG_ERR, "error", format, ap);
+ VAEND(ap);
+ longjmp(tcpd_buf, AC_ERROR);
+}