]>
Commit | Line | Data |
---|---|---|
77f18fb6 MK |
1 | .\" Copyright 2008, Linux Foundation, written by Michael Kerrisk |
2 | .\" <mtk.manpages@gmail.com> | |
3 | .\" | |
93015253 | 4 | .\" %%%LICENSE_START(VERBATIM) |
77f18fb6 MK |
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. | |
4b72fb64 | 24 | .\" %%%LICENSE_END |
77f18fb6 | 25 | .\" |
4b8c67d9 | 26 | .TH GETNETENT_R 3 2017-09-15 "GNU" "Linux Programmer's Manual" |
77f18fb6 | 27 | .SH NAME |
88850fde | 28 | getnetent_r, getnetbyname_r, getnetbyaddr_r \- get |
77f18fb6 MK |
29 | network entry (reentrant) |
30 | .SH SYNOPSIS | |
31 | .nf | |
32 | .B #include <netdb.h> | |
68e4db0a | 33 | .PP |
77f18fb6 MK |
34 | .BI "int getnetent_r(struct netent *" result_buf ", char *" buf , |
35 | .BI " size_t " buflen ", struct netent **" result , | |
36 | .BI " int *" h_errnop ); | |
68e4db0a | 37 | .PP |
77f18fb6 MK |
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 ); | |
68e4db0a | 42 | .PP |
77f18fb6 MK |
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 ); | |
68e4db0a | 47 | .PP |
77f18fb6 MK |
48 | .fi |
49 | .in -4n | |
50 | Feature Test Macro Requirements for glibc (see | |
51 | .BR feature_test_macros (7)): | |
52 | .ad l | |
53 | .in | |
68e4db0a | 54 | .PP |
77f18fb6 MK |
55 | .BR getnetent_r (), |
56 | .BR getnetbyname_r (), | |
88850fde | 57 | .BR getnetbyaddr_r (): |
51c612fb MK |
58 | Since glibc 2.19: |
59 | _DEFAULT_SOURCE | |
60 | Glibc 2.19 and earlier: | |
61 | _BSD_SOURCE || _SVID_SOURCE | |
77f18fb6 MK |
62 | .ad b |
63 | .SH DESCRIPTION | |
64 | The | |
65 | .BR getnetent_r (), | |
66 | .BR getnetbyname_r (), | |
67 | and | |
88850fde | 68 | .BR getnetbyaddr_r () |
77f18fb6 MK |
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 | |
54d75d6c | 79 | the nonreentrant functions. |
847e0d88 | 80 | .PP |
77f18fb6 MK |
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 . | |
847e0d88 | 86 | .PP |
77f18fb6 MK |
87 | The |
88 | .I buf | |
89 | array is used to store the string fields pointed to by the returned | |
90 | .I netent | |
91 | structure. | |
54d75d6c | 92 | (The nonreentrant functions allocate these strings in static storage.) |
77f18fb6 MK |
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; | |
54d75d6c | 102 | .\" the nonreentrant functions use a 1024 byte buffer -- mtk. |
847e0d88 | 103 | .PP |
77f18fb6 MK |
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. | |
847e0d88 | 111 | .PP |
77f18fb6 MK |
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 | |
54d75d6c | 116 | by the nonreentrant versions of these functions. |
77f18fb6 | 117 | .\" getnetent.3 doesn't document any use of h_errno, but nevertheless |
54d75d6c | 118 | .\" the nonreentrant functions no seem to set h_errno. |
47297adb | 119 | .SH RETURN VALUE |
77f18fb6 | 120 | On success, these functions return 0. |
535f0df5 | 121 | On error, they return one of the positive error numbers listed in ERRORS. |
847e0d88 | 122 | .PP |
77f18fb6 MK |
123 | On error, record not found |
124 | .RB ( getnetbyname_r (), | |
88850fde | 125 | .BR getnetbyaddr_r ()), |
77f18fb6 MK |
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 ). | |
8eb0dd50 ZL |
142 | .SH ATTRIBUTES |
143 | For an explanation of the terms used in this section, see | |
144 | .BR attributes (7). | |
74714ea8 | 145 | .ad l |
8eb0dd50 ZL |
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 | |
74714ea8 | 157 | .ad |
47297adb | 158 | .SH CONFORMING TO |
77f18fb6 MK |
159 | These functions are GNU extensions. |
160 | Functions with similar names exist on some other systems, | |
161 | though typically with different calling signatures. | |
47297adb | 162 | .SH SEE ALSO |
77f18fb6 | 163 | .BR getnetent (3), |
77f18fb6 | 164 | .BR networks (5) |