Commit | Line | Data |
---|---|---|
931a9d50 C |
1 | .TH GETHOSTENT 3N "9 February 1983" |
2 | .UC 4 | |
3 | .SH NAME | |
4 | gethostent, gethostbyaddr, gethostbyname, sethostent, endhostent \- get network host entry | |
5 | .SH SYNOPSIS | |
6 | .B "#include <netdb.h> | |
7 | .PP | |
8 | .B "struct hostent *gethostent() | |
9 | .PP | |
10 | .B "struct hostent *gethostbyname(name) | |
11 | .br | |
12 | .B "char *name; | |
13 | .PP | |
14 | .B "struct hostent *gethostbyaddr(addr, len, type) | |
15 | .br | |
16 | .B "char *addr; int len, type; | |
17 | .PP | |
18 | .B "sethostent(stayopen) | |
19 | .br | |
20 | .B "int stayopen | |
21 | .PP | |
22 | .B "endhostent() | |
23 | .SH DESCRIPTION | |
24 | .IR Gethostent , | |
25 | .IR gethostbyname , | |
26 | and | |
27 | .I gethostbyaddr | |
28 | each return a pointer to an object with the | |
29 | following structure | |
30 | containing the broken-out | |
31 | fields of a line in the network host data base, | |
32 | .IR /etc/hosts . | |
33 | .RS | |
34 | .PP | |
35 | .nf | |
36 | struct hostent { | |
37 | char *h_name; /* official name of host */ | |
38 | char **h_aliases; /* alias list */ | |
39 | int h_addrtype; /* address type */ | |
40 | int h_length; /* length of address */ | |
41 | char *h_addr; /* address */ | |
42 | }; | |
43 | .ft R | |
44 | .ad | |
45 | .fi | |
46 | .RE | |
47 | .PP | |
48 | The members of this structure are: | |
49 | .TP \w'h_addrtype'u+2n | |
50 | h_name | |
51 | Official name of the host. | |
52 | .TP \w'h_addrtype'u+2n | |
53 | h_aliases | |
54 | A zero terminated array of alternate names for the host. | |
55 | .TP \w'h_addrtype'u+2n | |
56 | h_addrtype | |
57 | The type of address being returned; currently always AF_INET. | |
58 | .TP \w'h_addrtype'u+2n | |
59 | h_length | |
60 | The length, in bytes, of the address. | |
61 | .TP \w'h_addrtype'u+2n | |
62 | h_addr | |
63 | A pointer to the network address for the host. | |
64 | Host addresses are returned | |
65 | in network byte order. | |
66 | .PP | |
67 | .I Gethostent | |
68 | reads the next line of the file, opening the file if necessary. | |
69 | .PP | |
70 | .I Sethostent | |
71 | opens and rewinds the file. If the | |
72 | .I stayopen | |
73 | flag is non-zero, | |
74 | the host data base will not be closed after each call to | |
75 | .I gethostent | |
76 | (either directly, or indirectly through one of the other | |
77 | \*(lqgethost\*(rq calls). | |
78 | .PP | |
79 | .I Endhostent | |
80 | closes the file. | |
81 | .PP | |
82 | .I Gethostbyname | |
83 | and | |
84 | .I gethostbyaddr | |
85 | sequentially search from the beginning | |
86 | of the file until a matching | |
87 | host name or | |
88 | host address is found, | |
89 | or until EOF is encountered. | |
90 | Host addresses are supplied in network order. | |
91 | .SH FILES | |
92 | /etc/hosts | |
93 | .SH "SEE ALSO" | |
94 | hosts(5) | |
95 | .SH DIAGNOSTICS | |
96 | Null pointer | |
97 | (0) returned on EOF or error. | |
98 | .SH BUGS | |
99 | All information | |
100 | is contained in a static area | |
101 | so it must be copied if it is | |
102 | to be saved. Only the Internet | |
103 | address format is currently understood. |