* Copyright (c) 1983 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
static char sccsid
[] = "@(#)gethostnamadr.c 5.1 (Berkeley) %G%";
static struct hostent host
;
static char *host_aliases
[MAXALIASES
];
static char hostbuf
[BUFSIZ
+1];
* 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));
bcopy(cp
, tp
, host
.h_length
);
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 (strcmp(hp
->h_name
, nam
) == 0)
for (cp
= hp
->h_aliases
; cp
!= 0 && *cp
!= 0; cp
++)
if (strcmp(*cp
, nam
) == 0)
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)