gethostent.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*
* files/gethostent.c -- "files" backend for nsswitch "hosts" database
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <netdb.h>
#include "files_common.h"
#include <string.h>
#include <strings.h>
#include <stddef.h>
#include <stdlib.h>
#include <ctype.h>
static int check_name();
static char *do_aliases();
static char *strcasestr();
int __nss_files_2herrno();
static int
{
char **aliasp;
return (0);
return (1);
}
return (1);
}
}
return (0);
}
static nss_status_t
void *a;
{
if (res != NSS_SUCCESS)
return (res);
}
int
{
/*
*/
}
static nss_status_t
void *a;
{
if (res != NSS_SUCCESS)
return (res);
}
static files_backend_op_t host_ops[] = {
};
/*ARGSUSED*/
{
return (_nss_files_constr(host_ops,
NULL));
}
/*
* XXX - this duplicates code from files_common.c because we need to keep
* going after we've found a match to satisfy the multihomed host case.
*/
const char *filter; /* hint for name string */
int type;
{
int parsestat;
char *first;
char *last;
int i, nhosts = 0;
char *abuf = 0; /* alias buffer */
char *abuf_start = 0, *abuf_end;
int (*func)();
return (NSS_UNAVAIL);
}
if (be->f == 0) {
return (res);
}
res = NSS_NOTFOUND;
for (;;) {
int linelen;
break; /* EOF */
}
/*
* This check avoids a malloc()/free() for the common
* case. Also, if we're trying to match an alias and an
* already matched entry doesn't share a canonical name
* with the current one, bail.
*/
continue;
}
*last-- = '\0';
;
/* Ignore blank and comment lines */
if (*first == '\0')
continue;
--last;
break;
}
/*
* If we've already matched once and have a possible match
* on this line, copy the aliases where they're safe from
* being overwritten when we look at the next entry. They're
* saved as a string of blank separated names for the alias
* parser. On errors, we return failure whether or not we
* have already obtained a valid address.
*/
res = NSS_UNAVAIL;
break;
}
abuf_start = &abuf[0];
res = NSS_NOTFOUND;
break;
}
*abuf++ = ' ';
res = NSS_NOTFOUND;
break;
}
}
if (parsestat != NSS_STR_PARSE_SUCCESS) {
if (parsestat == NSS_STR_PARSE_ERANGE)
continue;
}
/*
* Still need to check, strcasestr() above is just a hint.
*/
else {
sizeof (struct in6_addr));
}
if (nhosts == 1) {
res = NSS_SUCCESS;
continue;
}
break;
res = NSS_NOTFOUND;
break;
}
} else if (abuf &&
/*
* This line didn't have the requested name but
* is part of the same multihomed host (i.e. it
* has the same canonical name as the previous
* line), so march on...
*/
continue;
} else if (nhosts) {
break;
}
}
if (abuf) {
((nhosts + 1) * sizeof (char *) +
}
} else {
sizeof (*addrp6)));
((nhosts + 1) * sizeof (char *) +
sizeof (struct in6_addr));
}
}
} else {
}
}
/*
* stayopen is set to 0 by default in order to close the opened
* file. Some applications may break if it is set to 1.
*/
(void) _nss_files_endent(be, 0);
return (res);
}
/*
* A case-insensitive version of strstr().
*/
static char *
char *as1;
char *as2;
{
int c2;
register char *tptr;
return (0);
while (*s1) {
;
if (c2 == 0)
return ((char *)tptr - 1);
}
}
return (0);
}
static char *
char *abuf;
char *start;
char *end;
{
char **cp;
return ((char *)0);
}
*abuf++ = ' ';
}
*abuf = '\0';
return (abuf);
}
/*
* This is a copy of a routine in libnsl/nss/netdir_inet.c. It is
* here because /etc/lib/nss_files.so.1 cannot call routines
* in libnsl. Care should be taken to keep the two copies in sync.
*/
int
{
switch (nsstat) {
case NSS_SUCCESS:
/* no macro-defined success code for h_errno */
return (0);
case NSS_NOTFOUND:
return (HOST_NOT_FOUND);
case NSS_TRYAGAIN:
return (TRY_AGAIN);
case NSS_UNAVAIL:
return (NO_RECOVERY);
}
/* anything else */
return (NO_RECOVERY);
}