Plan 9 from Bell Labs’s /usr/web/sources/patch/maybe/ape-updates/gai_strerr.c

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>

#define nil	((void*)0)
#define nelem(a)	(sizeof(a)/sizeof((a)[0]))

char *gaitab[] = {
[-EAI_BADFLAGS]	"bad flags",
[-EAI_NONAME]	"authoratitive negative response",
[-EAI_AGAIN]		"temporary lookup failure",
[-EAI_FAIL]		"name resolution failure",
[-EAI_FAMILY]		"family not supported",
[-EAI_SOCKTYPE]	"ai_socktype not supported",
[-EAI_SERVICE]	"srvname unsupported",
[-EAI_MEMORY]	"no memory",
[-EAI_SYSTEM]		"see errno",
[-EAI_OVERFLOW]	"overflow",
};

const char*
gai_strerror(int error)
{
	unsigned int e;

	e = -error;
	if(e <= nelem(gaitab) && gaitab[e] != nil)
		return gaitab[e];
	return "bogus gai_strerror argument";
}


Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.