xref: /original-bsd/lib/libc/gen/getpwent.3 (revision 94c97675)
Copyright (c) 1988 Regents of the University of California.
All rights reserved. The Berkeley software License Agreement
specifies the terms and conditions for redistribution.

@(#)getpwent.3 6.4 (Berkeley) 09/17/88

GETPWENT 3 ""
.AT 3
NAME
getpwent, getpwuid, getpwnam, setpwent, endpwent, setpwfile - get password file entry
SYNOPSIS
 #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;

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, as described in < pwd.h > .

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).

FILES
/etc/passwd
"SEE ALSO"
getlogin(3), getgrent(3), passwd(5)
DIAGNOSTICS
The routines getpwent , getpwuid , and getpwnam , return a null pointer (0) on EOF or error. Setpwent returns 0 on failure, 1 on success. Endpwent and setpwfile have no return value.
BUGS
All information is contained in a static area so it must be copied if it is to be saved.