source: trunk/third/tcp_wrappers/diag.c @ 11717

Revision 11717, 1.4 KB checked in by danw, 26 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r11716, which included commits to RCS files with non-trunk default branches.
Line 
1 /*
2  * Routines to report various classes of problems. Each report is decorated
3  * with the current context (file name and line number), if available.
4  *
5  * tcpd_warn() reports a problem and proceeds.
6  *
7  * tcpd_jump() reports a problem and jumps.
8  *
9  * Author: Wietse Venema, Eindhoven University of Technology, The Netherlands.
10  */
11
12#ifndef lint
13static char sccsid[] = "@(#) diag.c 1.1 94/12/28 17:42:20";
14#endif
15
16/* System libraries */
17
18#include <syslog.h>
19#include <stdio.h>
20#include <setjmp.h>
21
22/* Local stuff */
23
24#include "tcpd.h"
25#include "mystdarg.h"
26
27struct tcpd_context tcpd_context;
28jmp_buf tcpd_buf;
29
30/* tcpd_diag - centralize error reporter */
31
32static void tcpd_diag(severity, tag, format, ap)
33int     severity;
34char   *tag;
35char   *format;
36va_list ap;
37{
38    char    fmt[BUFSIZ];
39
40    if (tcpd_context.file)
41        sprintf(fmt, "%s: %s, line %d: %s",
42                tag, tcpd_context.file, tcpd_context.line, format);
43    else
44        sprintf(fmt, "%s: %s", tag, format);
45    vsyslog(severity, fmt, ap);
46}
47
48/* tcpd_warn - report problem of some sort and proceed */
49
50void    VARARGS(tcpd_warn, char *, format)
51{
52    va_list ap;
53
54    VASTART(ap, char *, format);
55    tcpd_diag(LOG_ERR, "warning", format, ap);
56    VAEND(ap);
57}
58
59/* tcpd_jump - report serious problem and jump */
60
61void    VARARGS(tcpd_jump, char *, format)
62{
63    va_list ap;
64
65    VASTART(ap, char *, format);
66    tcpd_diag(LOG_ERR, "error", format, ap);
67    VAEND(ap);
68    longjmp(tcpd_buf, AC_ERROR);
69}
Note: See TracBrowser for help on using the repository browser.