fake-getaddrinfo.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* fake library for ssh
*
* This file includes getaddrinfo(), freeaddrinfo() and gai_strerror().
* These funtions are defined in rfc2133.
*
* But these functions are not implemented correctly. The minimum subset
* is implemented for ssh use only. For exapmle, this routine assumes
* that ai_family is AF_INET. Don't use it for another purpose.
*/
#include "includes.h"
#include "ssh.h"
RCSID("$Id: fake-getaddrinfo.c,v 1.2 2001/02/09 01:55:36 djm Exp $");
#pragma ident "%Z%%M% %I% %E% SMI"
#ifndef HAVE_GAI_STRERROR
char *gai_strerror(int ecode)
{
switch (ecode) {
case EAI_NODATA:
return "no address associated with hostname.";
case EAI_MEMORY:
return "memory allocation failure.";
default:
return "unknown error.";
}
}
#endif /* !HAVE_GAI_STRERROR */
#ifndef HAVE_FREEADDRINFO
{
do {
}
#endif /* !HAVE_FREEADDRINFO */
#ifndef HAVE_GETADDRINFO
{
return(NULL);
/* XXX -- ssh doesn't use sa_len */
return(ai);
}
{
int i, port;
if (servname)
else
port = 0;
return 0;
else
return EAI_MEMORY;
}
if (!hostname) {
return 0;
else
return EAI_MEMORY;
}
return 0;
else
return EAI_MEMORY;
}
for (i = 0; hp->h_addr_list[i]; i++) {
if (*res)
freeaddrinfo(*res);
return EAI_MEMORY;
}
if (prev)
else
}
return 0;
}
return EAI_NODATA;
}
#endif /* !HAVE_GETADDRINFO */