xref: /netbsd-src/include/grp.h (revision e2347743fc187c596f6bc80fdb6e3b3ba48ade02)
1*e2347743Schristos /*	$NetBSD: grp.h,v 1.24 2007/10/19 15:58:52 christos Exp $	*/
24d2cbfceScgd 
3e6b5ddd9Scgd /*-
4e6b5ddd9Scgd  * Copyright (c) 1989, 1993
5e6b5ddd9Scgd  *	The Regents of the University of California.  All rights reserved.
6e6b5ddd9Scgd  * (c) UNIX System Laboratories, Inc.
7e6b5ddd9Scgd  * All or some portions of this file are derived from material licensed
8e6b5ddd9Scgd  * to the University of California by American Telephone and Telegraph
9e6b5ddd9Scgd  * Co. or Unix System Laboratories, Inc. and are reproduced herein with
10e6b5ddd9Scgd  * the permission of UNIX System Laboratories, Inc.
11e6b5ddd9Scgd  *
12e6b5ddd9Scgd  * Redistribution and use in source and binary forms, with or without
13e6b5ddd9Scgd  * modification, are permitted provided that the following conditions
14e6b5ddd9Scgd  * are met:
15e6b5ddd9Scgd  * 1. Redistributions of source code must retain the above copyright
16e6b5ddd9Scgd  *    notice, this list of conditions and the following disclaimer.
17e6b5ddd9Scgd  * 2. Redistributions in binary form must reproduce the above copyright
18e6b5ddd9Scgd  *    notice, this list of conditions and the following disclaimer in the
19e6b5ddd9Scgd  *    documentation and/or other materials provided with the distribution.
20039cc956Sagc  * 3. Neither the name of the University nor the names of its contributors
21e6b5ddd9Scgd  *    may be used to endorse or promote products derived from this software
22e6b5ddd9Scgd  *    without specific prior written permission.
23e6b5ddd9Scgd  *
24e6b5ddd9Scgd  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25e6b5ddd9Scgd  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26e6b5ddd9Scgd  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27e6b5ddd9Scgd  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28e6b5ddd9Scgd  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29e6b5ddd9Scgd  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30e6b5ddd9Scgd  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31e6b5ddd9Scgd  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32e6b5ddd9Scgd  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33e6b5ddd9Scgd  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34e6b5ddd9Scgd  * SUCH DAMAGE.
35e6b5ddd9Scgd  *
364d2cbfceScgd  *	@(#)grp.h	8.2 (Berkeley) 1/21/94
37e6b5ddd9Scgd  */
38e6b5ddd9Scgd 
39e6b5ddd9Scgd #ifndef _GRP_H_
40e6b5ddd9Scgd #define	_GRP_H_
41e6b5ddd9Scgd 
420f222262Sjtc #include <sys/cdefs.h>
436ea15afcSkleink #include <sys/featuretest.h>
440f222262Sjtc #include <sys/types.h>
450f222262Sjtc 
464be7a2dcSbjh21 #if defined(_NETBSD_SOURCE)
47e6b5ddd9Scgd #define	_PATH_GROUP		"/etc/group"
48e6b5ddd9Scgd #endif
49e6b5ddd9Scgd 
50e6b5ddd9Scgd struct group {
51633b8f45Smycroft 	__aconst char *gr_name;			/* group name */
52633b8f45Smycroft 	__aconst char *gr_passwd;		/* group password */
53c2219d6aSmsaitoh 	gid_t	gr_gid;				/* group id */
54633b8f45Smycroft 	__aconst char *__aconst *gr_mem;	/* group members */
55e6b5ddd9Scgd };
56e6b5ddd9Scgd 
57e6b5ddd9Scgd __BEGIN_DECLS
5819b7469aSperry struct group	*getgrgid(gid_t);
5919b7469aSperry struct group	*getgrnam(const char *);
60abf1d9c9Skleink #if (_POSIX_C_SOURCE - 0) >= 199506L || (_XOPEN_SOURCE - 0) >= 500 || \
61abf1d9c9Skleink     defined(_REENTRANT) || defined(_NETBSD_SOURCE)
6219b7469aSperry int		 getgrgid_r(gid_t, struct group *, char *, size_t,
6319b7469aSperry 				struct group **);
6419b7469aSperry int		 getgrnam_r(const char *, struct group *, char *, size_t,
6519b7469aSperry 				struct group **);
666ea15afcSkleink #endif
67abf1d9c9Skleink #if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)
68abf1d9c9Skleink struct group	*getgrent(void);
69abf1d9c9Skleink void		 setgrent(void);
70abf1d9c9Skleink void		 endgrent(void);
71abf1d9c9Skleink #endif
72*e2347743Schristos #if defined(_NETBSD_SOURCE)
7319b7469aSperry void		 setgrfile(const char *);
7419b7469aSperry int		 setgroupent(int);
75a4d6d349Schristos int		 getgrent_r(struct group *, char *, size_t, struct group **);
7619b7469aSperry const char	*group_from_gid(gid_t, int);
7719b7469aSperry int		 gid_from_group(const char *, gid_t *);
7819b7469aSperry int		 pwcache_groupdb(int (*)(int), void (*)(void),
79463cd543Slukem 				    struct group * (*)(const char *),
8019b7469aSperry 				    struct group * (*)(gid_t));
816ea15afcSkleink #endif
82e6b5ddd9Scgd __END_DECLS
83e6b5ddd9Scgd 
84e6b5ddd9Scgd #endif /* !_GRP_H_ */
85