OSDN Git Service

LDP: Update original to LDP v3.79
[linuxjm/LDP_man-pages.git] / original / man3 / getnetent_r.3
1 .\" Copyright 2008, Linux Foundation, written by Michael Kerrisk
2 .\"     <mtk.manpages@gmail.com>
3 .\"
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.
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.
24 .\" %%%LICENSE_END
25 .\"
26 .TH GETNETENT_R 3  2010-09-10 "GNU" "Linux Programmer's Manual"
27 .SH NAME
28 getnetent_r, getnetbyname_r, getnetbyaddr_r \- get
29 network entry (reentrant)
30 .SH SYNOPSIS
31 .nf
32 .B #include <netdb.h>
33 .sp
34 .BI "int getnetent_r(struct netent *" result_buf ", char *" buf ,
35 .BI "                size_t " buflen ", struct netent **" result ,
36 .BI "                int *" h_errnop );
37 .sp
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 );
42 .sp
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 );
47 .sp
48 .fi
49 .in -4n
50 Feature Test Macro Requirements for glibc (see
51 .BR feature_test_macros (7)):
52 .ad l
53 .in
54 .sp
55 .BR getnetent_r (),
56 .BR getnetbyname_r (),
57 .BR getnetbyaddr_r ():
58 .RS 4
59 _BSD_SOURCE || _SVID_SOURCE
60 .RE
61 .ad b
62 .SH DESCRIPTION
63 The
64 .BR getnetent_r (),
65 .BR getnetbyname_r (),
66 and
67 .BR getnetbyaddr_r ()
68 functions are the reentrant equivalents of, respectively,
69 .BR getnetent (3),
70 .BR getnetbyname (3),
71 and
72 .BR getnetbynumber (3).
73 They differ in the way that the
74 .I netent
75 structure is returned,
76 and in the function calling signature and return value.
77 This manual page describes just the differences from
78 the nonreentrant functions.
79
80 Instead of returning a pointer to a statically allocated
81 .I netent
82 structure as the function result,
83 these functions copy the structure into the location pointed to by
84 .IR result_buf .
85
86 The
87 .I buf
88 array is used to store the string fields pointed to by the returned
89 .I netent
90 structure.
91 (The nonreentrant functions allocate these strings in static storage.)
92 The size of this array is specified in
93 .IR buflen .
94 If
95 .I buf
96 is too small, the call fails with the error
97 .BR ERANGE ,
98 and the caller must try again with a larger buffer.
99 (A buffer of length 1024 bytes should be sufficient for most applications.)
100 .\" I can find no information on the required/recommended buffer size;
101 .\" the nonreentrant functions use a 1024 byte buffer -- mtk.
102
103 If the function call successfully obtains a network record, then
104 .I *result
105 is set pointing to
106 .IR result_buf ;
107 otherwise,
108 .I *result
109 is set to NULL.
110
111 The buffer pointed to by
112 .I h_errnop
113 is used to return the value that would be stored in the global variable
114 .I h_errno
115 by the nonreentrant versions of these functions.
116 .\" getnetent.3 doesn't document any use of h_errno, but nevertheless
117 .\" the nonreentrant functions no seem to set h_errno.
118 .SH RETURN VALUE
119 On success, these functions return 0.
120 On error, they return one of the positive error numbers listed in ERRORS.
121
122 On error, record not found
123 .RB ( getnetbyname_r (),
124 .BR getnetbyaddr_r ()),
125 or end of input
126 .RB ( getnetent_r ())
127 .I result
128 is set to NULL.
129 .SH ERRORS
130 .TP
131 .B ENOENT
132 .RB ( getnetent_r ())
133 No more records in database.
134 .TP
135 .B ERANGE
136 .I buf
137 is too small.
138 Try again with a larger buffer
139 (and increased
140 .IR buflen ).
141 .SH CONFORMING TO
142 These functions are GNU extensions.
143 Functions with similar names exist on some other systems,
144 though typically with different calling signatures.
145 .SH SEE ALSO
146 .BR getnetent (3),
147 .BR networks (5)
148 .SH COLOPHON
149 This page is part of release 3.79 of the Linux
150 .I man-pages
151 project.
152 A description of the project,
153 information about reporting bugs,
154 and the latest version of this page,
155 can be found at
156 \%http://www.kernel.org/doc/man\-pages/.