1getnetent_r(3) Library Functions Manual getnetent_r(3)
2
3
4
6 getnetent_r, getnetbyname_r, getnetbyaddr_r - get network entry (reen‐
7 trant)
8
10 Standard C library (libc, -lc)
11
13 #include <netdb.h>
14
15 int getnetent_r(struct netent *restrict result_buf,
16 char buf[restrict .buflen], size_t buflen,
17 struct netent **restrict result,
18 int *restrict h_errnop);
19 int getnetbyname_r(const char *restrict name,
20 struct netent *restrict result_buf,
21 char buf[restrict .buflen], size_t buflen,
22 struct netent **restrict result,
23 int *restrict h_errnop);
24 int getnetbyaddr_r(uint32_t net, int type,
25 struct netent *restrict result_buf,
26 char buf[restrict .buflen], size_t buflen,
27 struct netent **restrict result,
28 int *restrict h_errnop);
29
30 Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
31
32 getnetent_r(), getnetbyname_r(), getnetbyaddr_r():
33 Since glibc 2.19:
34 _DEFAULT_SOURCE
35 glibc 2.19 and earlier:
36 _BSD_SOURCE || _SVID_SOURCE
37
39 The getnetent_r(), getnetbyname_r(), and getnetbyaddr_r() functions are
40 the reentrant equivalents of, respectively, getnetent(3), getnetby‐
41 name(3), and getnetbynumber(3). They differ in the way that the netent
42 structure is returned, and in the function calling signature and return
43 value. This manual page describes just the differences from the non‐
44 reentrant functions.
45
46 Instead of returning a pointer to a statically allocated netent struc‐
47 ture as the function result, these functions copy the structure into
48 the location pointed to by result_buf.
49
50 The buf array is used to store the string fields pointed to by the re‐
51 turned netent structure. (The nonreentrant functions allocate these
52 strings in static storage.) The size of this array is specified in bu‐
53 flen. If buf is too small, the call fails with the error ERANGE, and
54 the caller must try again with a larger buffer. (A buffer of length
55 1024 bytes should be sufficient for most applications.)
56
57 If the function call successfully obtains a network record, then *re‐
58 sult is set pointing to result_buf; otherwise, *result is set to NULL.
59
60 The buffer pointed to by h_errnop is used to return the value that
61 would be stored in the global variable h_errno by the nonreentrant ver‐
62 sions of these functions.
63
65 On success, these functions return 0. On error, they return one of the
66 positive error numbers listed in ERRORS.
67
68 On error, record not found (getnetbyname_r(), getnetbyaddr_r()), or end
69 of input (getnetent_r()) result is set to NULL.
70
72 ENOENT (getnetent_r()) No more records in database.
73
74 ERANGE buf is too small. Try again with a larger buffer (and increased
75 buflen).
76
78 For an explanation of the terms used in this section, see at‐
79 tributes(7).
80
81 ┌─────────────────────────────────────┬───────────────┬────────────────┐
82 │Interface │ Attribute │ Value │
83 ├─────────────────────────────────────┼───────────────┼────────────────┤
84 │getnetent_r(), getnetbyname_r(), │ Thread safety │ MT-Safe locale │
85 │getnetbyaddr_r() │ │ │
86 └─────────────────────────────────────┴───────────────┴────────────────┘
87
89 Functions with similar names exist on some other systems, though
90 typically with different calling signatures.
91
93 GNU.
94
96 getnetent(3), networks(5)
97
98
99
100Linux man-pages 6.05 2023-07-20 getnetent_r(3)