OSDN Git Service

(split) Import translated manuals from JM CVS Repository.
[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 .\" 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  2009-02-21 "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 _BSD_SOURCE || _SVID_SOURCE
57 .ad b
58 .SH DESCRIPTION
59 The
60 .BR getnetent_r (),
61 .BR getnetbyname_r (),
62 and
63 .BR getnetbyaddr_r ()
64 functions are the reentrant equivalents of, respectively,
65 .BR getnetent (3),
66 .BR getnetbyname (3),
67 and
68 .BR getnetbynumber (3).
69 They differ in the way that the
70 .I netent
71 structure is returned,
72 and in the function calling signature and return value.
73 This manual page describes just the differences from
74 the nonreentrant functions.
75
76 Instead of returning a pointer to a statically allocated
77 .I netent
78 structure as the function result,
79 these functions copy the structure into the location pointed to by
80 .IR result_buf .
81
82 The
83 .I buf
84 array is used to store the string fields pointed to by the returned
85 .I netent
86 structure.
87 (The nonreentrant functions allocate these strings in static storage.)
88 The size of this array is specified in
89 .IR buflen .
90 If
91 .I buf
92 is too small, the call fails with the error
93 .BR ERANGE ,
94 and the caller must try again with a larger buffer.
95 (A buffer of length 1024 bytes should be sufficient for most applications.)
96 .\" I can find no information on the required/recommended buffer size;
97 .\" the nonreentrant functions use a 1024 byte buffer -- mtk.
98
99 If the function call successfully obtains a network record, then
100 .I *result
101 is set pointing to
102 .IR result_buf ;
103 otherwise,
104 .I *result
105 is set to NULL.
106
107 The buffer pointed to by
108 .I h_errnop
109 is used to return the value that would be stored in the global variable
110 .I h_errno
111 by the nonreentrant versions of these functions.
112 .\" getnetent.3 doesn't document any use of h_errno, but nevertheless
113 .\" the nonreentrant functions no seem to set h_errno.
114 .SH "RETURN VALUE"
115 On success, these functions return 0.
116 On error, a positive error number is returned.
117
118 On error, record not found
119 .RB ( getnetbyname_r (),
120 .BR getnetbyaddr_r ()),
121 or end of input
122 .RB ( getnetent_r ())
123 .I result
124 is set to NULL.
125 .SH ERRORS
126 .TP
127 .B ENOENT
128 .RB ( getnetent_r ())
129 No more records in database.
130 .TP
131 .B ERANGE
132 .I buf
133 is too small.
134 Try again with a larger buffer
135 (and increased
136 .IR buflen ).
137 .SH "CONFORMING TO"
138 These functions are GNU extensions.
139 Functions with similar names exist on some other systems,
140 though typically with different calling signatures.
141 .SH "SEE ALSO"
142 .BR getnetent (3),
143 .BR networks (5)