xref: /openbsd/lib/libc/gen/getttyent.3 (revision df930be7)
1.\"	$NetBSD: getttyent.3,v 1.6 1995/02/27 04:13:16 cgd 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 BSD 4.3
39.Sh NAME
40.Nm getttyent ,
41.Nm getttynam ,
42.Nm setttyent ,
43.Nm endttyent
44.Nd get ttys file entry
45.Sh SYNOPSIS
46.Fd #include <ttyent.h>
47.Ft struct ttyent *
48.Fn getttyent
49.Ft struct ttyent *
50.Fn getttynam "char *name"
51.Ft int
52.Fn setttyent void
53.Ft int
54.Fn endttyent void
55.Sh DESCRIPTION
56The
57.Fn getttyent ,
58and
59.Fn getttynam
60functions
61each return a pointer to an object, with the following structure,
62containing the broken-out fields of a line from the tty description
63file.
64.Bd -literal
65struct ttyent {
66	char	*ty_name;	/* terminal device name */
67	char	*ty_getty;	/* command to execute */
68	char	*ty_type;	/* terminal type */
69#define	TTY_ON		0x01	/* enable logins */
70#define	TTY_SECURE	0x02	/* allow uid of 0 to login */
71#define	TTY_LOCAL	0x04	/* set 'CLOCAL' on open (dev. specific) */
72#define	TTY_RTSCTS	0x08	/* set 'CRTSCTS' on open (dev. specific) */
73#define	TTY_SOFTCAR	0x10	/* ignore hardware carrier (dev. spec.) */
74#define	TTY_MDMBUF	0x20	/* set 'MDMBUF' on open (dev. specific) */
75	int	ty_status;	/* flag values */
76	char	*ty_window;	/* command for window manager */
77	char	*ty_comment;	/* comment field */
78};
79.Ed
80.Pp
81The fields are as follows:
82.Bl -tag -width ty_comment
83.It Fa ty_name
84The name of the character-special file.
85.It Fa ty_getty
86The name of the command invoked by
87.Xr init 8
88to initialize tty line characteristics.
89.It Fa ty_type
90The name of the default terminal type connected to this tty line.
91.It Fa ty_status
92A mask of bit fields which indicate various actions allowed on this
93tty line.
94The possible flags are as follows:
95.Bl -tag -width TTY_SOFTCAR
96.It Dv TTY_ON
97Enables logins (i.e.,
98.Xr init 8
99will start the command referenced by
100.Fa ty_getty
101on this entry).
102.It Dv TTY_SECURE
103Allow users with a uid of 0 to login on this terminal.
104.It Dv TTY_LOCAL
105If the terminal port's driver supports it, cause the line
106to be treated as ``local.''
107.It Dv TTY_RTSCTS
108If the terminal port's driver supports it, use
109full-duplex RTS/CTS hardware flow control on the line
110by default.
111.It Dv TTY_SOFTCAR
112If the terminal port's driver supports it, ignore hardware
113carrier on the line.
114.El
115.It Fa ty_window
116The command to execute for a window system associated with the line.
117.It Fa ty_comment
118Any trailing comment field, with any leading hash marks (``#'') or
119whitespace removed.
120.El
121.Pp
122If any of the fields pointing to character strings are unspecified,
123they are returned as null pointers.
124The field
125.Fa ty_status
126will be zero if no flag values are specified.
127.Pp
128See
129.Xr ttys 5
130for a more complete discussion of the meaning and usage of the
131fields.
132.Pp
133The
134.Fn getttyent
135function
136reads the next line from the ttys file, opening the file if necessary.
137The
138.Fn setttyent
139function
140rewinds the file if open, or opens the file if it is unopened.
141The
142.Fn endttyent
143function
144closes any open files.
145.Pp
146The
147.Fn getttynam
148function
149searches from the beginning of the file until a matching
150.Fa name
151is found
152(or until
153.Dv EOF
154is encountered).
155.Sh RETURN VALUES
156The routines
157.Fn getttyent
158and
159.Fn getttynam
160return a null pointer on
161.Dv EOF
162or error.
163The
164.Fn setttyent
165function
166and
167.Fn endttyent
168return 0 on failure and 1 on success.
169.Sh FILES
170.Bl -tag -width /etc/ttys -compact
171.It Pa /etc/ttys
172.El
173.Sh SEE ALSO
174.Xr login 1 ,
175.Xr ttyslot 3 ,
176.Xr gettytab 5 ,
177.Xr termcap 5 ,
178.Xr ttys 5 ,
179.Xr getty 8 ,
180.Xr init 8 ,
181.Xr ttyflags 8
182.Sh HISTORY
183The
184.Fn getttyent ,
185.Fn getttynam ,
186.Fn setttyent ,
187and
188.Fn endttyent
189functions appeared in
190.Bx 4.3 .
191.Sh BUGS
192These functions use static data storage;
193if the data is needed for future use, it should be
194copied before any subsequent calls overwrite it.
195