@node getpwent, unix @subheading Syntax @example #include struct passwd *getpwent(void); @end example @subheading Description This function retrieves the next available password file entry. For MS-DOS, this is simulated by providing exactly one entry: @example struct passwd @{ char * pw_name; /* getlogin() */ int pw_uid; /* getuid() */ int pw_gid; /* getgid() */ char * pw_dir; /* "/" or getenv("HOME") */ char * pw_shell; /* "/bin/sh" or getenv("SHELL") */ @}; @end example The @code{pw_name} member is returned as described under @code{getlogin} (@pxref{getlogin}). The @code{pw_uid} member is returned as described under @code{getuid} (@pxref{getuid}). @code{pw_gid} is returned as described under @code{getgid} (@pxref{getgid}). The @code{pw_dir} member is set to the value of the environment variable @code{HOME} if it is defined, or to @file{/} otherwise. @code{pw_shell} is set as follows: @itemize @bullet @item If the environment variable @code{SHELL} is set, the value of @code{SHELL}. @item If @code{SHELL} is not set, but @code{COMSPEC} is, the value of @code{COMSPEC}. @item If neither of the above variables is defined, @code{pw_shell} is set to @code{"sh"}. @end itemize @subheading Return Value The next passwd entry, or @code{NULL} if there are no more. @subheading Portability @portability !ansi, !posix @subheading Example @example struct passwd *p; setpwent(); while ((p = getpwent()) != NULL) @{ printf("user %s name %s\n", p->pw_name, p->pw_gecos); @} endpwent(); @end example @c ---------------------------------------------------------------------- @node setpwent, unix @subheading Syntax @example #include void setpwent(void); @end example @subheading Description This function reinitializes @code{getpwent} so that scanning will start from the start of the list. @xref{getpwent}. @subheading Return Value None. @subheading Portability @portability !ansi, !posix @c ---------------------------------------------------------------------- @node endpwent, unix @subheading Syntax @example #include void endpwent(void); @end example @subheading Description This function should be called after the last call to getpwent (@pxref{getpwent}). @subheading Return Value None. @subheading Portability @portability !ansi, !posix