/* hosts.c - find out the official name of a host */
static char ident
[] = "@(#)$Id: hosts.c,v 1.7 1992/12/15 00:20:22 jromine Exp $";
/* In the SendMail world, we really don't know what the valid hosts are.
We could poke around in the sendmail.cf file, but that still isn't a
guarantee. As a result, we'll say that everything is a valid host, and
let SendMail worry about it. */
#include "../h/strings.h"
#include "../zotnet/mts.h"
#if defined(BSD42) || defined(SOCKETS)
#endif /* BSD42 or SOCKETS */
char *OfficialName (name
)
#if defined(BSD42) || defined(SOCKETS)
register struct hostent
*hp
;
#endif /* BSD42 or SOCKETS */
static char buffer
[BUFSIZ
];
for (p
= name
, q
= site
; *p
; p
++, q
++)
*q
= isupper (*p
) ? tolower (*p
) : *p
;
if (uleq (LocalName (), site
))
if (rhost (&q
) != NOTOK
) {
(void) strcpy (buffer
, q
);
#if defined(BSD42) || defined(SOCKETS)
if (hp
= gethostbyname (q
)) {
(void) strcpy (buffer
, hp
-> h_name
);
#endif /* BSD42 or SOCKETS */
if (hosts
.h_name
|| init_hs ())
for (h
= hosts
.h_next
; h
; h
= h
-> h_next
)
if (uleq (h
-> h_name
, q
))
for (r
= h
-> h_aliases
; *r
; r
++)
(void) strcpy (buffer
, site
);
/* Use hostable as an exception file for those hosts that aren't on the
Internet (listed in /etc/hosts). These are usually PhoneNet and UUCP
if ((fp
= fopen (hostable
, "r")) == NULL
)
while (fgets (buffer
, sizeof buffer
, fp
) != NULL
) {
if (cp
= index (buffer
, '#'))
if (cp
= index (buffer
, '\n'))
for (cp
= buffer
; *cp
; cp
++)
for (cp
= buffer
; isspace (*cp
); cp
++)
if (cp
= index (dp
= cp
, ' ')) {
if (cp
= index (*q
++ = cp
, ' '))
if (q
>= aliases
+ NALIASES
)
h
-> h_next
= (struct host
*) calloc (1, sizeof *h
);
h
-> h_name
= getcpy (dp
);
(char **) calloc ((unsigned) (q
- aliases
+ 1), sizeof *q
);
for (q
= aliases
; *q
; q
++)