Update.
[glibc.git] / grp / grp.h
blob265f3c20039ac2d6e2a9bc38af05be1d53d30e59
1 /* Copyright (C) 1991, 92, 95, 96, 97, 98 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
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.
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.
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. */
20 * POSIX Standard: 9.2.1 Group Database Access <grp.h>
23 #ifndef _GRP_H
24 #define _GRP_H 1
26 #include <features.h>
28 __BEGIN_DECLS
30 #include <bits/types.h>
32 #define __need_size_t
33 #include <stddef.h>
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
42 /* The group structure. */
43 struct group
45 char *gr_name; /* Group name. */
46 char *gr_passwd; /* Password. */
47 __gid_t gr_gid; /* Group ID. */
48 char **gr_mem; /* Member list. */
52 #if defined __USE_SVID || defined __USE_GNU
53 # define __need_FILE
54 # include <stdio.h>
55 #endif
57 #ifdef __USE_GNU
58 /* Return a new stream open on the group file. */
59 extern FILE *__grpopen __P ((void));
61 /* Read a group entry from STREAM, filling in G.
62 Return the `struct group' of G if successful, NULL on failure. */
63 extern struct group *__grpread __P ((FILE *__stream, __ptr_t __g));
65 /* Return a chunk of memory containing pre-initialized data for __grpread. */
66 extern __ptr_t __grpalloc __P ((void));
68 /* Scan the group file, filling in G, until SELECTOR returns nonzero for an
69 entry. Return the `struct group' of G if successful, NULL on failure. */
70 extern struct group *__grpscan __P ((__ptr_t *__p,
71 int (*__selector) (struct group *)));
72 #endif
75 #if defined __USE_SVID || defined __USE_BSD || defined __USE_XOPEN_EXTENDED
76 /* Rewind the group-file stream. */
77 extern void setgrent __P ((void));
79 /* Close the group-file stream. */
80 extern void endgrent __P ((void));
82 /* Read an entry from the group-file stream, opening it if necessary. */
83 extern struct group *getgrent __P ((void));
84 #endif
86 #ifdef __USE_SVID
87 /* Read a group entry from STREAM. */
88 extern struct group *fgetgrent __P ((FILE *__stream));
89 #endif
91 /* Search for an entry with a matching group ID. */
92 extern struct group *getgrgid __P ((__gid_t __gid));
94 /* Search for an entry with a matching group name. */
95 extern struct group *getgrnam __P ((__const char *__name));
97 #if defined __USE_POSIX || defined __USE_MISC
99 # ifdef __USE_MISC
100 /* Reasonable value for the buffer sized used in the reentrant
101 functions below. But better use `sysconf'. */
102 # define NSS_BUFLEN_GROUP 1024
103 # endif
105 /* Reentrant versions of some of the functions above.
107 PLEASE NOTE: the `getgrent_r' function is not (yet) standardized.
108 The interface may change in later versions of this library. But
109 the interface is designed following the principals used for the
110 other reentrant functions so the chances are good this is what the
111 POSIX people would choose. */
113 # if defined __USE_SVID || defined __USE_BSD || defined __USE_XOPEN_EXTENDED
114 extern int __getgrent_r __P ((struct group *__resultbuf, char *buffer,
115 size_t __buflen, struct group **__result));
116 extern int getgrent_r __P ((struct group *__resultbuf, char *buffer,
117 size_t __buflen, struct group **__result));
118 # endif
120 /* Search for an entry with a matching group ID. */
121 extern int getgrgid_r __P ((__gid_t __gid, struct group *__resultbuf,
122 char *buffer, size_t __buflen,
123 struct group **__result));
125 /* Search for an entry with a matching group name. */
126 extern int getgrnam_r __P ((__const char *__name, struct group *__resultbuf,
127 char *buffer, size_t __buflen,
128 struct group **__result));
130 # ifdef __USE_SVID
131 /* Read a group entry from STREAM. This function is not standardized
132 an probably never will. */
133 extern int __fgetgrent_r __P ((FILE * __stream, struct group *__resultbuf,
134 char *buffer, size_t __buflen,
135 struct group **__result));
136 extern int fgetgrent_r __P ((FILE * __stream, struct group *__resultbuf,
137 char *buffer, size_t __buflen,
138 struct group **__result));
139 # endif
141 #endif /* POSIX or reentrant */
144 #ifdef __USE_BSD
146 # define __need_size_t
147 # include <stddef.h>
149 /* Set the group set for the current user to GROUPS (N of them). */
150 extern int setgroups __P ((size_t __n, __const __gid_t *__groups));
152 /* Initialize the group set for the current user
153 by reading the group database and using all groups
154 of which USER is a member. Also include GROUP. */
155 extern int initgroups __P ((__const char *__user, __gid_t __group));
157 #endif /* Use BSD. */
159 __END_DECLS
161 #endif /* grp.h */