www.delorie.com/djgpp/doc/libc/libc_412.html   search  
libc.a reference

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

getpwent

Syntax

 
#include <pwd.h>

struct passwd *getpwent(void);

Description

This function retrieves the next available password file entry. For MS-DOS, this is simulated by providing exactly one entry:

 
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") */
  char * pw_gecos;   /* getlogin() */
  char * pw_passwd;  /* "" */
};

The pw_name and pw_gecos members are returned as described under getlogin (see section getlogin). The pw_uid member is returned as described under getuid (see section getuid). pw_gid is returned as described under getgid (see section getgid). The pw_passwd member is set to the empty string. The pw_dir member is set to the value of the environment variable HOME if it is defined, or to `/' otherwise. pw_shell is set as follows:

Return Value

The next passwd entry, or NULL if there are no more.

Portability

ANSI/ISO C No
POSIX No

Example

 
struct passwd *p;
setpwent();
while ((p = getpwent()) != NULL)
{
  printf("user %s name %s\n", p->pw_name, p->pw_gecos);
}
endpwent();


  webmaster   donations   bookstore     delorie software   privacy  
  Copyright 2004   by DJ Delorie     Updated Apr 2004