comparison src/w32.c @ 24857:031247d14ba1

(sys_strerror): New function.
author Andrew Innes <andrewi@gnu.org>
date Wed, 16 Jun 1999 20:00:19 +0000
parents fc89585ce76f
children 5f1b1f5fd7c8
comparison
equal deleted inserted replaced
24856:07a04c532706 24857:031247d14ba1
54 #undef dup 54 #undef dup
55 #undef dup2 55 #undef dup2
56 #undef pipe 56 #undef pipe
57 #undef read 57 #undef read
58 #undef write 58 #undef write
59
60 #undef strerror
59 61
60 #include "lisp.h" 62 #include "lisp.h"
61 63
62 #include <pwd.h> 64 #include <pwd.h>
63 65
2354 { 2356 {
2355 if (h_errno == 0 && winsock_lib != NULL) 2357 if (h_errno == 0 && winsock_lib != NULL)
2356 pfn_WSASetLastError (0); 2358 pfn_WSASetLastError (0);
2357 } 2359 }
2358 2360
2361 /* Extend strerror to handle the winsock-specific error codes. */
2362 struct {
2363 int errnum;
2364 char * msg;
2365 } _wsa_errlist[] = {
2366 WSAEINTR , "Interrupted function call",
2367 WSAEBADF , "Bad file descriptor",
2368 WSAEACCES , "Permission denied",
2369 WSAEFAULT , "Bad address",
2370 WSAEINVAL , "Invalid argument",
2371 WSAEMFILE , "Too many open files",
2372
2373 WSAEWOULDBLOCK , "Resource temporarily unavailable",
2374 WSAEINPROGRESS , "Operation now in progress",
2375 WSAEALREADY , "Operation already in progress",
2376 WSAENOTSOCK , "Socket operation on non-socket",
2377 WSAEDESTADDRREQ , "Destination address required",
2378 WSAEMSGSIZE , "Message too long",
2379 WSAEPROTOTYPE , "Protocol wrong type for socket",
2380 WSAENOPROTOOPT , "Bad protocol option",
2381 WSAEPROTONOSUPPORT , "Protocol not supported",
2382 WSAESOCKTNOSUPPORT , "Socket type not supported",
2383 WSAEOPNOTSUPP , "Operation not supported",
2384 WSAEPFNOSUPPORT , "Protocol family not supported",
2385 WSAEAFNOSUPPORT , "Address family not supported by protocol family",
2386 WSAEADDRINUSE , "Address already in use",
2387 WSAEADDRNOTAVAIL , "Cannot assign requested address",
2388 WSAENETDOWN , "Network is down",
2389 WSAENETUNREACH , "Network is unreachable",
2390 WSAENETRESET , "Network dropped connection on reset",
2391 WSAECONNABORTED , "Software caused connection abort",
2392 WSAECONNRESET , "Connection reset by peer",
2393 WSAENOBUFS , "No buffer space available",
2394 WSAEISCONN , "Socket is already connected",
2395 WSAENOTCONN , "Socket is not connected",
2396 WSAESHUTDOWN , "Cannot send after socket shutdown",
2397 WSAETOOMANYREFS , "Too many references", /* not sure */
2398 WSAETIMEDOUT , "Connection timed out",
2399 WSAECONNREFUSED , "Connection refused",
2400 WSAELOOP , "Network loop", /* not sure */
2401 WSAENAMETOOLONG , "Name is too long",
2402 WSAEHOSTDOWN , "Host is down",
2403 WSAEHOSTUNREACH , "No route to host",
2404 WSAENOTEMPTY , "Buffer not empty", /* not sure */
2405 WSAEPROCLIM , "Too many processes",
2406 WSAEUSERS , "Too many users", /* not sure */
2407 WSAEDQUOT , "Double quote in host name", /* really not sure */
2408 WSAESTALE , "Data is stale", /* not sure */
2409 WSAEREMOTE , "Remote error", /* not sure */
2410
2411 WSASYSNOTREADY , "Network subsystem is unavailable",
2412 WSAVERNOTSUPPORTED , "WINSOCK.DLL version out of range",
2413 WSANOTINITIALISED , "Winsock not initialized successfully",
2414 WSAEDISCON , "Graceful shutdown in progress",
2415 #ifdef WSAENOMORE
2416 WSAENOMORE , "No more operations allowed", /* not sure */
2417 WSAECANCELLED , "Operation cancelled", /* not sure */
2418 WSAEINVALIDPROCTABLE , "Invalid procedure table from service provider",
2419 WSAEINVALIDPROVIDER , "Invalid service provider version number",
2420 WSAEPROVIDERFAILEDINIT , "Unable to initialize a service provider",
2421 WSASYSCALLFAILURE , "System call failured",
2422 WSASERVICE_NOT_FOUND , "Service not found", /* not sure */
2423 WSATYPE_NOT_FOUND , "Class type not found",
2424 WSA_E_NO_MORE , "No more resources available", /* really not sure */
2425 WSA_E_CANCELLED , "Operation already cancelled", /* really not sure */
2426 WSAEREFUSED , "Operation refused", /* not sure */
2427 #endif
2428
2429 WSAHOST_NOT_FOUND , "Host not found",
2430 WSATRY_AGAIN , "Authoritative host not found during name lookup",
2431 WSANO_RECOVERY , "Non-recoverable error during name lookup",
2432 WSANO_DATA , "Valid name, no data record of requested type",
2433
2434 -1, NULL
2435 };
2436
2437 char *
2438 sys_strerror(int error_no)
2439 {
2440 int i;
2441 static char unknown_msg[40];
2442
2443 if (error_no >= 0 && error_no < _sys_nerr)
2444 return _sys_errlist[error_no];
2445
2446 for (i = 0; _wsa_errlist[i].errnum >= 0; i++)
2447 if (_wsa_errlist[i].errnum == error_no)
2448 return _wsa_errlist[i].msg;
2449
2450 sprintf(unknown_msg, "Unidentified error: %d", error_no);
2451 return unknown_msg;
2452 }
2453
2359 /* [andrewi 3-May-96] I've had conflicting results using both methods, 2454 /* [andrewi 3-May-96] I've had conflicting results using both methods,
2360 but I believe the method of keeping the socket handle separate (and 2455 but I believe the method of keeping the socket handle separate (and
2361 insuring it is not inheritable) is the correct one. */ 2456 insuring it is not inheritable) is the correct one. */
2362 2457
2363 //#define SOCK_REPLACE_HANDLE 2458 //#define SOCK_REPLACE_HANDLE