wait.2: Add ESRCH for when pid == INT_MIN
[man-pages.git] / man3 / getnetent.3
blobffbef15eaf8b4977db2e0eb04b3a397fc84a1f9e
1 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
2 .\"
3 .\" %%%LICENSE_START(VERBATIM)
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
7 .\"
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
12 .\"
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein.  The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
19 .\" professionally.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" %%%LICENSE_END
24 .\"
25 .\" References consulted:
26 .\"     Linux libc source code
27 .\"     Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
28 .\"     386BSD man pages
29 .\" Modified Sat Jul 24 21:48:06 1993 by Rik Faith (faith@cs.unc.edu)
30 .TH GETNETENT 3  2021-03-22 "GNU" "Linux Programmer's Manual"
31 .SH NAME
32 getnetent, getnetbyname, getnetbyaddr, setnetent, endnetent \-
33 get network entry
34 .SH SYNOPSIS
35 .nf
36 .B #include <netdb.h>
37 .PP
38 .B struct netent *getnetent(void);
39 .PP
40 .BI "struct netent *getnetbyname(const char *" name );
41 .BI "struct netent *getnetbyaddr(uint32_t " net ", int " type );
42 .PP
43 .BI "void setnetent(int " stayopen );
44 .B void endnetent(void);
45 .fi
46 .SH DESCRIPTION
47 The
48 .BR getnetent ()
49 function reads the next entry from the networks database
50 and returns a
51 .I netent
52 structure containing
53 the broken-out fields from the entry.
54 A connection is opened to the database if necessary.
55 .PP
56 The
57 .BR getnetbyname ()
58 function returns a
59 .I netent
60 structure
61 for the entry from the database
62 that matches the network
63 .IR name .
64 .PP
65 The
66 .BR getnetbyaddr ()
67 function returns a
68 .I netent
69 structure
70 for the entry from the database
71 that matches the network number
72 .I net
73 of type
74 .IR type .
75 The
76 .I net
77 argument must be in host byte order.
78 .PP
79 The
80 .BR setnetent ()
81 function opens a connection to the database,
82 and sets the next entry to the first entry.
84 .I stayopen
85 is nonzero,
86 then the connection to the database
87 will not be closed between calls to one of the
88 .BR getnet* ()
89 functions.
90 .PP
91 The
92 .BR endnetent ()
93 function closes the connection to the database.
94 .PP
95 The
96 .I netent
97 structure is defined in
98 .I <netdb.h>
99 as follows:
101 .in +4n
103 struct netent {
104     char      *n_name;     /* official network name */
105     char     **n_aliases;  /* alias list */
106     int        n_addrtype; /* net address type */
107     uint32_t   n_net;      /* network number */
112 The members of the
113 .I netent
114 structure are:
116 .I n_name
117 The official name of the network.
119 .I n_aliases
120 A NULL-terminated list of alternative names for the network.
122 .I n_addrtype
123 The type of the network number; always
124 .BR AF_INET .
126 .I n_net
127 The network number in host byte order.
128 .SH RETURN VALUE
130 .BR getnetent (),
131 .BR getnetbyname (),
133 .BR getnetbyaddr ()
134 functions return a pointer to a
135 statically allocated
136 .I netent
137 structure, or a null pointer if an
138 error occurs or the end of the file is reached.
139 .SH FILES
141 .I /etc/networks
142 networks database file
143 .SH ATTRIBUTES
144 For an explanation of the terms used in this section, see
145 .BR attributes (7).
146 .ad l
149 allbox;
150 lb lb lbx
151 l l l.
152 Interface       Attribute       Value
154 .BR getnetent ()
155 T}      Thread safety   T{
156 MT-Unsafe race:netent
157 race:netentbuf env locale
160 .BR getnetbyname ()
161 T}      Thread safety   T{
162 MT-Unsafe race:netbyname
163 env locale
166 .BR getnetbyaddr ()
167 T}      Thread safety   T{
168 MT-Unsafe race:netbyaddr
169 locale
172 .BR setnetent (),
173 .BR endnetent ()
174 T}      Thread safety   T{
175 MT-Unsafe race:netent env
176 locale
181 .sp 1
182 In the above table,
183 .I netent
185 .I race:netent
186 signifies that if any of the functions
187 .BR setnetent (),
188 .BR getnetent (),
190 .BR endnetent ()
191 are used in parallel in different threads of a program,
192 then data races could occur.
193 .SH CONFORMING TO
194 POSIX.1-2001, POSIX.1-2008, 4.3BSD.
195 .SH NOTES
196 In glibc versions before 2.2, the
197 .I net
198 argument of
199 .BR getnetbyaddr ()
200 was of type
201 .IR long .
202 .SH SEE ALSO
203 .BR getnetent_r (3),
204 .BR getprotoent (3),
205 .BR getservent (3)
206 .\" .BR networks (5)
208 RFC\ 1101