xref: /freebsd/libexec/getty/init.c (revision a6fe717c2a876105123214c05176cd74106fb94b)
18a16b7a1SPedro F. Giffuni /*-
28a16b7a1SPedro F. Giffuni  * SPDX-License-Identifier: BSD-3-Clause
38a16b7a1SPedro F. Giffuni  *
4cae66988SJoerg Wunsch  * Copyright (c) 1983, 1993
5cae66988SJoerg Wunsch  *	The Regents of the University of California.  All rights reserved.
6ea022d16SRodney W. Grimes  *
7ea022d16SRodney W. Grimes  * Redistribution and use in source and binary forms, with or without
8ea022d16SRodney W. Grimes  * modification, are permitted provided that the following conditions
9ea022d16SRodney W. Grimes  * are met:
10ea022d16SRodney W. Grimes  * 1. Redistributions of source code must retain the above copyright
11ea022d16SRodney W. Grimes  *    notice, this list of conditions and the following disclaimer.
12ea022d16SRodney W. Grimes  * 2. Redistributions in binary form must reproduce the above copyright
13ea022d16SRodney W. Grimes  *    notice, this list of conditions and the following disclaimer in the
14ea022d16SRodney W. Grimes  *    documentation and/or other materials provided with the distribution.
155efaea4cSChristian Brueffer  * 3. Neither the name of the University nor the names of its contributors
16ea022d16SRodney W. Grimes  *    may be used to endorse or promote products derived from this software
17ea022d16SRodney W. Grimes  *    without specific prior written permission.
18ea022d16SRodney W. Grimes  *
19ea022d16SRodney W. Grimes  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20ea022d16SRodney W. Grimes  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21ea022d16SRodney W. Grimes  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22ea022d16SRodney W. Grimes  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23ea022d16SRodney W. Grimes  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24ea022d16SRodney W. Grimes  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25ea022d16SRodney W. Grimes  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26ea022d16SRodney W. Grimes  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27ea022d16SRodney W. Grimes  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28ea022d16SRodney W. Grimes  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29ea022d16SRodney W. Grimes  * SUCH DAMAGE.
30ea022d16SRodney W. Grimes  */
31ea022d16SRodney W. Grimes 
32ea022d16SRodney W. Grimes /*
33ea022d16SRodney W. Grimes  * Getty table initializations.
34ea022d16SRodney W. Grimes  *
35ea022d16SRodney W. Grimes  * Melbourne getty.
36ea022d16SRodney W. Grimes  */
372ba80650SEdward Tomasz Napierala #include <stdio.h>
38cae66988SJoerg Wunsch #include <termios.h>
39ea022d16SRodney W. Grimes #include "gettytab.h"
40410f13a5SStefan Farfeleder #include "extern.h"
41ea022d16SRodney W. Grimes #include "pathnames.h"
42ea022d16SRodney W. Grimes 
43cae66988SJoerg Wunsch static char loginmsg[] = "login: ";
44cae66988SJoerg Wunsch static char nullstr[] = "";
45cae66988SJoerg Wunsch static char loginprg[] = _PATH_LOGIN;
46db563f31SYaroslav Tykhiy static char datefmt[] = "%+";
47ea022d16SRodney W. Grimes 
48*8ad7a14aSDag-Erling Smørgrav #define M(a) (char *)(&omode.c_cc[a])
4904688610SEdward Tomasz Napierala 
50ea022d16SRodney W. Grimes struct	gettystrs gettystrs[] = {
512ba80650SEdward Tomasz Napierala 	{ "nx", NULL, NULL },		/* next table */
522ba80650SEdward Tomasz Napierala 	{ "cl", NULL, NULL },		/* screen clear characters */
532ba80650SEdward Tomasz Napierala 	{ "im", NULL, NULL },		/* initial message */
542ba80650SEdward Tomasz Napierala 	{ "lm", loginmsg, NULL },	/* login message */
552ba80650SEdward Tomasz Napierala 	{ "er", M(VERASE), NULL },	/* erase character */
562ba80650SEdward Tomasz Napierala 	{ "kl", M(VKILL), NULL },	/* kill character */
572ba80650SEdward Tomasz Napierala 	{ "et", M(VEOF), NULL },	/* eof chatacter (eot) */
582ba80650SEdward Tomasz Napierala 	{ "pc", nullstr, NULL },	/* pad character */
592ba80650SEdward Tomasz Napierala 	{ "tt", NULL, NULL },		/* terminal type */
602ba80650SEdward Tomasz Napierala 	{ "ev", NULL, NULL },		/* environment */
612ba80650SEdward Tomasz Napierala 	{ "lo", loginprg, NULL },	/* login program */
622ba80650SEdward Tomasz Napierala 	{ "hn", hostname, NULL },	/* host name */
632ba80650SEdward Tomasz Napierala 	{ "he", NULL, NULL },		/* host name edit */
642ba80650SEdward Tomasz Napierala 	{ "in", M(VINTR), NULL },	/* interrupt char */
652ba80650SEdward Tomasz Napierala 	{ "qu", M(VQUIT), NULL },	/* quit char */
662ba80650SEdward Tomasz Napierala 	{ "xn", M(VSTART), NULL },	/* XON (start) char */
672ba80650SEdward Tomasz Napierala 	{ "xf", M(VSTOP), NULL },	/* XOFF (stop) char */
682ba80650SEdward Tomasz Napierala 	{ "bk", M(VEOL), NULL },	/* brk char (alt \n) */
692ba80650SEdward Tomasz Napierala 	{ "su", M(VSUSP), NULL },	/* suspend char */
702ba80650SEdward Tomasz Napierala 	{ "ds", M(VDSUSP), NULL },	/* delayed suspend */
712ba80650SEdward Tomasz Napierala 	{ "rp", M(VREPRINT), NULL },	/* reprint char */
722ba80650SEdward Tomasz Napierala 	{ "fl", M(VDISCARD), NULL },	/* flush output */
732ba80650SEdward Tomasz Napierala 	{ "we", M(VWERASE), NULL },	/* word erase */
742ba80650SEdward Tomasz Napierala 	{ "ln", M(VLNEXT), NULL },	/* literal next */
752ba80650SEdward Tomasz Napierala 	{ "Lo", NULL, NULL },		/* locale for strftime() */
762ba80650SEdward Tomasz Napierala 	{ "pp", NULL, NULL },		/* ppp login program */
772ba80650SEdward Tomasz Napierala 	{ "if", NULL, NULL },		/* sysv-like 'issue' filename */
782ba80650SEdward Tomasz Napierala 	{ "ic", NULL, NULL },		/* modem init-chat */
792ba80650SEdward Tomasz Napierala 	{ "ac", NULL, NULL },		/* modem answer-chat */
802ba80650SEdward Tomasz Napierala 	{ "al", NULL, NULL },		/* user to auto-login */
812ba80650SEdward Tomasz Napierala 	{ "df", datefmt, NULL },	/* format for strftime() */
822ba80650SEdward Tomasz Napierala 	{ "iM" , NULL, NULL },		/* initial message program */
832ba80650SEdward Tomasz Napierala 	{ NULL, NULL, NULL }
84ea022d16SRodney W. Grimes };
85ea022d16SRodney W. Grimes 
86ea022d16SRodney W. Grimes struct	gettynums gettynums[] = {
872ba80650SEdward Tomasz Napierala 	{ "is", 0, 0, 0 },		/* input speed */
882ba80650SEdward Tomasz Napierala 	{ "os", 0, 0, 0 },		/* output speed */
892ba80650SEdward Tomasz Napierala 	{ "sp", 0, 0, 0 },		/* both speeds */
902ba80650SEdward Tomasz Napierala 	{ "nd", 0, 0, 0 },		/* newline delay */
912ba80650SEdward Tomasz Napierala 	{ "cd", 0, 0, 0 },		/* carriage-return delay */
922ba80650SEdward Tomasz Napierala 	{ "td", 0, 0, 0 },		/* tab delay */
932ba80650SEdward Tomasz Napierala 	{ "fd", 0, 0, 0 },		/* form-feed delay */
942ba80650SEdward Tomasz Napierala 	{ "bd", 0, 0, 0 },		/* backspace delay */
952ba80650SEdward Tomasz Napierala 	{ "to", 0, 0, 0 },		/* timeout */
962ba80650SEdward Tomasz Napierala 	{ "f0", 0, 0, 0 },		/* output flags */
972ba80650SEdward Tomasz Napierala 	{ "f1", 0, 0, 0 },		/* input flags */
982ba80650SEdward Tomasz Napierala 	{ "f2", 0, 0, 0 },		/* user mode flags */
992ba80650SEdward Tomasz Napierala 	{ "pf", 0, 0, 0 },		/* delay before flush at 1st prompt */
1002ba80650SEdward Tomasz Napierala 	{ "c0", 0, 0, 0 },		/* output c_flags */
1012ba80650SEdward Tomasz Napierala 	{ "c1", 0, 0, 0 },		/* input c_flags */
1022ba80650SEdward Tomasz Napierala 	{ "c2", 0, 0, 0 },		/* user mode c_flags */
1032ba80650SEdward Tomasz Napierala 	{ "i0", 0, 0, 0 },		/* output i_flags */
1042ba80650SEdward Tomasz Napierala 	{ "i1", 0, 0, 0 },		/* input i_flags */
1052ba80650SEdward Tomasz Napierala 	{ "i2", 0, 0, 0 },		/* user mode i_flags */
1062ba80650SEdward Tomasz Napierala 	{ "l0", 0, 0, 0 },		/* output l_flags */
1072ba80650SEdward Tomasz Napierala 	{ "l1", 0, 0, 0 },		/* input l_flags */
1082ba80650SEdward Tomasz Napierala 	{ "l2", 0, 0, 0 },		/* user mode l_flags */
1092ba80650SEdward Tomasz Napierala 	{ "o0", 0, 0, 0 },		/* output o_flags */
1102ba80650SEdward Tomasz Napierala 	{ "o1", 0, 0, 0 },		/* input o_flags */
1112ba80650SEdward Tomasz Napierala 	{ "o2", 0, 0, 0 },		/* user mode o_flags */
1122ba80650SEdward Tomasz Napierala 	{ "de", 0, 0, 0 },		/* delay before sending 1st prompt */
1132ba80650SEdward Tomasz Napierala 	{ "rt", 0, 0, 0 },		/* reset timeout */
1142ba80650SEdward Tomasz Napierala 	{ "ct", 0, 0, 0 },		/* chat script timeout */
1152ba80650SEdward Tomasz Napierala 	{ "dc", 0, 0, 0 },		/* debug chat script value */
1162ba80650SEdward Tomasz Napierala 	{ NULL, 0, 0, 0 }
117ea022d16SRodney W. Grimes };
118ea022d16SRodney W. Grimes 
119b2a1dd44SMike Smith 
120ea022d16SRodney W. Grimes struct	gettyflags gettyflags[] = {
1212ba80650SEdward Tomasz Napierala 	{ "ht",	0, 0, 0, 0 },		/* has tabs */
1222ba80650SEdward Tomasz Napierala 	{ "nl",	1, 0, 0, 0 },		/* has newline char */
1232ba80650SEdward Tomasz Napierala 	{ "ep",	0, 0, 0, 0 },		/* even parity */
1242ba80650SEdward Tomasz Napierala 	{ "op",	0, 0, 0, 0 },		/* odd parity */
1252ba80650SEdward Tomasz Napierala 	{ "ap",	0, 0, 0, 0 },		/* any parity */
1262ba80650SEdward Tomasz Napierala 	{ "ec",	1, 0, 0, 0 },		/* no echo */
1272ba80650SEdward Tomasz Napierala 	{ "co",	0, 0, 0, 0 },		/* console special */
1282ba80650SEdward Tomasz Napierala 	{ "cb",	0, 0, 0, 0 },		/* crt backspace */
1292ba80650SEdward Tomasz Napierala 	{ "ck",	0, 0, 0, 0 },		/* crt kill */
1302ba80650SEdward Tomasz Napierala 	{ "ce",	0, 0, 0, 0 },		/* crt erase */
1312ba80650SEdward Tomasz Napierala 	{ "pe",	0, 0, 0, 0 },		/* printer erase */
1322ba80650SEdward Tomasz Napierala 	{ "rw",	1, 0, 0, 0 },		/* don't use raw */
1332ba80650SEdward Tomasz Napierala 	{ "xc",	1, 0, 0, 0 },		/* don't ^X ctl chars */
1342ba80650SEdward Tomasz Napierala 	{ "lc",	0, 0, 0, 0 },		/* terminal las lower case */
1352ba80650SEdward Tomasz Napierala 	{ "uc",	0, 0, 0, 0 },		/* terminal has no lower case */
1362ba80650SEdward Tomasz Napierala 	{ "ig",	0, 0, 0, 0 },		/* ignore garbage */
1372ba80650SEdward Tomasz Napierala 	{ "ps",	0, 0, 0, 0 },		/* do port selector speed select */
1382ba80650SEdward Tomasz Napierala 	{ "hc",	1, 0, 0, 0 },		/* don't set hangup on close */
1392ba80650SEdward Tomasz Napierala 	{ "ub", 0, 0, 0, 0 },		/* unbuffered output */
1402ba80650SEdward Tomasz Napierala 	{ "ab", 0, 0, 0, 0 },		/* auto-baud detect with '\r' */
1412ba80650SEdward Tomasz Napierala 	{ "dx", 0, 0, 0, 0 },		/* set decctlq */
1422ba80650SEdward Tomasz Napierala 	{ "np", 0, 0, 0, 0 },		/* no parity at all (8bit chars) */
1432ba80650SEdward Tomasz Napierala 	{ "mb", 0, 0, 0, 0 },		/* do MDMBUF flow control */
1442ba80650SEdward Tomasz Napierala 	{ "hw", 0, 0, 0, 0 },		/* do CTSRTS flow control */
1452ba80650SEdward Tomasz Napierala 	{ "nc", 0, 0, 0, 0 },		/* set clocal (no carrier) */
1462ba80650SEdward Tomasz Napierala 	{ "pl", 0, 0, 0, 0 },		/* use PPP instead of login(1) */
1472ba80650SEdward Tomasz Napierala 	{ NULL, 0, 0, 0, 0 }
148ea022d16SRodney W. Grimes };
149