pwd.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /* Copyright (C) 1991,92,95,96,97,98,99,2001 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.2 User Database Access <pwd.h>
  17. */
  18. #ifndef _PWD_H
  19. #define _PWD_H 1
  20. #include <features.h>
  21. __BEGIN_DECLS
  22. #include <bits/types.h>
  23. #define __need_size_t
  24. #include <stddef.h>
  25. #ifdef __USE_XOPEN
  26. /* The Single Unix specification says that some more types are
  27. available here. */
  28. # ifndef __gid_t_defined
  29. typedef __gid_t gid_t;
  30. # define __gid_t_defined
  31. # endif
  32. # ifndef __uid_t_defined
  33. typedef __uid_t uid_t;
  34. # define __uid_t_defined
  35. # endif
  36. #endif
  37. /* The passwd structure. */
  38. struct passwd
  39. {
  40. char *pw_name; /* Username. */
  41. char *pw_passwd; /* Password. */
  42. __uid_t pw_uid; /* User ID. */
  43. __gid_t pw_gid; /* Group ID. */
  44. char *pw_gecos; /* Real name. */
  45. char *pw_dir; /* Home directory. */
  46. char *pw_shell; /* Shell program. */
  47. };
  48. #if defined __USE_SVID || defined __USE_GNU
  49. # define __need_FILE
  50. # include <stdio.h>
  51. #endif
  52. #if defined __USE_SVID || defined __USE_MISC || defined __USE_XOPEN_EXTENDED
  53. /* Rewind the password-file stream. */
  54. extern void setpwent (void) __THROW;
  55. /* Close the password-file stream. */
  56. extern void endpwent (void) __THROW;
  57. /* Read an entry from the password-file stream, opening it if necessary. */
  58. extern struct passwd *getpwent (void) __THROW;
  59. #endif
  60. #ifdef __USE_SVID
  61. /* Read an entry from STREAM. */
  62. extern struct passwd *fgetpwent (FILE *__stream) __THROW;
  63. /* Write the given entry onto the given stream. */
  64. extern int putpwent (__const struct passwd *__restrict __p,
  65. FILE *__restrict __f) __THROW;
  66. #endif
  67. /* Search for an entry with a matching user ID. */
  68. extern struct passwd *getpwuid (__uid_t __uid) __THROW;
  69. /* Search for an entry with a matching username. */
  70. extern struct passwd *getpwnam (__const char *__name) __THROW;
  71. #if defined __USE_POSIX || defined __USE_MISC
  72. # ifdef __USE_MISC
  73. /* Reasonable value for the buffer sized used in the reentrant
  74. functions below. But better use `sysconf'. */
  75. # define NSS_BUFLEN_PASSWD 1024
  76. # endif
  77. /* Reentrant versions of some of the functions above.
  78. PLEASE NOTE: the `getpwent_r' function is not (yet) standardized.
  79. The interface may change in later versions of this library. But
  80. the interface is designed following the principals used for the
  81. other reentrant functions so the chances are good this is what the
  82. POSIX people would choose. */
  83. # if defined __USE_SVID || defined __USE_MISC
  84. extern int getpwent_r (struct passwd *__restrict __resultbuf,
  85. char *__restrict __buffer, size_t __buflen,
  86. struct passwd **__restrict __result) __THROW;
  87. # endif
  88. extern int getpwuid_r (__uid_t __uid,
  89. struct passwd *__restrict __resultbuf,
  90. char *__restrict __buffer, size_t __buflen,
  91. struct passwd **__restrict __result) __THROW;
  92. extern int getpwnam_r (__const char *__restrict __name,
  93. struct passwd *__restrict __resultbuf,
  94. char *__restrict __buffer, size_t __buflen,
  95. struct passwd **__restrict __result) __THROW;
  96. # ifdef __USE_SVID
  97. /* Read an entry from STREAM. This function is not standardized and
  98. probably never will. */
  99. extern int fgetpwent_r (FILE *__restrict __stream,
  100. struct passwd *__restrict __resultbuf,
  101. char *__restrict __buffer, size_t __buflen,
  102. struct passwd **__restrict __result) __THROW;
  103. # endif
  104. #endif /* POSIX or reentrant */
  105. #ifdef __USE_GNU
  106. /* Re-construct the password-file line for the given uid
  107. in the given buffer. This knows the format that the caller
  108. will expect, but this need not be the format of the password file. */
  109. extern int getpw (__uid_t __uid, char *__buffer) __THROW;
  110. #endif
  111. __END_DECLS
  112. #endif /* pwd.h */