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