/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* 3. Neither the name of the project nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* Issues to be discussed:
* - Thread safe-ness must be checked
* - Return values. There seems to be no standard for return value (RFC2553)
* but INRIA implementation returns EAI_xxx defined for getaddrinfo().
*/
#include <netdb.h>
#include <resolv.h>
#include <string.h>
#include <stddef.h>
#include "addrinfo.h"
#define SUCCESS 0
#define ANY 0
#define NO 0
static struct afd {
int a_af;
int a_addrlen;
int a_socklen;
int a_off;
} afdl [] = {
#ifdef INET6
#endif
{0, 0, 0},
};
struct sockinet {
};
#define ENI_NOSOCKET 0
int
char *host;
char *serv;
int flags;
{
char *addr, *p;
int h_error;
return ENI_NOSOCKET;
#ifdef HAVE_SA_LEN
#else
#endif
goto found;
}
return ENI_FAMILY;
/* what we should do? */
} else if (flags & NI_NUMERICSERV) {
return ENI_MEMORY;
} else {
if (sp) {
return ENI_MEMORY;
} else
return ENI_NOSERVNAME;
}
case AF_INET:
flags |= NI_NUMERICHOST;
flags |= NI_NUMERICHOST;
break;
#ifdef INET6
case AF_INET6:
{
case 0x00:
;
;
else
flags |= NI_NUMERICHOST;
break;
default:
flags |= NI_NUMERICHOST;
flags |= NI_NUMERICHOST;
break;
}
}
break;
#endif
}
/* what should we do? */
} else if (flags & NI_NUMERICHOST) {
/* NUMERICHOST and NAMEREQD conflicts with each other */
if (flags & NI_NAMEREQD)
return ENI_NOHOSTNAME;
== NULL)
return ENI_SYSTEM;
return ENI_MEMORY;
} else {
#ifdef USE_GETIPNODEBY
#else
#endif
if (hp) {
if (p) *p = '\0';
}
#ifdef USE_GETIPNODEBY
#endif
return ENI_MEMORY;
}
#ifdef USE_GETIPNODEBY
#endif
} else {
if (flags & NI_NAMEREQD)
return ENI_NOHOSTNAME;
== NULL)
return ENI_NOHOSTNAME;
return ENI_MEMORY;
}
}
return SUCCESS;
}