1 .\" Copyright 2008, Linux Foundation, written by Michael Kerrisk
2 .\" <mtk.manpages@gmail.com>
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.
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.
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
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
26 .TH GETNETENT_R 3 2021-03-22 "GNU" "Linux Programmer's Manual"
28 getnetent_r, getnetbyname_r, getnetbyaddr_r \- get
29 network entry (reentrant)
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 );
51 Feature Test Macro Requirements for glibc (see
52 .BR feature_test_macros (7)):
56 .BR getnetbyname_r (),
57 .BR getnetbyaddr_r ():
61 Glibc 2.19 and earlier:
62 _BSD_SOURCE || _SVID_SOURCE
67 .BR getnetbyname_r (),
70 functions are the reentrant equivalents of, respectively,
74 .BR getnetbynumber (3).
75 They differ in the way that the
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.
82 Instead of returning a pointer to a statically allocated
84 structure as the function result,
85 these functions copy the structure into the location pointed to by
90 array is used to store the string fields pointed to by the returned
93 (The nonreentrant functions allocate these strings in static storage.)
94 The size of this array is specified in
98 is too small, the call fails with the error
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
113 The buffer pointed to by
115 is used to return the value that would be stored in the global variable
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.
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 ()),
128 .RB ( getnetent_r ())
134 .RB ( getnetent_r ())
135 No more records in database.
140 Try again with a larger buffer
144 For an explanation of the terms used in this section, see
152 Interface Attribute Value
155 .BR getnetbyname_r (),
156 .BR getnetbyaddr_r ()
157 T} Thread safety MT-Safe locale
163 These functions are GNU extensions.
164 Functions with similar names exist on some other systems,
165 though typically with different calling signatures.