Update.
[platform/upstream/glibc.git] / grp / grp.h
1 /* Copyright (C) 1991, 92, 95, 96, 97, 98 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 not,
16    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17    Boston, MA 02111-1307, USA.  */
18
19 /*
20  *      POSIX Standard: 9.2.1 Group Database Access     <grp.h>
21  */
22
23 #ifndef _GRP_H
24 #define _GRP_H  1
25
26 #include <features.h>
27
28 __BEGIN_DECLS
29
30 #include <bits/types.h>
31
32 #define __need_size_t
33 #include <stddef.h>
34
35
36 /* For the Single Unix specification we must define this type here.  */
37 #if defined __USE_XOPEN && !defined gid_t
38 typedef __gid_t gid_t;
39 # define gid_t gid_t
40 #endif
41
42 /* The group structure.  */
43 struct group
44   {
45     char *gr_name;              /* Group name.  */
46     char *gr_passwd;            /* Password.    */
47     __gid_t gr_gid;             /* Group ID.    */
48     char **gr_mem;              /* Member list. */
49   };
50
51
52 #if defined __USE_SVID || defined __USE_GNU
53 # define __need_FILE
54 # include <stdio.h>
55 #endif
56
57
58 #if defined __USE_SVID || defined __USE_BSD || defined __USE_XOPEN_EXTENDED
59 /* Rewind the group-file stream.  */
60 extern void setgrent __P ((void));
61
62 /* Close the group-file stream.  */
63 extern void endgrent __P ((void));
64
65 /* Read an entry from the group-file stream, opening it if necessary.  */
66 extern struct group *getgrent __P ((void));
67 #endif
68
69 #ifdef  __USE_SVID
70 /* Read a group entry from STREAM.  */
71 extern struct group *fgetgrent __P ((FILE *__stream));
72 #endif
73
74 #ifdef __USE_GNU
75 /* Write the given entry onto the given stream.  */
76 extern int putgrent __P ((__const struct group *__p, FILE *__f));
77 #endif
78
79 /* Search for an entry with a matching group ID.  */
80 extern struct group *getgrgid __P ((__gid_t __gid));
81
82 /* Search for an entry with a matching group name.  */
83 extern struct group *getgrnam __P ((__const char *__name));
84
85 #if defined __USE_POSIX || defined __USE_MISC
86
87 # ifdef __USE_MISC
88 /* Reasonable value for the buffer sized used in the reentrant
89    functions below.  But better use `sysconf'.  */
90 #  define NSS_BUFLEN_GROUP      1024
91 # endif
92
93 /* Reentrant versions of some of the functions above.
94
95    PLEASE NOTE: the `getgrent_r' function is not (yet) standardized.
96    The interface may change in later versions of this library.  But
97    the interface is designed following the principals used for the
98    other reentrant functions so the chances are good this is what the
99    POSIX people would choose.  */
100
101 # if defined __USE_SVID || defined __USE_BSD || defined __USE_XOPEN_EXTENDED
102 extern int getgrent_r __P ((struct group *__resultbuf, char *__buffer,
103                             size_t __buflen, struct group **__result));
104 # endif
105
106 /* Search for an entry with a matching group ID.  */
107 extern int getgrgid_r __P ((__gid_t __gid, struct group *__resultbuf,
108                             char *__buffer, size_t __buflen,
109                             struct group **__result));
110
111 /* Search for an entry with a matching group name.  */
112 extern int getgrnam_r __P ((__const char *__name, struct group *__resultbuf,
113                             char *__buffer, size_t __buflen,
114                             struct group **__result));
115
116 # ifdef __USE_SVID
117 /* Read a group entry from STREAM.  This function is not standardized
118    an probably never will.  */
119 extern int fgetgrent_r __P ((FILE * __stream, struct group *__resultbuf,
120                              char *__buffer, size_t __buflen,
121                              struct group **__result));
122 # endif
123
124 #endif  /* POSIX or reentrant */
125
126
127 #ifdef  __USE_BSD
128
129 # define __need_size_t
130 # include <stddef.h>
131
132 /* Set the group set for the current user to GROUPS (N of them).  */
133 extern int setgroups __P ((size_t __n, __const __gid_t *__groups));
134
135 /* Initialize the group set for the current user
136    by reading the group database and using all groups
137    of which USER is a member.  Also include GROUP.  */
138 extern int initgroups __P ((__const char *__user, __gid_t __group));
139
140 #endif /* Use BSD.  */
141
142 __END_DECLS
143
144 #endif /* grp.h  */