xref: /minix3/lib/libc/gen/gr_private.h (revision 84d9c625bfea59e274550651111ae9edfdc40fbd)
12fe8fb19SBen Gras /*	$NetBSD: gr_private.h,v 1.2 2008/04/28 20:22:59 martin Exp $	*/
22fe8fb19SBen Gras 
32fe8fb19SBen Gras /*-
42fe8fb19SBen Gras  * Copyright (c) 2004-2005 The NetBSD Foundation, Inc.
52fe8fb19SBen Gras  * All rights reserved.
62fe8fb19SBen Gras  *
72fe8fb19SBen Gras  * This code is derived from software contributed to The NetBSD Foundation
82fe8fb19SBen Gras  * by Luke Mewburn.
92fe8fb19SBen Gras  *
102fe8fb19SBen Gras  * Redistribution and use in source and binary forms, with or without
112fe8fb19SBen Gras  * modification, are permitted provided that the following conditions
122fe8fb19SBen Gras  * are met:
132fe8fb19SBen Gras  * 1. Redistributions of source code must retain the above copyright
142fe8fb19SBen Gras  *    notice, this list of conditions and the following disclaimer.
152fe8fb19SBen Gras  * 2. Redistributions in binary form must reproduce the above copyright
162fe8fb19SBen Gras  *    notice, this list of conditions and the following disclaimer in the
172fe8fb19SBen Gras  *    documentation and/or other materials provided with the distribution.
182fe8fb19SBen Gras  *
192fe8fb19SBen Gras  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
202fe8fb19SBen Gras  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
212fe8fb19SBen Gras  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
222fe8fb19SBen Gras  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
232fe8fb19SBen Gras  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
242fe8fb19SBen Gras  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
252fe8fb19SBen Gras  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
262fe8fb19SBen Gras  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
272fe8fb19SBen Gras  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
282fe8fb19SBen Gras  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
292fe8fb19SBen Gras  * POSSIBILITY OF SUCH DAMAGE.
302fe8fb19SBen Gras  */
312fe8fb19SBen Gras 
322fe8fb19SBen Gras /*
332fe8fb19SBen Gras  * Structures and functions used by various group(5) public functions
342fe8fb19SBen Gras  * and their back-end implementations.
352fe8fb19SBen Gras  * These are subject to change without notice and should not be used
362fe8fb19SBen Gras  * outside of libc (even by third-party nss_*.so modules implementing
372fe8fb19SBen Gras  * group(5) back-ends).
382fe8fb19SBen Gras  */
392fe8fb19SBen Gras 
402fe8fb19SBen Gras #define _GROUP_COMPAT	/* "group" defaults to compat, so always provide it */
412fe8fb19SBen Gras 
422fe8fb19SBen Gras 
43*84d9c625SLionel Sambuc #if defined(__minix) && defined(_REENTRANT)
442fe8fb19SBen Gras 	/*
452fe8fb19SBen Gras 	 * mutex to serialize the public group(5) functions use of the
462fe8fb19SBen Gras 	 * back-end implementations, which may not be reentrant.
472fe8fb19SBen Gras 	 */
482fe8fb19SBen Gras extern 	mutex_t		__grmutex;
49*84d9c625SLionel Sambuc #endif /* defined(__minix) */
502fe8fb19SBen Gras 
512fe8fb19SBen Gras 	/*
522fe8fb19SBen Gras 	 * files methods
532fe8fb19SBen Gras 	 */
542fe8fb19SBen Gras struct __grstate_files {	/* state shared between files methods */
552fe8fb19SBen Gras 	int	 stayopen;	/* see getgroupent(3) */
562fe8fb19SBen Gras 	FILE	*fp;		/* groups file handle */
572fe8fb19SBen Gras };
582fe8fb19SBen Gras 
592fe8fb19SBen Gras extern int	__grstart_files(struct __grstate_files *);
602fe8fb19SBen Gras extern int	__grend_files(struct __grstate_files *);
612fe8fb19SBen Gras extern int	__grscan_files(int *, struct group *, char *, size_t,
622fe8fb19SBen Gras 			struct __grstate_files *, int, const char *, gid_t);
632fe8fb19SBen Gras 
642fe8fb19SBen Gras 	/*
652fe8fb19SBen Gras 	 * dns methods
662fe8fb19SBen Gras 	 */
672fe8fb19SBen Gras struct __grstate_dns {		/* state shared between dns methods */
682fe8fb19SBen Gras 	int	 stayopen;	/* see getgroupent(3) */
692fe8fb19SBen Gras 	void	*context;	/* Hesiod context */
702fe8fb19SBen Gras 	int	 num;		/* group index, -1 if no more */
712fe8fb19SBen Gras };
722fe8fb19SBen Gras 
732fe8fb19SBen Gras extern int	__grstart_dns(struct __grstate_dns *);
742fe8fb19SBen Gras extern int	__grend_dns(struct __grstate_dns *state);
752fe8fb19SBen Gras extern int	__grscan_dns(int *, struct group *, char *, size_t,
762fe8fb19SBen Gras 			struct __grstate_dns *, int, const char *, gid_t);
772fe8fb19SBen Gras 
782fe8fb19SBen Gras 	/*
792fe8fb19SBen Gras 	 * nis methods
802fe8fb19SBen Gras 	 */
812fe8fb19SBen Gras struct __grstate_nis {		/* state shared between nis methods */
822fe8fb19SBen Gras 	int	 stayopen;	/* see getgroupent(3) */
832fe8fb19SBen Gras 	char	*domain;	/* NIS domain */
842fe8fb19SBen Gras 	int	 done;		/* non-zero if search exhausted */
852fe8fb19SBen Gras 	char	*current;	/* current first/next match */
862fe8fb19SBen Gras 	int	 currentlen;	/* length of _nis_current */
872fe8fb19SBen Gras };
882fe8fb19SBen Gras 
892fe8fb19SBen Gras extern int	__grstart_nis(struct __grstate_nis *);
902fe8fb19SBen Gras extern int	__grend_nis(struct __grstate_nis *);
912fe8fb19SBen Gras extern int	__grscan_nis(int *, struct group *, char *, size_t,
922fe8fb19SBen Gras 			struct __grstate_nis *, int, const char *, gid_t);
932fe8fb19SBen Gras 
942fe8fb19SBen Gras 	/*
952fe8fb19SBen Gras 	 * compat methods
962fe8fb19SBen Gras 	 */
972fe8fb19SBen Gras struct __grstate_compat {	/* state shared between compat methods */
982fe8fb19SBen Gras 	int	 stayopen;	/* see getgroupent(3) */
992fe8fb19SBen Gras 	FILE	*fp;		/* file handle */
1002fe8fb19SBen Gras /*
1012fe8fb19SBen Gras  * XXX:	convert name to a separate compatstate enum and grow name as necessary
1022fe8fb19SBen Gras  *	instead of using strdup & free for each + line
1032fe8fb19SBen Gras  */
1042fe8fb19SBen Gras 	char	*name;		/* NULL if reading file,	*/
1052fe8fb19SBen Gras 				/*   "" if compat "+",		*/
1062fe8fb19SBen Gras 				/* name if compat "+name"	*/
1072fe8fb19SBen Gras };
1082fe8fb19SBen Gras 
1092fe8fb19SBen Gras extern int	__grbad_compat(void *nsrv, void *nscb, va_list ap);
1102fe8fb19SBen Gras extern int	__grstart_compat(struct __grstate_compat *);
1112fe8fb19SBen Gras extern int	__grend_compat(struct __grstate_compat *);
1122fe8fb19SBen Gras extern int	__grscan_compat(int *, struct group *, char *, size_t,
1132fe8fb19SBen Gras 			struct __grstate_compat *, int, const char *, gid_t,
1142fe8fb19SBen Gras 			int (*)(void *, struct group **), void *);
115