GETPWENT(3) — Kubota Pacfic Computer Inc. (C Library Functions−BSD)
NAME
getpwent, getpwuid, getpwnam, setpwent, endpwent − get password file entry
SYNOPSIS
#include <pwd.h>
struct passwd ∗getpwuid(uid)
int uid;
struct passwd ∗getpwnam(name)
char ∗name;
struct passwd ∗getpwent()
setpwent()
endpwent()
DESCRIPTION
getpwent, getpwuid and getpwnam each return a pointer to an object with the following structure containing the broken-out fields of a line in the password file.
structpasswd { /∗ see getpwent(3) ∗/
char∗pw_name;
char∗pw_passwd;
intpw_uid;
intpw_gid;
intpw_quota;
char∗pw_comment;
char∗pw_gecos;
char∗pw_dir;
char∗pw_shell;
};
struct passwd ∗getpwent(), ∗getpwuid(), ∗getpwnam();
The fields pw_quota and pw_comment are unused; the others have meanings described in passwd(4).
Searching the password file is done using the ndbm database access routines. setpwent opens the database; endpwent closes it. getpwuid and getpwnam search the database (opening it if necessary) for a matching uid or name. EOF is returned if there is no entry.
For programs wishing to read the entire database, getpwent reads the next line (opening the database if necessary). In addition to opening the database, setpwent can be used to make getpwent begin its search from the beginning of the database.
FILES
/etc/passwd
SEE ALSO
getlogin(3), getgrent(3), passwd(4)
DIAGNOSTICS
The routines getpwent, getpwuid, and getpwnam, return NULL on EOF or error.
BUGS
All information is contained in a static area so it must be copied if it is to be saved.
September 02, 1992