Commit | Line | Data |
---|---|---|
931a9d50 C |
1 | .TH GETNETENT 3N "9 February 1983" |
2 | .UC 4 | |
3 | .SH NAME | |
4 | getnetent, getnetbyaddr, getnetbyname, setnetent, endnetent \- get network entry | |
5 | .SH SYNOPSIS | |
6 | .nf | |
7 | .ft B | |
8 | #include <netdb.h> | |
9 | .PP | |
10 | .ft B | |
11 | struct netent *getnetent() | |
12 | .PP | |
13 | .ft B | |
14 | struct netent *getnetbyname(name) | |
15 | char *name; | |
16 | .PP | |
17 | .ft B | |
18 | struct netent *getnetbyaddr(net) | |
19 | long net; | |
20 | .PP | |
21 | .ft B | |
22 | setnetent(stayopen) | |
23 | int stayopen | |
24 | .PP | |
25 | .ft B | |
26 | endnetent() | |
27 | .fi | |
28 | .SH DESCRIPTION | |
29 | .IR Getnetent , | |
30 | .IR getnetbyname , | |
31 | and | |
32 | .I getnetbyaddr | |
33 | each return a pointer to an object with the | |
34 | following structure | |
35 | containing the broken-out | |
36 | fields of a line in the network data base, | |
37 | .IR /etc/networks . | |
38 | .RS | |
39 | .PP | |
40 | .nf | |
41 | struct netent { | |
42 | char *n_name; /* official name of net */ | |
43 | char **n_aliases; /* alias list */ | |
44 | int n_addrtype; /* net number type */ | |
45 | long n_net; /* net number */ | |
46 | }; | |
47 | .ft R | |
48 | .ad | |
49 | .fi | |
50 | .RE | |
51 | .PP | |
52 | The members of this structure are: | |
53 | .TP \w'n_addrtype'u+2n | |
54 | n_name | |
55 | The official name of the network. | |
56 | .TP \w'n_addrtype'u+2n | |
57 | n_aliases | |
58 | A zero terminated list of alternate names for the network. | |
59 | .TP \w'n_addrtype'u+2n | |
60 | n_addrtype | |
61 | The type of the network number returned; currently only AF_INET. | |
62 | .TP \w'n_addrtype'u+2n | |
63 | n_net | |
64 | The network number. Network numbers are returned in machine byte | |
65 | order. | |
66 | .PP | |
67 | .I Getnetent | |
68 | reads the next line of the file, opening the file if necessary. | |
69 | .PP | |
70 | .I Setnetent | |
71 | opens and rewinds the file. If the | |
72 | .I stayopen | |
73 | flag is non-zero, | |
74 | the net data base will not be closed after each call to | |
75 | .I getnetent | |
76 | (either directly, or indirectly through one of | |
77 | the other \*(lqgetnet\*(rq calls). | |
78 | .PP | |
79 | .I Endnetent | |
80 | closes the file. | |
81 | .PP | |
82 | .I Getnetbyname | |
83 | and | |
84 | .I getnetbyaddr | |
85 | sequentially search from the beginning | |
86 | of the file until a matching | |
87 | net name or | |
88 | net address is found, | |
89 | or until EOF is encountered. | |
90 | Network numbers are supplied in host order. | |
91 | .SH FILES | |
92 | /etc/networks | |
93 | .SH "SEE ALSO" | |
94 | networks(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 Internet network | |
103 | numbers are currently understood. | |
104 | Expecting network numbers to fit | |
105 | in no more than 32 bits is probably | |
106 | naive. |