Standardize on the vi editing directives being on the first line.
[oweals/busybox.git] / include / grp_.h
1 /* vi: set sw=4 ts=4: */
2 /* Copyright (C) 1991,92,95,96,97,98,99,2000,01 Free Software Foundation, Inc.
3    This file is part of the GNU C Library.
4
5    The GNU C Library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Lesser General Public
7    License as published by the Free Software Foundation; either
8    version 2.1 of the License, or (at your option) any later version.
9
10    The GNU C Library is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    Lesser General Public License for more details.
14
15    You should have received a copy of the GNU Lesser General Public
16    License along with the GNU C Library; if not, write to the Free
17    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18    02111-1307 USA.  */
19
20 /*
21  *      POSIX Standard: 9.2.1 Group Database Access     <grp.h>
22  */
23
24
25 #if !defined CONFIG_USE_BB_PWD_GRP
26 #include <grp.h>
27
28 #else
29
30 #ifndef _GRP_H
31 #define _GRP_H  1
32
33
34 #include <sys/types.h>
35 #include <features.h>
36 #include <stdio.h>
37
38
39 /* The group structure.  */
40 struct group
41 {
42     char *gr_name;              /* Group name.  */
43     char *gr_passwd;            /* Password.    */
44     gid_t gr_gid;               /* Group ID.    */
45     char **gr_mem;              /* Member list. */
46 };
47
48
49 /* Rewind the group-file stream.  */
50 extern void setgrent (void);
51
52 /* Close the group-file stream.  */
53 extern void endgrent (void);
54
55 /* Read an entry from the group-file stream, opening it if necessary.  */
56 extern struct group *getgrent (void);
57
58 /* Read a group entry from STREAM.  */
59 extern struct group *fgetgrent (FILE *__stream);
60
61 /* Write the given entry onto the given stream.  */
62 extern int putgrent (__const struct group *__restrict __p,
63                      FILE *__restrict __f);
64
65 /* Search for an entry with a matching group ID.  */
66 extern struct group *getgrgid (gid_t __gid);
67
68 /* Search for an entry with a matching group name.  */
69 extern struct group *getgrnam (__const char *__name);
70
71 /* Reentrant versions of some of the functions above.
72
73    PLEASE NOTE: the `getgrent_r' function is not (yet) standardized.
74    The interface may change in later versions of this library.  But
75    the interface is designed following the principals used for the
76    other reentrant functions so the chances are good this is what the
77    POSIX people would choose.  */
78
79 extern int getgrent_r (struct group *__restrict __resultbuf,
80                        char *__restrict __buffer, size_t __buflen,
81                        struct group **__restrict __result);
82
83 /* Search for an entry with a matching group ID.  */
84 extern int getgrgid_r (gid_t __gid, struct group *__restrict __resultbuf,
85                        char *__restrict __buffer, size_t __buflen,
86                        struct group **__restrict __result);
87
88 /* Search for an entry with a matching group name.  */
89 extern int getgrnam_r (__const char *__restrict __name,
90                        struct group *__restrict __resultbuf,
91                        char *__restrict __buffer, size_t __buflen,
92                        struct group **__restrict __result);
93
94 /* Read a group entry from STREAM.  This function is not standardized
95    an probably never will.  */
96 extern int fgetgrent_r (FILE *__restrict __stream,
97                         struct group *__restrict __resultbuf,
98                         char *__restrict __buffer, size_t __buflen,
99                         struct group **__restrict __result);
100
101 /* Set the group set for the current user to GROUPS (N of them).  */
102 extern int setgroups (size_t __n, __const gid_t *__groups);
103
104 /* Store at most *NGROUPS members of the group set for USER into
105    *GROUPS.  Also include GROUP.  The actual number of groups found is
106    returned in *NGROUPS.  Return -1 if the if *NGROUPS is too small.  */
107 extern int getgrouplist (__const char *__user, gid_t __group,
108                          gid_t *__groups, int *__ngroups);
109
110 /* Initialize the group set for the current user
111    by reading the group database and using all groups
112    of which USER is a member.  Also include GROUP.  */
113 extern int initgroups (__const char *__user, gid_t __group);
114
115
116 #endif /* grp.h  */
117 #endif