mount_setattr.2: ffix
[man-pages.git] / man3 / getnetent_r.3
blob16aacef4010c250a542434637e37ff1b8a58bfb9
1 .\" Copyright 2008, Linux Foundation, written by Michael Kerrisk
2 .\"     <mtk.manpages@gmail.com>
3 .\"
4 .\" %%%LICENSE_START(VERBATIM)
5 .\" Permission is granted to make and distribute verbatim copies of this
6 .\" manual provided the copyright notice and this permission notice are
7 .\" preserved on all copies.
8 .\"
9 .\" Permission is granted to copy and distribute modified versions of this
10 .\" manual under the conditions for verbatim copying, provided that the
11 .\" entire resulting derived work is distributed under the terms of a
12 .\" permission notice identical to this one.
13 .\"
14 .\" Since the Linux kernel and libraries are constantly changing, this
15 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
16 .\" responsibility for errors or omissions, or for damages resulting from
17 .\" the use of the information contained herein.  The author(s) may not
18 .\" have taken the same level of care in the production of this manual,
19 .\" which is licensed free of charge, as they might when working
20 .\" professionally.
21 .\"
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
24 .\" %%%LICENSE_END
25 .\"
26 .TH GETNETENT_R 3  2021-03-22 "GNU" "Linux Programmer's Manual"
27 .SH NAME
28 getnetent_r, getnetbyname_r, getnetbyaddr_r \- get
29 network entry (reentrant)
30 .SH SYNOPSIS
31 .nf
32 .B #include <netdb.h>
33 .PP
34 .BI "int getnetent_r(struct netent *restrict " result_buf ,
35 .BI "                char *restrict " buf ", size_t " buflen ,
36 .BI "                struct netent **restrict " result ,
37 .BI "                int *restrict " h_errnop );
38 .BI "int getnetbyname_r(const char *restrict " name ,
39 .BI "                struct netent *restrict " result_buf ,
40 .BI "                char *restrict " buf ", size_t " buflen ,
41 .BI "                struct netent **restrict " result ,
42 .BI "                int *restrict " h_errnop );
43 .BI "int getnetbyaddr_r(uint32_t " net ", int " type ,
44 .BI "                struct netent *restrict " result_buf ,
45 .BI "                char *restrict " buf ", size_t " buflen ,
46 .BI "                struct netent **restrict " result ,
47 .BI "                int *restrict " h_errnop );
48 .PP
49 .fi
50 .RS -4
51 Feature Test Macro Requirements for glibc (see
52 .BR feature_test_macros (7)):
53 .RE
54 .PP
55 .BR getnetent_r (),
56 .BR getnetbyname_r (),
57 .BR getnetbyaddr_r ():
58 .nf
59     Since glibc 2.19:
60         _DEFAULT_SOURCE
61     Glibc 2.19 and earlier:
62         _BSD_SOURCE || _SVID_SOURCE
63 .fi
64 .SH DESCRIPTION
65 The
66 .BR getnetent_r (),
67 .BR getnetbyname_r (),
68 and
69 .BR getnetbyaddr_r ()
70 functions are the reentrant equivalents of, respectively,
71 .BR getnetent (3),
72 .BR getnetbyname (3),
73 and
74 .BR getnetbynumber (3).
75 They differ in the way that the
76 .I netent
77 structure is returned,
78 and in the function calling signature and return value.
79 This manual page describes just the differences from
80 the nonreentrant functions.
81 .PP
82 Instead of returning a pointer to a statically allocated
83 .I netent
84 structure as the function result,
85 these functions copy the structure into the location pointed to by
86 .IR result_buf .
87 .PP
88 The
89 .I buf
90 array is used to store the string fields pointed to by the returned
91 .I netent
92 structure.
93 (The nonreentrant functions allocate these strings in static storage.)
94 The size of this array is specified in
95 .IR buflen .
97 .I buf
98 is too small, the call fails with the error
99 .BR ERANGE ,
100 and the caller must try again with a larger buffer.
101 (A buffer of length 1024 bytes should be sufficient for most applications.)
102 .\" I can find no information on the required/recommended buffer size;
103 .\" the nonreentrant functions use a 1024 byte buffer -- mtk.
105 If the function call successfully obtains a network record, then
106 .I *result
107 is set pointing to
108 .IR result_buf ;
109 otherwise,
110 .I *result
111 is set to NULL.
113 The buffer pointed to by
114 .I h_errnop
115 is used to return the value that would be stored in the global variable
116 .I h_errno
117 by the nonreentrant versions of these functions.
118 .\" getnetent.3 doesn't document any use of h_errno, but nevertheless
119 .\" the nonreentrant functions no seem to set h_errno.
120 .SH RETURN VALUE
121 On success, these functions return 0.
122 On error, they return one of the positive error numbers listed in ERRORS.
124 On error, record not found
125 .RB ( getnetbyname_r (),
126 .BR getnetbyaddr_r ()),
127 or end of input
128 .RB ( getnetent_r ())
129 .I result
130 is set to NULL.
131 .SH ERRORS
133 .B ENOENT
134 .RB ( getnetent_r ())
135 No more records in database.
137 .B ERANGE
138 .I buf
139 is too small.
140 Try again with a larger buffer
141 (and increased
142 .IR buflen ).
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 lbx lb lb
151 l l l.
152 Interface       Attribute       Value
154 .BR getnetent_r (),
155 .BR getnetbyname_r (),
156 .BR getnetbyaddr_r ()
157 T}      Thread safety   MT-Safe locale
161 .sp 1
162 .SH CONFORMING TO
163 These functions are GNU extensions.
164 Functions with similar names exist on some other systems,
165 though typically with different calling signatures.
166 .SH SEE ALSO
167 .BR getnetent (3),
168 .BR networks (5)