Mercurial > hg > octave-shane > gnulib-hg
annotate lib/gai_strerror.c @ 10661:65c9436dc0d3
Move the getdomainname() declaration to <unistd.h>.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Sun, 19 Oct 2008 03:36:00 +0200 |
parents | cae55a1e8678 |
children | 5721d1f9e1ef |
rev | line source |
---|---|
6619
29248383a0c7
Mingw32 fixes for getaddrinfo.
Simon Josefsson <simon@josefsson.org>
parents:
6221
diff
changeset
|
1 /* Copyright (C) 1997, 2001, 2002, 2004, 2005, 2006 Free Software Foundation, Inc. |
5408 | 2 This file is part of the GNU C Library. |
3 Contributed by Philip Blundell <pjb27@cam.ac.uk>, 1997. | |
4 | |
5623
597e498573cd
gai_strerror.c: Use GPL in header.
Simon Josefsson <simon@josefsson.org>
parents:
5408
diff
changeset
|
5 This program is free software; you can redistribute it and/or modify |
597e498573cd
gai_strerror.c: Use GPL in header.
Simon Josefsson <simon@josefsson.org>
parents:
5408
diff
changeset
|
6 it under the terms of the GNU General Public License as published by |
597e498573cd
gai_strerror.c: Use GPL in header.
Simon Josefsson <simon@josefsson.org>
parents:
5408
diff
changeset
|
7 the Free Software Foundation; either version 2, or (at your option) |
597e498573cd
gai_strerror.c: Use GPL in header.
Simon Josefsson <simon@josefsson.org>
parents:
5408
diff
changeset
|
8 any later version. |
5408 | 9 |
5623
597e498573cd
gai_strerror.c: Use GPL in header.
Simon Josefsson <simon@josefsson.org>
parents:
5408
diff
changeset
|
10 This program is distributed in the hope that it will be useful, |
5408 | 11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
5623
597e498573cd
gai_strerror.c: Use GPL in header.
Simon Josefsson <simon@josefsson.org>
parents:
5408
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
597e498573cd
gai_strerror.c: Use GPL in header.
Simon Josefsson <simon@josefsson.org>
parents:
5408
diff
changeset
|
13 GNU General Public License for more details. |
5408 | 14 |
5623
597e498573cd
gai_strerror.c: Use GPL in header.
Simon Josefsson <simon@josefsson.org>
parents:
5408
diff
changeset
|
15 You should have received a copy of the GNU General Public License |
597e498573cd
gai_strerror.c: Use GPL in header.
Simon Josefsson <simon@josefsson.org>
parents:
5408
diff
changeset
|
16 along with this program; if not, write to the Free Software Foundation, |
5848
a48fb0e98c8c
*** empty log message ***
Paul Eggert <eggert@cs.ucla.edu>
parents:
5623
diff
changeset
|
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ |
5408 | 18 |
7302
8a1a9361108c
* _fpending.c: Include <config.h> unconditionally, since we no
Paul Eggert <eggert@cs.ucla.edu>
parents:
6619
diff
changeset
|
19 #ifndef _LIBC |
6221
ee77add4f839
* gai_strerror.c: Include config.h when available. Include
Derek R. Price <derek@ximbiot.com>
parents:
5848
diff
changeset
|
20 # include <config.h> |
ee77add4f839
* gai_strerror.c: Include config.h when available. Include
Derek R. Price <derek@ximbiot.com>
parents:
5848
diff
changeset
|
21 # include "getaddrinfo.h" |
ee77add4f839
* gai_strerror.c: Include config.h when available. Include
Derek R. Price <derek@ximbiot.com>
parents:
5848
diff
changeset
|
22 #endif |
ee77add4f839
* gai_strerror.c: Include config.h when available. Include
Derek R. Price <derek@ximbiot.com>
parents:
5848
diff
changeset
|
23 |
5408 | 24 #include <stdio.h> |
6619
29248383a0c7
Mingw32 fixes for getaddrinfo.
Simon Josefsson <simon@josefsson.org>
parents:
6221
diff
changeset
|
25 #ifdef HAVE_NETDB_H |
29248383a0c7
Mingw32 fixes for getaddrinfo.
Simon Josefsson <simon@josefsson.org>
parents:
6221
diff
changeset
|
26 # include <netdb.h> |
29248383a0c7
Mingw32 fixes for getaddrinfo.
Simon Josefsson <simon@josefsson.org>
parents:
6221
diff
changeset
|
27 #endif |
5408 | 28 |
29 #ifdef _LIBC | |
30 # include <libintl.h> | |
31 #else | |
32 # include "gettext.h" | |
33 # define _(String) gettext (String) | |
34 # define N_(String) String | |
35 #endif | |
36 | |
37 static struct | |
38 { | |
39 int code; | |
40 const char *msg; | |
41 } | |
42 values[] = | |
43 { | |
44 { EAI_ADDRFAMILY, N_("Address family for hostname not supported") }, | |
45 { EAI_AGAIN, N_("Temporary failure in name resolution") }, | |
46 { EAI_BADFLAGS, N_("Bad value for ai_flags") }, | |
47 { EAI_FAIL, N_("Non-recoverable failure in name resolution") }, | |
48 { EAI_FAMILY, N_("ai_family not supported") }, | |
49 { EAI_MEMORY, N_("Memory allocation failure") }, | |
50 { EAI_NODATA, N_("No address associated with hostname") }, | |
51 { EAI_NONAME, N_("Name or service not known") }, | |
52 { EAI_SERVICE, N_("Servname not supported for ai_socktype") }, | |
53 { EAI_SOCKTYPE, N_("ai_socktype not supported") }, | |
54 { EAI_SYSTEM, N_("System error") }, | |
8053
cae55a1e8678
(values): Add EAI_OVERFLOW.
Simon Josefsson <simon@josefsson.org>
parents:
7302
diff
changeset
|
55 { EAI_OVERFLOW, N_("Argument buffer too small") }, |
5408 | 56 #ifdef __USE_GNU |
57 { EAI_INPROGRESS, N_("Processing request in progress") }, | |
58 { EAI_CANCELED, N_("Request canceled") }, | |
59 { EAI_NOTCANCELED, N_("Request not canceled") }, | |
60 { EAI_ALLDONE, N_("All requests done") }, | |
61 { EAI_INTR, N_("Interrupted by a signal") }, | |
62 { EAI_IDN_ENCODE, N_("Parameter string not correctly encoded") } | |
63 #endif | |
64 }; | |
65 | |
66 const char * | |
67 gai_strerror (int code) | |
68 { | |
69 size_t i; | |
70 for (i = 0; i < sizeof (values) / sizeof (values[0]); ++i) | |
71 if (values[i].code == code) | |
72 return _(values[i].msg); | |
73 | |
74 return _("Unknown error"); | |
75 } | |
76 #ifdef _LIBC | |
77 libc_hidden_def (gai_strerror) | |
78 #endif |