xref: /netbsd-src/libexec/getty/init.c (revision bd3f97bffb9d4b563c805b5c133bbcc48afdfb75)
1*bd3f97bfSdholland /*	$NetBSD: init.c,v 1.18 2013/08/11 05:42:41 dholland Exp $	*/
23ff0b1a7Sthorpej 
361f28255Scgd /*
4fe822416Spk  * Copyright (c) 1983, 1993
5fe822416Spk  *	The Regents of the University of California.  All rights reserved.
661f28255Scgd  *
761f28255Scgd  * Redistribution and use in source and binary forms, with or without
861f28255Scgd  * modification, are permitted provided that the following conditions
961f28255Scgd  * are met:
1061f28255Scgd  * 1. Redistributions of source code must retain the above copyright
1161f28255Scgd  *    notice, this list of conditions and the following disclaimer.
1261f28255Scgd  * 2. Redistributions in binary form must reproduce the above copyright
1361f28255Scgd  *    notice, this list of conditions and the following disclaimer in the
1461f28255Scgd  *    documentation and/or other materials provided with the distribution.
158e6ab883Sagc  * 3. Neither the name of the University nor the names of its contributors
1661f28255Scgd  *    may be used to endorse or promote products derived from this software
1761f28255Scgd  *    without specific prior written permission.
1861f28255Scgd  *
1961f28255Scgd  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2061f28255Scgd  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2161f28255Scgd  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2261f28255Scgd  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2361f28255Scgd  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2461f28255Scgd  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2561f28255Scgd  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2661f28255Scgd  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2761f28255Scgd  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2861f28255Scgd  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2961f28255Scgd  * SUCH DAMAGE.
3061f28255Scgd  */
3161f28255Scgd 
3264521eb3Smikel #include <sys/cdefs.h>
3361f28255Scgd #ifndef lint
343ff0b1a7Sthorpej #if 0
353ff0b1a7Sthorpej static char sccsid[] = "from: @(#)init.c	8.1 (Berkeley) 6/4/93";
363ff0b1a7Sthorpej #else
37*bd3f97bfSdholland __RCSID("$NetBSD: init.c,v 1.18 2013/08/11 05:42:41 dholland Exp $");
383ff0b1a7Sthorpej #endif
3961f28255Scgd #endif /* not lint */
4061f28255Scgd 
4161f28255Scgd /*
4261f28255Scgd  * Getty table initializations.
4361f28255Scgd  *
4461f28255Scgd  * Melbourne getty.
4561f28255Scgd  */
4664521eb3Smikel 
47*bd3f97bfSdholland #include <stddef.h>
487243f6f6Spk #include <termios.h>
4964521eb3Smikel 
5061f28255Scgd #include "gettytab.h"
5161f28255Scgd #include "pathnames.h"
5261f28255Scgd 
537243f6f6Spk extern	struct termios tmode;
5461f28255Scgd extern	char hostname[];
5561f28255Scgd 
56f8013c38Schristos #define M(a) ((char *)&tmode.c_cc[a])
57f8013c38Schristos 
5861f28255Scgd struct	gettystrs gettystrs[] = {
59*bd3f97bfSdholland 	{ "nx", NULL,        NULL },	/* next table */
60*bd3f97bfSdholland 	{ "cl", NULL,        NULL },	/* screen clear characters */
61*bd3f97bfSdholland 	{ "im", NULL,        NULL },	/* initial message */
62*bd3f97bfSdholland 	{ "lm", "login: ",   NULL },	/* login message */
63*bd3f97bfSdholland 	{ "er", M(VERASE),   NULL },	/* erase character */
64*bd3f97bfSdholland 	{ "kl", M(VKILL),    NULL },	/* kill character */
65*bd3f97bfSdholland 	{ "et", M(VEOF),     NULL },	/* eof chatacter (eot) */
66*bd3f97bfSdholland 	{ "pc", "",          NULL },	/* pad character */
67*bd3f97bfSdholland 	{ "tt", NULL,        NULL },	/* terminal type */
68*bd3f97bfSdholland 	{ "ev", NULL,        NULL },	/* environment */
69*bd3f97bfSdholland 	{ "lo", _PATH_LOGIN, NULL },	/* login program */
70*bd3f97bfSdholland 	{ "hn", hostname,    NULL },	/* host name */
71*bd3f97bfSdholland 	{ "he", NULL,        NULL },	/* host name edit */
72*bd3f97bfSdholland 	{ "in", M(VINTR),    NULL },	/* interrupt char */
73*bd3f97bfSdholland 	{ "qu", M(VQUIT),    NULL },	/* quit char */
74*bd3f97bfSdholland 	{ "xn", M(VSTART),   NULL },	/* XON (start) char */
75*bd3f97bfSdholland 	{ "xf", M(VSTOP),    NULL },	/* XOFF (stop) char */
76*bd3f97bfSdholland 	{ "bk", M(VEOL),     NULL },	/* brk char (alt \n) */
77*bd3f97bfSdholland 	{ "su", M(VSUSP),    NULL },	/* suspend char */
78*bd3f97bfSdholland 	{ "ds", M(VDSUSP),   NULL },	/* delayed suspend */
79*bd3f97bfSdholland 	{ "rp", M(VREPRINT), NULL },	/* reprint char */
80*bd3f97bfSdholland 	{ "fl", M(VDISCARD), NULL },	/* flush output */
81*bd3f97bfSdholland 	{ "we", M(VWERASE),  NULL },	/* word erase */
82*bd3f97bfSdholland 	{ "ln", M(VLNEXT),   NULL },	/* literal next */
83*bd3f97bfSdholland 	{ "st", M(VSTATUS),  NULL },	/* status */
84*bd3f97bfSdholland 	{ "b2", M(VEOL2),    NULL },	/* alt brk char */
85*bd3f97bfSdholland 	{ "pp", NULL,        NULL },	/* ppp login program */
86*bd3f97bfSdholland 	{ "if", NULL,        NULL },	/* sysv-like 'issue' filename */
87*bd3f97bfSdholland 	{ "al", NULL,        NULL },	/* user to auto-login */
88*bd3f97bfSdholland 	{ NULL, NULL, NULL }
8961f28255Scgd };
9061f28255Scgd 
9161f28255Scgd struct	gettynums gettynums[] = {
92*bd3f97bfSdholland 	{ "is", 0,0,0 },		/* input speed */
93*bd3f97bfSdholland 	{ "os", 0,0,0 },		/* output speed */
94*bd3f97bfSdholland 	{ "sp", 0,0,0 },		/* both speeds */
95*bd3f97bfSdholland 	{ "nd", 0,0,0 },		/* newline delay */
96*bd3f97bfSdholland 	{ "cd", 0,0,0 },		/* carriage-return delay */
97*bd3f97bfSdholland 	{ "td", 0,0,0 },		/* tab delay */
98*bd3f97bfSdholland 	{ "fd", 0,0,0 },		/* form-feed delay */
99*bd3f97bfSdholland 	{ "bd", 0,0,0 },		/* backspace delay */
100*bd3f97bfSdholland 	{ "to", 0,0,0 },		/* timeout */
101*bd3f97bfSdholland 	{ "f0", 0,0,0 },		/* output flags */
102*bd3f97bfSdholland 	{ "f1", 0,0,0 },		/* input flags */
103*bd3f97bfSdholland 	{ "f2", 0,0,0 },		/* user mode flags */
104*bd3f97bfSdholland 	{ "pf", 0,0,0 },		/* delay before flush at 1st prompt */
105*bd3f97bfSdholland 	{ "c0", 0,0,0 },		/* output c_flags */
106*bd3f97bfSdholland 	{ "c1", 0,0,0 },		/* input c_flags */
107*bd3f97bfSdholland 	{ "c2", 0,0,0 },		/* user mode c_flags */
108*bd3f97bfSdholland 	{ "i0", 0,0,0 },		/* output i_flags */
109*bd3f97bfSdholland 	{ "i1", 0,0,0 },		/* input i_flags */
110*bd3f97bfSdholland 	{ "i2", 0,0,0 },		/* user mode i_flags */
111*bd3f97bfSdholland 	{ "l0", 0,0,0 },		/* output l_flags */
112*bd3f97bfSdholland 	{ "l1", 0,0,0 },		/* input l_flags */
113*bd3f97bfSdholland 	{ "l2", 0,0,0 },		/* user mode l_flags */
114*bd3f97bfSdholland 	{ "o0", 0,0,0 },		/* output o_flags */
115*bd3f97bfSdholland 	{ "o1", 0,0,0 },		/* input o_flags */
116*bd3f97bfSdholland 	{ "o2", 0,0,0 },		/* user mode o_flags */
117*bd3f97bfSdholland 	{ 0,0,0,0 }
11861f28255Scgd };
11961f28255Scgd 
12061f28255Scgd struct	gettyflags gettyflags[] = {
121*bd3f97bfSdholland 	{ "ht",	0, 0,0,0 },		/* has tabs */
122*bd3f97bfSdholland 	{ "nl",	1, 0,0,0 },		/* has newline char */
123*bd3f97bfSdholland 	{ "ep",	0, 0,0,0 },		/* even parity */
124*bd3f97bfSdholland 	{ "op",	0, 0,0,0 },		/* odd parity */
125*bd3f97bfSdholland 	{ "ap",	0, 0,0,0 },		/* any parity */
126*bd3f97bfSdholland 	{ "ec",	1, 0,0,0 },		/* no echo */
127*bd3f97bfSdholland 	{ "co",	0, 0,0,0 },		/* console special */
128*bd3f97bfSdholland 	{ "cb",	0, 0,0,0 },		/* crt backspace */
129*bd3f97bfSdholland 	{ "ck",	0, 0,0,0 },		/* crt kill */
130*bd3f97bfSdholland 	{ "ce",	0, 0,0,0 },		/* crt erase */
131*bd3f97bfSdholland 	{ "pe",	0, 0,0,0 },		/* printer erase */
132*bd3f97bfSdholland 	{ "rw",	1, 0,0,0 },		/* don't use raw */
133*bd3f97bfSdholland 	{ "xc",	1, 0,0,0 },		/* don't ^X ctl chars */
134*bd3f97bfSdholland 	{ "lc",	0, 0,0,0 },		/* terminal las lower case */
135*bd3f97bfSdholland 	{ "uc",	0, 0,0,0 },		/* terminal has no lower case */
136*bd3f97bfSdholland 	{ "ig",	0, 0,0,0 },		/* ignore garbage */
137*bd3f97bfSdholland 	{ "ps",	0, 0,0,0 },		/* do port selector speed select */
138*bd3f97bfSdholland 	{ "hc",	1, 0,0,0 },		/* don't set hangup on close */
139*bd3f97bfSdholland 	{ "ub", 0, 0,0,0 },		/* unbuffered output */
140*bd3f97bfSdholland 	{ "ab", 0, 0,0,0 },		/* auto-baud detect with '\r' */
141*bd3f97bfSdholland 	{ "dx", 0, 0,0,0 },		/* set decctlq */
142*bd3f97bfSdholland 	{ "np", 0, 0,0,0 },		/* no parity at all (8bit chars) */
143*bd3f97bfSdholland 	{ "mb", 0, 0,0,0 },		/* do MDMBUF flow control */
144*bd3f97bfSdholland 	{ "cs", 0, 0,0,0 },		/* clear screen based on term type */
145*bd3f97bfSdholland 	{ "nn", 0, 0,0,0 },		/* don't prompt for login name */
146*bd3f97bfSdholland 	{ NULL,0,0,0,0 }
14761f28255Scgd };
148