pwd_.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /* vi: set sw=4 ts=4: */
  2. /* Copyright (C) 1991,92,95,96,97,98,99,2001 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.2 User Database Access <pwd.h>
  18. */
  19. #if !ENABLE_USE_BB_PWD_GRP
  20. #include <pwd.h>
  21. #else
  22. #ifndef _PWD_H
  23. #define _PWD_H 1
  24. /* The passwd structure. */
  25. struct passwd {
  26. char *pw_name; /* Username. */
  27. char *pw_passwd; /* Password. */
  28. uid_t pw_uid; /* User ID. */
  29. gid_t pw_gid; /* Group ID. */
  30. char *pw_gecos; /* Real name. */
  31. char *pw_dir; /* Home directory. */
  32. char *pw_shell; /* Shell program. */
  33. };
  34. #define setpwent bb_internal_setpwent
  35. #define endpwent bb_internal_endpwent
  36. #define getpwent bb_internal_getpwent
  37. #define fgetpwent bb_internal_fgetpwent
  38. #define putpwent bb_internal_putpwent
  39. #define getpwuid bb_internal_getpwuid
  40. #define getpwnam bb_internal_getpwnam
  41. #define getpwent_r bb_internal_getpwent_r
  42. #define getpwuid_r bb_internal_getpwuid_r
  43. #define getpwnam_r bb_internal_getpwnam_r
  44. #define fgetpwent_r bb_internal_fgetpwent_r
  45. #define getpw bb_internal_getpw
  46. /* All function names below should be remapped by #defines above
  47. * in order to not collide with libc names.
  48. * In theory it isn't necessary, but I saw weird interactions at link time.
  49. * Let's play safe */
  50. /* Rewind the password-file stream. */
  51. extern void setpwent(void);
  52. /* Close the password-file stream. */
  53. extern void endpwent(void);
  54. /* Read an entry from the password-file stream, opening it if necessary. */
  55. extern struct passwd *getpwent(void);
  56. /* Read an entry from STREAM. */
  57. extern struct passwd *fgetpwent(FILE *__stream);
  58. /* Write the given entry onto the given stream. */
  59. extern int putpwent(__const struct passwd *__restrict __p,
  60. FILE *__restrict __f);
  61. /* Search for an entry with a matching user ID. */
  62. extern struct passwd *getpwuid(uid_t __uid);
  63. /* Search for an entry with a matching username. */
  64. extern struct passwd *getpwnam(__const char *__name);
  65. /* Reentrant versions of some of the functions above.
  66. PLEASE NOTE: the `getpwent_r' function is not (yet) standardized.
  67. The interface may change in later versions of this library. But
  68. the interface is designed following the principals used for the
  69. other reentrant functions so the chances are good this is what the
  70. POSIX people would choose. */
  71. extern int getpwent_r(struct passwd *__restrict __resultbuf,
  72. char *__restrict __buffer, size_t __buflen,
  73. struct passwd **__restrict __result);
  74. extern int getpwuid_r(uid_t __uid,
  75. struct passwd *__restrict __resultbuf,
  76. char *__restrict __buffer, size_t __buflen,
  77. struct passwd **__restrict __result);
  78. extern int getpwnam_r(__const char *__restrict __name,
  79. struct passwd *__restrict __resultbuf,
  80. char *__restrict __buffer, size_t __buflen,
  81. struct passwd **__restrict __result);
  82. /* Read an entry from STREAM. This function is not standardized and
  83. probably never will. */
  84. extern int fgetpwent_r(FILE *__restrict __stream,
  85. struct passwd *__restrict __resultbuf,
  86. char *__restrict __buffer, size_t __buflen,
  87. struct passwd **__restrict __result);
  88. /* Re-construct the password-file line for the given uid
  89. in the given buffer. This knows the format that the caller
  90. will expect, but this need not be the format of the password file. */
  91. extern int getpw(uid_t __uid, char *__buffer);
  92. #endif /* pwd.h */
  93. #endif