blob: 3ac5c8461936bf2d924e9a9c906ffe92ecd78c92 [file] [log] [blame]
"Robert P. J. Day"63fc1a92006-07-02 19:47:05 +00001/* vi: set sw=4 ts=4: */
Eric Andersen9615a082004-07-15 12:53:49 +00002/* 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
Eric Andersenab050f52001-01-27 06:01:43 +000024
Robert Grieblea1a63a2002-06-04 20:10:23 +000025#if !defined CONFIG_USE_BB_PWD_GRP
Eric Andersen887ca792002-07-03 23:19:26 +000026#include <grp.h>
Robert Grieblea1a63a2002-06-04 20:10:23 +000027
Eric Andersenab050f52001-01-27 06:01:43 +000028#else
29
Eric Andersen9615a082004-07-15 12:53:49 +000030#ifndef _GRP_H
31#define _GRP_H 1
32
33
Eric Andersenab050f52001-01-27 06:01:43 +000034#include <sys/types.h>
35#include <features.h>
36#include <stdio.h>
37
Robert Grieblea1a63a2002-06-04 20:10:23 +000038
Eric Andersen9615a082004-07-15 12:53:49 +000039/* The group structure. */
Eric Andersenab050f52001-01-27 06:01:43 +000040struct group
41{
Eric Andersen9615a082004-07-15 12:53:49 +000042 char *gr_name; /* Group name. */
43 char *gr_passwd; /* Password. */
44 gid_t gr_gid; /* Group ID. */
45 char **gr_mem; /* Member list. */
Eric Andersenab050f52001-01-27 06:01:43 +000046};
47
Eric Andersenab050f52001-01-27 06:01:43 +000048
Eric Andersen9615a082004-07-15 12:53:49 +000049/* Rewind the group-file stream. */
50extern void setgrent (void);
Eric Andersenab050f52001-01-27 06:01:43 +000051
Eric Andersen9615a082004-07-15 12:53:49 +000052/* Close the group-file stream. */
53extern void endgrent (void);
Eric Andersenab050f52001-01-27 06:01:43 +000054
Eric Andersen9615a082004-07-15 12:53:49 +000055/* Read an entry from the group-file stream, opening it if necessary. */
56extern struct group *getgrent (void);
Eric Andersenab050f52001-01-27 06:01:43 +000057
Eric Andersen9615a082004-07-15 12:53:49 +000058/* Read a group entry from STREAM. */
59extern struct group *fgetgrent (FILE *__stream);
Eric Andersenab050f52001-01-27 06:01:43 +000060
Eric Andersen9615a082004-07-15 12:53:49 +000061/* Write the given entry onto the given stream. */
62extern int putgrent (__const struct group *__restrict __p,
63 FILE *__restrict __f);
Eric Andersenab050f52001-01-27 06:01:43 +000064
Eric Andersen9615a082004-07-15 12:53:49 +000065/* Search for an entry with a matching group ID. */
66extern struct group *getgrgid (gid_t __gid);
67
68/* Search for an entry with a matching group name. */
69extern 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
79extern 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. */
84extern 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. */
89extern 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. */
96extern 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). */
102extern 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. */
107extern 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. */
113extern int initgroups (__const char *__user, gid_t __group);
114
115
116#endif /* grp.h */
117#endif