update from main archive 961030
[platform/upstream/glibc.git] / grp / grp.h
1 /* Copyright (C) 1991, 1992, 1995, 1996 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public
15 License along with the GNU C Library; see the file COPYING.LIB.  If
16 not, write to the Free Software Foundation, Inc., 675 Mass Ave,
17 Cambridge, MA 02139, USA.  */
18
19 /*
20  *      POSIX Standard: 9.2.1 Group Database Access     <grp.h>
21  */
22
23 #ifndef _GRP_H
24
25 #define _GRP_H  1
26 #include <features.h>
27
28 __BEGIN_DECLS
29
30 #include <gnu/types.h>
31
32
33 /* The group structure.  */
34 struct group
35   {
36     char *gr_name;              /* Group name.  */
37     char *gr_passwd;            /* Password.    */
38     __gid_t gr_gid;             /* Group ID.    */
39     char **gr_mem;              /* Member list. */
40   };
41
42
43 #if defined(__USE_SVID) || defined(__USE_GNU)
44 #define __need_FILE
45 #include <stdio.h>
46 #endif
47
48 #ifdef  __USE_GNU
49 /* Return a new stream open on the group file.  */
50 extern FILE *__grpopen __P ((void));
51
52 /* Read a group entry from STREAM, filling in G.
53    Return the `struct group' of G if successful, NULL on failure.  */
54 extern struct group *__grpread __P ((FILE *__stream, __ptr_t __g));
55
56 /* Return a chunk of memory containing pre-initialized data for __grpread.  */
57 extern __ptr_t __grpalloc __P ((void));
58
59 /* Scan the group file, filling in G, until SELECTOR returns nonzero for an
60    entry.  Return the `struct group' of G if successful, NULL on failure.  */
61 extern struct group *__grpscan __P ((__ptr_t *__p,
62                                      int (*__selector) (struct group *)));
63 #endif
64
65
66 #if defined(__USE_SVID) || defined(__USE_MISC) || defined (__USE_BSD)
67 /* Rewind the group-file stream.  */
68 extern void setgrent __P ((void));
69
70 /* Close the group-file stream.  */
71 extern void endgrent __P ((void));
72
73 /* Read an entry from the group-file stream, opening it if necessary.  */
74 extern struct group *getgrent __P ((void));
75 #endif
76
77 #ifdef  __USE_SVID
78 /* Read a group entry from STREAM.  */
79 extern struct group *fgetgrent __P ((FILE *__stream));
80 #endif
81
82 /* Search for an entry with a matching group ID.  */
83 extern struct group *getgrgid __P ((__gid_t __gid));
84
85 /* Search for an entry with a matching group name.  */
86 extern struct group *getgrnam __P ((__const char *__name));
87
88 #ifdef  __USE_REENTRANT
89 /* Reasonable value for the buffer sized used in the reentrant
90    functions below.  But better use `sysconf'.  */
91 #define NSS_BUFLEN_GROUP        1024
92
93 /* Reentrant versions of some of the functions above.
94
95    PLEASE NOTE: these functions are not yet standardized.  The interface
96    may change in later versions of this library.  */
97
98 #if defined(__USE_SVID) || defined(__USE_MISC) || defined (__USE_BSD)
99 extern int getgrent_r __P ((struct group *__resultbuf, char *buffer,
100                             size_t __buflen, struct group **__result));
101 #endif
102
103 /* Search for an entry with a matching group ID.  */
104 extern int getgrgid_r __P ((__gid_t __gid, struct group *__resultbuf,
105                             char *buffer, size_t __buflen,
106                             struct group **__result));
107
108 /* Search for an entry with a matching group name.  */
109 extern int getgrnam_r __P ((__const char *__name, struct group *__resultbuf,
110                             char *buffer, size_t __buflen,
111                             struct group **__result));
112
113 #ifdef  __USE_SVID
114 /* Read a group entry from STREAM.  */
115 extern int __fgetgrent_r __P ((FILE * __stream, struct group *__resultbuf,
116                                char *buffer, size_t __buflen,
117                                struct group **__result));
118 extern int fgetgrent_r __P ((FILE * __stream, struct group *__resultbuf,
119                              char *buffer, size_t __buflen,
120                              struct group **__result));
121 #endif
122
123 #endif  /* reentrant */
124
125
126 #ifdef  __USE_BSD
127
128 #define __need_size_t
129 #include <stddef.h>
130
131 /* Set the group set for the current user to GROUPS (N of them).  */
132 extern int setgroups __P ((size_t __n, __const __gid_t *__groups));
133
134 /* Initialize the group set for the current user
135    by reading the group database and using all groups
136    of which USER is a member.  Also include GROUP.  */
137 extern int initgroups __P ((__const char *__user, __gid_t __group));
138
139 #endif /* Use BSD.  */
140
141 __END_DECLS
142
143 #endif /* grp.h  */