secondary cache feature in vm.
[minix.git] / lib / libc / ip / gai_strerror.c
blobccb0acfa56eb083ca60cfc2ba5e3f11f4ed58ef3
1 #include <errno.h>
2 #include <netdb.h>
3 #include <stdio.h>
4 #include <string.h>
6 /*
7 * gai_strerror is based on
8 * http://www.opengroup.org/onlinepubs/009695399/functions/gai_strerror.html
9 */
10 const char *gai_strerror(int ecode)
12 static char buffer[256];
14 /* check for each known error code */
15 switch (ecode)
17 case EAI_AGAIN:
18 return "The name could not be resolved at this time";
20 case EAI_BADFLAGS:
21 return "The flags had an invalid value";
23 case EAI_FAIL:
24 return "A non-recoverable error occurred";
26 case EAI_FAMILY:
27 return "The address family was not recognized or the "
28 "address length was invalid for the specified "
29 "family";
31 case EAI_MEMORY:
32 return "There was a memory allocation failure";
34 case EAI_NONAME:
35 return "The name does not resolve for the supplied "
36 "parameters, NI_NAMEREQD is set and the host's "
37 "name cannot be located, or both nodename and "
38 "servname were null";
40 case EAI_SERVICE:
41 return "The service passed was not recognized for the "
42 "specified socket type";
44 case EAI_SOCKTYPE:
45 return "The intended socket type was not recognized";
47 case EAI_SYSTEM:
48 snprintf(buffer,
49 sizeof(buffer),
50 "A system error occurred: %s",
51 strerror(errno));
52 return buffer;
54 case EAI_OVERFLOW:
55 return "An argument buffer overflowed";
58 /* unknown error code */
59 snprintf(buffer,
60 sizeof(buffer),
61 "An unknown error code was passed to gai_strerror: %d",
62 ecode);
63 return buffer;