gai_strerror.c revision 15a44745412679c30a6d022733925af70a38b715
d389069a397c99347b5b281f90577e19e7662b03Mark Andrews/*
c29c3e51b1d7502c8d9978633df43e6a267bc427Mark Andrews * Copyright (C) 2000 Internet Software Consortium.
d389069a397c99347b5b281f90577e19e7662b03Mark Andrews *
d389069a397c99347b5b281f90577e19e7662b03Mark Andrews * Permission to use, copy, modify, and distribute this software for any
d389069a397c99347b5b281f90577e19e7662b03Mark Andrews * purpose with or without fee is hereby granted, provided that the above
d389069a397c99347b5b281f90577e19e7662b03Mark Andrews * copyright notice and this permission notice appear in all copies.
d389069a397c99347b5b281f90577e19e7662b03Mark Andrews *
d389069a397c99347b5b281f90577e19e7662b03Mark Andrews * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
d389069a397c99347b5b281f90577e19e7662b03Mark Andrews * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
d389069a397c99347b5b281f90577e19e7662b03Mark Andrews * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
d389069a397c99347b5b281f90577e19e7662b03Mark Andrews * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
d389069a397c99347b5b281f90577e19e7662b03Mark Andrews * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
d389069a397c99347b5b281f90577e19e7662b03Mark Andrews * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
d389069a397c99347b5b281f90577e19e7662b03Mark Andrews * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
d389069a397c99347b5b281f90577e19e7662b03Mark Andrews * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
d389069a397c99347b5b281f90577e19e7662b03Mark Andrews */
d389069a397c99347b5b281f90577e19e7662b03Mark Andrews
d389069a397c99347b5b281f90577e19e7662b03Mark Andrews/* $Id: gai_strerror.c,v 1.11 2000/07/27 09:53:38 tale Exp $ */
d389069a397c99347b5b281f90577e19e7662b03Mark Andrews
d389069a397c99347b5b281f90577e19e7662b03Mark Andrews#include <lwres/netdb.h>
d389069a397c99347b5b281f90577e19e7662b03Mark Andrews
d389069a397c99347b5b281f90577e19e7662b03Mark Andrewsstatic const char *gai_messages[] = {
d389069a397c99347b5b281f90577e19e7662b03Mark Andrews "no error",
d389069a397c99347b5b281f90577e19e7662b03Mark Andrews "address family for hostname not supported",
d389069a397c99347b5b281f90577e19e7662b03Mark Andrews "temporary failure in name resolution",
d389069a397c99347b5b281f90577e19e7662b03Mark Andrews "invalid value for ai_flags",
d389069a397c99347b5b281f90577e19e7662b03Mark Andrews "non-recoverable failure in name resolution",
d389069a397c99347b5b281f90577e19e7662b03Mark Andrews "ai_family not supported",
d389069a397c99347b5b281f90577e19e7662b03Mark Andrews "memory allocation failure",
d389069a397c99347b5b281f90577e19e7662b03Mark Andrews "no address associated with hostname",
d389069a397c99347b5b281f90577e19e7662b03Mark Andrews "hostname nor servname provided, or not known",
d389069a397c99347b5b281f90577e19e7662b03Mark Andrews "servname not supported for ai_socktype",
d389069a397c99347b5b281f90577e19e7662b03Mark Andrews "ai_socktype not supported",
d389069a397c99347b5b281f90577e19e7662b03Mark Andrews "system error returned in errno"
d389069a397c99347b5b281f90577e19e7662b03Mark Andrews};
d389069a397c99347b5b281f90577e19e7662b03Mark Andrews
d389069a397c99347b5b281f90577e19e7662b03Mark Andrewschar *
d389069a397c99347b5b281f90577e19e7662b03Mark Andrewslwres_gai_strerror(int ecode) {
d389069a397c99347b5b281f90577e19e7662b03Mark Andrews union {
d389069a397c99347b5b281f90577e19e7662b03Mark Andrews const char *const_ptr;
d389069a397c99347b5b281f90577e19e7662b03Mark Andrews char *deconst_ptr;
d389069a397c99347b5b281f90577e19e7662b03Mark Andrews } ptr;
d389069a397c99347b5b281f90577e19e7662b03Mark Andrews
d389069a397c99347b5b281f90577e19e7662b03Mark Andrews if ((ecode < 0) || (ecode > EAI_MAX))
d389069a397c99347b5b281f90577e19e7662b03Mark Andrews ptr.const_ptr = "invalid error code";
d389069a397c99347b5b281f90577e19e7662b03Mark Andrews else
d389069a397c99347b5b281f90577e19e7662b03Mark Andrews ptr.const_ptr = gai_messages[ecode];
d389069a397c99347b5b281f90577e19e7662b03Mark Andrews return (ptr.deconst_ptr);
d389069a397c99347b5b281f90577e19e7662b03Mark Andrews}
d389069a397c99347b5b281f90577e19e7662b03Mark Andrews