.so header
.he /PASSWORD(3C)/Kreider OS-9 C Library/PASSWORD(3C)/
.sh NAME
.bb
*getpwent, *getpwuid, *getpwnam, setpwent, endpwent, getpwdlm
.sp
Password file operations
.eb
.sh SYNOPSIS
.bb
#include <password.h>

PWENT *getpwent()

PWENT *getpwuid(uid)
int uid;

PWENT *getpwnam(name)
char *name;

void setpwent()

void endpwent()

int getpwdlm()
.eb
.sh DESCRIPTION
.db
Each of the functions described below perform some operation on the \fBPASSWORD\fP file maintained in \fB/DD/SYS.\f
.sp
Notice also that three of the functions are declared as pointer functions, and
two are of type VOID.
.sp \fBGETPWENT\fP returns a pointer to a structure containing the broken down password entry.
It searches for the file \fB/DD/SYS/PASSWORD,\fP opens it on the first call, and
reads the first password entry. Any subsequent calls will overwrite the data
contained in the structure \fBPWENT\fP defined in \fBPASSWORD.H, so that data must\fP be copied out before the next call is made to preserve it.
.sp
This function returns a \fInull\fP upon reaching the end of the password file, and a -1 if an error occurs.
.sp \fBGETPWUID\fP performs the same function as \fBGETPWENT\fP above, but it searches the password
file until a given user ID, as defined by UID, is found.
.sp \fBGETPWNAME\fP again performs the same as \fBGWTPWENT,\fP but searches the password file until
the entry defined my \fIname\fP is found. The search for \fIname\fP is not case sensitive.
.sp \fBSETPWENT\fP rewinds the password file pointer so additional reads can be made
after the end of the file is reached.
.sp \fBENDPWENT\fP terminates access and closes the password file.
.sp \fBGETPWDLM\fP returns the current password file delimiter character. In an OS9
password file, the field delimiting character is a comma, while in other
password utilities and files, a semi-colon is used for the delimiter
character. This function is provided as a means to check the current type.
.ed
.sh NOTE
.db
For user convinence, function declarations are made in the header file
Password.h provided below.
.bb
/*
**  Password.h
**
**  Definitions for accessing the OS9 password file.
**  Two different delimiters are accepted, ',' and ':'.
**  In the second (Unix like) case, an extra field is
**  defined for comments (ugcos).
*/

#ifdef TEST
#define  PASSWORD "/dd/sys/massword"
#else
#define  PASSWORD "/dd/sys/password"
#endif

#define  PWEMAX   64       /* maximum lines in password file */
#define  PWSIZ    132  /* maximim size of password file line */
#define  PWNSIZ   32          /* maximum size of user's name */
#define  PWPSIZ   32      /* maximum size of user's password */
#define  UNXDLM   ':'      /* Unix style password file delim */
#define  OS9DLM   ','       /* OS9 style password file delim */

typedef struct {
      char  *unam,
            *upw,
            *uid,
            *upri,
            *ugcos,
            *ucmd,
            *udat,
            *ujob;                      /* field pointers */
      } PWENT;


/* returns a pointer to broken down password entry */
PWENT    *getpwent();

/* same, but for the given int uid */
PWENT    *getpwuid();

/* same, but for the given char *name */
PWENT    *getpwnam();

/* rewinds the password file for another scan */
/*void*/ setpwent();

/* terminates password file access (closes) file */
/*void*/ endpwent();

/* returns the current password entry delimiter */
/*void*/ getpwdlm();
.eb
.ed
