Commit | Line | Data |
---|---|---|
49114fd4 LC |
1 | /* Copyright (C) 1997, 2001-2002, 2004-2006, 2008-2011 Free Software |
2 | Foundation, Inc. | |
40ff484d LC |
3 | This file is part of the GNU C Library. |
4 | Contributed by Philip Blundell <pjb27@cam.ac.uk>, 1997. | |
5 | ||
6 | This program is free software; you can redistribute it and/or modify | |
7 | it under the terms of the GNU Lesser General Public License as published by | |
8 | the Free Software Foundation; either version 2, or (at your option) | |
9 | any later version. | |
10 | ||
11 | This program is distributed in the hope that it will be useful, | |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | GNU Lesser General Public License for more details. | |
15 | ||
16 | You should have received a copy of the GNU Lesser General Public License | |
17 | along with this program; if not, write to the Free Software Foundation, | |
18 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ | |
19 | ||
20 | #ifndef _LIBC | |
21 | # include <config.h> | |
22 | #endif | |
23 | ||
24 | #include <stdio.h> | |
25 | #include <netdb.h> | |
26 | ||
27 | #ifdef _LIBC | |
28 | # include <libintl.h> | |
29 | #else | |
30 | # include "gettext.h" | |
31 | # define _(String) gettext (String) | |
32 | # define N_(String) String | |
33 | #endif | |
34 | ||
3d458a81 AW |
35 | #if HAVE_DECL_GAI_STRERROR |
36 | ||
37 | # include <sys/socket.h> | |
38 | # undef gai_strerror | |
39 | # if HAVE_DECL_GAI_STRERRORA | |
40 | # define gai_strerror gai_strerrorA | |
41 | # endif | |
42 | ||
43 | const char * | |
44 | rpl_gai_strerror (int code) | |
45 | { | |
46 | return gai_strerror (code); | |
47 | } | |
48 | ||
49 | #else /* !HAVE_DECL_GAI_STRERROR */ | |
50 | ||
40ff484d LC |
51 | static struct |
52 | { | |
53 | int code; | |
54 | const char *msg; | |
55 | } | |
56 | values[] = | |
57 | { | |
58 | { EAI_ADDRFAMILY, N_("Address family for hostname not supported") }, | |
59 | { EAI_AGAIN, N_("Temporary failure in name resolution") }, | |
60 | { EAI_BADFLAGS, N_("Bad value for ai_flags") }, | |
61 | { EAI_FAIL, N_("Non-recoverable failure in name resolution") }, | |
62 | { EAI_FAMILY, N_("ai_family not supported") }, | |
63 | { EAI_MEMORY, N_("Memory allocation failure") }, | |
64 | { EAI_NODATA, N_("No address associated with hostname") }, | |
65 | { EAI_NONAME, N_("Name or service not known") }, | |
66 | { EAI_SERVICE, N_("Servname not supported for ai_socktype") }, | |
67 | { EAI_SOCKTYPE, N_("ai_socktype not supported") }, | |
68 | { EAI_SYSTEM, N_("System error") }, | |
69 | { EAI_OVERFLOW, N_("Argument buffer too small") }, | |
70 | #ifdef EAI_INPROGRESS | |
71 | { EAI_INPROGRESS, N_("Processing request in progress") }, | |
72 | { EAI_CANCELED, N_("Request canceled") }, | |
73 | { EAI_NOTCANCELED, N_("Request not canceled") }, | |
74 | { EAI_ALLDONE, N_("All requests done") }, | |
75 | { EAI_INTR, N_("Interrupted by a signal") }, | |
76 | { EAI_IDN_ENCODE, N_("Parameter string not correctly encoded") } | |
77 | #endif | |
78 | }; | |
79 | ||
80 | const char * | |
81 | gai_strerror (int code) | |
82 | { | |
83 | size_t i; | |
84 | for (i = 0; i < sizeof (values) / sizeof (values[0]); ++i) | |
85 | if (values[i].code == code) | |
86 | return _(values[i].msg); | |
87 | ||
88 | return _("Unknown error"); | |
89 | } | |
3d458a81 | 90 | # ifdef _LIBC |
40ff484d | 91 | libc_hidden_def (gai_strerror) |
3d458a81 AW |
92 | # endif |
93 | #endif /* !HAVE_DECL_GAI_STRERROR */ |