April 2024 | ||||||
Mo | Tu | We | Th | Fr | Sa | Su |
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 1 | 2 | 3 | 4 | 5 |
6 | 7 | 8 | 9 | 10 | 11 | 12 |
001: /* Copyright (C) 1991,1992,1995-2001,2003,2004,2010 002: Free Software Foundation, Inc. 003: This file is part of the GNU C Library. 004: 005: The GNU C Library is free software; you can redistribute it and/or 006: modify it under the terms of the GNU Lesser General Public 007: License as published by the Free Software Foundation; either 008: version 2.1 of the License, or (at your option) any later version. 009: 010: The GNU C Library is distributed in the hope that it will be useful, 011: but WITHOUT ANY WARRANTY; without even the implied warranty of 012: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 013: Lesser General Public License for more details. 014: 015: You should have received a copy of the GNU Lesser General Public 016: License along with the GNU C Library; if not, write to the Free 017: Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 018: 02111-1307 USA. */ 019: 020: /* 021: * POSIX Standard: 9.2.1 Group Database Access <grp.h> 022: */ 023: 024: #ifndef _GRP_H 025: #define _GRP_H 1 026: 027: #include <features.h> 028: 029: __BEGIN_DECLS 030: 031: #include <bits/types.h> 032: 033: #define __need_size_t 034: #include <stddef.h> 035: 036: 037: /* For the Single Unix specification we must define this type here. */ 038: #if (defined __USE_XOPEN || defined __USE_XOPEN2K) && !defined __gid_t_defined 039: typedef __gid_t gid_t; 040: # define __gid_t_defined 041: #endif 042: 043: /* The group structure. */ 044: struct group 045: { 046: char *gr_name; /* Group name. */ 047: char *gr_passwd; /* Password. */ 048: __gid_t gr_gid; /* Group ID. */ 049: char **gr_mem; /* Member list. */ 050: }; 051: 052: 053: #if defined __USE_SVID || defined __USE_GNU 054: # define __need_FILE 055: # include <stdio.h> 056: #endif 057: 058: 059: #if defined __USE_SVID || defined __USE_BSD || defined __USE_XOPEN_EXTENDED 060: /* Rewind the group-file stream. 061: 062: This function is a possible cancellation point and therefore not 063: marked with __THROW. */ 064: extern void setgrent (void); 065: #endif 066: 067: #if defined __USE_SVID || defined __USE_BSD || defined __USE_XOPEN_EXTENDED \ 068: || defined __USE_XOPEN2K8 069: /* Close the group-file stream. 070: 071: This function is a possible cancellation point and therefore not 072: marked with __THROW. */ 073: extern void endgrent (void); 074: 075: /* Read an entry from the group-file stream, opening it if necessary. 076: 077: This function is a possible cancellation point and therefore not 078: marked with __THROW. */ 079: extern struct group *getgrent (void); 080: #endif 081: 082: #ifdef __USE_SVID 083: /* Read a group entry from STREAM. 084: 085: This function is not part of POSIX and therefore no official 086: cancellation point. But due to similarity with an POSIX interface 087: or due to the implementation it is a cancellation point and 088: therefore not marked with __THROW. */ 089: extern struct group *fgetgrent (FILE *__stream); 090: #endif 091: 092: #ifdef __USE_GNU 093: /* Write the given entry onto the given stream. 094: 095: This function is not part of POSIX and therefore no official 096: cancellation point. But due to similarity with an POSIX interface 097: or due to the implementation it is a cancellation point and 098: therefore not marked with __THROW. */ 099: extern int putgrent (__const struct group *__restrict __p, 100: FILE *__restrict __f); 101: #endif 102: 103: /* Search for an entry with a matching group ID. 104: 105: This function is a possible cancellation point and therefore not 106: marked with __THROW. */ 107: extern struct group *getgrgid (__gid_t __gid); 108: 109: /* Search for an entry with a matching group name. 110: 111: This function is a possible cancellation point and therefore not 112: marked with __THROW. */ 113: extern struct group *getgrnam (__const char *__name); 114: 115: #if defined __USE_POSIX || defined __USE_MISC 116: 117: # ifdef __USE_MISC 118: /* Reasonable value for the buffer sized used in the reentrant 119: functions below. But better use `sysconf'. */ 120: # define NSS_BUFLEN_GROUP 1024 121: # endif 122: 123: /* Reentrant versions of some of the functions above. 124: 125: PLEASE NOTE: the `getgrent_r' function is not (yet) standardized. 126: The interface may change in later versions of this library. But 127: the interface is designed following the principals used for the 128: other reentrant functions so the chances are good this is what the 129: POSIX people would choose. 130: 131: This function is not part of POSIX and therefore no official 132: cancellation point. But due to similarity with an POSIX interface 133: or due to the implementation it is a cancellation point and 134: therefore not marked with __THROW. */ 135: 136: # ifdef __USE_GNU 137: extern int getgrent_r (struct group *__restrict __resultbuf, 138: char *__restrict __buffer, size_t __buflen, 139: struct group **__restrict __result); 140: # endif 141: 142: /* Search for an entry with a matching group ID. 143: 144: This function is a possible cancellation point and therefore not 145: marked with __THROW. */ 146: extern int getgrgid_r (__gid_t __gid, struct group *__restrict __resultbuf, 147: char *__restrict __buffer, size_t __buflen, 148: struct group **__restrict __result); 149: 150: /* Search for an entry with a matching group name. 151: 152: This function is a possible cancellation point and therefore not 153: marked with __THROW. */ 154: extern int getgrnam_r (__const char *__restrict __name, 155: struct group *__restrict __resultbuf, 156: char *__restrict __buffer, size_t __buflen, 157: struct group **__restrict __result); 158: 159: # ifdef __USE_SVID 160: /* Read a group entry from STREAM. This function is not standardized 161: an probably never will. 162: 163: This function is not part of POSIX and therefore no official 164: cancellation point. But due to similarity with an POSIX interface 165: or due to the implementation it is a cancellation point and 166: therefore not marked with __THROW. */ 167: extern int fgetgrent_r (FILE *__restrict __stream, 168: struct group *__restrict __resultbuf, 169: char *__restrict __buffer, size_t __buflen, 170: struct group **__restrict __result); 171: # endif 172: 173: #endif /* POSIX or reentrant */ 174: 175: 176: #ifdef __USE_BSD 177: 178: # define __need_size_t 179: # include <stddef.h> 180: 181: /* Set the group set for the current user to GROUPS (N of them). */ 182: extern int setgroups (size_t __n, __const __gid_t *__groups) __THROW; 183: 184: /* Store at most *NGROUPS members of the group set for USER into 185: *GROUPS. Also include GROUP. The actual number of groups found is 186: returned in *NGROUPS. Return -1 if the if *NGROUPS is too small. 187: 188: This function is not part of POSIX and therefore no official 189: cancellation point. But due to similarity with an POSIX interface 190: or due to the implementation it is a cancellation point and 191: therefore not marked with __THROW. */ 192: extern int getgrouplist (__const char *__user, __gid_t __group, 193: __gid_t *__groups, int *__ngroups); 194: 195: /* Initialize the group set for the current user 196: by reading the group database and using all groups 197: of which USER is a member. Also include GROUP. 198: 199: This function is not part of POSIX and therefore no official 200: cancellation point. But due to similarity with an POSIX interface 201: or due to the implementation it is a cancellation point and 202: therefore not marked with __THROW. */ 203: extern int initgroups (__const char *__user, __gid_t __group); 204: 205: #endif /* Use BSD. */ 206: 207: __END_DECLS 208: 209: #endif /* grp.h */ 210: