pwd.h 6.1 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, 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. #if defined __USE_XOPEN || defined __USE_XOPEN2K
  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. This function is a possible cancellation point and therefore not
  55. marked with __THROW. */
  56. extern void setpwent (void);
  57. /* Close the password-file stream.
  58. This function is a possible cancellation point and therefore not
  59. marked with __THROW. */
  60. extern void endpwent (void);
  61. /* Read an entry from the password-file stream, opening it if necessary.
  62. This function is a possible cancellation point and therefore not
  63. marked with __THROW. */
  64. extern struct passwd *getpwent (void);
  65. #endif
  66. #ifdef __USE_SVID
  67. /* Read an entry from STREAM.
  68. This function is not part of POSIX and therefore no official
  69. cancellation point. But due to similarity with an POSIX interface
  70. or due to the implementation it is a cancellation point and
  71. therefore not marked with __THROW. */
  72. extern struct passwd *fgetpwent (FILE *__stream);
  73. /* Write the given entry onto the given stream.
  74. This function is not part of POSIX and therefore no official
  75. cancellation point. But due to similarity with an POSIX interface
  76. or due to the implementation it is a cancellation point and
  77. therefore not marked with __THROW. */
  78. extern int putpwent (__const struct passwd *__restrict __p,
  79. FILE *__restrict __f);
  80. #endif
  81. /* Search for an entry with a matching user ID.
  82. This function is a possible cancellation point and therefore not
  83. marked with __THROW. */
  84. extern struct passwd *getpwuid (__uid_t __uid);
  85. /* Search for an entry with a matching username.
  86. This function is a possible cancellation point and therefore not
  87. marked with __THROW. */
  88. extern struct passwd *getpwnam (__const char *__name);
  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 */