Path: blob/main/crypto/heimdal/lib/roken/gai_strerror.c
39507 views
/*1* Copyright (c) 1999 Kungliga Tekniska Högskolan2* (Royal Institute of Technology, Stockholm, Sweden).3* All rights reserved.4*5* Redistribution and use in source and binary forms, with or without6* modification, are permitted provided that the following conditions7* are met:8*9* 1. Redistributions of source code must retain the above copyright10* notice, this list of conditions and the following disclaimer.11*12* 2. Redistributions in binary form must reproduce the above copyright13* notice, this list of conditions and the following disclaimer in the14* documentation and/or other materials provided with the distribution.15*16* 3. Neither the name of the Institute nor the names of its contributors17* may be used to endorse or promote products derived from this software18* without specific prior written permission.19*20* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND21* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE22* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE23* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE24* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL25* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS26* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)27* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT28* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY29* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF30* SUCH DAMAGE.31*/3233#include <config.h>3435#include "roken.h"3637static struct gai_error {38int code;39const char *str;40} errors[] = {41{EAI_NOERROR, "no error"},42#ifdef EAI_ADDRFAMILY43{EAI_ADDRFAMILY, "address family for nodename not supported"},44#endif45{EAI_AGAIN, "temporary failure in name resolution"},46{EAI_BADFLAGS, "invalid value for ai_flags"},47{EAI_FAIL, "non-recoverable failure in name resolution"},48{EAI_FAMILY, "ai_family not supported"},49{EAI_MEMORY, "memory allocation failure"},50#ifdef EAI_NODATA51{EAI_NODATA, "no address associated with nodename"},52#endif53{EAI_NONAME, "nodename nor servname provided, or not known"},54{EAI_SERVICE, "servname not supported for ai_socktype"},55{EAI_SOCKTYPE, "ai_socktype not supported"},56{EAI_SYSTEM, "system error returned in errno"},57{0, NULL},58};5960/*61*62*/6364ROKEN_LIB_FUNCTION const char * ROKEN_LIB_CALL65gai_strerror(int ecode)66{67struct gai_error *g;6869for (g = errors; g->str != NULL; ++g)70if (g->code == ecode)71return g->str;72return "unknown error code in gai_strerror";73}747576