3 Errors and warnings... */
6 * Copyright (c) 1995 RadioMail Corporation.
7 * Copyright (c) 1996-2000 Internet Software Consortium.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. Neither the name of The Internet Software Consortium nor the names
20 * of its contributors may be used to endorse or promote products derived
21 * from this software without specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND
24 * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
25 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
26 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27 * DISCLAIMED. IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR
28 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
30 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
31 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
32 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
33 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
34 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 * This software was written for RadioMail Corporation by Ted Lemon
38 * under a contract with Vixie Enterprises. Further modifications have
39 * been made for the Internet Software Consortium under a contract
40 * with Vixie Laboratories.
44 static char copyright[] =
45 "$Id: errwarn.c,v 1.9 2000/09/29 20:01:49 mellon Exp $ Copyright (c) 1996 The Internet Software Consortium. All rights reserved.\n";
48 #include <omapip/omapip_p.h>
57 void (*log_cleanup) (void);
59 #define CVT_BUF_MAX 1023
60 static char mbuf [CVT_BUF_MAX + 1];
61 static char fbuf [CVT_BUF_MAX + 1];
63 /* Log an error message, then exit... */
65 void log_fatal (const char * fmt, ... )
69 do_percentm (fbuf, fmt);
72 vsnprintf (mbuf, sizeof mbuf, fbuf, list);
76 syslog (log_priority | LOG_ERR, "%s", mbuf);
79 /* Also log it to stderr? */
81 write (2, mbuf, strlen (mbuf));
85 #if !defined (NOMINUM)
87 log_error ("If you did not get this software from ftp.isc.org, please");
88 log_error ("get the latest from ftp.isc.org and install that before");
89 log_error ("requesting help.");
91 log_error ("If you did get this software from ftp.isc.org and have not");
92 log_error ("yet read the README, please read it before requesting help.");
93 log_error ("If you intend to request help from the dhcp-server@isc.org");
94 log_error ("mailing list, please read the section on the README about");
95 log_error ("submitting bug reports and requests for help.");
97 log_error ("Please do not under any circumstances send requests for");
98 log_error ("help directly to the authors of this software - please");
99 log_error ("send them to the appropriate mailing list as described in");
100 log_error ("the README file.");
101 log_error ("%s", "");
102 log_error ("exiting.");
109 /* Log an error message... */
111 int log_error (const char * fmt, ...)
115 do_percentm (fbuf, fmt);
117 va_start (list, fmt);
118 vsnprintf (mbuf, sizeof mbuf, fbuf, list);
122 syslog (log_priority | LOG_ERR, "%s", mbuf);
126 write (2, mbuf, strlen (mbuf));
135 int log_info (const char *fmt, ...)
139 do_percentm (fbuf, fmt);
141 va_start (list, fmt);
142 vsnprintf (mbuf, sizeof mbuf, fbuf, list);
146 syslog (log_priority | LOG_INFO, "%s", mbuf);
150 write (2, mbuf, strlen (mbuf));
157 /* Log a debug message... */
159 int log_debug (const char *fmt, ...)
163 do_percentm (fbuf, fmt);
165 va_start (list, fmt);
166 vsnprintf (mbuf, sizeof mbuf, fbuf, list);
170 syslog (log_priority | LOG_DEBUG, "%s", mbuf);
174 write (2, mbuf, strlen (mbuf));
181 /* Find %m in the input string and substitute an error message string. */
183 void do_percentm (obuf, ibuf)
187 const char *s = ibuf;
197 m = strerror (errno);
202 m = "<unknown error>";
204 if (len > CVT_BUF_MAX)
210 if (++len > CVT_BUF_MAX)
218 if (++len > CVT_BUF_MAX)
231 extern char *sys_errlist [];
233 static char errbuf [128];
235 if (err < 0 || err >= sys_nerr) {
236 sprintf (errbuf, "Error %d", err);
239 return sys_errlist [err];
241 #endif /* NO_STRERROR */
246 int err = WSAGetLastError ();
251 return "Permission denied";
253 return "Address already in use";
254 case WSAEADDRNOTAVAIL:
255 return "Cannot assign requested address";
256 case WSAEAFNOSUPPORT:
257 return "Address family not supported by protocol family";
259 return "Operation already in progress";
260 case WSAECONNABORTED:
261 return "Software caused connection abort";
262 case WSAECONNREFUSED:
263 return "Connection refused";
265 return "Connection reset by peer";
266 case WSAEDESTADDRREQ:
267 return "Destination address required";
269 return "Bad address";
271 return "Host is down";
272 case WSAEHOSTUNREACH:
273 return "No route to host";
275 return "Operation now in progress";
277 return "Interrupted function call";
279 return "Invalid argument";
281 return "Socket is already connected";
283 return "Too many open files";
285 return "Message too long";
287 return "Network is down";
289 return "Network dropped connection on reset";
291 return "Network is unreachable";
293 return "No buffer space available";
295 return "Bad protocol option";
297 return "Socket is not connected";
299 return "Socket operation on non-socket";
301 return "Operation not supported";
302 case WSAEPFNOSUPPORT:
303 return "Protocol family not supported";
305 return "Too many processes";
306 case WSAEPROTONOSUPPORT:
307 return "Protocol not supported";
309 return "Protocol wrong type for socket";
311 return "Cannot send after socket shutdown";
312 case WSAESOCKTNOSUPPORT:
313 return "Socket type not supported";
315 return "Connection timed out";
317 return "Resource temporarily unavailable";
318 case WSAHOST_NOT_FOUND:
319 return "Host not found";
321 case WSA_INVALID_HANDLE:
322 return "Specified event object handle is invalid";
323 case WSA_INVALID_PARAMETER:
324 return "One or more parameters are invalid";
325 case WSAINVALIDPROCTABLE:
326 return "Invalid procedure table from service provider";
327 case WSAINVALIDPROVIDER:
328 return "Invalid service provider version number";
330 return "Overlapped operations will complete later";
331 case WSA_IO_INCOMPLETE:
332 return "Overlapped I/O event object not in signaled state";
333 case WSA_NOT_ENOUGH_MEMORY:
334 return "Insufficient memory available";
336 case WSANOTINITIALISED:
337 return "Successful WSAStartup not yet performer";
339 return "Valid name, no data record of requested type";
341 return "This is a non-recoverable error";
343 case WSAPROVIDERFAILEDINIT:
344 return "Unable to initialize a service provider";
345 case WSASYSCALLFAILURE:
346 return "System call failure";
349 return "Network subsystem is unavailable";
351 return "Non-authoritative host not found";
352 case WSAVERNOTSUPPORTED:
353 return "WINSOCK.DLL version out of range";
355 return "Graceful shutdown in progress";
357 case WSA_OPERATION_ABORTED:
358 return "Overlapped operation aborted";
361 return "Unknown WinSock error";