3 Errors and warnings... */
6 * Copyright (c) 1995 RadioMail Corporation.
7 * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
8 * Copyright (c) 1996-2003 by Internet Software Consortium
10 * Permission to use, copy, modify, and distribute this software for any
11 * purpose with or without fee is hereby granted, provided that the above
12 * copyright notice and this permission notice appear in all copies.
14 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
15 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
16 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
17 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
20 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22 * Internet Systems Consortium, Inc.
24 * Redwood City, CA 94063
28 * This software was written for RadioMail Corporation by Ted Lemon
29 * under a contract with Vixie Enterprises. Further modifications have
30 * been made for Internet Systems Consortium under a contract
31 * with Vixie Laboratories.
35 static char copyright[] =
36 "$Id: errwarn.c,v 1.9.2.3 2004/09/30 20:38:32 dhankins Exp $ Copyright (c) 2004 Internet Systems Consortium. All rights reserved.\n";
39 #include <omapip/omapip_p.h>
48 void (*log_cleanup) (void);
50 #define CVT_BUF_MAX 1023
51 static char mbuf [CVT_BUF_MAX + 1];
52 static char fbuf [CVT_BUF_MAX + 1];
54 /* Log an error message, then exit... */
56 void log_fatal (const char * fmt, ... )
60 do_percentm (fbuf, fmt);
62 /* %Audit% This is log output. %2004.06.17,Safe%
63 * If we truncate we hope the user can get a hint from the log.
66 vsnprintf (mbuf, sizeof mbuf, fbuf, list);
70 syslog (log_priority | LOG_ERR, "%s", mbuf);
73 /* Also log it to stderr? */
75 write (STDERR_FILENO, mbuf, strlen (mbuf));
76 write (STDERR_FILENO, "\n", 1);
79 #if !defined (NOMINUM)
81 log_error ("If you did not get this software from ftp.isc.org, please");
82 log_error ("get the latest from ftp.isc.org and install that before");
83 log_error ("requesting help.");
85 log_error ("If you did get this software from ftp.isc.org and have not");
86 log_error ("yet read the README, please read it before requesting help.");
87 log_error ("If you intend to request help from the dhcp-server@isc.org");
88 log_error ("mailing list, please read the section on the README about");
89 log_error ("submitting bug reports and requests for help.");
91 log_error ("Please do not under any circumstances send requests for");
92 log_error ("help directly to the authors of this software - please");
93 log_error ("send them to the appropriate mailing list as described in");
94 log_error ("the README file.");
96 log_error ("exiting.");
103 /* Log an error message... */
105 int log_error (const char * fmt, ...)
109 do_percentm (fbuf, fmt);
111 /* %Audit% This is log output. %2004.06.17,Safe%
112 * If we truncate we hope the user can get a hint from the log.
114 va_start (list, fmt);
115 vsnprintf (mbuf, sizeof mbuf, fbuf, list);
119 syslog (log_priority | LOG_ERR, "%s", mbuf);
123 write (STDERR_FILENO, mbuf, strlen (mbuf));
124 write (STDERR_FILENO, "\n", 1);
132 int log_info (const char *fmt, ...)
136 do_percentm (fbuf, fmt);
138 /* %Audit% This is log output. %2004.06.17,Safe%
139 * If we truncate we hope the user can get a hint from the log.
141 va_start (list, fmt);
142 vsnprintf (mbuf, sizeof mbuf, fbuf, list);
146 syslog (log_priority | LOG_INFO, "%s", mbuf);
150 write (STDERR_FILENO, mbuf, strlen (mbuf));
151 write (STDERR_FILENO, "\n", 1);
157 /* Log a debug message... */
159 int log_debug (const char *fmt, ...)
163 do_percentm (fbuf, fmt);
165 /* %Audit% This is log output. %2004.06.17,Safe%
166 * If we truncate we hope the user can get a hint from the log.
168 va_start (list, fmt);
169 vsnprintf (mbuf, sizeof mbuf, fbuf, list);
173 syslog (log_priority | LOG_DEBUG, "%s", mbuf);
177 write (STDERR_FILENO, mbuf, strlen (mbuf));
178 write (STDERR_FILENO, "\n", 1);
184 /* Find %m in the input string and substitute an error message string. */
186 void do_percentm (obuf, ibuf)
190 const char *s = ibuf;
200 m = strerror (errno);
205 m = "<unknown error>";
207 if (len > CVT_BUF_MAX)
213 if (++len > CVT_BUF_MAX)
221 if (++len > CVT_BUF_MAX)
234 extern char *sys_errlist [];
236 static char errbuf [128];
238 if (err < 0 || err >= sys_nerr) {
239 sprintf (errbuf, "Error %d", err);
242 return sys_errlist [err];
244 #endif /* NO_STRERROR */
249 int err = WSAGetLastError ();
254 return "Permission denied";
256 return "Address already in use";
257 case WSAEADDRNOTAVAIL:
258 return "Cannot assign requested address";
259 case WSAEAFNOSUPPORT:
260 return "Address family not supported by protocol family";
262 return "Operation already in progress";
263 case WSAECONNABORTED:
264 return "Software caused connection abort";
265 case WSAECONNREFUSED:
266 return "Connection refused";
268 return "Connection reset by peer";
269 case WSAEDESTADDRREQ:
270 return "Destination address required";
272 return "Bad address";
274 return "Host is down";
275 case WSAEHOSTUNREACH:
276 return "No route to host";
278 return "Operation now in progress";
280 return "Interrupted function call";
282 return "Invalid argument";
284 return "Socket is already connected";
286 return "Too many open files";
288 return "Message too long";
290 return "Network is down";
292 return "Network dropped connection on reset";
294 return "Network is unreachable";
296 return "No buffer space available";
298 return "Bad protocol option";
300 return "Socket is not connected";
302 return "Socket operation on non-socket";
304 return "Operation not supported";
305 case WSAEPFNOSUPPORT:
306 return "Protocol family not supported";
308 return "Too many processes";
309 case WSAEPROTONOSUPPORT:
310 return "Protocol not supported";
312 return "Protocol wrong type for socket";
314 return "Cannot send after socket shutdown";
315 case WSAESOCKTNOSUPPORT:
316 return "Socket type not supported";
318 return "Connection timed out";
320 return "Resource temporarily unavailable";
321 case WSAHOST_NOT_FOUND:
322 return "Host not found";
324 case WSA_INVALID_HANDLE:
325 return "Specified event object handle is invalid";
326 case WSA_INVALID_PARAMETER:
327 return "One or more parameters are invalid";
328 case WSAINVALIDPROCTABLE:
329 return "Invalid procedure table from service provider";
330 case WSAINVALIDPROVIDER:
331 return "Invalid service provider version number";
333 return "Overlapped operations will complete later";
334 case WSA_IO_INCOMPLETE:
335 return "Overlapped I/O event object not in signaled state";
336 case WSA_NOT_ENOUGH_MEMORY:
337 return "Insufficient memory available";
339 case WSANOTINITIALISED:
340 return "Successful WSAStartup not yet performer";
342 return "Valid name, no data record of requested type";
344 return "This is a non-recoverable error";
346 case WSAPROVIDERFAILEDINIT:
347 return "Unable to initialize a service provider";
348 case WSASYSCALLFAILURE:
349 return "System call failure";
352 return "Network subsystem is unavailable";
354 return "Non-authoritative host not found";
355 case WSAVERNOTSUPPORTED:
356 return "WINSOCK.DLL version out of range";
358 return "Graceful shutdown in progress";
360 case WSA_OPERATION_ABORTED:
361 return "Overlapped operation aborted";
364 return "Unknown WinSock error";