xref: /netbsd-src/lib/libc/gen/getttyent.3 (revision aaf4ece63a859a04e37cf3a7229b5fab0157cc06)
1.\"	$NetBSD: getttyent.3,v 1.15 2003/08/07 16:42:51 agc 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.\"     @(#)getttyent.3	8.1 (Berkeley) 6/4/93
31.\"
32.Dd June 4, 1993
33.Dt GETTTYENT 3
34.Os
35.Sh NAME
36.Nm getttyent ,
37.Nm getttynam ,
38.Nm setttyent ,
39.Nm endttyent
40.Nd get ttys file entry
41.Sh LIBRARY
42.Lb libc
43.Sh SYNOPSIS
44.In ttyent.h
45.Ft struct ttyent *
46.Fn getttyent
47.Ft struct ttyent *
48.Fn getttynam "char *name"
49.Ft int
50.Fn setttyent void
51.Ft int
52.Fn endttyent void
53.Sh DESCRIPTION
54The
55.Fn getttyent ,
56and
57.Fn getttynam
58functions
59each return a pointer to an object, with the following structure,
60containing the broken-out fields of a line from the tty description
61file.
62.Bd -literal
63struct ttyent {
64	char	*ty_name;	/* terminal device name */
65	char	*ty_getty;	/* command to execute */
66	char	*ty_type;	/* terminal type */
67#define	TTY_ON		0x01	/* enable logins */
68#define	TTY_SECURE	0x02	/* allow uid of 0 to login */
69#define	TTY_LOCAL	0x04	/* set 'CLOCAL' on open (dev. specific) */
70#define	TTY_RTSCTS	0x08	/* set 'CRTSCTS' on open (dev. specific) */
71#define	TTY_SOFTCAR	0x10	/* ignore hardware carrier (dev. spec.) */
72#define	TTY_MDMBUF	0x20	/* set 'MDMBUF' on open (dev. specific) */
73#define	TTY_DTRCTS	0x40	/* set 'CDTRCTS' on open (dev. specific) */
74	int	ty_status;	/* flag values */
75	char	*ty_window;	/* command for window manager */
76	char	*ty_comment;	/* comment field */
77	char	*ty_class;	/* category of tty usage */
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_MDMBUF
108If the terminal port's driver supports it, use
109DTR/DCD hardware flow control on the line by default.
110.It Dv TTY_RTSCTS
111If the terminal port's driver supports it, use
112full-duplex RTS/CTS hardware flow control on the line
113by default.
114.It Dv TTY_SOFTCAR
115If the terminal port's driver supports it, ignore hardware
116carrier on the line.
117.El
118.It Fa ty_window
119The command to execute for a window system associated with the line.
120.It Fa ty_comment
121Any trailing comment field, with any leading hash marks (``#'') or
122whitespace removed.
123.It Fa ty_class
124A key indexing into a termcap-style database (/etc/ttyclasses)
125of attributes for this class of tty.
126No attributes are currently defined or used,
127so there are currently no functions to retrieve them.
128.El
129.Pp
130If any of the fields pointing to character strings are unspecified,
131they are returned as null pointers.
132The field
133.Fa ty_status
134will be zero if no flag values are specified.
135.Pp
136See
137.Xr ttys 5
138for a more complete discussion of the meaning and usage of the
139fields.
140.Pp
141The
142.Fn getttyent
143function
144reads the next line from the ttys file, opening the file if necessary.
145The
146.Fn setttyent
147function
148rewinds the file if open, or opens the file if it is unopened.
149The
150.Fn endttyent
151function
152closes any open files.
153.Pp
154The
155.Fn getttynam
156function
157searches from the beginning of the file until a matching
158.Fa name
159is found
160(or until
161.Dv EOF
162is encountered).
163.Sh RETURN VALUES
164The routines
165.Fn getttyent
166and
167.Fn getttynam
168return a null pointer on
169.Dv EOF
170or error.
171The
172.Fn setttyent
173function
174and
175.Fn endttyent
176return 0 on failure and 1 on success.
177.Sh FILES
178.Bl -tag -width /etc/ttys -compact
179.It Pa /etc/ttys
180.El
181.Sh SEE ALSO
182.Xr login 1 ,
183.Xr ttyslot 3 ,
184.Xr gettytab 5 ,
185.Xr termcap 5 ,
186.Xr ttys 5 ,
187.Xr getty 8 ,
188.Xr init 8 ,
189.Xr ttyflags 8
190.Sh HISTORY
191The
192.Fn getttyent ,
193.Fn getttynam ,
194.Fn setttyent ,
195and
196.Fn endttyent
197functions appeared in
198.Bx 4.3 .
199.Sh BUGS
200These functions use static data storage;
201if the data is needed for future use, it should be
202copied before any subsequent calls overwrite it.
203