All rights reserved. The Berkeley software License Agreement
specifies the terms and conditions for redistribution.
@(#)getpwent.3 6.4 (Berkeley) 09/17/88
#include <pwd.h>struct passwd *getpwuid(uid) uid_t uid;
struct passwd *getpwnam(name) char *name;
struct passwd *getpwent()
void setpwent()
void endpwent()
setpwfile(name) char *name;
struct passwd { char *pw_name; char *pw_passwd; uid_t pw_uid; gid_t pw_gid; int pw_quota; char *pw_comment; char *pw_gecos; char *pw_dir; char *pw_shell; };
The fields pw_quota and pw_comment are unused; the others have meanings described in passwd (5).
Setpwfile changes the default password file to name , thus allowing usage of alternate password files. If ndbm databases are available for any password files, they are used, otherwise the file itself is linearly searched.
Setpwent opens the database or file (closing any previously opened database or file) or rewinds it if it is already open.
Endpwent closes any open databases or files.
Getpwuid and getpwnam search the entire database or file (opening it if necessary) for a matching uid or name .
For programs wishing to read the entire database, getpwent reads the next entry (opening the database or file if necessary).