| 1 | .TH GETTTYENT 3
 | 
|---|
| 2 | .SH NAME
 | 
|---|
| 3 | getttyent, getttynam, setttyent, endttyent \- interface to /etc/ttytab
 | 
|---|
| 4 | .SH SYNOPSIS
 | 
|---|
| 5 | .ft B
 | 
|---|
| 6 | .nf
 | 
|---|
| 7 | #include <ttyent.h>
 | 
|---|
| 8 | 
 | 
|---|
| 9 | struct ttyent *getttyent(void)
 | 
|---|
| 10 | struct ttyent *getttynam(const char *\fIname\fP)
 | 
|---|
| 11 | int setttyent(void)
 | 
|---|
| 12 | void endttyent(void)
 | 
|---|
| 13 | .fi
 | 
|---|
| 14 | .ft P
 | 
|---|
| 15 | .SH DESCRIPTION
 | 
|---|
| 16 | The
 | 
|---|
| 17 | .B getttyent
 | 
|---|
| 18 | functions provide an interface to the /etc/ttytab.  (See
 | 
|---|
| 19 | .BR ttytab (5)).
 | 
|---|
| 20 | .PP
 | 
|---|
| 21 | To read one of these files one calls
 | 
|---|
| 22 | .B getttyent()
 | 
|---|
| 23 | several times to read the entries in the table until NULL is returned for
 | 
|---|
| 24 | end-of-file.
 | 
|---|
| 25 | .PP
 | 
|---|
| 26 | .B Getttyname()
 | 
|---|
| 27 | searches the
 | 
|---|
| 28 | .B ttytab
 | 
|---|
| 29 | file for the given terminal device.  It is equivalent to a call to
 | 
|---|
| 30 | .BR setttyent(),
 | 
|---|
| 31 | several calls to
 | 
|---|
| 32 | .B getttyent()
 | 
|---|
| 33 | to locate the entry, and a final
 | 
|---|
| 34 | .B endttyent()
 | 
|---|
| 35 | to close the file.
 | 
|---|
| 36 | .PP
 | 
|---|
| 37 | .B Setttyent()
 | 
|---|
| 38 | opens or rewinds the ttytab database, and
 | 
|---|
| 39 | .B endttyent() closes it.
 | 
|---|
| 40 | .B Getttyent()
 | 
|---|
| 41 | opens the database if not already open, but does not close it.
 | 
|---|
| 42 | .PP
 | 
|---|
| 43 | The struct ttyent is defined by <ttyent.h> as follows:
 | 
|---|
| 44 | .sp
 | 
|---|
| 45 | .nf
 | 
|---|
| 46 | .ta +4n +6n +15n
 | 
|---|
| 47 | struct ttyent {
 | 
|---|
| 48 |         char    *ty_name;       /* Name of the terminal device. */
 | 
|---|
| 49 |         char    *ty_type;       /* Terminal type name (termcap(3)). */
 | 
|---|
| 50 |         char    **ty_getty;     /* Program to run, normally getty. */
 | 
|---|
| 51 |         char    **ty_init;      /* Initialization command, normally stty. */
 | 
|---|
| 52 | };
 | 
|---|
| 53 | .fi
 | 
|---|
| 54 | .PP
 | 
|---|
| 55 | A valid entry has at least two strings, so both
 | 
|---|
| 56 | .B ty_name
 | 
|---|
| 57 | and
 | 
|---|
| 58 | .B ty_type
 | 
|---|
| 59 | are filled in.  The optional
 | 
|---|
| 60 | .B ty_getty
 | 
|---|
| 61 | and
 | 
|---|
| 62 | .B ty_init
 | 
|---|
| 63 | may be NULL (field omitted), point to a pointer that is NULL (null lenght
 | 
|---|
| 64 | field, i.e. ""), or an array of strings terminated by a NULL (field
 | 
|---|
| 65 | present).  For now no useful distinction can be made between a omitted field
 | 
|---|
| 66 | and an empty field, so treat both cases as an omission.
 | 
|---|
| 67 | .SH FILES
 | 
|---|
| 68 | .TP 15
 | 
|---|
| 69 | .B /etc/ttytab
 | 
|---|
| 70 | The terminal device database
 | 
|---|
| 71 | .SH "SEE ALSO"
 | 
|---|
| 72 | .BR ttyname (3),
 | 
|---|
| 73 | .BR ttyslot (3),
 | 
|---|
| 74 | .BR ttytab (5),
 | 
|---|
| 75 | .BR init (8).
 | 
|---|
| 76 | .SH DIAGNOSTICS
 | 
|---|
| 77 | .B Setttyent()
 | 
|---|
| 78 | has the same return value and error codes as the
 | 
|---|
| 79 | .BR open (2)
 | 
|---|
| 80 | call it uses to open the ttytab file.  The
 | 
|---|
| 81 | .BI get xxx ()
 | 
|---|
| 82 | functions return NULL on end of file, entry not found, or error.  You can
 | 
|---|
| 83 | set
 | 
|---|
| 84 | .B errno
 | 
|---|
| 85 | to zero before the call and check it after.
 | 
|---|
| 86 | .SH NOTES
 | 
|---|
| 87 | .B Getttyent()
 | 
|---|
| 88 | and
 | 
|---|
| 89 | .B getttynam()
 | 
|---|
| 90 | return a pointer to static storage that is overwritten in each call.
 | 
|---|
| 91 | .PP
 | 
|---|
| 92 | The MINIX 3
 | 
|---|
| 93 | .B struct ttyent
 | 
|---|
| 94 | has only the
 | 
|---|
| 95 | .B ty_name
 | 
|---|
| 96 | and
 | 
|---|
| 97 | .B ty_type
 | 
|---|
| 98 | fields in common with the BSD implementation.  This does not seem to be a
 | 
|---|
| 99 | problem, because most third party software that need to know about terminals
 | 
|---|
| 100 | only look at the
 | 
|---|
| 101 | .B ty_name
 | 
|---|
| 102 | field.
 | 
|---|
| 103 | .SH AUTHOR
 | 
|---|
| 104 | Kees J. Bot (kjb@cs.vu.nl)
 | 
|---|
| 105 | 
 | 
|---|
| 106 | .\"
 | 
|---|
| 107 | .\" $PchId: getttyent.3,v 1.2 1996/04/11 06:57:26 philip Exp $
 | 
|---|