3 Errors and warnings... */
6 * Copyright (c) 1995 RadioMail Corporation.
7 * Copyright (c) 2004,2007,2009 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
26 * https://www.isc.org/
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.
36 #include <omapip/omapip_p.h>
46 void (*log_cleanup) (void);
48 #define CVT_BUF_MAX 1023
49 static char mbuf [CVT_BUF_MAX + 1];
50 static char fbuf [CVT_BUF_MAX + 1];
52 /* Log an error message, then exit... */
54 void log_fatal (const char * fmt, ... )
58 do_percentm (fbuf, fmt);
60 /* %Audit% This is log output. %2004.06.17,Safe%
61 * If we truncate we hope the user can get a hint from the log.
64 vsnprintf (mbuf, sizeof mbuf, fbuf, list);
68 syslog (log_priority | LOG_ERR, "%s", mbuf);
71 /* Also log it to stderr? */
73 IGNORE_RET (write (STDERR_FILENO, mbuf, strlen (mbuf)));
74 IGNORE_RET (write (STDERR_FILENO, "\n", 1));
77 #if !defined (NOMINUM)
79 log_error ("If you did not get this software from ftp.isc.org, please");
80 log_error ("get the latest from ftp.isc.org and install that before");
81 log_error ("requesting help.");
83 log_error ("If you did get this software from ftp.isc.org and have not");
84 log_error ("yet read the README, please read it before requesting help.");
85 log_error ("If you intend to request help from the dhcp-server@isc.org");
86 log_error ("mailing list, please read the section on the README about");
87 log_error ("submitting bug reports and requests for help.");
89 log_error ("Please do not under any circumstances send requests for");
90 log_error ("help directly to the authors of this software - please");
91 log_error ("send them to the appropriate mailing list as described in");
92 log_error ("the README file.");
94 log_error ("exiting.");
101 /* Log an error message... */
103 int log_error (const char * fmt, ...)
107 do_percentm (fbuf, fmt);
109 /* %Audit% This is log output. %2004.06.17,Safe%
110 * If we truncate we hope the user can get a hint from the log.
112 va_start (list, fmt);
113 vsnprintf (mbuf, sizeof mbuf, fbuf, list);
117 syslog (log_priority | LOG_ERR, "%s", mbuf);
121 IGNORE_RET (write (STDERR_FILENO, mbuf, strlen (mbuf)));
122 IGNORE_RET (write (STDERR_FILENO, "\n", 1));
130 int log_info (const char *fmt, ...)
134 do_percentm (fbuf, fmt);
136 /* %Audit% This is log output. %2004.06.17,Safe%
137 * If we truncate we hope the user can get a hint from the log.
139 va_start (list, fmt);
140 vsnprintf (mbuf, sizeof mbuf, fbuf, list);
144 syslog (log_priority | LOG_INFO, "%s", mbuf);
148 IGNORE_RET (write (STDERR_FILENO, mbuf, strlen (mbuf)));
149 IGNORE_RET (write (STDERR_FILENO, "\n", 1));
155 /* Log a debug message... */
157 int log_debug (const char *fmt, ...)
161 do_percentm (fbuf, fmt);
163 /* %Audit% This is log output. %2004.06.17,Safe%
164 * If we truncate we hope the user can get a hint from the log.
166 va_start (list, fmt);
167 vsnprintf (mbuf, sizeof mbuf, fbuf, list);
171 syslog (log_priority | LOG_DEBUG, "%s", mbuf);
175 IGNORE_RET (write (STDERR_FILENO, mbuf, strlen (mbuf)));
176 IGNORE_RET (write (STDERR_FILENO, "\n", 1));
182 /* Find %m in the input string and substitute an error message string. */
184 void do_percentm (obuf, ibuf)
188 const char *s = ibuf;
198 m = strerror (errno);
203 m = "<unknown error>";
205 if (len > CVT_BUF_MAX)
211 if (++len > CVT_BUF_MAX)
219 if (++len > CVT_BUF_MAX)
232 extern char *sys_errlist [];
234 static char errbuf [128];
236 if (err < 0 || err >= sys_nerr) {
237 sprintf (errbuf, "Error %d", err);
240 return sys_errlist [err];
242 #endif /* NO_STRERROR */
247 int err = WSAGetLastError ();
252 return "Permission denied";
254 return "Address already in use";
255 case WSAEADDRNOTAVAIL:
256 return "Cannot assign requested address";
257 case WSAEAFNOSUPPORT:
258 return "Address family not supported by protocol family";
260 return "Operation already in progress";
261 case WSAECONNABORTED:
262 return "Software caused connection abort";
263 case WSAECONNREFUSED:
264 return "Connection refused";
266 return "Connection reset by peer";
267 case WSAEDESTADDRREQ:
268 return "Destination address required";
270 return "Bad address";
272 return "Host is down";
273 case WSAEHOSTUNREACH:
274 return "No route to host";
276 return "Operation now in progress";
278 return "Interrupted function call";
280 return "Invalid argument";
282 return "Socket is already connected";
284 return "Too many open files";
286 return "Message too long";
288 return "Network is down";
290 return "Network dropped connection on reset";
292 return "Network is unreachable";
294 return "No buffer space available";
296 return "Bad protocol option";
298 return "Socket is not connected";
300 return "Socket operation on non-socket";
302 return "Operation not supported";
303 case WSAEPFNOSUPPORT:
304 return "Protocol family not supported";
306 return "Too many processes";
307 case WSAEPROTONOSUPPORT:
308 return "Protocol not supported";
310 return "Protocol wrong type for socket";
312 return "Cannot send after socket shutdown";
313 case WSAESOCKTNOSUPPORT:
314 return "Socket type not supported";
316 return "Connection timed out";
318 return "Resource temporarily unavailable";
319 case WSAHOST_NOT_FOUND:
320 return "Host not found";
322 case WSA_INVALID_HANDLE:
323 return "Specified event object handle is invalid";
324 case WSA_INVALID_PARAMETER:
325 return "One or more parameters are invalid";
326 case WSAINVALIDPROCTABLE:
327 return "Invalid procedure table from service provider";
328 case WSAINVALIDPROVIDER:
329 return "Invalid service provider version number";
331 return "Overlapped operations will complete later";
332 case WSA_IO_INCOMPLETE:
333 return "Overlapped I/O event object not in signaled state";
334 case WSA_NOT_ENOUGH_MEMORY:
335 return "Insufficient memory available";
337 case WSANOTINITIALISED:
338 return "Successful WSAStartup not yet performer";
340 return "Valid name, no data record of requested type";
342 return "This is a non-recoverable error";
344 case WSAPROVIDERFAILEDINIT:
345 return "Unable to initialize a service provider";
346 case WSASYSCALLFAILURE:
347 return "System call failure";
350 return "Network subsystem is unavailable";
352 return "Non-authoritative host not found";
353 case WSAVERNOTSUPPORTED:
354 return "WINSOCK.DLL version out of range";
356 return "Graceful shutdown in progress";
358 case WSA_OPERATION_ABORTED:
359 return "Overlapped operation aborted";
362 return "Unknown WinSock error";