]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - libexec/getty/init.c
Reduce code duplication; no functional changes.
[FreeBSD/FreeBSD.git] / libexec / getty / init.c
1 /*-
2  * SPDX-License-Identifier: BSD-3-Clause
3  *
4  * Copyright (c) 1983, 1993
5  *      The Regents of the University of California.  All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  * 3. Neither the name of the University nor the names of its contributors
16  *    may be used to endorse or promote products derived from this software
17  *    without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29  * SUCH DAMAGE.
30  */
31
32 #ifndef lint
33 #if 0
34 static char sccsid[] = "@(#)from: init.c        8.1 (Berkeley) 6/4/93";
35 #endif
36 static const char rcsid[] =
37   "$FreeBSD$";
38 #endif /* not lint */
39
40 /*
41  * Getty table initializations.
42  *
43  * Melbourne getty.
44  */
45 #include <termios.h>
46 #include "gettytab.h"
47 #include "extern.h"
48 #include "pathnames.h"
49
50 static char loginmsg[] = "login: ";
51 static char nullstr[] = "";
52 static char loginprg[] = _PATH_LOGIN;
53 static char datefmt[] = "%+";
54
55 #define M(a) (&omode.c_cc[a])
56
57 struct  gettystrs gettystrs[] = {
58         { "nx" },                       /* next table */
59         { "cl" },                       /* screen clear characters */
60         { "im" },                       /* initial message */
61         { "lm", loginmsg },             /* login message */
62         { "er", M(VERASE) },            /* erase character */
63         { "kl", M(VKILL) },             /* kill character */
64         { "et", M(VEOF) },              /* eof chatacter (eot) */
65         { "pc", nullstr },              /* pad character */
66         { "tt" },                       /* terminal type */
67         { "ev" },                       /* environment */
68         { "lo", loginprg },             /* login program */
69         { "hn", hostname },             /* host name */
70         { "he" },                       /* host name edit */
71         { "in", M(VINTR) },             /* interrupt char */
72         { "qu", M(VQUIT) },             /* quit char */
73         { "xn", M(VSTART) },            /* XON (start) char */
74         { "xf", M(VSTOP) },             /* XOFF (stop) char */
75         { "bk", M(VEOL) },              /* brk char (alt \n) */
76         { "su", M(VSUSP) },             /* suspend char */
77         { "ds", M(VDSUSP) },            /* delayed suspend */
78         { "rp", M(VREPRINT) },          /* reprint char */
79         { "fl", M(VDISCARD) },          /* flush output */
80         { "we", M(VWERASE) },           /* word erase */
81         { "ln", M(VLNEXT) },            /* literal next */
82         { "Lo" },                       /* locale for strftime() */
83         { "pp" },                       /* ppp login program */
84         { "if" },                       /* sysv-like 'issue' filename */
85         { "ic" },                       /* modem init-chat */
86         { "ac" },                       /* modem answer-chat */
87         { "al" },                       /* user to auto-login */
88         { "df", datefmt},               /* format for strftime() */
89         { "iM" },                       /* initial message program */
90         { 0 }
91 };
92
93 struct  gettynums gettynums[] = {
94         { "is" },                       /* input speed */
95         { "os" },                       /* output speed */
96         { "sp" },                       /* both speeds */
97         { "nd" },                       /* newline delay */
98         { "cd" },                       /* carriage-return delay */
99         { "td" },                       /* tab delay */
100         { "fd" },                       /* form-feed delay */
101         { "bd" },                       /* backspace delay */
102         { "to" },                       /* timeout */
103         { "f0" },                       /* output flags */
104         { "f1" },                       /* input flags */
105         { "f2" },                       /* user mode flags */
106         { "pf" },                       /* delay before flush at 1st prompt */
107         { "c0" },                       /* output c_flags */
108         { "c1" },                       /* input c_flags */
109         { "c2" },                       /* user mode c_flags */
110         { "i0" },                       /* output i_flags */
111         { "i1" },                       /* input i_flags */
112         { "i2" },                       /* user mode i_flags */
113         { "l0" },                       /* output l_flags */
114         { "l1" },                       /* input l_flags */
115         { "l2" },                       /* user mode l_flags */
116         { "o0" },                       /* output o_flags */
117         { "o1" },                       /* input o_flags */
118         { "o2" },                       /* user mode o_flags */
119         { "de" },                       /* delay before sending 1st prompt */
120         { "rt" },                       /* reset timeout */
121         { "ct" },                       /* chat script timeout */
122         { "dc" },                       /* debug chat script value */
123         { 0 }
124 };
125   
126
127 struct  gettyflags gettyflags[] = {
128         { "ht", 0 },                    /* has tabs */
129         { "nl", 1 },                    /* has newline char */
130         { "ep", 0 },                    /* even parity */
131         { "op", 0 },                    /* odd parity */
132         { "ap", 0 },                    /* any parity */
133         { "ec", 1 },                    /* no echo */
134         { "co", 0 },                    /* console special */
135         { "cb", 0 },                    /* crt backspace */
136         { "ck", 0 },                    /* crt kill */
137         { "ce", 0 },                    /* crt erase */
138         { "pe", 0 },                    /* printer erase */
139         { "rw", 1 },                    /* don't use raw */
140         { "xc", 1 },                    /* don't ^X ctl chars */
141         { "lc", 0 },                    /* terminal las lower case */
142         { "uc", 0 },                    /* terminal has no lower case */
143         { "ig", 0 },                    /* ignore garbage */
144         { "ps", 0 },                    /* do port selector speed select */
145         { "hc", 1 },                    /* don't set hangup on close */
146         { "ub", 0 },                    /* unbuffered output */
147         { "ab", 0 },                    /* auto-baud detect with '\r' */
148         { "dx", 0 },                    /* set decctlq */
149         { "np", 0 },                    /* no parity at all (8bit chars) */
150         { "mb", 0 },                    /* do MDMBUF flow control */
151         { "hw", 0 },                    /* do CTSRTS flow control */
152         { "nc", 0 },                    /* set clocal (no carrier) */
153         { "pl", 0 },                    /* use PPP instead of login(1) */
154         { 0 }
155 };