Blame lib/gai_strerror.c

Packit Service 2723c6
/* Copyright (C) 1997, 2001-2002, 2004-2006, 2008-2018 Free Software
Packit Service 2723c6
   Foundation, Inc.
Packit Service 2723c6
   This file is part of the GNU C Library.
Packit Service 2723c6
   Contributed by Philip Blundell <pjb27@cam.ac.uk>, 1997.
Packit Service 2723c6
Packit Service 2723c6
   This program is free software; you can redistribute it and/or modify
Packit Service 2723c6
   it under the terms of the GNU General Public License as published by
Packit Service 2723c6
   the Free Software Foundation; either version 3, or (at your option)
Packit Service 2723c6
   any later version.
Packit Service 2723c6
Packit Service 2723c6
   This program is distributed in the hope that it will be useful,
Packit Service 2723c6
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 2723c6
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit Service 2723c6
   GNU General Public License for more details.
Packit Service 2723c6
Packit Service 2723c6
   You should have received a copy of the GNU General Public License
Packit Service 2723c6
   along with this program; if not, see <https://www.gnu.org/licenses/>.  */
Packit Service 2723c6
Packit Service 2723c6
#ifndef _LIBC
Packit Service 2723c6
# include <config.h>
Packit Service 2723c6
#endif
Packit Service 2723c6
Packit Service 2723c6
#include <stdio.h>
Packit Service 2723c6
#include <netdb.h>
Packit Service 2723c6
Packit Service 2723c6
#ifdef _LIBC
Packit Service 2723c6
# include <libintl.h>
Packit Service 2723c6
#else
Packit Service 2723c6
# include "gettext.h"
Packit Service 2723c6
# define _(String) gettext (String)
Packit Service 2723c6
# define N_(String) String
Packit Service 2723c6
#endif
Packit Service 2723c6
Packit Service 2723c6
#if HAVE_DECL_GAI_STRERROR
Packit Service 2723c6
Packit Service 2723c6
# include <sys/socket.h>
Packit Service 2723c6
# undef gai_strerror
Packit Service 2723c6
# if HAVE_DECL_GAI_STRERRORA
Packit Service 2723c6
#  define gai_strerror gai_strerrorA
Packit Service 2723c6
# endif
Packit Service 2723c6
Packit Service 2723c6
const char *
Packit Service 2723c6
rpl_gai_strerror (int code)
Packit Service 2723c6
{
Packit Service 2723c6
  return gai_strerror (code);
Packit Service 2723c6
}
Packit Service 2723c6
Packit Service 2723c6
#else /* !HAVE_DECL_GAI_STRERROR */
Packit Service 2723c6
Packit Service 2723c6
static struct
Packit Service 2723c6
  {
Packit Service 2723c6
    int code;
Packit Service 2723c6
    const char *msg;
Packit Service 2723c6
  }
Packit Service 2723c6
values[] =
Packit Service 2723c6
  {
Packit Service 2723c6
    { EAI_ADDRFAMILY, N_("Address family for hostname not supported") },
Packit Service 2723c6
    { EAI_AGAIN, N_("Temporary failure in name resolution") },
Packit Service 2723c6
    { EAI_BADFLAGS, N_("Bad value for ai_flags") },
Packit Service 2723c6
    { EAI_FAIL, N_("Non-recoverable failure in name resolution") },
Packit Service 2723c6
    { EAI_FAMILY, N_("ai_family not supported") },
Packit Service 2723c6
    { EAI_MEMORY, N_("Memory allocation failure") },
Packit Service 2723c6
    { EAI_NODATA, N_("No address associated with hostname") },
Packit Service 2723c6
    { EAI_NONAME, N_("Name or service not known") },
Packit Service 2723c6
    { EAI_SERVICE, N_("Servname not supported for ai_socktype") },
Packit Service 2723c6
    { EAI_SOCKTYPE, N_("ai_socktype not supported") },
Packit Service 2723c6
    { EAI_SYSTEM, N_("System error") },
Packit Service 2723c6
    { EAI_OVERFLOW, N_("Argument buffer too small") },
Packit Service 2723c6
#ifdef EAI_INPROGRESS
Packit Service 2723c6
    { EAI_INPROGRESS, N_("Processing request in progress") },
Packit Service 2723c6
    { EAI_CANCELED, N_("Request canceled") },
Packit Service 2723c6
    { EAI_NOTCANCELED, N_("Request not canceled") },
Packit Service 2723c6
    { EAI_ALLDONE, N_("All requests done") },
Packit Service 2723c6
    { EAI_INTR, N_("Interrupted by a signal") },
Packit Service 2723c6
    { EAI_IDN_ENCODE, N_("Parameter string not correctly encoded") }
Packit Service 2723c6
#endif
Packit Service 2723c6
  };
Packit Service 2723c6
Packit Service 2723c6
const char *
Packit Service 2723c6
gai_strerror (int code)
Packit Service 2723c6
{
Packit Service 2723c6
  size_t i;
Packit Service 2723c6
  for (i = 0; i < sizeof (values) / sizeof (values[0]); ++i)
Packit Service 2723c6
    if (values[i].code == code)
Packit Service 2723c6
      return _(values[i].msg);
Packit Service 2723c6
Packit Service 2723c6
  return _("Unknown error");
Packit Service 2723c6
}
Packit Service 2723c6
# ifdef _LIBC
Packit Service 2723c6
libc_hidden_def (gai_strerror)
Packit Service 2723c6
# endif
Packit Service 2723c6
#endif /* !HAVE_DECL_GAI_STRERROR */