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