getttyent(3)
Name
getttyent, getttynam, setttyent, endttyent − get ttys file entry
Syntax
#include <ttyent.h>
struct ttyent *getttyent()
struct ttyent *getttynam(name) char *name;
void setttyent()
void endttyent()
Arguments
name The name of the terminal’s special file in the /dev directory.
Description
These functions allow a program to access data in the file /etc/ttys. The getttyent function reads the /etc/ttys file line by line, opening the file if necessary. setttyent rewinds the file, and endttyent closes it. getttynam searches from the beginning of the file until a matching name is found, or until end-of-file is encountered.
The functions getttyent and getttynam each return a pointer to an object that has the following structure. Each element of the structure contains one field of a line in the /etc/ttys file.
struct ttyent { /* see getttyent(3) */
char *ty_name; /* terminal device name */
char *ty_getty; /* command to execute, usually getty */
char *ty_type; /* terminal type for termcap (3x) */
int ty_status; /* status flags (see below for defines) */
char *ty_window; /* command to start up window manager */
char *ty_comment;/* usually the location of the terminal */
};
#define TTY_ON 0x1 /* enable logins (startup getty) */
#define TTY_SECURE 0x2 /* allow root to login */
#define TTY_LOCAL 0x4 /* line is local direct connect and
should ignore modem signals */
#define TTY_SHARED 0x8 /* line is shared: it can be use
for both incoming and outgoing
connections. */
#define TTY_TRACK 0x10 /* track modem status changes */
#define TTY_TERMIO 0x20 /* open line with termio defaults */
#define TTY_SU 0x40 /* disallow su to root */
extern struct ttyent *getttyent();
extern struct ttyent *getttynam();
A description of the fields follows:
ty_name
is the name of the terminal’s special file in the directory /dev.
ty_getty
is the command invoked by init to initialize terminal line characteristics. This command is usually getty(,), but any arbitrary command can be used. A typical use is to initiate a terminal emulator in a window system.
ty_type
is the name of the default terminal type connected to this tty line. This is typically a name from the termcap() data base. The environment variable ‘TERM’ is initialized with this name by login(.).
ty_status
is a mask of bit flags that indicate various actions allowed on this terminal line. The following is a description of each flag.
TTY_ON
Enables logins. For instance, init() will start the specified getty command on this entry.
TTY_SECURE
Allows root to login on this terminal. TTY_ON must also be included for this to work.
TTY_LOCAL
Indicates that the line is to ignore modem signals.
TTY_SHARED
Indicates that the line can be used for both incoming and outgoing connections.
TTY_TERMIO
Indicates that a line is to be opened with default terminal attributes which are compliant with System Five termio defaults. The line discipline will be set to be TERMIODISC.
TTY_SU
Indicates that a user is allowed to su to root on this terminal. The default if this flag is not set is that a user cannot su to root on this terminal.
ty_window
is the quoted string of a command to execute for a window system associated with the line. If no command is specified, this field is a null string.
ty_comment
Currently unused.
Restrictions
The information returned is in a static area, so you must copy it to save it.
Return Values
A null pointer (0) is returned on an end-of-file or error.
Files
/etc/ttys The file examined by these routines.