]>
Commit | Line | Data |
---|---|---|
77f18fb6 MK |
1 | .\" Copyright 2008, Linux Foundation, written by Michael Kerrisk |
2 | .\" <mtk.manpages@gmail.com> | |
3 | .\" | |
5fbde956 | 4 | .\" SPDX-License-Identifier: Linux-man-pages-copyleft |
77f18fb6 | 5 | .\" |
45186a5d | 6 | .TH GETNETENT_R 3 2021-03-22 "Linux man-pages (unreleased)" |
77f18fb6 | 7 | .SH NAME |
88850fde | 8 | getnetent_r, getnetbyname_r, getnetbyaddr_r \- get |
77f18fb6 | 9 | network entry (reentrant) |
42009080 AC |
10 | .SH LIBRARY |
11 | Standard C library | |
12 | .RI ( libc ", " \-lc ) | |
77f18fb6 MK |
13 | .SH SYNOPSIS |
14 | .nf | |
15 | .B #include <netdb.h> | |
68e4db0a | 16 | .PP |
0bbc1dec AC |
17 | .BI "int getnetent_r(struct netent *restrict " result_buf , |
18 | .BI " char *restrict " buf ", size_t " buflen , | |
19 | .BI " struct netent **restrict " result , | |
20 | .BI " int *restrict " h_errnop ); | |
21 | .BI "int getnetbyname_r(const char *restrict " name , | |
22 | .BI " struct netent *restrict " result_buf , | |
23 | .BI " char *restrict " buf ", size_t " buflen , | |
24 | .BI " struct netent **restrict " result , | |
25 | .BI " int *restrict " h_errnop ); | |
77f18fb6 | 26 | .BI "int getnetbyaddr_r(uint32_t " net ", int " type , |
0bbc1dec AC |
27 | .BI " struct netent *restrict " result_buf , |
28 | .BI " char *restrict " buf ", size_t " buflen , | |
29 | .BI " struct netent **restrict " result , | |
30 | .BI " int *restrict " h_errnop ); | |
68e4db0a | 31 | .PP |
77f18fb6 | 32 | .fi |
d39ad78f | 33 | .RS -4 |
77f18fb6 MK |
34 | Feature Test Macro Requirements for glibc (see |
35 | .BR feature_test_macros (7)): | |
d39ad78f | 36 | .RE |
68e4db0a | 37 | .PP |
77f18fb6 MK |
38 | .BR getnetent_r (), |
39 | .BR getnetbyname_r (), | |
88850fde | 40 | .BR getnetbyaddr_r (): |
9d2adbae | 41 | .nf |
51c612fb MK |
42 | Since glibc 2.19: |
43 | _DEFAULT_SOURCE | |
44 | Glibc 2.19 and earlier: | |
45 | _BSD_SOURCE || _SVID_SOURCE | |
9d2adbae | 46 | .fi |
77f18fb6 MK |
47 | .SH DESCRIPTION |
48 | The | |
49 | .BR getnetent_r (), | |
50 | .BR getnetbyname_r (), | |
51 | and | |
88850fde | 52 | .BR getnetbyaddr_r () |
77f18fb6 MK |
53 | functions are the reentrant equivalents of, respectively, |
54 | .BR getnetent (3), | |
55 | .BR getnetbyname (3), | |
56 | and | |
57 | .BR getnetbynumber (3). | |
58 | They differ in the way that the | |
59 | .I netent | |
60 | structure is returned, | |
61 | and in the function calling signature and return value. | |
62 | This manual page describes just the differences from | |
54d75d6c | 63 | the nonreentrant functions. |
847e0d88 | 64 | .PP |
77f18fb6 MK |
65 | Instead of returning a pointer to a statically allocated |
66 | .I netent | |
67 | structure as the function result, | |
68 | these functions copy the structure into the location pointed to by | |
69 | .IR result_buf . | |
847e0d88 | 70 | .PP |
77f18fb6 MK |
71 | The |
72 | .I buf | |
73 | array is used to store the string fields pointed to by the returned | |
74 | .I netent | |
75 | structure. | |
54d75d6c | 76 | (The nonreentrant functions allocate these strings in static storage.) |
77f18fb6 MK |
77 | The size of this array is specified in |
78 | .IR buflen . | |
79 | If | |
80 | .I buf | |
81 | is too small, the call fails with the error | |
82 | .BR ERANGE , | |
83 | and the caller must try again with a larger buffer. | |
84 | (A buffer of length 1024 bytes should be sufficient for most applications.) | |
85 | .\" I can find no information on the required/recommended buffer size; | |
54d75d6c | 86 | .\" the nonreentrant functions use a 1024 byte buffer -- mtk. |
847e0d88 | 87 | .PP |
77f18fb6 MK |
88 | If the function call successfully obtains a network record, then |
89 | .I *result | |
90 | is set pointing to | |
91 | .IR result_buf ; | |
92 | otherwise, | |
93 | .I *result | |
94 | is set to NULL. | |
847e0d88 | 95 | .PP |
77f18fb6 MK |
96 | The buffer pointed to by |
97 | .I h_errnop | |
98 | is used to return the value that would be stored in the global variable | |
99 | .I h_errno | |
54d75d6c | 100 | by the nonreentrant versions of these functions. |
77f18fb6 | 101 | .\" getnetent.3 doesn't document any use of h_errno, but nevertheless |
54d75d6c | 102 | .\" the nonreentrant functions no seem to set h_errno. |
47297adb | 103 | .SH RETURN VALUE |
77f18fb6 | 104 | On success, these functions return 0. |
535f0df5 | 105 | On error, they return one of the positive error numbers listed in ERRORS. |
847e0d88 | 106 | .PP |
77f18fb6 MK |
107 | On error, record not found |
108 | .RB ( getnetbyname_r (), | |
88850fde | 109 | .BR getnetbyaddr_r ()), |
77f18fb6 MK |
110 | or end of input |
111 | .RB ( getnetent_r ()) | |
112 | .I result | |
113 | is set to NULL. | |
114 | .SH ERRORS | |
115 | .TP | |
116 | .B ENOENT | |
117 | .RB ( getnetent_r ()) | |
118 | No more records in database. | |
119 | .TP | |
120 | .B ERANGE | |
121 | .I buf | |
122 | is too small. | |
123 | Try again with a larger buffer | |
124 | (and increased | |
125 | .IR buflen ). | |
8eb0dd50 ZL |
126 | .SH ATTRIBUTES |
127 | For an explanation of the terms used in this section, see | |
128 | .BR attributes (7). | |
74714ea8 | 129 | .ad l |
c466875e | 130 | .nh |
8eb0dd50 ZL |
131 | .TS |
132 | allbox; | |
c466875e | 133 | lbx lb lb |
8eb0dd50 ZL |
134 | l l l. |
135 | Interface Attribute Value | |
136 | T{ | |
137 | .BR getnetent_r (), | |
138 | .BR getnetbyname_r (), | |
139 | .BR getnetbyaddr_r () | |
140 | T} Thread safety MT-Safe locale | |
141 | .TE | |
c466875e | 142 | .hy |
74714ea8 | 143 | .ad |
c466875e | 144 | .sp 1 |
3113c7f3 | 145 | .SH STANDARDS |
77f18fb6 MK |
146 | These functions are GNU extensions. |
147 | Functions with similar names exist on some other systems, | |
148 | though typically with different calling signatures. | |
47297adb | 149 | .SH SEE ALSO |
77f18fb6 | 150 | .BR getnetent (3), |
77f18fb6 | 151 | .BR networks (5) |