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.3 2005/08/11 17:13:30 drochner 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.
67 vsnprintf (mbuf
, sizeof mbuf
, fmt
, list
);
71 syslog (log_priority
| LOG_ERR
, "%s", mbuf
);
74 /* Also log it to stderr? */
76 write (STDERR_FILENO
, mbuf
, strlen (mbuf
));
77 write (STDERR_FILENO
, "\n", 1);
80 #if !defined (NOMINUM)
82 log_error ("If you did not get this software from ftp.isc.org, please");
83 log_error ("get the latest from ftp.isc.org and install that before");
84 log_error ("requesting help.");
86 log_error ("If you did get this software from ftp.isc.org and have not");
87 log_error ("yet read the README, please read it before requesting help.");
88 log_error ("If you intend to request help from the dhcp-server@isc.org");
89 log_error ("mailing list, please read the section on the README about");
90 log_error ("submitting bug reports and requests for help.");
92 log_error ("Please do not under any circumstances send requests for");
93 log_error ("help directly to the authors of this software - please");
94 log_error ("send them to the appropriate mailing list as described in");
95 log_error ("the README file.");
97 log_error ("exiting.");
104 /* Log an error message... */
106 int log_error (const char * fmt
, ...)
110 do_percentm (fbuf
, fmt
);
112 /* %Audit% This is log output. %2004.06.17,Safe%
113 * If we truncate we hope the user can get a hint from the log.
115 va_start (list
, fmt
);
117 vsnprintf (mbuf
, sizeof mbuf
, fmt
, list
);
121 syslog (log_priority
| LOG_ERR
, "%s", mbuf
);
125 write (STDERR_FILENO
, mbuf
, strlen (mbuf
));
126 write (STDERR_FILENO
, "\n", 1);
134 int log_info (const char *fmt
, ...)
138 do_percentm (fbuf
, fmt
);
140 /* %Audit% This is log output. %2004.06.17,Safe%
141 * If we truncate we hope the user can get a hint from the log.
143 va_start (list
, fmt
);
145 vsnprintf (mbuf
, sizeof mbuf
, fmt
, list
);
149 syslog (log_priority
| LOG_INFO
, "%s", mbuf
);
153 write (STDERR_FILENO
, mbuf
, strlen (mbuf
));
154 write (STDERR_FILENO
, "\n", 1);
160 /* Log a debug message... */
162 int log_debug (const char *fmt
, ...)
166 do_percentm (fbuf
, fmt
);
168 /* %Audit% This is log output. %2004.06.17,Safe%
169 * If we truncate we hope the user can get a hint from the log.
171 va_start (list
, fmt
);
173 vsnprintf (mbuf
, sizeof mbuf
, fmt
, list
);
177 syslog (log_priority
| LOG_DEBUG
, "%s", mbuf
);
181 write (STDERR_FILENO
, mbuf
, strlen (mbuf
));
182 write (STDERR_FILENO
, "\n", 1);
188 /* Find %m in the input string and substitute an error message string. */
190 void do_percentm (obuf
, ibuf
)
194 const char *s
= ibuf
;
204 m
= strerror (errno
);
209 m
= "<unknown error>";
211 if (len
> CVT_BUF_MAX
)
217 if (++len
> CVT_BUF_MAX
)
225 if (++len
> CVT_BUF_MAX
)
238 extern char *sys_errlist
[];
240 static char errbuf
[128];
242 if (err
< 0 || err
>= sys_nerr
) {
243 sprintf (errbuf
, "Error %d", err
);
246 return sys_errlist
[err
];
248 #endif /* NO_STRERROR */
253 int err
= WSAGetLastError ();
258 return "Permission denied";
260 return "Address already in use";
261 case WSAEADDRNOTAVAIL
:
262 return "Cannot assign requested address";
263 case WSAEAFNOSUPPORT
:
264 return "Address family not supported by protocol family";
266 return "Operation already in progress";
267 case WSAECONNABORTED
:
268 return "Software caused connection abort";
269 case WSAECONNREFUSED
:
270 return "Connection refused";
272 return "Connection reset by peer";
273 case WSAEDESTADDRREQ
:
274 return "Destination address required";
276 return "Bad address";
278 return "Host is down";
279 case WSAEHOSTUNREACH
:
280 return "No route to host";
282 return "Operation now in progress";
284 return "Interrupted function call";
286 return "Invalid argument";
288 return "Socket is already connected";
290 return "Too many open files";
292 return "Message too long";
294 return "Network is down";
296 return "Network dropped connection on reset";
298 return "Network is unreachable";
300 return "No buffer space available";
302 return "Bad protocol option";
304 return "Socket is not connected";
306 return "Socket operation on non-socket";
308 return "Operation not supported";
309 case WSAEPFNOSUPPORT
:
310 return "Protocol family not supported";
312 return "Too many processes";
313 case WSAEPROTONOSUPPORT
:
314 return "Protocol not supported";
316 return "Protocol wrong type for socket";
318 return "Cannot send after socket shutdown";
319 case WSAESOCKTNOSUPPORT
:
320 return "Socket type not supported";
322 return "Connection timed out";
324 return "Resource temporarily unavailable";
325 case WSAHOST_NOT_FOUND
:
326 return "Host not found";
328 case WSA_INVALID_HANDLE
:
329 return "Specified event object handle is invalid";
330 case WSA_INVALID_PARAMETER
:
331 return "One or more parameters are invalid";
332 case WSAINVALIDPROCTABLE
:
333 return "Invalid procedure table from service provider";
334 case WSAINVALIDPROVIDER
:
335 return "Invalid service provider version number";
337 return "Overlapped operations will complete later";
338 case WSA_IO_INCOMPLETE
:
339 return "Overlapped I/O event object not in signaled state";
340 case WSA_NOT_ENOUGH_MEMORY
:
341 return "Insufficient memory available";
343 case WSANOTINITIALISED
:
344 return "Successful WSAStartup not yet performer";
346 return "Valid name, no data record of requested type";
348 return "This is a non-recoverable error";
350 case WSAPROVIDERFAILEDINIT
:
351 return "Unable to initialize a service provider";
352 case WSASYSCALLFAILURE
:
353 return "System call failure";
356 return "Network subsystem is unavailable";
358 return "Non-authoritative host not found";
359 case WSAVERNOTSUPPORTED
:
360 return "WINSOCK.DLL version out of range";
362 return "Graceful shutdown in progress";
364 case WSA_OPERATION_ABORTED
:
365 return "Overlapped operation aborted";
368 return "Unknown WinSock error";