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