gai_strerror.c revision 144708
113007Swpaul/* 213007Swpaul * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. 313007Swpaul * All rights reserved. 413007Swpaul * 513007Swpaul * Redistribution and use in source and binary forms, with or without 613007Swpaul * modification, are permitted provided that the following conditions 713007Swpaul * are met: 813007Swpaul * 1. Redistributions of source code must retain the above copyright 913007Swpaul * notice, this list of conditions and the following disclaimer. 1013007Swpaul * 2. Redistributions in binary form must reproduce the above copyright 1113007Swpaul * notice, this list of conditions and the following disclaimer in the 1213007Swpaul * documentation and/or other materials provided with the distribution. 1313007Swpaul * 3. Neither the name of the project nor the names of its contributors 1413007Swpaul * may be used to endorse or promote products derived from this software 1513007Swpaul * without specific prior written permission. 1613007Swpaul * 1713007Swpaul * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 1813007Swpaul * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1913007Swpaul * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2013007Swpaul * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 2113007Swpaul * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2213007Swpaul * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2313007Swpaul * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2413007Swpaul * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2513007Swpaul * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2613007Swpaul * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2713007Swpaul * SUCH DAMAGE. 2813007Swpaul */ 2913007Swpaul 3013007Swpaul#include <sys/cdefs.h> 3113007Swpaul__FBSDID("$FreeBSD: head/lib/libc/net/gai_strerror.c 144708 2005-04-06 12:45:51Z ume $"); 3231626Scharnier 3331626Scharnier#include <netdb.h> 3431626Scharnier 3550476Speter/* Entries EAI_ADDRFAMILY (1) and EAI_NODATA (7) are obsoleted, but left */ 3631626Scharnier/* for backward compatibility with userland code prior to 2553bis-02 */ 3731626Scharnierstatic const char *ai_errlist[] = { 3819181Swpaul "Success", /* 0 */ 3919181Swpaul "Address family for hostname not supported", /* 1 */ 4013895Swpaul "Temporary failure in name resolution", /* EAI_AGAIN */ 4113895Swpaul "Invalid value for ai_flags", /* EAI_BADFLAGS */ 4213895Swpaul "Non-recoverable failure in name resolution", /* EAI_FAIL */ 4313007Swpaul "ai_family not supported", /* EAI_FAMILY */ 4413007Swpaul "Memory allocation failure", /* EAI_MEMORY */ 4513007Swpaul "No address associated with hostname", /* 7 */ 4613007Swpaul "hostname nor servname provided, or not known", /* EAI_NONAME */ 4713007Swpaul "servname not supported for ai_socktype", /* EAI_SERVICE */ 4813007Swpaul "ai_socktype not supported", /* EAI_SOCKTYPE */ 4990298Sdes "System error returned in errno", /* EAI_SYSTEM */ 5090298Sdes "Invalid value for hints", /* EAI_BADHINTS */ 5113007Swpaul "Resolved protocol is unknown" /* EAI_PROTOCOL */ 5290297Sdes}; 5313007Swpaul 5461187Sjlemonconst char * 5513007Swpaulgai_strerror(int ecode) 5613007Swpaul{ 5713007Swpaul if (ecode >= 0 && ecode < EAI_MAX) 5813007Swpaul return ai_errlist[ecode]; 5913007Swpaul return "Unknown error"; 6013007Swpaul} 6113007Swpaul