Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ getpwent(3P) — Interactive 2.2

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

getgrent(3P)

getlogin(3C)

passwd(4)



          getpwent(3P)     INTERACTIVE UNIX System (POSIX)     getpwent(3P)



          NAME
               getpwent, getpwuid, getpwnam, setpwent, endpwent, fgetpwent
               - get password file entry

          SYNOPSIS
               #include <pwd.h>

               struct passwd *getpwent ()

               struct passwd *getpwuid (uid)
               uid_t uid;

               struct passwd *getpwnam (name)
               char *name;

               void setpwent ()

               void endpwent ()

               struct passwd *fgetpwent (f)
               FILE *f;

          DESCRIPTION
               The getpwent, getpwuid, and getpwnam functions each return a
               pointer to an object with the following structure containing
               the ``broken-out'' fields of a line in the /etc/passwd file.
               Each line in the file contains a passwd structure, declared
               in the <pwd.h> header file:

                    struct     passwd {
                          char *pw_name;
                          char *pw_passwd;
                          uid_tpw_uid;
                          gid_tpw_gid;
                          char *pw_age;
                          char *pw_comment;
                          char *pw_gecos;
                          char *pw_dir;
                          char *pw_shell;
                    };

               This structure is declared in <pwd.h> so it is not necessary
               to redeclare it.

               The fields have meanings described in passwd(4).

               The getpwent function, when first called, returns a pointer
               to the first passwd structure in the file; thereafter, it
               returns a pointer to the next passwd structure in the file,
               so successive calls can be used to search the entire file.
               The getpwuid command searches from the beginning of the file
               until a numerical user-ID matching uid is found and returns
               a pointer to the particular structure in which it was found.


          Rev. 1.1                                                   Page 1





          getpwent(3P)     INTERACTIVE UNIX System (POSIX)     getpwent(3P)



               The getpwnam command searches from the beginning of the file
               until a login name matching name is found and returns a
               pointer to the particular structure in which it was found.
               If an end-of-file or an error is encountered on reading,
               these functions return a NULL pointer.

               A call to setpwent has the effect of rewinding the password
               file to allow repeated searches.  The endpwent command may
               be called to close the password file when processing is com-
               plete.

          FILES
               /etc/passwd

          SEE ALSO
               getgrent(3P), getlogin(3C), passwd(4).

          DIAGNOSTICS
               NULL is returned on EOF or error.

          WARNING
               All information is contained in a static area, so it must be
               copied if it is to be saved.
































          Rev. 1.1                                                   Page 2



Typewritten Software • bear@typewritten.org • Edmonds, WA 98026