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 * @(#) diag.c 1.1 94/12/28 17:42:20 12 * $DragonFly: src/contrib/tcp_wrappers/diag.c,v 1.2 2005/09/15 04:33:04 sephe Exp $ 13 */ 14 15 /* System libraries */ 16 17 #include <syslog.h> 18 #include <setjmp.h> 19 #include <stdarg.h> 20 21 /* Local stuff */ 22 23 #include "tcpd.h" 24 25 struct tcpd_context tcpd_context; 26 jmp_buf tcpd_buf; 27 28 /* tcpd_diag - centralize error reporter */ 29 30 static void 31 tcpd_diag(int severity, const char *tag, const char *format, va_list ap) 32 { 33 char fmt[BUFSIZ]; 34 35 if (tcpd_context.file) 36 sprintf(fmt, "%s: %s, line %d: %s", 37 tag, tcpd_context.file, tcpd_context.line, format); 38 else 39 sprintf(fmt, "%s: %s", tag, format); 40 vsyslog(severity, fmt, ap); 41 } 42 43 /* tcpd_warn - report problem of some sort and proceed */ 44 45 void 46 tcpd_warn(const char *format, ...) 47 { 48 va_list ap; 49 50 va_start(ap, format); 51 tcpd_diag(LOG_ERR, "warning", format, ap); 52 va_end(ap); 53 } 54 55 /* tcpd_jump - report serious problem and jump */ 56 57 void 58 tcpd_jump(const char *format, ...) 59 { 60 va_list ap; 61 62 va_start(ap, format); 63 tcpd_diag(LOG_ERR, "error", format, ap); 64 va_end(ap); 65 longjmp(tcpd_buf, AC_ERROR); 66 } 67