8999 SMBIOS: cleanup 32-bit specific code
[unleashed.git] / usr / src / man / man3c / getnetgrent.3c
bloba404bbaad596247c7594831894b2ce78607db950
1 '\" te
2 .\" Copyright (c) 2004, Sun Microsystems, Inc.  All Rights Reserved.
3 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
4 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
5 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
6 .TH GETNETGRENT 3C "Feb 25, 2017"
7 .SH NAME
8 getnetgrent, getnetgrent_r, setnetgrent, endnetgrent, innetgr \- get network
9 group entry
10 .SH SYNOPSIS
11 .LP
12 .nf
13 #include <netdb.h>
15 \fBint\fR \fBgetnetgrent\fR(\fBchar **\fR\fImachinep\fR, \fBchar **\fR\fIuserp\fR, \fBchar **\fR\fIdomainp\fR);
16 .fi
18 .LP
19 .nf
20 \fBint\fR \fBgetnetgrent_r\fR(\fBchar **\fR\fImachinep\fR, \fBchar **\fR\fIuserp\fR, \fBchar **\fR\fIdomainp\fR,
21      \fBchar *\fR\fIbuffer\fR, \fBint\fR\fIbuflen\fR);
22 .fi
24 .LP
25 .nf
26 \fBint\fR \fBsetnetgrent\fR(\fBconst char *\fR\fInetgroup\fR);
27 .fi
29 .LP
30 .nf
31 \fBint\fR \fBendnetgrent\fR(\fBvoid\fR);
32 .fi
34 .LP
35 .nf
36 \fBint\fR \fBinnetgr\fR(\fBconst char *\fR\fInetgroup\fR, \fBconst char *\fR\fImachine\fR,
37      \fBconst char *\fR\fIuser\fR, \fBconst char *\fR\fIdomain\fR);
38 .fi
40 .SH DESCRIPTION
41 .LP
42 These functions are used to test membership in and enumerate members of
43 ``netgroup'' network groups defined in a system database.  Netgroups are sets
44 of (machine,user,domain) triples (see \fBnetgroup\fR(4)).
45 .sp
46 .LP
47 These functions consult the source specified for \fBnetgroup\fR in the
48 \fB/etc/nsswitch.conf\fR file (see \fBnsswitch.conf\fR(4)).
49 .sp
50 .LP
51 The function \fBinnetgr()\fR returns  \fB1\fR if there is a netgroup
52 \fInetgroup\fR that contains the specified \fImachine,\fR \fIuser,\fR
53 \fIdomain\fR triple as a member; otherwise it returns  \fB0\fR. Any of the
54 supplied pointers \fImachine\fR, \fIuser\fR, and \fIdomain\fR may be
55 \fINULL,\fR signifying a "wild card" that matches all values in that position
56 of the triple.
57 .sp
58 .LP
59 The \fBinnetgr()\fR function is safe for use in single-threaded and
60 multithreaded applications.
61 .sp
62 .LP
63 The functions \fBsetnetgrent()\fR, \fBgetnetgrent()\fR, and \fBendnetgrent()\fR
64 are used to enumerate the members of a given network group.
65 .sp
66 .LP
67 The function \fBsetnetgrent()\fR establishes the network group specified in the
68 parameter \fInetgroup\fR as the current group whose members are to be
69 enumerated.
70 .sp
71 .LP
72 Successive calls to the function \fBgetnetgrent()\fR will enumerate the members
73 of the group established by calling \fBsetnetgrent()\fR; each call returns
74 \fB1\fR if it succeeds in obtaining another member of the network group, or
75 \fB0\fR if there are no further members of the group.
76 .sp
77 .LP
78 When calling either \fBgetnetgrent()\fR or \fBgetnetgrent_r()\fR, addresses of
79 the three character pointers are used as arguments, for example:
80 .sp
81 .in +2
82 .nf
83 char \fI*mp\fR, \fI*up\fR, \fI*dp\fR;
84 getnetgrent(\fI&mp\fR, \fI&up\fR, \fI&dp\fR);
85 .fi
86 .in -2
88 .sp
89 .LP
90 Upon successful return from  \fBgetnetgrent()\fR, the pointer \fImp\fR points
91 to a string containing the name of the machine part of the member triple,
92 \fIup\fR points to a string containing the user name and \fIdp\fR points to a
93 string containing the domain name. If the pointer returned for \fImp\fR,
94 \fIup\fR, or \fIdp\fR is \fINULL,\fR it signifies that the element of the
95 netgroup contains wild card specifier in that position of the triple.
96 .sp
97 .LP
98 The pointers returned by \fBgetnetgrent()\fR point into a buffer allocated by
99 \fBsetnetgrent()\fR that is reused by each call. This space is released when an
100 \fBendnetgrent()\fR call is made, and should not be released by the caller.
101 This implementation is not safe for use in multi-threaded applications.
104 The function \fBgetnetgrent_r()\fR is similar to \fBgetnetgrent()\fR function,
105 but it uses a buffer supplied by the caller for the space needed to store the
106 results.   The parameter \fIbuffer\fR should be a pointer to a buffer allocated
107 by the caller and the length of this buffer should be specified by the
108 parameter \fIbuflen\fR. The buffer must be large enough to hold the data
109 associated with the triple. The \fBgetnetgrent_r()\fR function is safe for use
110 both in single-threaded and multi-threaded applications.
113 The function \fBendnetgrent()\fR frees the space allocated by the previous
114 \fBsetnetgrent()\fR call.  The equivalent of an \fBendnetgrent()\fR implicitly
115 performed whenever a  \fBsetnetgrent()\fR call is made to a new network group.
118 Note that while \fBsetnetgrent()\fR and \fBendnetgrent()\fR are safe for use in
119 multi-threaded applications, the effect of each is process-wide.  Calling
120 \fBsetnetgrent()\fR resets the enumeration position for all threads. If
121 multiple threads interleave calls to \fBgetnetgrent_r()\fR each will enumerate
122 a disjoint subset of the netgroup. Thus the effective use of these functions in
123 multi-threaded applications may require coordination by the caller.
124 .SH ERRORS
126 The function \fBgetnetgrent_r()\fR will return  \fB0\fR and set \fBerrno\fR to
127 \fBERANGE\fR if the length of the buffer supplied by caller is not large enough
128 to store the result.  See \fBIntro\fR(2) for the proper usage and
129 interpretation of \fBerrno\fR in multi-threaded applications.
132 The functions \fBsetnetgrent()\fR and \fBendnetgrent()\fR return \fB0\fR upon
133 success.
134 .SH FILES
135 .ne 2
137 \fB\fB/etc/nsswitch.conf\fR\fR
139 .RS 22n
143 .SH ATTRIBUTES
145 See \fBattributes\fR(5) for descriptions of the following attributes:
150 box;
151 c | c
152 l | l .
153 ATTRIBUTE TYPE  ATTRIBUTE VALUE
155 MT-Level        See \fBDESCRIPTION\fR section.
158 .SH SEE ALSO
160 \fBIntro\fR(2), \fBIntro\fR(3), \fBnetgroup\fR(4), \fBnsswitch.conf\fR(4),
161 \fBattributes\fR(5)
162 .SH WARNINGS
164 The function \fBgetnetgrent_r()\fR is included in this release on an
165 uncommitted basis only, and is subject to change or removal in future minor
166 releases.
167 .SH NOTES
169 Only the Network Information Services, \fBNIS\fR, is supported
170 as a source for the \fBnetgroup\fR database.
173 When compiling multi-threaded applications, see  \fBIntro\fR(3), \fINotes On
174 Multithread Applications\fR, for information about the use of the
175 \fB_REENTRANT\fR flag.