Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

ttyname(3)

ttys(5)

init(8)

getttyent(3)

NAME

getttyent, getttynam, setttyent, endttyent − get ttys file entry

SYNTAX

#include <ttyent.h>
struct ttyent *getttyent()
struct ttyent *getttynam(name) char *name;
int setttyent()
int endttyent()

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 - i.e. 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 */
 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.

ty_window
is the quoted string of a command to execute for a window system associated with the line. If none is specified, this will be a null string.

ty_comment
Currently unused.

RESTRICTIONS

The information returned is in a static area, so you must copy it to save it.  (Static areas are described in "The C Programming Language," ULTRIX-32 Supplementary Documents, Vol. II:Programmers.) 

RETURN VALUE

A null pointer (0) is returned on an end-of-file or error. 

FILES

/etc/ttys
The file examined by these routines.

SEE ALSO

ttyname(3), ttys(5), init(8)

Subroutines

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026