pwd.h 6.0 KB

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