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