mirror of
git://sourceware.org/git/glibc.git
synced 2024-11-21 01:12:26 +08:00
* sysdeps/posix/gai_strerror.c: Complete rewrite. Avoid relocations.
* sysdeps/posix/gai_strerror-strs.h: New file. * sysdeps/posix/Dist: New file.
This commit is contained in:
parent
192c0fa590
commit
2094e1a975
@ -1,5 +1,9 @@
|
|||||||
2005-12-20 Ulrich Drepper <drepper@redhat.com>
|
2005-12-20 Ulrich Drepper <drepper@redhat.com>
|
||||||
|
|
||||||
|
* sysdeps/posix/gai_strerror.c: Complete rewrite. Avoid relocations.
|
||||||
|
* sysdeps/posix/gai_strerror-strs.h: New file.
|
||||||
|
* sysdeps/posix/Dist: New file.
|
||||||
|
|
||||||
* sysdeps/posix/getaddrinfo.c (gaih): Mark as const.
|
* sysdeps/posix/getaddrinfo.c (gaih): Mark as const.
|
||||||
* locale/loadlocale.c (_nl_value_types): Likewise.
|
* locale/loadlocale.c (_nl_value_types): Likewise.
|
||||||
* iconv/gconv_conf.c (builtin_aliases): Likewise.
|
* iconv/gconv_conf.c (builtin_aliases): Likewise.
|
||||||
|
1
sysdeps/posix/Dist
Normal file
1
sysdeps/posix/Dist
Normal file
@ -0,0 +1 @@
|
|||||||
|
gai_strerror-strs.h
|
17
sysdeps/posix/gai_strerror-strs.h
Normal file
17
sysdeps/posix/gai_strerror-strs.h
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
_S(EAI_ADDRFAMILY, N_("Address family for hostname not supported"))
|
||||||
|
_S(EAI_AGAIN, N_("Temporary failure in name resolution"))
|
||||||
|
_S(EAI_BADFLAGS, N_("Bad value for ai_flags"))
|
||||||
|
_S(EAI_FAIL, N_("Non-recoverable failure in name resolution"))
|
||||||
|
_S(EAI_FAMILY, N_("ai_family not supported"))
|
||||||
|
_S(EAI_MEMORY, N_("Memory allocation failure"))
|
||||||
|
_S(EAI_NODATA, N_("No address associated with hostname"))
|
||||||
|
_S(EAI_NONAME, N_("Name or service not known"))
|
||||||
|
_S(EAI_SERVICE, N_("Servname not supported for ai_socktype"))
|
||||||
|
_S(EAI_SOCKTYPE, N_("ai_socktype not supported"))
|
||||||
|
_S(EAI_SYSTEM, N_("System error"))
|
||||||
|
_S(EAI_INPROGRESS, N_("Processing request in progress"))
|
||||||
|
_S(EAI_CANCELED, N_("Request canceled"))
|
||||||
|
_S(EAI_NOTCANCELED, N_("Request not canceled"))
|
||||||
|
_S(EAI_ALLDONE, N_("All requests done"))
|
||||||
|
_S(EAI_INTR, N_("Interrupted by a signal"))
|
||||||
|
_S(EAI_IDN_ENCODE, N_("Parameter string not correctly encoded"))
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 1997, 2001, 2002, 2004 Free Software Foundation, Inc.
|
/* Copyright (C) 1997, 2001, 2002, 2004, 2005 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
Contributed by Philip Blundell <pjb27@cam.ac.uk>, 1997.
|
Contributed by Philip Blundell <pjb27@cam.ac.uk>, 1997.
|
||||||
|
|
||||||
@ -17,44 +17,54 @@
|
|||||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||||
02111-1307 USA. */
|
02111-1307 USA. */
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <netdb.h>
|
|
||||||
#include <libintl.h>
|
#include <libintl.h>
|
||||||
|
#include <netdb.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
static struct
|
|
||||||
|
#define MSGSTRFIELD(line) MSGSTRFIELD1 (line)
|
||||||
|
#define MSGSTRFIELD1(line) str##line
|
||||||
|
static const union msgstr_t
|
||||||
|
{
|
||||||
|
struct
|
||||||
{
|
{
|
||||||
int code;
|
#define _S(n, s) char MSGSTRFIELD(__LINE__)[sizeof (s)];
|
||||||
const char *msg;
|
#include "gai_strerror-strs.h"
|
||||||
}
|
#undef _S
|
||||||
values[] =
|
|
||||||
{
|
|
||||||
{ EAI_ADDRFAMILY, N_("Address family for hostname not supported") },
|
|
||||||
{ EAI_AGAIN, N_("Temporary failure in name resolution") },
|
|
||||||
{ EAI_BADFLAGS, N_("Bad value for ai_flags") },
|
|
||||||
{ EAI_FAIL, N_("Non-recoverable failure in name resolution") },
|
|
||||||
{ EAI_FAMILY, N_("ai_family not supported") },
|
|
||||||
{ EAI_MEMORY, N_("Memory allocation failure") },
|
|
||||||
{ EAI_NODATA, N_("No address associated with hostname") },
|
|
||||||
{ EAI_NONAME, N_("Name or service not known") },
|
|
||||||
{ EAI_SERVICE, N_("Servname not supported for ai_socktype") },
|
|
||||||
{ EAI_SOCKTYPE, N_("ai_socktype not supported") },
|
|
||||||
{ EAI_SYSTEM, N_("System error") },
|
|
||||||
{ EAI_INPROGRESS, N_("Processing request in progress") },
|
|
||||||
{ EAI_CANCELED, N_("Request canceled") },
|
|
||||||
{ EAI_NOTCANCELED, N_("Request not canceled") },
|
|
||||||
{ EAI_ALLDONE, N_("All requests done") },
|
|
||||||
{ EAI_INTR, N_("Interrupted by a signal") },
|
|
||||||
{ EAI_IDN_ENCODE, N_("Parameter string not correctly encoded") }
|
|
||||||
};
|
};
|
||||||
|
char str[0];
|
||||||
|
} msgstr =
|
||||||
|
{
|
||||||
|
{
|
||||||
|
#define _S(n, s) s,
|
||||||
|
#include "gai_strerror-strs.h"
|
||||||
|
#undef _S
|
||||||
|
}
|
||||||
|
};
|
||||||
|
static const struct
|
||||||
|
{
|
||||||
|
int16_t code;
|
||||||
|
uint16_t idx;
|
||||||
|
} msgidx[] =
|
||||||
|
{
|
||||||
|
#define _S(n, s) { n, offsetof (union msgstr_t, MSGSTRFIELD (__LINE__)) },
|
||||||
|
#include "gai_strerror-strs.h"
|
||||||
|
#undef _S
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
gai_strerror (int code)
|
gai_strerror (int code)
|
||||||
{
|
{
|
||||||
size_t i;
|
const char *result = "Unknown error";
|
||||||
for (i = 0; i < sizeof (values) / sizeof (values[0]); ++i)
|
for (size_t i = 0; i < sizeof (msgidx) / sizeof (msgidx[0]); ++i)
|
||||||
if (values[i].code == code)
|
if (msgidx[i].code == code)
|
||||||
return _(values[i].msg);
|
{
|
||||||
|
result = msgstr.str + msgidx[i].idx;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
return _("Unknown error");
|
return _(result);
|
||||||
}
|
}
|
||||||
libc_hidden_def (gai_strerror)
|
libc_hidden_def (gai_strerror)
|
||||||
|
Loading…
Reference in New Issue
Block a user