Update.
[glibc.git] / grp / grp.h
blobb44f97fe875301a51d8c6d6f6a0a2ec9188cc5f1
1 /* Copyright (C) 1991, 1992, 1995, 1996, 1997 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
25 #define _GRP_H 1
26 #include <features.h>
28 __BEGIN_DECLS
30 #include <gnu/types.h>
32 #define __need_size_t
33 #include <stddef.h>
35 #define __need_size_t
36 #include <stddef.h>
39 /* The group structure. */
40 struct group
42 char *gr_name; /* Group name. */
43 char *gr_passwd; /* Password. */
44 __gid_t gr_gid; /* Group ID. */
45 char **gr_mem; /* Member list. */
49 #if defined(__USE_SVID) || defined(__USE_GNU)
50 #define __need_FILE
51 #include <stdio.h>
52 #endif
54 #ifdef __USE_GNU
55 /* Return a new stream open on the group file. */
56 extern FILE *__grpopen __P ((void));
58 /* Read a group entry from STREAM, filling in G.
59 Return the `struct group' of G if successful, NULL on failure. */
60 extern struct group *__grpread __P ((FILE *__stream, __ptr_t __g));
62 /* Return a chunk of memory containing pre-initialized data for __grpread. */
63 extern __ptr_t __grpalloc __P ((void));
65 /* Scan the group file, filling in G, until SELECTOR returns nonzero for an
66 entry. Return the `struct group' of G if successful, NULL on failure. */
67 extern struct group *__grpscan __P ((__ptr_t *__p,
68 int (*__selector) (struct group *)));
69 #endif
72 #if defined(__USE_SVID) || defined (__USE_BSD) || defined(__USE_XOPEN_EXTENDED)
73 /* Rewind the group-file stream. */
74 extern void setgrent __P ((void));
76 /* Close the group-file stream. */
77 extern void endgrent __P ((void));
79 /* Read an entry from the group-file stream, opening it if necessary. */
80 extern struct group *getgrent __P ((void));
81 #endif
83 #ifdef __USE_SVID
84 /* Read a group entry from STREAM. */
85 extern struct group *fgetgrent __P ((FILE *__stream));
86 #endif
88 /* Search for an entry with a matching group ID. */
89 extern struct group *getgrgid __P ((__gid_t __gid));
91 /* Search for an entry with a matching group name. */
92 extern struct group *getgrnam __P ((__const char *__name));
94 #if defined __USE_POSIX || defined __USE_MISC
96 #ifdef __USE_MISC
97 /* Reasonable value for the buffer sized used in the reentrant
98 functions below. But better use `sysconf'. */
99 #define NSS_BUFLEN_GROUP 1024
100 #endif
102 /* Reentrant versions of some of the functions above.
104 PLEASE NOTE: the `getgrent_r' function is not (yet) standardized.
105 The interface may change in later versions of this library. But
106 the interface is designed following the principals used for the
107 other reentrant functions so the chances are good this is what the
108 POSIX people would choose. */
110 #if defined(__USE_SVID) || defined (__USE_BSD) || defined(__USE_XOPEN_EXTENDED)
111 extern int __getgrent_r __P ((struct group *__resultbuf, char *buffer,
112 size_t __buflen, struct group **__result));
113 extern int getgrent_r __P ((struct group *__resultbuf, char *buffer,
114 size_t __buflen, struct group **__result));
115 #endif
117 /* Search for an entry with a matching group ID. */
118 extern int getgrgid_r __P ((__gid_t __gid, struct group *__resultbuf,
119 char *buffer, size_t __buflen,
120 struct group **__result));
122 /* Search for an entry with a matching group name. */
123 extern int getgrnam_r __P ((__const char *__name, struct group *__resultbuf,
124 char *buffer, size_t __buflen,
125 struct group **__result));
127 #ifdef __USE_SVID
128 /* Read a group entry from STREAM. This function is not standardized
129 an probably never will. */
130 extern int __fgetgrent_r __P ((FILE * __stream, struct group *__resultbuf,
131 char *buffer, size_t __buflen,
132 struct group **__result));
133 extern int fgetgrent_r __P ((FILE * __stream, struct group *__resultbuf,
134 char *buffer, size_t __buflen,
135 struct group **__result));
136 #endif
138 #endif /* POSIX or reentrant */
141 #ifdef __USE_BSD
143 #define __need_size_t
144 #include <stddef.h>
146 /* Set the group set for the current user to GROUPS (N of them). */
147 extern int setgroups __P ((size_t __n, __const __gid_t *__groups));
149 /* Initialize the group set for the current user
150 by reading the group database and using all groups
151 of which USER is a member. Also include GROUP. */
152 extern int initgroups __P ((__const char *__user, __gid_t __group));
154 #endif /* Use BSD. */
156 __END_DECLS
158 #endif /* grp.h */