grp_.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /* vi: set sw=4 ts=4: */
  2. /* 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. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; if not, write to the Free
  14. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  15. 02111-1307 USA. */
  16. /*
  17. * POSIX Standard: 9.2.1 Group Database Access <grp.h>
  18. */
  19. #ifndef _GRP_H
  20. #define _GRP_H 1
  21. #if __GNUC_PREREQ(4,1)
  22. # pragma GCC visibility push(hidden)
  23. #endif
  24. /* The group structure. */
  25. struct group {
  26. char *gr_name; /* Group name. */
  27. char *gr_passwd; /* Password. */
  28. gid_t gr_gid; /* Group ID. */
  29. char **gr_mem; /* Member list. */
  30. };
  31. #define setgrent bb_internal_setgrent
  32. #define endgrent bb_internal_endgrent
  33. #define getgrent bb_internal_getgrent
  34. #define fgetgrent bb_internal_fgetgrent
  35. #define putgrent bb_internal_putgrent
  36. #define getgrgid bb_internal_getgrgid
  37. #define getgrnam bb_internal_getgrnam
  38. #define getgrent_r bb_internal_getgrent_r
  39. #define getgrgid_r bb_internal_getgrgid_r
  40. #define getgrnam_r bb_internal_getgrnam_r
  41. #define fgetgrent_r bb_internal_fgetgrent_r
  42. #define getgrouplist bb_internal_getgrouplist
  43. #define initgroups bb_internal_initgroups
  44. /* All function names below should be remapped by #defines above
  45. * in order to not collide with libc names.
  46. * In theory it isn't necessary, but I saw weird interactions at link time.
  47. * Let's play safe */
  48. /* Rewind the group-file stream. */
  49. extern void setgrent(void);
  50. /* Close the group-file stream. */
  51. extern void endgrent(void);
  52. /* Read an entry from the group-file stream, opening it if necessary. */
  53. extern struct group *getgrent(void);
  54. /* Read a group entry from STREAM. */
  55. extern struct group *fgetgrent(FILE *__stream);
  56. /* Write the given entry onto the given stream. */
  57. extern int putgrent(__const struct group *__restrict __p,
  58. FILE *__restrict __f);
  59. /* Search for an entry with a matching group ID. */
  60. extern struct group *getgrgid(gid_t __gid);
  61. /* Search for an entry with a matching group name. */
  62. extern struct group *getgrnam(__const char *__name);
  63. /* Reentrant versions of some of the functions above.
  64. PLEASE NOTE: the `getgrent_r' function is not (yet) standardized.
  65. The interface may change in later versions of this library. But
  66. the interface is designed following the principals used for the
  67. other reentrant functions so the chances are good this is what the
  68. POSIX people would choose. */
  69. extern int getgrent_r(struct group *__restrict __resultbuf,
  70. char *__restrict __buffer, size_t __buflen,
  71. struct group **__restrict __result);
  72. /* Search for an entry with a matching group ID. */
  73. extern int getgrgid_r(gid_t __gid, struct group *__restrict __resultbuf,
  74. char *__restrict __buffer, size_t __buflen,
  75. struct group **__restrict __result);
  76. /* Search for an entry with a matching group name. */
  77. extern int getgrnam_r(__const char *__restrict __name,
  78. struct group *__restrict __resultbuf,
  79. char *__restrict __buffer, size_t __buflen,
  80. struct group **__restrict __result);
  81. /* Read a group entry from STREAM. This function is not standardized
  82. an probably never will. */
  83. extern int fgetgrent_r(FILE *__restrict __stream,
  84. struct group *__restrict __resultbuf,
  85. char *__restrict __buffer, size_t __buflen,
  86. struct group **__restrict __result);
  87. /* Store at most *NGROUPS members of the group set for USER into
  88. *GROUPS. Also include GROUP. The actual number of groups found is
  89. returned in *NGROUPS. Return -1 if the if *NGROUPS is too small. */
  90. extern int getgrouplist(__const char *__user, gid_t __group,
  91. gid_t *__groups, int *__ngroups);
  92. /* Initialize the group set for the current user
  93. by reading the group database and using all groups
  94. of which USER is a member. Also include GROUP. */
  95. extern int initgroups(__const char *__user, gid_t __group);
  96. #if __GNUC_PREREQ(4,1)
  97. # pragma GCC visibility pop
  98. #endif
  99. #endif