* Copyright (c) 1983 Regents of the University of California.
* Redistribution and use in source and binary forms are permitted
* provided that the above copyright notice and this paragraph are
* duplicated in all such forms and that any documentation,
* advertising materials, and other materials related to such
* distribution and use acknowledge that the software was developed
* by the University of California, Berkeley. The name of the
* University may not be used to endorse or promote products derived
* from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid
[] = "@(#)gethostnamadr.c 5.7 (Berkeley) 6/27/88";
#endif /* LIBC_SCCS and not lint */
static struct hostent host
;
static char *host_aliases
[MAXALIASES
];
static char hostbuf
[BUFSIZ
+1];
static char *host_addrs
[2];
* The following is shared with gethostent.c
DBM
*_host_db
= (DBM
*)NULL
;
int _host_stayopen
; /* set by sethostent(), cleared by endhostent() */
register char *cp
, *tp
, **ap
;
return ((struct hostent
*)NULL
);
key
= dbm_fetch(_host_db
, key
);
return ((struct hostent
*)NULL
);
bcopy(cp
, (char *)&naliases
, sizeof(int)); cp
+= sizeof (int);
for (ap
= host_aliases
; naliases
> 0; naliases
--) {
host
.h_aliases
= host_aliases
;
bcopy(cp
, (char *)&host
.h_addrtype
, sizeof (int));
bcopy(cp
, (char *)&host
.h_length
, sizeof (int));
host
.h_addr_list
= host_addrs
;
bcopy(cp
, tp
, host
.h_length
);
register struct hostent
*hp
;
register char *lp
= lowname
;
if ((_host_db
== (DBM
*)NULL
)
&& ((_host_db
= dbm_open(_host_file
, O_RDONLY
)) == (DBM
*)NULL
)) {
sethostent(_host_stayopen
);
while (hp
= gethostent()) {
if (strcmp(hp
->h_name
, lowname
) == 0)
for (cp
= hp
->h_aliases
; cp
!= 0 && *cp
!= 0; cp
++)
if (strcmp(*cp
, lowname
) == 0)
key
.dsize
= strlen(lowname
);
h_errno
= HOST_NOT_FOUND
;
gethostbyaddr(addr
, length
, type
)
register struct hostent
*hp
;
if ((_host_db
== (DBM
*)NULL
)
&& ((_host_db
= dbm_open(_host_file
, O_RDONLY
)) == (DBM
*)NULL
)) {
sethostent(_host_stayopen
);
while (hp
= gethostent()) {
if (hp
->h_addrtype
== type
&& hp
->h_length
== length
&& bcmp(hp
->h_addr
, addr
, length
) == 0)
h_errno
= HOST_NOT_FOUND
;
h_errno
= HOST_NOT_FOUND
;