]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man3/getnetent_r.3
getent.1, intro.1, time.1, _exit.2, _syscall.2, accept.2, access.2, acct.2, adjtimex...
[thirdparty/man-pages.git] / man3 / getnetent_r.3
1 .\" Copyright 2008, Linux Foundation, written by Michael Kerrisk
2 .\" <mtk.manpages@gmail.com>
3 .\"
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
7 .\"
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
12 .\"
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date. The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein. The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
19 .\" professionally.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\"
24 .TH GETNETENT_R 3 2010-09-10 "GNU" "Linux Programmer's Manual"
25 .SH NAME
26 getnetent_r, getnetbyname_r, getnetbyaddr_r \- get
27 network entry (reentrant)
28 .SH SYNOPSIS
29 .nf
30 .B #include <netdb.h>
31 .sp
32 .BI "int getnetent_r(struct netent *" result_buf ", char *" buf ,
33 .BI " size_t " buflen ", struct netent **" result ,
34 .BI " int *" h_errnop );
35 .sp
36 .BI "int getnetbyname_r(const char *" name ,
37 .BI " struct netent *" result_buf ", char *" buf ,
38 .BI " size_t " buflen ", struct netent **" result ,
39 .BI " int *" h_errnop );
40 .sp
41 .BI "int getnetbyaddr_r(uint32_t " net ", int " type ,
42 .BI " struct netent *" result_buf ", char *" buf ,
43 .BI " size_t " buflen ", struct netent **" result ,
44 .BI " int *" h_errnop );
45 .sp
46 .fi
47 .in -4n
48 Feature Test Macro Requirements for glibc (see
49 .BR feature_test_macros (7)):
50 .ad l
51 .in
52 .sp
53 .BR getnetent_r (),
54 .BR getnetbyname_r (),
55 .BR getnetbyaddr_r ():
56 .RS 4
57 _BSD_SOURCE || _SVID_SOURCE
58 .RE
59 .ad b
60 .SH DESCRIPTION
61 The
62 .BR getnetent_r (),
63 .BR getnetbyname_r (),
64 and
65 .BR getnetbyaddr_r ()
66 functions are the reentrant equivalents of, respectively,
67 .BR getnetent (3),
68 .BR getnetbyname (3),
69 and
70 .BR getnetbynumber (3).
71 They differ in the way that the
72 .I netent
73 structure is returned,
74 and in the function calling signature and return value.
75 This manual page describes just the differences from
76 the nonreentrant functions.
77
78 Instead of returning a pointer to a statically allocated
79 .I netent
80 structure as the function result,
81 these functions copy the structure into the location pointed to by
82 .IR result_buf .
83
84 The
85 .I buf
86 array is used to store the string fields pointed to by the returned
87 .I netent
88 structure.
89 (The nonreentrant functions allocate these strings in static storage.)
90 The size of this array is specified in
91 .IR buflen .
92 If
93 .I buf
94 is too small, the call fails with the error
95 .BR ERANGE ,
96 and the caller must try again with a larger buffer.
97 (A buffer of length 1024 bytes should be sufficient for most applications.)
98 .\" I can find no information on the required/recommended buffer size;
99 .\" the nonreentrant functions use a 1024 byte buffer -- mtk.
100
101 If the function call successfully obtains a network record, then
102 .I *result
103 is set pointing to
104 .IR result_buf ;
105 otherwise,
106 .I *result
107 is set to NULL.
108
109 The buffer pointed to by
110 .I h_errnop
111 is used to return the value that would be stored in the global variable
112 .I h_errno
113 by the nonreentrant versions of these functions.
114 .\" getnetent.3 doesn't document any use of h_errno, but nevertheless
115 .\" the nonreentrant functions no seem to set h_errno.
116 .SH RETURN VALUE
117 On success, these functions return 0.
118 On error, they return one of the positive error numbers listed in ERRORS.
119
120 On error, record not found
121 .RB ( getnetbyname_r (),
122 .BR getnetbyaddr_r ()),
123 or end of input
124 .RB ( getnetent_r ())
125 .I result
126 is set to NULL.
127 .SH ERRORS
128 .TP
129 .B ENOENT
130 .RB ( getnetent_r ())
131 No more records in database.
132 .TP
133 .B ERANGE
134 .I buf
135 is too small.
136 Try again with a larger buffer
137 (and increased
138 .IR buflen ).
139 .SH CONFORMING TO
140 These functions are GNU extensions.
141 Functions with similar names exist on some other systems,
142 though typically with different calling signatures.
143 .SH SEE ALSO
144 .BR getnetent (3),
145 .BR networks (5)