Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ getpwent(3C) — sys5 — Apollo

Media Vault

Software Library

Restoration Projects

Artifacts Sought



GETPWENT(3C)    DOMAIN/IX Reference Manual (SYS5)    GETPWENT(3C)



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

USAGE
     #include <pwd.h>

     struct passwd *getpwent ( )

     struct passwd *getpwuid (uid)
     int uid;

     struct passwd *getpwnam (name)
     char *name;

     void setpwent ( )

     void endpwent ( )

     struct passwd *fgetpwent (f)
     FILE *f;

DESCRIPTION
     Getpwent, getpwuid, and getpwnam return pointers to an
     object with the following structure.  The structure contains
     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;
               int  pw_uid;
               int  pw_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 pwcomment field is unused; the others have meanings
     described in passwd(4).

     Getpwent returns a pointer to the first ``passwd'' structure
     in the file, when it is first called.  Thereafter, it
     returns a pointer to the next ``passwd'' structure in the
     file.  Thus, successive calls can be used to search the
     entire file.  Getpwuid searches from the beginning of the



Printed 5/10/85                                        GETPWENT-1





GETPWENT(3C)    DOMAIN/IX Reference Manual (SYS5)    GETPWENT(3C)



     file until a numerical user ID matching uid is found and
     returns a pointer to the particular structure in which it
     was found.  Getpwnam searches from the beginning of the file
     until a log-in 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 rewinds the password file to allow
     repeated searches.  Endpwent is called to close the password
     file when processing is complete.

     Fgetpwent returns a pointer to the next passwd structure in
     the stream f, which matches the format of /etc/passwd.

NOTES
     All data resides in a static area, so it must be copied if
     you wish to saved it.
     These routines use <stdio.h>, which causes them to increase
     the size of programs, even though the programs do not other-
     wise use standard I/O.

FILES
     /etc/passwd

DIAGNOSTICS
     A NULL pointer is returned on EOF or error.

RELATED INFORMATION
     getlogin(3C), getgrent(3C), passwd(4)

























GETPWENT-2                                        Printed 5/10/85



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