dmake: do not set MAKEFLAGS=k
[unleashed/tickless.git] / usr / src / lib / libwrap / diag.c
blob8fd6a92cab2778bd0b1c9d0be77af96b507f074b
1 /*
2 * Copyright 2001 Sun Microsystems, Inc. All rights reserved.
3 * Use is subject to license terms.
4 */
5 #pragma ident "%Z%%M% %I% %E% SMI"
7 /*
8 * Routines to report various classes of problems. Each report is decorated
9 * with the current context (file name and line number), if available.
11 * tcpd_warn() reports a problem and proceeds.
13 * tcpd_jump() reports a problem and jumps.
15 * Author: Wietse Venema, Eindhoven University of Technology, The Netherlands.
18 static char sccsid[] = "@(#) diag.c 1.1 94/12/28 17:42:20";
20 /* System libraries */
22 #include <syslog.h>
23 #include <stdio.h>
24 #include <setjmp.h>
26 /* Local stuff */
28 #include "tcpd.h"
29 #include "mystdarg.h"
31 struct tcpd_context tcpd_context;
32 jmp_buf tcpd_buf;
34 /* tcpd_diag - centralize error reporter */
36 static void tcpd_diag(severity, tag, format, ap)
37 int severity;
38 char *tag;
39 char *format;
40 va_list ap;
42 char fmt[BUFSIZ];
44 if (tcpd_context.file)
45 sprintf(fmt, "%s: %s, line %d: %s",
46 tag, tcpd_context.file, tcpd_context.line, format);
47 else
48 sprintf(fmt, "%s: %s", tag, format);
49 vsyslog(severity, fmt, ap);
52 /* tcpd_warn - report problem of some sort and proceed */
54 void VARARGS(tcpd_warn, char *, format)
56 va_list ap;
58 VASTART(ap, char *, format);
59 tcpd_diag(LOG_ERR, "warning", format, ap);
60 VAEND(ap);
63 /* tcpd_jump - report serious problem and jump */
65 void VARARGS(tcpd_jump, char *, format)
67 va_list ap;
69 VASTART(ap, char *, format);
70 tcpd_diag(LOG_ERR, "error", format, ap);
71 VAEND(ap);
72 longjmp(tcpd_buf, AC_ERROR);