9 date 92.12.15.00.20.22; author jromine; state Exp;
14 date 92.01.31.21.37.07; author jromine; state Exp;
19 date 90.04.05.15.30.14; author sources; state Exp;
24 date 90.04.05.14.43.37; author sources; state Exp;
29 date 90.02.06.12.57.57; author sources; state Exp;
34 date 90.02.05.14.52.35; author sources; state Exp;
39 date 90.02.05.14.52.05; author sources; state Exp;
53 @/* hosts.c - find out the official name of a host */
55 static char ident[] = "@@(#)$Id: hosts.c,v 1.6 1992/01/31 21:37:07 jromine Exp jromine $";
60 /* In the SendMail world, we really don't know what the valid hosts are.
61 We could poke around in the sendmail.cf file, but that still isn't a
62 guarantee. As a result, we'll say that everything is a valid host, and
63 let SendMail worry about it. */
66 #include "../h/strings.h"
68 #include "../zotnet/mts.h"
70 #if defined(BSD42) || defined(SOCKETS)
72 #endif /* BSD42 or SOCKETS */
90 char *OfficialName (name)
96 #if defined(BSD42) || defined(SOCKETS)
97 register struct hostent *hp;
98 #endif /* BSD42 or SOCKETS */
99 static char buffer[BUFSIZ];
101 register struct host *h;
103 for (p = name, q = site; *p; p++, q++)
104 *q = isupper (*p) ? tolower (*p) : *p;
108 if (uleq (LocalName (), site))
112 if (rhost (&q) != NOTOK) {
113 (void) strcpy (buffer, q);
118 #if defined(BSD42) || defined(SOCKETS)
122 if (hp = gethostbyname (q)) {
123 (void) strcpy (buffer, hp -> h_name);
126 #endif /* BSD42 or SOCKETS */
128 if (hosts.h_name || init_hs ())
129 for (h = hosts.h_next; h; h = h -> h_next)
130 if (uleq (h -> h_name, q))
133 for (r = h -> h_aliases; *r; r++)
137 (void) strcpy (buffer, site);
143 /* Use hostable as an exception file for those hosts that aren't on the
144 Internet (listed in /etc/hosts). These are usually PhoneNet and UUCP
150 static int init_hs () {
157 register struct host *h;
160 if ((fp = fopen (hostable, "r")) == NULL)
164 while (fgets (buffer, sizeof buffer, fp) != NULL) {
165 if (cp = index (buffer, '#'))
167 if (cp = index (buffer, '\n'))
169 for (cp = buffer; *cp; cp++)
172 for (cp = buffer; isspace (*cp); cp++)
178 if (cp = index (dp = cp, ' ')) {
180 for (cp++; *cp; cp++) {
181 while (isspace (*cp))
185 if (cp = index (*q++ = cp, ' '))
189 if (q >= aliases + NALIASES)
196 h -> h_next = (struct host *) calloc (1, sizeof *h);
198 h -> h_name = getcpy (dp);
200 (char **) calloc ((unsigned) (q - aliases + 1), sizeof *q);
201 for (q = aliases; *q; q++)
219 static char ident[] = "@@(#)$Id: hosts.c,v 1.5 1990/04/05 15:30:14 sources Exp jromine $";
223 #endif BSD42 or SOCKETS
226 #endif BSD42 or SOCKETS
232 #endif BSD42 or SOCKETS
243 static char ident[] = "@@(#)$Id:$";
281 static char ident[] = "$Id:";