3
0

pwd_.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. #ifndef BB_PWD_H
  20. #define BB_PWD_H 1
  21. #if __GNUC_PREREQ(4,1)
  22. # pragma GCC visibility push(hidden)
  23. #endif
  24. /* This file is #included after #include <pwd.h>
  25. * We will use libc-defined structures, but will #define function names
  26. * so that function calls are directed to bb_internal_XXX replacements
  27. */
  28. #define setpwent bb_internal_setpwent
  29. #define endpwent bb_internal_endpwent
  30. #define getpwent bb_internal_getpwent
  31. #define fgetpwent bb_internal_fgetpwent
  32. #define putpwent bb_internal_putpwent
  33. #define getpwuid bb_internal_getpwuid
  34. #define getpwnam bb_internal_getpwnam
  35. #define getpwent_r bb_internal_getpwent_r
  36. #define getpwuid_r bb_internal_getpwuid_r
  37. #define getpwnam_r bb_internal_getpwnam_r
  38. #define fgetpwent_r bb_internal_fgetpwent_r
  39. //#define getpw bb_internal_getpw
  40. /* All function names below should be remapped by #defines above
  41. * in order to not collide with libc names. */
  42. /* Rewind the password-file stream. */
  43. extern void setpwent(void);
  44. /* Close the password-file stream. */
  45. extern void endpwent(void);
  46. /* Read an entry from the password-file stream, opening it if necessary. */
  47. extern struct passwd *getpwent(void);
  48. /* Read an entry from STREAM. */
  49. extern struct passwd *fgetpwent(FILE *__stream);
  50. /* Write the given entry onto the given stream. */
  51. extern int putpwent(const struct passwd *__restrict __p,
  52. FILE *__restrict __f);
  53. /* Search for an entry with a matching user ID. */
  54. extern struct passwd *getpwuid(uid_t __uid);
  55. /* Search for an entry with a matching username. */
  56. extern struct passwd *getpwnam(const char *__name);
  57. /* Reentrant versions of some of the functions above.
  58. PLEASE NOTE: the `getpwent_r' function is not (yet) standardized.
  59. The interface may change in later versions of this library. But
  60. the interface is designed following the principals used for the
  61. other reentrant functions so the chances are good this is what the
  62. POSIX people would choose. */
  63. extern int getpwent_r(struct passwd *__restrict __resultbuf,
  64. char *__restrict __buffer, size_t __buflen,
  65. struct passwd **__restrict __result);
  66. extern int getpwuid_r(uid_t __uid,
  67. struct passwd *__restrict __resultbuf,
  68. char *__restrict __buffer, size_t __buflen,
  69. struct passwd **__restrict __result);
  70. extern int getpwnam_r(const char *__restrict __name,
  71. struct passwd *__restrict __resultbuf,
  72. char *__restrict __buffer, size_t __buflen,
  73. struct passwd **__restrict __result);
  74. /* Read an entry from STREAM. This function is not standardized and
  75. probably never will. */
  76. extern int fgetpwent_r(FILE *__restrict __stream,
  77. struct passwd *__restrict __resultbuf,
  78. char *__restrict __buffer, size_t __buflen,
  79. struct passwd **__restrict __result);
  80. /* Re-construct the password-file line for the given uid
  81. in the given buffer. This knows the format that the caller
  82. will expect, but this need not be the format of the password file. */
  83. /* UNUSED extern int getpw(uid_t __uid, char *__buffer); */
  84. #if __GNUC_PREREQ(4,1)
  85. # pragma GCC visibility pop
  86. #endif
  87. #endif /* pwd.h */