]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/getnetent.3
All pages: Remove the 5th argument to .TH
[thirdparty/man-pages.git] / man3 / getnetent.3
CommitLineData
fea681da
MK
1.\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
2.\"
5fbde956 3.\" SPDX-License-Identifier: Linux-man-pages-copyleft
fea681da
MK
4.\"
5.\" References consulted:
6.\" Linux libc source code
7.\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
8.\" 386BSD man pages
9.\" Modified Sat Jul 24 21:48:06 1993 by Rik Faith (faith@cs.unc.edu)
45186a5d 10.TH GETNETENT 3 2021-03-22 "Linux man-pages (unreleased)"
fea681da
MK
11.SH NAME
12getnetent, getnetbyname, getnetbyaddr, setnetent, endnetent \-
c13182ef 13get network entry
42009080
AC
14.SH LIBRARY
15Standard C library
16.RI ( libc ", " \-lc )
fea681da
MK
17.SH SYNOPSIS
18.nf
19.B #include <netdb.h>
68e4db0a 20.PP
fea681da 21.B struct netent *getnetent(void);
68e4db0a 22.PP
fea681da 23.BI "struct netent *getnetbyname(const char *" name );
15c15ebd 24.BI "struct netent *getnetbyaddr(uint32_t " net ", int " type );
68e4db0a 25.PP
fea681da 26.BI "void setnetent(int " stayopen );
fea681da
MK
27.B void endnetent(void);
28.fi
29.SH DESCRIPTION
60a90ecd
MK
30The
31.BR getnetent ()
8dea53c5 32function reads the next entry from the networks database
c6fa0841
MK
33and returns a
34.I netent
35structure containing
8dea53c5
MK
36the broken-out fields from the entry.
37A connection is opened to the database if necessary.
fea681da 38.PP
60a90ecd
MK
39The
40.BR getnetbyname ()
c6fa0841
MK
41function returns a
42.I netent
43structure
8dea53c5 44for the entry from the database
c6fa0841
MK
45that matches the network
46.IR name .
fea681da 47.PP
60a90ecd
MK
48The
49.BR getnetbyaddr ()
c6fa0841
MK
50function returns a
51.I netent
52structure
8dea53c5 53for the entry from the database
c6fa0841
MK
54that matches the network number
55.I net
56of type
57.IR type .
50fda6b3
MK
58The
59.I net
60argument must be in host byte order.
fea681da 61.PP
60a90ecd
MK
62The
63.BR setnetent ()
8dea53c5
MK
64function opens a connection to the database,
65and sets the next entry to the first entry.
c6fa0841
MK
66If
67.I stayopen
68is nonzero,
8dea53c5
MK
69then the connection to the database
70will not be closed between calls to one of the
71.BR getnet* ()
72functions.
fea681da 73.PP
60a90ecd
MK
74The
75.BR endnetent ()
8dea53c5 76function closes the connection to the database.
fea681da 77.PP
c6fa0841
MK
78The
79.I netent
80structure is defined in
81.I <netdb.h>
82as follows:
51f5698d 83.PP
a08ea57c 84.in +4n
b8302363 85.EX
fea681da 86struct netent {
e66cd0f2
MK
87 char *n_name; /* official network name */
88 char **n_aliases; /* alias list */
89 int n_addrtype; /* net address type */
90 uint32_t n_net; /* network number */
fea681da 91}
b8302363 92.EE
a08ea57c 93.in
fea681da 94.PP
c6fa0841
MK
95The members of the
96.I netent
97structure are:
fea681da
MK
98.TP
99.I n_name
100The official name of the network.
101.TP
102.I n_aliases
8dea53c5 103A NULL-terminated list of alternative names for the network.
fea681da
MK
104.TP
105.I n_addrtype
2f0af33b
MK
106The type of the network number; always
107.BR AF_INET .
fea681da
MK
108.TP
109.I n_net
110The network number in host byte order.
47297adb 111.SH RETURN VALUE
60a90ecd
MK
112The
113.BR getnetent (),
d556548b 114.BR getnetbyname (),
60a90ecd
MK
115and
116.BR getnetbyaddr ()
d285b8b3 117functions return a pointer to a
c6fa0841
MK
118statically allocated
119.I netent
b437fdd9 120structure, or a null pointer if an
fea681da
MK
121error occurs or the end of the file is reached.
122.SH FILES
123.TP
124.I /etc/networks
125networks database file
d476c631
ZL
126.SH ATTRIBUTES
127For an explanation of the terms used in this section, see
128.BR attributes (7).
c466875e
MK
129.ad l
130.nh
d476c631
ZL
131.TS
132allbox;
c466875e 133lb lb lbx
d476c631
ZL
134l l l.
135Interface Attribute Value
136T{
137.BR getnetent ()
138T} Thread safety T{
139MT-Unsafe race:netent
d476c631
ZL
140race:netentbuf env locale
141T}
142T{
143.BR getnetbyname ()
144T} Thread safety T{
145MT-Unsafe race:netbyname
d476c631
ZL
146env locale
147T}
148T{
149.BR getnetbyaddr ()
150T} Thread safety T{
151MT-Unsafe race:netbyaddr
d476c631
ZL
152locale
153T}
154T{
155.BR setnetent (),
d476c631
ZL
156.BR endnetent ()
157T} Thread safety T{
158MT-Unsafe race:netent env
d476c631
ZL
159locale
160T}
161.TE
c466875e
MK
162.hy
163.ad
847e0d88 164.sp 1
d476c631
ZL
165In the above table,
166.I netent
167in
168.I race:netent
169signifies that if any of the functions
bf7bc8b8
MK
170.BR setnetent (),
171.BR getnetent (),
d476c631 172or
bf7bc8b8 173.BR endnetent ()
d476c631
ZL
174are used in parallel in different threads of a program,
175then data races could occur.
3113c7f3 176.SH STANDARDS
dfac2a0a 177POSIX.1-2001, POSIX.1-2008, 4.3BSD.
15c15ebd
MK
178.SH NOTES
179In glibc versions before 2.2, the
180.I net
181argument of
182.BR getnetbyaddr ()
183was of type
184.IR long .
47297adb 185.SH SEE ALSO
d285b8b3 186.BR getnetent_r (3),
fea681da 187.BR getprotoent (3),
8dea53c5
MK
188.BR getservent (3)
189.\" .BR networks (5)
fea681da 190.br
331da7c3 191RFC\ 1101