gr_private.h revision 1.2.8.2 1 1.2.8.2 martin /* $NetBSD: gr_private.h,v 1.2.8.2 2008/04/28 20:23:00 martin Exp $ */
2 1.2.8.2 martin
3 1.2.8.2 martin /*-
4 1.2.8.2 martin * Copyright (c) 2004-2005 The NetBSD Foundation, Inc.
5 1.2.8.2 martin * All rights reserved.
6 1.2.8.2 martin *
7 1.2.8.2 martin * This code is derived from software contributed to The NetBSD Foundation
8 1.2.8.2 martin * by Luke Mewburn.
9 1.2.8.2 martin *
10 1.2.8.2 martin * Redistribution and use in source and binary forms, with or without
11 1.2.8.2 martin * modification, are permitted provided that the following conditions
12 1.2.8.2 martin * are met:
13 1.2.8.2 martin * 1. Redistributions of source code must retain the above copyright
14 1.2.8.2 martin * notice, this list of conditions and the following disclaimer.
15 1.2.8.2 martin * 2. Redistributions in binary form must reproduce the above copyright
16 1.2.8.2 martin * notice, this list of conditions and the following disclaimer in the
17 1.2.8.2 martin * documentation and/or other materials provided with the distribution.
18 1.2.8.2 martin *
19 1.2.8.2 martin * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 1.2.8.2 martin * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 1.2.8.2 martin * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 1.2.8.2 martin * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 1.2.8.2 martin * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 1.2.8.2 martin * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 1.2.8.2 martin * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 1.2.8.2 martin * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 1.2.8.2 martin * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 1.2.8.2 martin * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 1.2.8.2 martin * POSSIBILITY OF SUCH DAMAGE.
30 1.2.8.2 martin */
31 1.2.8.2 martin
32 1.2.8.2 martin /*
33 1.2.8.2 martin * Structures and functions used by various group(5) public functions
34 1.2.8.2 martin * and their back-end implementations.
35 1.2.8.2 martin * These are subject to change without notice and should not be used
36 1.2.8.2 martin * outside of libc (even by third-party nss_*.so modules implementing
37 1.2.8.2 martin * group(5) back-ends).
38 1.2.8.2 martin */
39 1.2.8.2 martin
40 1.2.8.2 martin #define _GROUP_COMPAT /* "group" defaults to compat, so always provide it */
41 1.2.8.2 martin
42 1.2.8.2 martin
43 1.2.8.2 martin /*
44 1.2.8.2 martin * mutex to serialize the public group(5) functions use of the
45 1.2.8.2 martin * back-end implementations, which may not be reentrant.
46 1.2.8.2 martin */
47 1.2.8.2 martin extern mutex_t __grmutex;
48 1.2.8.2 martin
49 1.2.8.2 martin /*
50 1.2.8.2 martin * files methods
51 1.2.8.2 martin */
52 1.2.8.2 martin struct __grstate_files { /* state shared between files methods */
53 1.2.8.2 martin int stayopen; /* see getgroupent(3) */
54 1.2.8.2 martin FILE *fp; /* groups file handle */
55 1.2.8.2 martin };
56 1.2.8.2 martin
57 1.2.8.2 martin extern int __grstart_files(struct __grstate_files *);
58 1.2.8.2 martin extern int __grend_files(struct __grstate_files *);
59 1.2.8.2 martin extern int __grscan_files(int *, struct group *, char *, size_t,
60 1.2.8.2 martin struct __grstate_files *, int, const char *, gid_t);
61 1.2.8.2 martin
62 1.2.8.2 martin /*
63 1.2.8.2 martin * dns methods
64 1.2.8.2 martin */
65 1.2.8.2 martin struct __grstate_dns { /* state shared between dns methods */
66 1.2.8.2 martin int stayopen; /* see getgroupent(3) */
67 1.2.8.2 martin void *context; /* Hesiod context */
68 1.2.8.2 martin int num; /* group index, -1 if no more */
69 1.2.8.2 martin };
70 1.2.8.2 martin
71 1.2.8.2 martin extern int __grstart_dns(struct __grstate_dns *);
72 1.2.8.2 martin extern int __grend_dns(struct __grstate_dns *state);
73 1.2.8.2 martin extern int __grscan_dns(int *, struct group *, char *, size_t,
74 1.2.8.2 martin struct __grstate_dns *, int, const char *, gid_t);
75 1.2.8.2 martin
76 1.2.8.2 martin /*
77 1.2.8.2 martin * nis methods
78 1.2.8.2 martin */
79 1.2.8.2 martin struct __grstate_nis { /* state shared between nis methods */
80 1.2.8.2 martin int stayopen; /* see getgroupent(3) */
81 1.2.8.2 martin char *domain; /* NIS domain */
82 1.2.8.2 martin int done; /* non-zero if search exhausted */
83 1.2.8.2 martin char *current; /* current first/next match */
84 1.2.8.2 martin int currentlen; /* length of _nis_current */
85 1.2.8.2 martin };
86 1.2.8.2 martin
87 1.2.8.2 martin extern int __grstart_nis(struct __grstate_nis *);
88 1.2.8.2 martin extern int __grend_nis(struct __grstate_nis *);
89 1.2.8.2 martin extern int __grscan_nis(int *, struct group *, char *, size_t,
90 1.2.8.2 martin struct __grstate_nis *, int, const char *, gid_t);
91 1.2.8.2 martin
92 1.2.8.2 martin /*
93 1.2.8.2 martin * compat methods
94 1.2.8.2 martin */
95 1.2.8.2 martin struct __grstate_compat { /* state shared between compat methods */
96 1.2.8.2 martin int stayopen; /* see getgroupent(3) */
97 1.2.8.2 martin FILE *fp; /* file handle */
98 1.2.8.2 martin /*
99 1.2.8.2 martin * XXX: convert name to a separate compatstate enum and grow name as necessary
100 1.2.8.2 martin * instead of using strdup & free for each + line
101 1.2.8.2 martin */
102 1.2.8.2 martin char *name; /* NULL if reading file, */
103 1.2.8.2 martin /* "" if compat "+", */
104 1.2.8.2 martin /* name if compat "+name" */
105 1.2.8.2 martin };
106 1.2.8.2 martin
107 1.2.8.2 martin extern int __grbad_compat(void *nsrv, void *nscb, va_list ap);
108 1.2.8.2 martin extern int __grstart_compat(struct __grstate_compat *);
109 1.2.8.2 martin extern int __grend_compat(struct __grstate_compat *);
110 1.2.8.2 martin extern int __grscan_compat(int *, struct group *, char *, size_t,
111 1.2.8.2 martin struct __grstate_compat *, int, const char *, gid_t,
112 1.2.8.2 martin int (*)(void *, struct group **), void *);
113