Update.
[gsasl.git] / gl / gai_strerror.c
blobd97b858be6f06166f6e2510d8bcf960d9ae11708
1 /* Copyright (C) 1997, 2001, 2002, 2004, 2005, 2006 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Philip Blundell <pjb27@cam.ac.uk>, 1997.
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 2, or (at your option)
8 any later version.
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.
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 Foundation,
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
19 #ifdef HAVE_CONFIG_H
20 # include <config.h>
21 #endif
23 #ifndef _LIBC
24 # include "getaddrinfo.h"
25 #endif
27 #include <stdio.h>
28 #ifdef HAVE_NETDB_H
29 # include <netdb.h>
30 #endif
32 #ifdef _LIBC
33 # include <libintl.h>
34 #else
35 # include "gettext.h"
36 # define _(String) gettext (String)
37 # define N_(String) String
38 #endif
40 static struct
42 int code;
43 const char *msg;
45 values[] =
47 { EAI_ADDRFAMILY, N_("Address family for hostname not supported") },
48 { EAI_AGAIN, N_("Temporary failure in name resolution") },
49 { EAI_BADFLAGS, N_("Bad value for ai_flags") },
50 { EAI_FAIL, N_("Non-recoverable failure in name resolution") },
51 { EAI_FAMILY, N_("ai_family not supported") },
52 { EAI_MEMORY, N_("Memory allocation failure") },
53 { EAI_NODATA, N_("No address associated with hostname") },
54 { EAI_NONAME, N_("Name or service not known") },
55 { EAI_SERVICE, N_("Servname not supported for ai_socktype") },
56 { EAI_SOCKTYPE, N_("ai_socktype not supported") },
57 { EAI_SYSTEM, N_("System error") },
58 #ifdef __USE_GNU
59 { EAI_INPROGRESS, N_("Processing request in progress") },
60 { EAI_CANCELED, N_("Request canceled") },
61 { EAI_NOTCANCELED, N_("Request not canceled") },
62 { EAI_ALLDONE, N_("All requests done") },
63 { EAI_INTR, N_("Interrupted by a signal") },
64 { EAI_IDN_ENCODE, N_("Parameter string not correctly encoded") }
65 #endif
68 const char *
69 gai_strerror (int code)
71 size_t i;
72 for (i = 0; i < sizeof (values) / sizeof (values[0]); ++i)
73 if (values[i].code == code)
74 return _(values[i].msg);
76 return _("Unknown error");
78 #ifdef _LIBC
79 libc_hidden_def (gai_strerror)
80 #endif