xref: /freebsd/libexec/getty/init.c (revision 8ddb146abcdf061be9f2c0db7e391697dafad85c)
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 <stdio.h>
46 #include <termios.h>
47 #include "gettytab.h"
48 #include "extern.h"
49 #include "pathnames.h"
50 
51 static char loginmsg[] = "login: ";
52 static char nullstr[] = "";
53 static char loginprg[] = _PATH_LOGIN;
54 static char datefmt[] = "%+";
55 
56 #define M(a) (&omode.c_cc[a])
57 
58 struct	gettystrs gettystrs[] = {
59 	{ "nx", NULL, NULL },		/* next table */
60 	{ "cl", NULL, NULL },		/* screen clear characters */
61 	{ "im", NULL, NULL },		/* initial message */
62 	{ "lm", loginmsg, NULL },	/* login message */
63 	{ "er", M(VERASE), NULL },	/* erase character */
64 	{ "kl", M(VKILL), NULL },	/* kill character */
65 	{ "et", M(VEOF), NULL },	/* eof chatacter (eot) */
66 	{ "pc", nullstr, NULL },	/* pad character */
67 	{ "tt", NULL, NULL },		/* terminal type */
68 	{ "ev", NULL, NULL },		/* environment */
69 	{ "lo", loginprg, NULL },	/* login program */
70 	{ "hn", hostname, NULL },	/* host name */
71 	{ "he", NULL, NULL },		/* host name edit */
72 	{ "in", M(VINTR), NULL },	/* interrupt char */
73 	{ "qu", M(VQUIT), NULL },	/* quit char */
74 	{ "xn", M(VSTART), NULL },	/* XON (start) char */
75 	{ "xf", M(VSTOP), NULL },	/* XOFF (stop) char */
76 	{ "bk", M(VEOL), NULL },	/* brk char (alt \n) */
77 	{ "su", M(VSUSP), NULL },	/* suspend char */
78 	{ "ds", M(VDSUSP), NULL },	/* delayed suspend */
79 	{ "rp", M(VREPRINT), NULL },	/* reprint char */
80 	{ "fl", M(VDISCARD), NULL },	/* flush output */
81 	{ "we", M(VWERASE), NULL },	/* word erase */
82 	{ "ln", M(VLNEXT), NULL },	/* literal next */
83 	{ "Lo", NULL, NULL },		/* locale for strftime() */
84 	{ "pp", NULL, NULL },		/* ppp login program */
85 	{ "if", NULL, NULL },		/* sysv-like 'issue' filename */
86 	{ "ic", NULL, NULL },		/* modem init-chat */
87 	{ "ac", NULL, NULL },		/* modem answer-chat */
88 	{ "al", NULL, NULL },		/* user to auto-login */
89 	{ "df", datefmt, NULL },	/* format for strftime() */
90 	{ "iM" , NULL, NULL },		/* initial message program */
91 	{ NULL, NULL, NULL }
92 };
93 
94 struct	gettynums gettynums[] = {
95 	{ "is", 0, 0, 0 },		/* input speed */
96 	{ "os", 0, 0, 0 },		/* output speed */
97 	{ "sp", 0, 0, 0 },		/* both speeds */
98 	{ "nd", 0, 0, 0 },		/* newline delay */
99 	{ "cd", 0, 0, 0 },		/* carriage-return delay */
100 	{ "td", 0, 0, 0 },		/* tab delay */
101 	{ "fd", 0, 0, 0 },		/* form-feed delay */
102 	{ "bd", 0, 0, 0 },		/* backspace delay */
103 	{ "to", 0, 0, 0 },		/* timeout */
104 	{ "f0", 0, 0, 0 },		/* output flags */
105 	{ "f1", 0, 0, 0 },		/* input flags */
106 	{ "f2", 0, 0, 0 },		/* user mode flags */
107 	{ "pf", 0, 0, 0 },		/* delay before flush at 1st prompt */
108 	{ "c0", 0, 0, 0 },		/* output c_flags */
109 	{ "c1", 0, 0, 0 },		/* input c_flags */
110 	{ "c2", 0, 0, 0 },		/* user mode c_flags */
111 	{ "i0", 0, 0, 0 },		/* output i_flags */
112 	{ "i1", 0, 0, 0 },		/* input i_flags */
113 	{ "i2", 0, 0, 0 },		/* user mode i_flags */
114 	{ "l0", 0, 0, 0 },		/* output l_flags */
115 	{ "l1", 0, 0, 0 },		/* input l_flags */
116 	{ "l2", 0, 0, 0 },		/* user mode l_flags */
117 	{ "o0", 0, 0, 0 },		/* output o_flags */
118 	{ "o1", 0, 0, 0 },		/* input o_flags */
119 	{ "o2", 0, 0, 0 },		/* user mode o_flags */
120 	{ "de", 0, 0, 0 },		/* delay before sending 1st prompt */
121 	{ "rt", 0, 0, 0 },		/* reset timeout */
122 	{ "ct", 0, 0, 0 },		/* chat script timeout */
123 	{ "dc", 0, 0, 0 },		/* debug chat script value */
124 	{ NULL, 0, 0, 0 }
125 };
126 
127 
128 struct	gettyflags gettyflags[] = {
129 	{ "ht",	0, 0, 0, 0 },		/* has tabs */
130 	{ "nl",	1, 0, 0, 0 },		/* has newline char */
131 	{ "ep",	0, 0, 0, 0 },		/* even parity */
132 	{ "op",	0, 0, 0, 0 },		/* odd parity */
133 	{ "ap",	0, 0, 0, 0 },		/* any parity */
134 	{ "ec",	1, 0, 0, 0 },		/* no echo */
135 	{ "co",	0, 0, 0, 0 },		/* console special */
136 	{ "cb",	0, 0, 0, 0 },		/* crt backspace */
137 	{ "ck",	0, 0, 0, 0 },		/* crt kill */
138 	{ "ce",	0, 0, 0, 0 },		/* crt erase */
139 	{ "pe",	0, 0, 0, 0 },		/* printer erase */
140 	{ "rw",	1, 0, 0, 0 },		/* don't use raw */
141 	{ "xc",	1, 0, 0, 0 },		/* don't ^X ctl chars */
142 	{ "lc",	0, 0, 0, 0 },		/* terminal las lower case */
143 	{ "uc",	0, 0, 0, 0 },		/* terminal has no lower case */
144 	{ "ig",	0, 0, 0, 0 },		/* ignore garbage */
145 	{ "ps",	0, 0, 0, 0 },		/* do port selector speed select */
146 	{ "hc",	1, 0, 0, 0 },		/* don't set hangup on close */
147 	{ "ub", 0, 0, 0, 0 },		/* unbuffered output */
148 	{ "ab", 0, 0, 0, 0 },		/* auto-baud detect with '\r' */
149 	{ "dx", 0, 0, 0, 0 },		/* set decctlq */
150 	{ "np", 0, 0, 0, 0 },		/* no parity at all (8bit chars) */
151 	{ "mb", 0, 0, 0, 0 },		/* do MDMBUF flow control */
152 	{ "hw", 0, 0, 0, 0 },		/* do CTSRTS flow control */
153 	{ "nc", 0, 0, 0, 0 },		/* set clocal (no carrier) */
154 	{ "pl", 0, 0, 0, 0 },		/* use PPP instead of login(1) */
155 	{ NULL, 0, 0, 0, 0 }
156 };
157