getusershell(3C)
NAME
getusershell(), getusershell_r(), setusershell(), setusershell_r(), endusershell(), endusershell_r() − get legal user shells
SYNOPSIS
#include <unistd.h>
char *getusershell(void);
char *getusershell_r(char **shell_datap);
void setusershell(void);
void setusershell_r(char **shell_datap);
void endusershell(void);
void endusershell_r(char **shell_datap);
DESCRIPTION
getusershell() Returns a pointer to the first legal user shell as defined in the file /etc/shells (see shells(4)). If /etc/shells does not exist or is not readable, getusershell() returns the following standard system shells:
/sbin/sh
/usr/bin/sh
/usr/bin/rsh
/usr/bin/ksh
/usr/bin/rksh
/usr/bin/csh
/usr/bin/keysh
as if they were contained in /etc/shells. The file is left open so that the next call returns the next shell. A null pointer (0) is returned on EOF or error.
setusershell() Rewinds the file.
endusershell() Closes the file.
Reentrant Interfaces
getusershell_r(), setusershell_r() and endusershell_r() expect to be passed the address of a character pointer so that state information can be maintained between calls. *shell_datap should be initialized to NULL before the first call to either setusershell_r() or getusershell_r(). Thereafter it should not be modified. After the first call to setusershell_r() or getusershell_r(), *shell_datap points to state information that is needed on subsequent calls to getusershell_r().
endusershell_r() should be called when done so that any memory that has been internally allocated can be freed.
WARNINGS
In the non-reentrant versions of these routines, all information is contained in a static area and therefore must be copied if it is to be saved.
getusershell(), setusershell(), and endusershell() are unsafe in multi-thread applications. getusershell_r(), setusershell_r(), and endusershell_r() are MT-Safe and should be used instead.
AUTHOR
getusershell() was developed by HP and the University of California, Berkeley.
FILES
/etc/shells
SEE ALSO
Hewlett-Packard Company — HP-UX Release 10.20: July 1996