3
0

grp_.h 3.9 KB

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