]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man3/getnetent_r.3
fanotify_init.2, fanotify.7: Document FAN_REPORT_TID
[thirdparty/man-pages.git] / man3 / getnetent_r.3
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 2017-09-15 "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 *" result_buf ", char *" buf ,
35 .BI " size_t " buflen ", struct netent **" result ,
36 .BI " int *" h_errnop );
37 .PP
38 .BI "int getnetbyname_r(const char *" name ,
39 .BI " struct netent *" result_buf ", char *" buf ,
40 .BI " size_t " buflen ", struct netent **" result ,
41 .BI " int *" h_errnop );
42 .PP
43 .BI "int getnetbyaddr_r(uint32_t " net ", int " type ,
44 .BI " struct netent *" result_buf ", char *" buf ,
45 .BI " size_t " buflen ", struct netent **" result ,
46 .BI " int *" h_errnop );
47 .PP
48 .fi
49 .in -4n
50 Feature Test Macro Requirements for glibc (see
51 .BR feature_test_macros (7)):
52 .ad l
53 .in
54 .PP
55 .BR getnetent_r (),
56 .BR getnetbyname_r (),
57 .BR getnetbyaddr_r ():
58 Since glibc 2.19:
59 _DEFAULT_SOURCE
60 Glibc 2.19 and earlier:
61 _BSD_SOURCE || _SVID_SOURCE
62 .ad b
63 .SH DESCRIPTION
64 The
65 .BR getnetent_r (),
66 .BR getnetbyname_r (),
67 and
68 .BR getnetbyaddr_r ()
69 functions are the reentrant equivalents of, respectively,
70 .BR getnetent (3),
71 .BR getnetbyname (3),
72 and
73 .BR getnetbynumber (3).
74 They differ in the way that the
75 .I netent
76 structure is returned,
77 and in the function calling signature and return value.
78 This manual page describes just the differences from
79 the nonreentrant functions.
80 .PP
81 Instead of returning a pointer to a statically allocated
82 .I netent
83 structure as the function result,
84 these functions copy the structure into the location pointed to by
85 .IR result_buf .
86 .PP
87 The
88 .I buf
89 array is used to store the string fields pointed to by the returned
90 .I netent
91 structure.
92 (The nonreentrant functions allocate these strings in static storage.)
93 The size of this array is specified in
94 .IR buflen .
95 If
96 .I buf
97 is too small, the call fails with the error
98 .BR ERANGE ,
99 and the caller must try again with a larger buffer.
100 (A buffer of length 1024 bytes should be sufficient for most applications.)
101 .\" I can find no information on the required/recommended buffer size;
102 .\" the nonreentrant functions use a 1024 byte buffer -- mtk.
103 .PP
104 If the function call successfully obtains a network record, then
105 .I *result
106 is set pointing to
107 .IR result_buf ;
108 otherwise,
109 .I *result
110 is set to NULL.
111 .PP
112 The buffer pointed to by
113 .I h_errnop
114 is used to return the value that would be stored in the global variable
115 .I h_errno
116 by the nonreentrant versions of these functions.
117 .\" getnetent.3 doesn't document any use of h_errno, but nevertheless
118 .\" the nonreentrant functions no seem to set h_errno.
119 .SH RETURN VALUE
120 On success, these functions return 0.
121 On error, they return one of the positive error numbers listed in ERRORS.
122 .PP
123 On error, record not found
124 .RB ( getnetbyname_r (),
125 .BR getnetbyaddr_r ()),
126 or end of input
127 .RB ( getnetent_r ())
128 .I result
129 is set to NULL.
130 .SH ERRORS
131 .TP
132 .B ENOENT
133 .RB ( getnetent_r ())
134 No more records in database.
135 .TP
136 .B ERANGE
137 .I buf
138 is too small.
139 Try again with a larger buffer
140 (and increased
141 .IR buflen ).
142 .SH ATTRIBUTES
143 For an explanation of the terms used in this section, see
144 .BR attributes (7).
145 .ad l
146 .TS
147 allbox;
148 lbw17 lb lb
149 l l l.
150 Interface Attribute Value
151 T{
152 .BR getnetent_r (),
153 .BR getnetbyname_r (),
154 .BR getnetbyaddr_r ()
155 T} Thread safety MT-Safe locale
156 .TE
157 .ad
158 .SH CONFORMING TO
159 These functions are GNU extensions.
160 Functions with similar names exist on some other systems,
161 though typically with different calling signatures.
162 .SH SEE ALSO
163 .BR getnetent (3),
164 .BR networks (5)