1.\" $NetBSD: getttyent.3,v 1.12 2002/02/07 07:00:13 ross Exp $ 2.\" 3.\" Copyright (c) 1989, 1991, 1993 4.\" The Regents of the University of California. All rights reserved. 5.\" 6.\" Redistribution and use in source and binary forms, with or without 7.\" modification, are permitted provided that the following conditions 8.\" are met: 9.\" 1. Redistributions of source code must retain the above copyright 10.\" notice, this list of conditions and the following disclaimer. 11.\" 2. Redistributions in binary form must reproduce the above copyright 12.\" notice, this list of conditions and the following disclaimer in the 13.\" documentation and/or other materials provided with the distribution. 14.\" 3. All advertising materials mentioning features or use of this software 15.\" must display the following acknowledgement: 16.\" This product includes software developed by the University of 17.\" California, Berkeley and its contributors. 18.\" 4. Neither the name of the University nor the names of its contributors 19.\" may be used to endorse or promote products derived from this software 20.\" without specific prior written permission. 21.\" 22.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 23.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 26.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32.\" SUCH DAMAGE. 33.\" 34.\" @(#)getttyent.3 8.1 (Berkeley) 6/4/93 35.\" 36.Dd June 4, 1993 37.Dt GETTTYENT 3 38.Os 39.Sh NAME 40.Nm getttyent , 41.Nm getttynam , 42.Nm setttyent , 43.Nm endttyent 44.Nd get ttys file entry 45.Sh LIBRARY 46.Lb libc 47.Sh SYNOPSIS 48.Fd #include \*[Lt]ttyent.h\*[Gt] 49.Ft struct ttyent * 50.Fn getttyent 51.Ft struct ttyent * 52.Fn getttynam "char *name" 53.Ft int 54.Fn setttyent void 55.Ft int 56.Fn endttyent void 57.Sh DESCRIPTION 58The 59.Fn getttyent , 60and 61.Fn getttynam 62functions 63each return a pointer to an object, with the following structure, 64containing the broken-out fields of a line from the tty description 65file. 66.Bd -literal 67struct ttyent { 68 char *ty_name; /* terminal device name */ 69 char *ty_getty; /* command to execute */ 70 char *ty_type; /* terminal type */ 71#define TTY_ON 0x01 /* enable logins */ 72#define TTY_SECURE 0x02 /* allow uid of 0 to login */ 73#define TTY_LOCAL 0x04 /* set 'CLOCAL' on open (dev. specific) */ 74#define TTY_RTSCTS 0x08 /* set 'CRTSCTS' on open (dev. specific) */ 75#define TTY_SOFTCAR 0x10 /* ignore hardware carrier (dev. spec.) */ 76#define TTY_MDMBUF 0x20 /* set 'MDMBUF' on open (dev. specific) */ 77#define TTY_DTRCTS 0x40 /* set 'CDTRCTS' on open (dev. specific) */ 78 int ty_status; /* flag values */ 79 char *ty_window; /* command for window manager */ 80 char *ty_comment; /* comment field */ 81 char *ty_class; /* category of tty usage */ 82}; 83.Ed 84.Pp 85The fields are as follows: 86.Bl -tag -width ty_comment 87.It Fa ty_name 88The name of the character-special file. 89.It Fa ty_getty 90The name of the command invoked by 91.Xr init 8 92to initialize tty line characteristics. 93.It Fa ty_type 94The name of the default terminal type connected to this tty line. 95.It Fa ty_status 96A mask of bit fields which indicate various actions allowed on this 97tty line. 98The possible flags are as follows: 99.Bl -tag -width TTY_SOFTCAR 100.It Dv TTY_ON 101Enables logins (i.e., 102.Xr init 8 103will start the command referenced by 104.Fa ty_getty 105on this entry). 106.It Dv TTY_SECURE 107Allow users with a uid of 0 to login on this terminal. 108.It Dv TTY_LOCAL 109If the terminal port's driver supports it, cause the line 110to be treated as ``local.'' 111.It Dv TTY_MDMBUF 112If the terminal port's driver supports it, use 113DTR/DCD hardware flow control on the line by default. 114.It Dv TTY_RTSCTS 115If the terminal port's driver supports it, use 116full-duplex RTS/CTS hardware flow control on the line 117by default. 118.It Dv TTY_SOFTCAR 119If the terminal port's driver supports it, ignore hardware 120carrier on the line. 121.El 122.It Fa ty_window 123The command to execute for a window system associated with the line. 124.It Fa ty_comment 125Any trailing comment field, with any leading hash marks (``#'') or 126whitespace removed. 127.It Fa ty_class 128A key indexing into a termcap-style database (/etc/ttyclasses) 129of attributes for this class of tty. No attributes are currently 130defined or used, so there are currently no functions to retrieve 131them. 132.El 133.Pp 134If any of the fields pointing to character strings are unspecified, 135they are returned as null pointers. 136The field 137.Fa ty_status 138will be zero if no flag values are specified. 139.Pp 140See 141.Xr ttys 5 142for a more complete discussion of the meaning and usage of the 143fields. 144.Pp 145The 146.Fn getttyent 147function 148reads the next line from the ttys file, opening the file if necessary. 149The 150.Fn setttyent 151function 152rewinds the file if open, or opens the file if it is unopened. 153The 154.Fn endttyent 155function 156closes any open files. 157.Pp 158The 159.Fn getttynam 160function 161searches from the beginning of the file until a matching 162.Fa name 163is found 164(or until 165.Dv EOF 166is encountered). 167.Sh RETURN VALUES 168The routines 169.Fn getttyent 170and 171.Fn getttynam 172return a null pointer on 173.Dv EOF 174or error. 175The 176.Fn setttyent 177function 178and 179.Fn endttyent 180return 0 on failure and 1 on success. 181.Sh FILES 182.Bl -tag -width /etc/ttys -compact 183.It Pa /etc/ttys 184.El 185.Sh SEE ALSO 186.Xr login 1 , 187.Xr ttyslot 3 , 188.Xr gettytab 5 , 189.Xr termcap 5 , 190.Xr ttys 5 , 191.Xr getty 8 , 192.Xr init 8 , 193.Xr ttyflags 8 194.Sh HISTORY 195The 196.Fn getttyent , 197.Fn getttynam , 198.Fn setttyent , 199and 200.Fn endttyent 201functions appeared in 202.Bx 4.3 . 203.Sh BUGS 204These functions use static data storage; 205if the data is needed for future use, it should be 206copied before any subsequent calls overwrite it. 207