| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
#include <netdb.h> |
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
#ifndef EAI_BADFLAGS |
| 25 |
# define EAI_BADFLAGS -1 |
| 26 |
#endif |
| 27 |
|
| 28 |
#ifndef EAI_NONAME |
| 29 |
# define EAI_NONAME -2 |
| 30 |
#endif |
| 31 |
|
| 32 |
#ifndef EAI_AGAIN |
| 33 |
# define EAI_AGAIN -3 |
| 34 |
#endif |
| 35 |
|
| 36 |
#ifndef EAI_FAIL |
| 37 |
# define EAI_FAIL -4 |
| 38 |
#endif |
| 39 |
|
| 40 |
#ifndef EAI_NODATA |
| 41 |
# define EAI_NODATA -5 |
| 42 |
#endif |
| 43 |
|
| 44 |
#ifndef EAI_FAMILY |
| 45 |
# define EAI_FAMILY -6 |
| 46 |
#endif |
| 47 |
|
| 48 |
#ifndef EAI_SOCKTYPE |
| 49 |
# define EAI_SOCKTYPE -7 |
| 50 |
#endif |
| 51 |
|
| 52 |
#ifndef EAI_SERVICE |
| 53 |
# define EAI_SERVICE -8 |
| 54 |
#endif |
| 55 |
|
| 56 |
#ifndef EAI_ADDRFAMILY |
| 57 |
# define EAI_ADDRFAMILY -9 |
| 58 |
#endif |
| 59 |
|
| 60 |
#ifndef EAI_MEMORY |
| 61 |
# define EAI_MEMORY -10 |
| 62 |
#endif |
| 63 |
|
| 64 |
#ifndef EAI_SYSTEM |
| 65 |
# define EAI_SYSTEM -11 |
| 66 |
#endif |
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
#ifndef EAI_INPROGRESS |
| 71 |
# define EAI_INPROGRESS -100 |
| 72 |
#endif |
| 73 |
|
| 74 |
#ifndef EAI_CANCELED |
| 75 |
# define EAI_CANCELED -101 |
| 76 |
#endif |
| 77 |
|
| 78 |
#ifndef EAI_NOTCANCELED |
| 79 |
# define EAI_NOTCANCELED -102 |
| 80 |
#endif |
| 81 |
|
| 82 |
#ifndef EAI_ALLDONE |
| 83 |
# define EAI_ALLDONE -103 |
| 84 |
#endif |
| 85 |
|
| 86 |
#ifndef EAI_INTR |
| 87 |
# define EAI_INTR -104 |
| 88 |
#endif |
| 89 |
|
| 90 |
static struct { |
| 91 |
int code; |
| 92 |
const char *msg; |
| 93 |
|
| 94 |
} values[] = { |
| 95 |
|
| 96 |
{ EAI_ADDRFAMILY, "Address family for hostname not supported" }, |
| 97 |
{ EAI_AGAIN, "Temporary failure in name resolution" }, |
| 98 |
{ EAI_BADFLAGS, "Bad value for ai_flags" }, |
| 99 |
{ EAI_FAIL, "Non-recoverable failure in name resolution" }, |
| 100 |
{ EAI_FAMILY, "ai_family not supported" }, |
| 101 |
{ EAI_MEMORY, "Memory allocation failure" }, |
| 102 |
{ EAI_NODATA, "No address associated with hostname" }, |
| 103 |
{ EAI_NONAME, "Name or service not known" }, |
| 104 |
{ EAI_SERVICE, "Servname not supported for ai_socktype" }, |
| 105 |
{ EAI_SOCKTYPE, "ai_socktype not supported" }, |
| 106 |
{ EAI_SYSTEM, "System error" }, |
| 107 |
{ EAI_INPROGRESS, "Processing request in progress" }, |
| 108 |
{ EAI_CANCELED, "Request canceled" }, |
| 109 |
{ EAI_NOTCANCELED, "Request not canceled" }, |
| 110 |
{ EAI_ALLDONE, "All requests done" }, |
| 111 |
{ EAI_INTR, "Interrupted by a signal" } |
| 112 |
}; |
| 113 |
|
| 114 |
const char *pr_gai_strerror(int code) { |
| 115 |
register unsigned int i; |
| 116 |
for (i = 0; i < sizeof(values) / sizeof(values[0]); ++i) |
| 117 |
if (values[i].code == code) |
| 118 |
return values[i].msg; |
| 119 |
|
| 120 |
return "Unknown error"; |
| 121 |
} |