1*53ee8cc1Swenshuai.xi /* Copyright (C) 1991,1992,1995-2001,2003,2004 Free Software Foundation, Inc. 2*53ee8cc1Swenshuai.xi This file is part of the GNU C Library. 3*53ee8cc1Swenshuai.xi 4*53ee8cc1Swenshuai.xi The GNU C Library is free software; you can redistribute it and/or 5*53ee8cc1Swenshuai.xi modify it under the terms of the GNU Lesser General Public 6*53ee8cc1Swenshuai.xi License as published by the Free Software Foundation; either 7*53ee8cc1Swenshuai.xi version 2.1 of the License, or (at your option) any later version. 8*53ee8cc1Swenshuai.xi 9*53ee8cc1Swenshuai.xi The GNU C Library is distributed in the hope that it will be useful, 10*53ee8cc1Swenshuai.xi but WITHOUT ANY WARRANTY; without even the implied warranty of 11*53ee8cc1Swenshuai.xi MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12*53ee8cc1Swenshuai.xi Lesser General Public License for more details. 13*53ee8cc1Swenshuai.xi 14*53ee8cc1Swenshuai.xi You should have received a copy of the GNU Lesser General Public 15*53ee8cc1Swenshuai.xi License along with the GNU C Library; if not, write to the Free 16*53ee8cc1Swenshuai.xi Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 17*53ee8cc1Swenshuai.xi 02111-1307 USA. */ 18*53ee8cc1Swenshuai.xi 19*53ee8cc1Swenshuai.xi /* 20*53ee8cc1Swenshuai.xi * POSIX Standard: 9.2.2 User Database Access <pwd.h> 21*53ee8cc1Swenshuai.xi */ 22*53ee8cc1Swenshuai.xi 23*53ee8cc1Swenshuai.xi #ifndef _PWD_H 24*53ee8cc1Swenshuai.xi #define _PWD_H 1 25*53ee8cc1Swenshuai.xi 26*53ee8cc1Swenshuai.xi #include <features.h> 27*53ee8cc1Swenshuai.xi 28*53ee8cc1Swenshuai.xi __BEGIN_DECLS 29*53ee8cc1Swenshuai.xi 30*53ee8cc1Swenshuai.xi #include <bits/types.h> 31*53ee8cc1Swenshuai.xi 32*53ee8cc1Swenshuai.xi #define __need_size_t 33*53ee8cc1Swenshuai.xi #include <stddef.h> 34*53ee8cc1Swenshuai.xi 35*53ee8cc1Swenshuai.xi #if defined __USE_XOPEN || defined __USE_XOPEN2K 36*53ee8cc1Swenshuai.xi /* The Single Unix specification says that some more types are 37*53ee8cc1Swenshuai.xi available here. */ 38*53ee8cc1Swenshuai.xi # ifndef __gid_t_defined 39*53ee8cc1Swenshuai.xi typedef __gid_t gid_t; 40*53ee8cc1Swenshuai.xi # define __gid_t_defined 41*53ee8cc1Swenshuai.xi # endif 42*53ee8cc1Swenshuai.xi 43*53ee8cc1Swenshuai.xi # ifndef __uid_t_defined 44*53ee8cc1Swenshuai.xi typedef __uid_t uid_t; 45*53ee8cc1Swenshuai.xi # define __uid_t_defined 46*53ee8cc1Swenshuai.xi # endif 47*53ee8cc1Swenshuai.xi #endif 48*53ee8cc1Swenshuai.xi 49*53ee8cc1Swenshuai.xi /* The passwd structure. */ 50*53ee8cc1Swenshuai.xi struct passwd 51*53ee8cc1Swenshuai.xi { 52*53ee8cc1Swenshuai.xi char *pw_name; /* Username. */ 53*53ee8cc1Swenshuai.xi char *pw_passwd; /* Password. */ 54*53ee8cc1Swenshuai.xi __uid_t pw_uid; /* User ID. */ 55*53ee8cc1Swenshuai.xi __gid_t pw_gid; /* Group ID. */ 56*53ee8cc1Swenshuai.xi char *pw_gecos; /* Real name. */ 57*53ee8cc1Swenshuai.xi char *pw_dir; /* Home directory. */ 58*53ee8cc1Swenshuai.xi char *pw_shell; /* Shell program. */ 59*53ee8cc1Swenshuai.xi }; 60*53ee8cc1Swenshuai.xi 61*53ee8cc1Swenshuai.xi 62*53ee8cc1Swenshuai.xi #if defined __USE_SVID || defined __USE_GNU 63*53ee8cc1Swenshuai.xi # define __need_FILE 64*53ee8cc1Swenshuai.xi # include <stdio.h> 65*53ee8cc1Swenshuai.xi #endif 66*53ee8cc1Swenshuai.xi 67*53ee8cc1Swenshuai.xi 68*53ee8cc1Swenshuai.xi #if defined __USE_SVID || defined __USE_MISC || defined __USE_XOPEN_EXTENDED 69*53ee8cc1Swenshuai.xi /* Rewind the password-file stream. 70*53ee8cc1Swenshuai.xi 71*53ee8cc1Swenshuai.xi This function is a possible cancellation point and therefore not 72*53ee8cc1Swenshuai.xi marked with __THROW. */ 73*53ee8cc1Swenshuai.xi extern void setpwent (void); 74*53ee8cc1Swenshuai.xi 75*53ee8cc1Swenshuai.xi /* Close the password-file stream. 76*53ee8cc1Swenshuai.xi 77*53ee8cc1Swenshuai.xi This function is a possible cancellation point and therefore not 78*53ee8cc1Swenshuai.xi marked with __THROW. */ 79*53ee8cc1Swenshuai.xi extern void endpwent (void); 80*53ee8cc1Swenshuai.xi 81*53ee8cc1Swenshuai.xi /* Read an entry from the password-file stream, opening it if necessary. 82*53ee8cc1Swenshuai.xi 83*53ee8cc1Swenshuai.xi This function is a possible cancellation point and therefore not 84*53ee8cc1Swenshuai.xi marked with __THROW. */ 85*53ee8cc1Swenshuai.xi extern struct passwd *getpwent (void); 86*53ee8cc1Swenshuai.xi #endif 87*53ee8cc1Swenshuai.xi 88*53ee8cc1Swenshuai.xi #ifdef __USE_SVID 89*53ee8cc1Swenshuai.xi /* Read an entry from STREAM. 90*53ee8cc1Swenshuai.xi 91*53ee8cc1Swenshuai.xi This function is not part of POSIX and therefore no official 92*53ee8cc1Swenshuai.xi cancellation point. But due to similarity with an POSIX interface 93*53ee8cc1Swenshuai.xi or due to the implementation it is a cancellation point and 94*53ee8cc1Swenshuai.xi therefore not marked with __THROW. */ 95*53ee8cc1Swenshuai.xi extern struct passwd *fgetpwent (FILE *__stream); 96*53ee8cc1Swenshuai.xi 97*53ee8cc1Swenshuai.xi /* Write the given entry onto the given stream. 98*53ee8cc1Swenshuai.xi 99*53ee8cc1Swenshuai.xi This function is not part of POSIX and therefore no official 100*53ee8cc1Swenshuai.xi cancellation point. But due to similarity with an POSIX interface 101*53ee8cc1Swenshuai.xi or due to the implementation it is a cancellation point and 102*53ee8cc1Swenshuai.xi therefore not marked with __THROW. */ 103*53ee8cc1Swenshuai.xi extern int putpwent (__const struct passwd *__restrict __p, 104*53ee8cc1Swenshuai.xi FILE *__restrict __f); 105*53ee8cc1Swenshuai.xi #endif 106*53ee8cc1Swenshuai.xi 107*53ee8cc1Swenshuai.xi /* Search for an entry with a matching user ID. 108*53ee8cc1Swenshuai.xi 109*53ee8cc1Swenshuai.xi This function is a possible cancellation point and therefore not 110*53ee8cc1Swenshuai.xi marked with __THROW. */ 111*53ee8cc1Swenshuai.xi extern struct passwd *getpwuid (__uid_t __uid); 112*53ee8cc1Swenshuai.xi 113*53ee8cc1Swenshuai.xi /* Search for an entry with a matching username. 114*53ee8cc1Swenshuai.xi 115*53ee8cc1Swenshuai.xi This function is a possible cancellation point and therefore not 116*53ee8cc1Swenshuai.xi marked with __THROW. */ 117*53ee8cc1Swenshuai.xi extern struct passwd *getpwnam (__const char *__name); 118*53ee8cc1Swenshuai.xi 119*53ee8cc1Swenshuai.xi #if defined __USE_POSIX || defined __USE_MISC 120*53ee8cc1Swenshuai.xi 121*53ee8cc1Swenshuai.xi # ifdef __USE_MISC 122*53ee8cc1Swenshuai.xi /* Reasonable value for the buffer sized used in the reentrant 123*53ee8cc1Swenshuai.xi functions below. But better use `sysconf'. */ 124*53ee8cc1Swenshuai.xi # define NSS_BUFLEN_PASSWD 1024 125*53ee8cc1Swenshuai.xi # endif 126*53ee8cc1Swenshuai.xi 127*53ee8cc1Swenshuai.xi /* Reentrant versions of some of the functions above. 128*53ee8cc1Swenshuai.xi 129*53ee8cc1Swenshuai.xi PLEASE NOTE: the `getpwent_r' function is not (yet) standardized. 130*53ee8cc1Swenshuai.xi The interface may change in later versions of this library. But 131*53ee8cc1Swenshuai.xi the interface is designed following the principals used for the 132*53ee8cc1Swenshuai.xi other reentrant functions so the chances are good this is what the 133*53ee8cc1Swenshuai.xi POSIX people would choose. */ 134*53ee8cc1Swenshuai.xi 135*53ee8cc1Swenshuai.xi # if defined __USE_SVID || defined __USE_MISC 136*53ee8cc1Swenshuai.xi /* This function is not part of POSIX and therefore no official 137*53ee8cc1Swenshuai.xi cancellation point. But due to similarity with an POSIX interface 138*53ee8cc1Swenshuai.xi or due to the implementation it is a cancellation point and 139*53ee8cc1Swenshuai.xi therefore not marked with __THROW. */ 140*53ee8cc1Swenshuai.xi extern int getpwent_r (struct passwd *__restrict __resultbuf, 141*53ee8cc1Swenshuai.xi char *__restrict __buffer, size_t __buflen, 142*53ee8cc1Swenshuai.xi struct passwd **__restrict __result); 143*53ee8cc1Swenshuai.xi # endif 144*53ee8cc1Swenshuai.xi 145*53ee8cc1Swenshuai.xi extern int getpwuid_r (__uid_t __uid, 146*53ee8cc1Swenshuai.xi struct passwd *__restrict __resultbuf, 147*53ee8cc1Swenshuai.xi char *__restrict __buffer, size_t __buflen, 148*53ee8cc1Swenshuai.xi struct passwd **__restrict __result); 149*53ee8cc1Swenshuai.xi 150*53ee8cc1Swenshuai.xi extern int getpwnam_r (__const char *__restrict __name, 151*53ee8cc1Swenshuai.xi struct passwd *__restrict __resultbuf, 152*53ee8cc1Swenshuai.xi char *__restrict __buffer, size_t __buflen, 153*53ee8cc1Swenshuai.xi struct passwd **__restrict __result); 154*53ee8cc1Swenshuai.xi 155*53ee8cc1Swenshuai.xi 156*53ee8cc1Swenshuai.xi # ifdef __USE_SVID 157*53ee8cc1Swenshuai.xi /* Read an entry from STREAM. This function is not standardized and 158*53ee8cc1Swenshuai.xi probably never will. 159*53ee8cc1Swenshuai.xi 160*53ee8cc1Swenshuai.xi This function is not part of POSIX and therefore no official 161*53ee8cc1Swenshuai.xi cancellation point. But due to similarity with an POSIX interface 162*53ee8cc1Swenshuai.xi or due to the implementation it is a cancellation point and 163*53ee8cc1Swenshuai.xi therefore not marked with __THROW. */ 164*53ee8cc1Swenshuai.xi extern int fgetpwent_r (FILE *__restrict __stream, 165*53ee8cc1Swenshuai.xi struct passwd *__restrict __resultbuf, 166*53ee8cc1Swenshuai.xi char *__restrict __buffer, size_t __buflen, 167*53ee8cc1Swenshuai.xi struct passwd **__restrict __result); 168*53ee8cc1Swenshuai.xi # endif 169*53ee8cc1Swenshuai.xi 170*53ee8cc1Swenshuai.xi #endif /* POSIX or reentrant */ 171*53ee8cc1Swenshuai.xi 172*53ee8cc1Swenshuai.xi #ifdef __USE_GNU 173*53ee8cc1Swenshuai.xi /* Re-construct the password-file line for the given uid 174*53ee8cc1Swenshuai.xi in the given buffer. This knows the format that the caller 175*53ee8cc1Swenshuai.xi will expect, but this need not be the format of the password file. 176*53ee8cc1Swenshuai.xi 177*53ee8cc1Swenshuai.xi This function is not part of POSIX and therefore no official 178*53ee8cc1Swenshuai.xi cancellation point. But due to similarity with an POSIX interface 179*53ee8cc1Swenshuai.xi or due to the implementation it is a cancellation point and 180*53ee8cc1Swenshuai.xi therefore not marked with __THROW. */ 181*53ee8cc1Swenshuai.xi extern int getpw (__uid_t __uid, char *__buffer); 182*53ee8cc1Swenshuai.xi #endif 183*53ee8cc1Swenshuai.xi 184*53ee8cc1Swenshuai.xi __END_DECLS 185*53ee8cc1Swenshuai.xi 186*53ee8cc1Swenshuai.xi #endif /* pwd.h */ 187