Commit | Line | Data |
---|---|---|
5e69ceb7 | 1 | /* Copyright (C) 1997, 2001-2002, 2004-2006, 2008-2014 Free Software |
49114fd4 | 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 | |
005de2e8 | 17 | along with this program; if not, see <http://www.gnu.org/licenses/>. */ |
40ff484d LC |
18 | |
19 | #ifndef _LIBC | |
20 | # include <config.h> | |
21 | #endif | |
22 | ||
23 | #include <stdio.h> | |
24 | #include <netdb.h> | |
25 | ||
26 | #ifdef _LIBC | |
27 | # include <libintl.h> | |
28 | #else | |
29 | # include "gettext.h" | |
30 | # define _(String) gettext (String) | |
31 | # define N_(String) String | |
32 | #endif | |
33 | ||
3d458a81 AW |
34 | #if HAVE_DECL_GAI_STRERROR |
35 | ||
36 | # include <sys/socket.h> | |
37 | # undef gai_strerror | |
38 | # if HAVE_DECL_GAI_STRERRORA | |
39 | # define gai_strerror gai_strerrorA | |
40 | # endif | |
41 | ||
42 | const char * | |
43 | rpl_gai_strerror (int code) | |
44 | { | |
45 | return gai_strerror (code); | |
46 | } | |
47 | ||
48 | #else /* !HAVE_DECL_GAI_STRERROR */ | |
49 | ||
40ff484d LC |
50 | static struct |
51 | { | |
52 | int code; | |
53 | const char *msg; | |
54 | } | |
55 | values[] = | |
56 | { | |
57 | { EAI_ADDRFAMILY, N_("Address family for hostname not supported") }, | |
58 | { EAI_AGAIN, N_("Temporary failure in name resolution") }, | |
59 | { EAI_BADFLAGS, N_("Bad value for ai_flags") }, | |
60 | { EAI_FAIL, N_("Non-recoverable failure in name resolution") }, | |
61 | { EAI_FAMILY, N_("ai_family not supported") }, | |
62 | { EAI_MEMORY, N_("Memory allocation failure") }, | |
63 | { EAI_NODATA, N_("No address associated with hostname") }, | |
64 | { EAI_NONAME, N_("Name or service not known") }, | |
65 | { EAI_SERVICE, N_("Servname not supported for ai_socktype") }, | |
66 | { EAI_SOCKTYPE, N_("ai_socktype not supported") }, | |
67 | { EAI_SYSTEM, N_("System error") }, | |
68 | { EAI_OVERFLOW, N_("Argument buffer too small") }, | |
69 | #ifdef EAI_INPROGRESS | |
70 | { EAI_INPROGRESS, N_("Processing request in progress") }, | |
71 | { EAI_CANCELED, N_("Request canceled") }, | |
72 | { EAI_NOTCANCELED, N_("Request not canceled") }, | |
73 | { EAI_ALLDONE, N_("All requests done") }, | |
74 | { EAI_INTR, N_("Interrupted by a signal") }, | |
75 | { EAI_IDN_ENCODE, N_("Parameter string not correctly encoded") } | |
76 | #endif | |
77 | }; | |
78 | ||
79 | const char * | |
80 | gai_strerror (int code) | |
81 | { | |
82 | size_t i; | |
83 | for (i = 0; i < sizeof (values) / sizeof (values[0]); ++i) | |
84 | if (values[i].code == code) | |
85 | return _(values[i].msg); | |
86 | ||
87 | return _("Unknown error"); | |
88 | } | |
3d458a81 | 89 | # ifdef _LIBC |
40ff484d | 90 | libc_hidden_def (gai_strerror) |
3d458a81 AW |
91 | # endif |
92 | #endif /* !HAVE_DECL_GAI_STRERROR */ |