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