1 /* Copyright (C) 1997, 1999, 2002, 2007 Free Software Foundation, Inc.
2
3 This file is part of jwhois
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
20 #ifdef HAVE_CONFIG_H
21 # include <config.h>
22 #endif
23 #ifdef STDC_HEADERS
24 # include <stdio.h>
25 # include <stdlib.h>
26 #endif
27
28 #ifdef HAVE_NETDB_H
29 # include <netdb.h>
30 #endif
31
32 #ifdef ENABLE_NLS
33 # include <libintl.h>
34 # define _(s) gettext(s)
35 #else
36 # define _(s) (s)
37 #endif
38
39 #ifndef HAVE_GAI_STRERROR
40
41 /* Error values for `getaddrinfo' function. */
42 # define EAI_BADFLAGS -1 /* Invalid value for `ai_flags' field. */
43 # define EAI_NONAME -2 /* NAME or SERVICE is unknown. */
44 # define EAI_AGAIN -3 /* Temporary failure in name resolution. */
45 # define EAI_FAIL -4 /* Non-recoverable failure in name res. */
46 # define EAI_NODATA -5 /* No address associated with NAME. */
47 # define EAI_FAMILY -6 /* `ai_family' not supported. */
48 # define EAI_SOCKTYPE -7 /* `ai_socktype' not supported. */
49 # define EAI_SERVICE -8 /* SERVICE not supported for `ai_socktype'. */
50 # define EAI_ADDRFAMILY -9 /* Address family for NAME not supported. */
51 # define EAI_MEMORY -10 /* Memory allocation failure. */
52 # define EAI_SYSTEM -11 /* System error returned in `errno'. */
53
54 const char *
gai_strerror(int code)55 gai_strerror (int code)
56 {
57 size_t i;
58 switch(code)
59 {
60 case EAI_ADDRFAMILY:
61 return (char *) _("Address family for hostname not supported");
62 case EAI_AGAIN:
63 return (char *) _("Temporary failure in name resolution");
64 case EAI_BADFLAGS:
65 return (char *) _("Bad value for ai_flags");
66 case EAI_FAIL:
67 return (char *) _("Non-recoverable failure in name resolution");
68 case EAI_FAMILY:
69 return (char *) _("ai_family not supported");
70 case EAI_MEMORY:
71 return (char *) _("Memory allocation failure");
72 case EAI_NODATA:
73 return (char *) _("No address associated with hostname");
74 case EAI_NONAME:
75 return (char *) _("Name or service not known");
76 case EAI_SERVICE:
77 return (char *) _("Servname not supported for ai_socktype");
78 case EAI_SOCKTYPE:
79 return (char *) _("ai_socktype not supported");
80 case EAI_SYSTEM:
81 return (char *) _("System error");
82 default:
83 return (char *) _("Unknown error");
84 }
85 }
86
87 #endif /* !HAVE_GAI_STRERROR */
88