gai_strerror.c revision 0c27b3fe77ac1d5094ba3521e8142d9e7973133f
/*
* Copyright (C) 2000, 2001, 2004-2007, 2014, 2016 Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/* $Id: gai_strerror.c,v 1.22 2007/06/19 23:47:22 tbox Exp $ */
/*! \file gai_strerror.c
* lwres_gai_strerror() returns an error message corresponding to an
* error code returned by getaddrinfo(). The following error codes and
*
* \li #EAI_ADDRFAMILY address family for hostname not supported
* \li #EAI_AGAIN temporary failure in name resolution
* \li #EAI_BADFLAGS invalid value for #ai_flags
* \li #EAI_FAIL non-recoverable failure in name resolution
* \li #EAI_FAMILY ai_family not supported
* \li #EAI_MEMORY memory allocation failure
* \li #EAI_NODATA no address associated with hostname
* \li #EAI_NONAME hostname or servname not provided, or not known
* \li #EAI_SERVICE servname not supported for ai_socktype
* \li #EAI_SOCKTYPE ai_socktype not supported
* \li #EAI_SYSTEM system error returned in errno
*
* The message invalid error code is returned if ecode is out of range.
*
* ai_flags, ai_family and ai_socktype are elements of the struct
* addrinfo used by lwres_getaddrinfo().
*
* \section gai_strerror_see See Also
*
* strerror, lwres_getaddrinfo(), getaddrinfo(), RFC2133.
*/
#include <config.h>
/*% Text of error messages. */
static const char *gai_messages[] = {
"no error",
"address family for hostname not supported",
"temporary failure in name resolution",
"invalid value for ai_flags",
"non-recoverable failure in name resolution",
"ai_family not supported",
"memory allocation failure",
"no address associated with hostname",
"hostname nor servname provided, or not known",
"servname not supported for ai_socktype",
"ai_socktype not supported",
"system error returned in errno",
"bad hints",
"bad protocol",
"overflow"
};
/*% Returns an error message corresponding to an error code returned by getaddrinfo() */
char *
lwres_gai_strerror(int ecode) {
union {
const char *const_ptr;
char *deconst_ptr;
} ptr;
if ((ecode < 0) ||
else
return (ptr.deconst_ptr);
}