1.\"	$OpenBSD: getttyent.3,v 1.12 2013/06/05 03:39:22 tedu 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. Neither the name of the University nor the names of its contributors
15.\"    may be used to endorse or promote products derived from this software
16.\"    without specific prior written permission.
17.\"
18.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28.\" SUCH DAMAGE.
29.\"
30.Dd $Mdocdate: June 5 2013 $
31.Dt GETTTYENT 3
32.Os
33.Sh NAME
34.Nm getttyent ,
35.Nm getttynam ,
36.Nm setttyent ,
37.Nm endttyent
38.Nd get ttys file entry
39.Sh SYNOPSIS
40.In ttyent.h
41.Ft struct ttyent *
42.Fn getttyent "void"
43.Ft struct ttyent *
44.Fn getttynam "const char *name"
45.Ft int
46.Fn setttyent "void"
47.Ft int
48.Fn endttyent "void"
49.Sh DESCRIPTION
50The
51.Fn getttyent
52and
53.Fn getttynam
54functions each return a pointer to an object, with the following structure,
55containing the broken-out fields of a line from the tty description file.
56.Bd -literal -offset indent
57struct ttyent {
58	char	*ty_name;	/* terminal device name */
59	char	*ty_getty;	/* command to execute */
60	char	*ty_type;	/* terminal type */
61#define	TTY_ON		0x01	/* enable logins */
62#define	TTY_SECURE	0x02	/* allow uid of 0 to login */
63#define	TTY_LOCAL	0x04	/* set 'CLOCAL' on open */
64#define	TTY_RTSCTS	0x08	/* set 'CRTSCTS' on open */
65#define	TTY_SOFTCAR	0x10	/* ignore hardware carrier */
66#define	TTY_MDMBUF	0x20	/* set 'MDMBUF' on open */
67	int	ty_status;	/* flag values */
68	char	*ty_window;	/* command for window manager */
69	char	*ty_comment;	/* comment field */
70};
71.Ed
72.Pp
73The fields are as follows:
74.Bl -tag -width ty_comment
75.It Fa ty_name
76Name of the character-special file.
77.It Fa ty_getty
78Name of the command invoked by
79.Xr init 8
80to initialize tty line characteristics.
81.It Fa ty_type
82Name of the default terminal type connected to this tty line.
83.It Fa ty_status
84A mask of bit fields which indicate various actions allowed on this
85tty line.
86The possible flags are as follows:
87.Bl -tag -width TTY_SOFTCAR
88.It Dv TTY_ON
89Enables logins (i.e.,
90.Xr init 8
91will start the command referenced by
92.Fa ty_getty
93on this entry).
94.It Dv TTY_SECURE
95Allow users with a UID of 0 to login on this terminal.
96.It Dv TTY_LOCAL
97If the terminal port's driver supports it, cause the line to be treated as
98.Dq local .
99.It Dv TTY_MDMBUF
100If the terminal port's driver supports it, use
101DTR/DCD hardware flow control on the line by default.
102.It Dv TTY_RTSCTS
103If the terminal port's driver supports it, use
104full-duplex RTS/CTS hardware flow control on the line by default.
105.It Dv TTY_SOFTCAR
106If the terminal port's driver supports it, ignore hardware
107carrier on the line.
108.El
109.It Fa ty_window
110Command to execute for a window system associated with the line.
111.It Fa ty_comment
112Any trailing comment field, with any leading hash marks
113.Pq Sq \&#
114or whitespace removed.
115.El
116.Pp
117If any of the fields pointing to character strings are unspecified,
118they are returned as null pointers.
119The field
120.Fa ty_status
121will be zero if no flag values are specified.
122.Pp
123See
124.Xr ttys 5
125for a more complete discussion of the meaning and usage of the
126fields.
127.Pp
128The
129.Fn getttyent
130function reads the next line from the ttys file, opening the file if necessary.
131.Fn setttyent
132rewinds the file if open, or opens the file if it is unopened.
133.Fn endttyent
134closes any open files.
135.Pp
136.Fn getttynam
137searches from the beginning of the file until a matching
138.Fa name
139is found (or until
140.Dv EOF
141is encountered).
142.Sh RETURN VALUES
143The routines
144.Fn getttyent
145and
146.Fn getttynam
147return a null pointer on
148.Dv EOF
149or error.
150The
151.Fn setttyent
152function and
153.Fn endttyent
154return 0 on failure or 1 on success.
155.Sh FILES
156.Bl -tag -width /etc/ttys -compact
157.It Pa /etc/ttys
158.El
159.Sh SEE ALSO
160.Xr login 1 ,
161.Xr ttyslot 3 ,
162.Xr gettytab 5 ,
163.Xr termcap 5 ,
164.Xr ttys 5 ,
165.Xr getty 8 ,
166.Xr init 8 ,
167.Xr ttyflags 8
168.Sh HISTORY
169The
170.Fn getttyent ,
171.Fn getttynam ,
172.Fn setttyent ,
173and
174.Fn endttyent
175functions appeared in
176.Bx 4.3 .
177.Sh BUGS
178These functions use static data storage; if the data is needed for future use,
179it should be copied before any subsequent calls overwrite it.
180