0
|
1 /* hosts.c - find out the official name of a host */
|
|
2 #ifndef lint
|
|
3 static char ident[] = "@(#)$Id$";
|
|
4 #endif /* lint */
|
|
5
|
|
6 /* LINTLIBRARY */
|
|
7
|
|
8 #undef NETWORK
|
|
9 #if defined(BSD41A) || defined(BSD42) || defined(SOCKETS)
|
|
10 #define NETWORK
|
|
11 #endif /* not (defined(BSD41A) || defined(BSD42) || defined(SOCKETS)) */
|
|
12
|
|
13 #include "../h/strings.h"
|
|
14 #include <stdio.h>
|
|
15 #include "../zotnet/mts.h"
|
|
16 #include <ctype.h>
|
|
17 #if defined(BSD42) || defined(SOCKETS)
|
|
18 #include <netdb.h>
|
|
19 #endif /* BSD42 or SOCKETS */
|
|
20
|
|
21
|
|
22 #define NOTOK (-1)
|
|
23
|
|
24 /* */
|
|
25
|
|
26 struct hostent *mh_gethostbyname();
|
|
27
|
|
28 char *OfficialName (name)
|
|
29 char *name;
|
|
30 {
|
|
31 register char *p;
|
|
32 char *q,
|
|
33 site[BUFSIZ];
|
|
34 #ifdef NETWORK
|
|
35 static char buffer[BUFSIZ];
|
|
36 #if defined(BSD42) || defined(SOCKETS)
|
|
37 register struct hostent *hp;
|
|
38 #endif /* BSD42 or SOCKETS */
|
|
39 #endif /* NETWORK */
|
|
40
|
|
41 for (p = name, q = site; *p; p++, q++)
|
|
42 *q = isupper (*p) ? tolower (*p) : *p;
|
|
43 *q = 0;
|
|
44 q = site;
|
|
45
|
|
46 if (uleq (LocalName (), site))
|
|
47 return LocalName ();
|
|
48
|
|
49 #ifdef BSD41A
|
|
50 if (rhost (&q) != NOTOK) {
|
|
51 (void) strcpy (buffer, q);
|
|
52 free (q);
|
|
53 return buffer;
|
|
54 }
|
|
55 #endif /* BSD41A */
|
|
56 #if defined(BSD42) || defined(SOCKETS)
|
|
57 if (hp = mh_gethostbyname (q)) {
|
|
58 (void) strcpy (buffer, hp -> h_name);
|
|
59 return buffer;
|
|
60 }
|
|
61 #endif /* BSD42 or SOCKETS */
|
|
62
|
|
63 return NULL;
|
|
64 }
|