1 | |
---|
2 | CONVERTING BSD fc,fs,xc,xs PARAMETERS TO PLP ty FORMAT: |
---|
3 | ------------------------------------------------------- |
---|
4 | Justin Mason <jmason@iona.ie> |
---|
5 | Updated by |
---|
6 | Patrick Powell <papowell@sdsu.edu> |
---|
7 | |
---|
8 | One of the worst things about old LPDs is that they expected you |
---|
9 | to give it line characteristics as octal numbers, using the |
---|
10 | fc,fs,xc,xs printcap parameters. There are a number of disadvantages |
---|
11 | to this, compared to using the "ty" parameter. |
---|
12 | |
---|
13 | The ty format is portable, as it is supported on all UNIXes, rather |
---|
14 | than simply BSD-derived ones; it's also _much_ easier to understand |
---|
15 | than the fc,fs,xc,xs format -- compare these lines: |
---|
16 | |
---|
17 | :ty=pass8 -parity tabs litout nl: |
---|
18 | |
---|
19 | :fc#0000374:fs#0000003:xc#0:xs#0040040: |
---|
20 | |
---|
21 | Note, also, that "ty" uses the same symbolic names as the "stty" |
---|
22 | command, which is (relatively) well documented. |
---|
23 | |
---|
24 | Anyway, assuming you have a set of printcaps which use the fc,fs,xc,xs |
---|
25 | method, you can convert them to "ty" strings using the following |
---|
26 | table. |
---|
27 | |
---|
28 | Each parameter is an octal number, composed by logical-or'ing the |
---|
29 | bits for the desired parameters together. The bit patterns below |
---|
30 | have been worked out from SunOS 4.1.2 /usr/include/sys/ttold.h. |
---|
31 | |
---|
32 | For example, the following fc,fs,xc,xs set: |
---|
33 | |
---|
34 | :fc#0000374:fs#0000003:xc#0:xs#0040040: |
---|
35 | |
---|
36 | converts to the following ty string: |
---|
37 | |
---|
38 | :ty=-parity -echo -crmod -raw -lcase tandem cbreak litout decctq: |
---|
39 | |
---|
40 | Quite often, the resulting strings seem a little complicated, but |
---|
41 | usually they can be broken down using combination modes. See the |
---|
42 | printcap(5) manual page for details of which combination modes |
---|
43 | PLP supports. |
---|
44 | |
---|
45 | |
---|
46 | In order to help you, the source for the 'xlate' program is attached |
---|
47 | to the end of this document and is available in the LPRng distribution |
---|
48 | as UTILS/xlate.c. The output for the following line is: |
---|
49 | xlate ":fc#0000374:fs#0000003:xc#0:xs#0040040:" |
---|
50 | fc = 374 |
---|
51 | clear LCASE (simulate lower case) try '-lcase' |
---|
52 | clear ECHO (echo input) try '-echo' |
---|
53 | clear CRMOD (map \r to \r\n on output) try '-crmod' |
---|
54 | clear RAW (no i/o processing) try '-raw' |
---|
55 | clear ODDP (get/send odd parity) try '-oddp' |
---|
56 | clear EVENP (get/send even parity) try '-evenp' |
---|
57 | clear ANYP (get any parity/send none) try '-parity? anyp? pass8? (caution)' |
---|
58 | fs = 3 |
---|
59 | set TANDEM (send stopc on out q full) try 'tandem' |
---|
60 | set CBREAK (half-cooked mode) try 'cbreak' |
---|
61 | xc = 0 |
---|
62 | xs = 40040 |
---|
63 | set LITOUT (literal output) try 'litout' |
---|
64 | set DECCTQ (only ^Q starts after ^S) try 'decctlq' |
---|
65 | |
---|
66 | Note that when you clear odd and even parity, then you get |
---|
67 | no parity or any parity. You should use -parity to be compatible. |
---|
68 | You might also want to add 'pass8' as well. |
---|
69 | Thus, using the xlate output, you would try: |
---|
70 | :ty=-lcase -echo -crmod -raw -parity pass8 tandem cbreak litout decctlq: |
---|
71 | |
---|
72 | |
---|
73 | Bits used in the fc, fs parameters: |
---|
74 | |
---|
75 | TANDEM 00000001 /* send stopc on out q full */ |
---|
76 | CBREAK 00000002 /* half-cooked mode */ |
---|
77 | LCASE 00000004 /* simulate lower case */ |
---|
78 | ECHO 00000010 /* echo input */ |
---|
79 | CRMOD 00000020 /* map \r to \r\n on output */ |
---|
80 | RAW 00000040 /* no i/o processing */ |
---|
81 | ODDP 00000100 /* get/send odd parity */ |
---|
82 | EVENP 00000200 /* get/send even parity */ |
---|
83 | ANYP 00000300 /* get any parity/send none */ |
---|
84 | |
---|
85 | NLDELAY 00001400 /* \n delay */ |
---|
86 | NL0 00000000 |
---|
87 | NL1 00000400 /* tty 37 */ |
---|
88 | NL2 00001000 /* vt05 */ |
---|
89 | NL3 00001400 |
---|
90 | |
---|
91 | TBDELAY 00006000 /* horizontal tab delay */ |
---|
92 | TAB0 00000000 |
---|
93 | TAB1 00002000 /* tty 37 */ |
---|
94 | TAB2 00004000 |
---|
95 | |
---|
96 | XTABS 00006000 /* expand tabs on output */ |
---|
97 | |
---|
98 | CRDELAY 00030000 /* \r delay */ |
---|
99 | CR0 00000000 |
---|
100 | CR1 00010000 /* tn 300 */ |
---|
101 | CR2 00020000 /* tty 37 */ |
---|
102 | CR3 00030000 /* concept 100 */ |
---|
103 | |
---|
104 | VTDELAY 00040000 /* vertical tab delay */ |
---|
105 | FF0 00000000 |
---|
106 | FF1 00040000 /* tty 37 */ |
---|
107 | |
---|
108 | BSDELAY 00100000 /* \b delay */ |
---|
109 | BS0 00000000 |
---|
110 | BS1 00100000 |
---|
111 | |
---|
112 | ALLDELAY 00177400 |
---|
113 | |
---|
114 | bits used in the xc, xs parameters: |
---|
115 | |
---|
116 | CRTBS 00000001 /* do backspacing for crt */ |
---|
117 | PRTERA 00000002 /* \ ... / erase */ |
---|
118 | CRTERA 00000004 /* " \b " to wipe out char */ |
---|
119 | TILDE 00000010 /* hazeltine tilde kludge */ |
---|
120 | MDMBUF 00000020 /* start/stop output on carrier intr */ |
---|
121 | LITOUT 00000040 /* literal output */ |
---|
122 | TOSTOP 00000100 /* SIGSTOP on background output */ |
---|
123 | FLUSHO 00000200 /* flush output to terminal */ |
---|
124 | NOHANG 00000400 /* no SIGHUP on carrier drop */ |
---|
125 | CRTKIL 00002000 /* kill line with " \b " */ |
---|
126 | PASS8 00004000 /* pass 8 bits */ |
---|
127 | CTLECH 00010000 /* echo control chars as ^X */ |
---|
128 | PENDIN 00020000 /* tp->t_rawq needs reread */ |
---|
129 | DECCTQ 00040000 /* only ^Q starts after ^S */ |
---|
130 | NOFLSH 00100000 /* no output flush on signal */ |
---|
131 | |
---|
132 | --------------------- xlate.c ------------------------ |
---|
133 | /*************************************************************************** |
---|
134 | * LPRng - An Extended Print Spooler System |
---|
135 | * |
---|
136 | * Copyright 1988-1995 Patrick Powell, San Diego State University |
---|
137 | * papowell@sdsu.edu |
---|
138 | * See LICENSE for conditions of use. |
---|
139 | * |
---|
140 | *************************************************************************** |
---|
141 | * MODULE: xlate.c |
---|
142 | * PURPOSE: translate the FC, FS, SX, XS fields |
---|
143 | * |
---|
144 | * xlate ":fc#0000374:fs#0000003:xc#0:xs#0040040:" |
---|
145 | * - makes best guesses about the various fields |
---|
146 | **************************************************************************/ |
---|
147 | |
---|
148 | #include <stdio.h> |
---|
149 | #include <string.h> |
---|
150 | |
---|
151 | static char _id[] = "$Id: Using_stty.txt,v 1.1.1.1 1999-02-17 15:29:17 ghudson Exp $"; |
---|
152 | |
---|
153 | struct bits{ |
---|
154 | char *name; |
---|
155 | int bitfields; |
---|
156 | char *comment; |
---|
157 | char *try; |
---|
158 | int mask; |
---|
159 | }; |
---|
160 | |
---|
161 | /* f flags - used with the TIOCGET and the struct sgttyb.sg_flags field */ |
---|
162 | struct bits tiocget[] = { |
---|
163 | { "TANDEM",00000001, "send stopc on out q full", "tandem" }, |
---|
164 | { "CBREAK",00000002, "half-cooked mode", "cbreak" }, |
---|
165 | { "LCASE",00000004, "simulate lower case", "lcase" }, |
---|
166 | { "ECHO",00000010, "echo input", "echo" }, |
---|
167 | { "CRMOD",00000020, "map \\r to \\r\\n on output", "crmod" }, |
---|
168 | { "RAW",00000040, "no i/o processing", "raw" }, |
---|
169 | { "ODDP",00000100, "get/send odd parity", "oddp" }, |
---|
170 | { "EVENP",00000200, "get/send even parity", "evenp" }, |
---|
171 | { "ANYP",00000300, "get any parity/send none", "parity? anyp? pass8? (caution)" }, |
---|
172 | { "NL0",0000000, "new line delay", "nl??",00001400 }, |
---|
173 | { "NL1",00000400, "new line delay tty 37", "nl??",00001400 }, |
---|
174 | { "NL2",00001000, "new line delay vt05", "nl??",00001400 }, |
---|
175 | { "NL3",00001400, "new line delay", "nl??",00001400 }, |
---|
176 | { "TAB0",00000000, "tab expansion delay", "tab??",00006000 }, |
---|
177 | { "TAB1",00002000, "tab expansion delay tty 37", "tab??",00006000 }, |
---|
178 | { "TAB2",00004000, "tab expansion delay", "tab??",00006000 }, |
---|
179 | { "XTABS",00006000, "expand tabs on output", "tabs" }, |
---|
180 | { "CR0",00000000, "cr??", "",00030000 }, |
---|
181 | { "CR1",00010000, "tn 300", "cr??",00030000 }, |
---|
182 | { "CR2",00020000, "tty 37", "cr??",00030000 }, |
---|
183 | { "CR3",00030000, "concept 100", "cr??",00030000}, |
---|
184 | { "FF1",00040000, "form feed delay tty 37", "ff??" }, |
---|
185 | { "BS1",0010000, "backspace timing", "bs??" }, |
---|
186 | { 0 } }; |
---|
187 | |
---|
188 | /* x flags - used with the TIOCLGET and the struct sgttyb.sg_flags field */ |
---|
189 | struct bits tiolget[] = { |
---|
190 | { "CRTBS",00000001, "do backspacing for crt", "crterase" }, |
---|
191 | { "PRTERA",00000002, "\\ ... / erase", "prterase" }, |
---|
192 | { "CRTERA",00000004, "\"\\b\" to wipe out char", "crterase" }, |
---|
193 | { "TILDE",00000010, "hazeltine tilde kludge", "don't even think about this" }, |
---|
194 | { "MDMBUF",00000020, "start/stop output on carrier intr", "crtscts" }, |
---|
195 | { "LITOUT",00000040, "literal output", "litout" }, |
---|
196 | { "TOSTOP",00000100, "SIGSTOP on background output", "tostop" }, |
---|
197 | { "FLUSHO",00000200, "flush output to terminal", "noflsh?? (caution)" }, |
---|
198 | { "NOHANG",00000400, "no SIGHUP on carrier drop", "nohand" }, |
---|
199 | { "CRTKIL",00002000, "kill line with \"\\b\"", "crtkill" }, |
---|
200 | { "PASS8",00004000, "pass 8 bits", "pass8" }, |
---|
201 | { "CTLECH",00010000, "echo control chars as ^X", "echok" }, |
---|
202 | { "PENDIN",00020000, "tp->t_rawq needs reread", "don't even think about this" }, |
---|
203 | { "DECCTQ",00040000, "only ^Q starts after ^S", "decctlq? -ixany? (caution)" }, |
---|
204 | { "NOFLSH",00100000, "no output flush on signal", "noflsh" }, |
---|
205 | { 0 } }; |
---|
206 | |
---|
207 | char *msg[] = { |
---|
208 | "xlate optionstrings", |
---|
209 | " Example", |
---|
210 | " xlate \":fc#0000374:fs#0000003:xc#0:xs#0040040:\"", |
---|
211 | 0 |
---|
212 | }; |
---|
213 | |
---|
214 | usage() |
---|
215 | { |
---|
216 | char **m; |
---|
217 | for( m = msg; *m; ++m ){ |
---|
218 | fprintf( stderr, "%s\n", *m ); |
---|
219 | } |
---|
220 | exit( 1 ); |
---|
221 | } |
---|
222 | |
---|
223 | |
---|
224 | main( argc, argv ) |
---|
225 | int argc; |
---|
226 | char *argv[]; |
---|
227 | { |
---|
228 | char *s, *end; |
---|
229 | char *value; |
---|
230 | int c, v, set; |
---|
231 | struct bits *table; |
---|
232 | |
---|
233 | if( argc != 2 ) usage(); |
---|
234 | for( s = argv[1]; s && *s; s = end ){ |
---|
235 | end = strchr( s, ':' ); |
---|
236 | if( end ){ |
---|
237 | *end++ = 0; |
---|
238 | } |
---|
239 | while( (c = *s) && isspace( c ) ) ++s; |
---|
240 | if( c == 0 ) continue; |
---|
241 | |
---|
242 | /* now translate option */ |
---|
243 | value = strchr( s, '#' ); |
---|
244 | if( value == 0 ) usage(); |
---|
245 | *value++ = 0; |
---|
246 | v = strtol( value, (char **)0, 0 ); |
---|
247 | printf( "%s = %o\n", s, v); |
---|
248 | switch( s[0] ){ |
---|
249 | case 'f': table = tiocget; break; |
---|
250 | case 'x': table = tiolget; break; |
---|
251 | default: usage(); |
---|
252 | } |
---|
253 | switch( s[1] ){ |
---|
254 | case 's': set = 1; break; |
---|
255 | case 'c': set = 0; break; |
---|
256 | default: usage(); |
---|
257 | } |
---|
258 | /* now we scan down the values */ |
---|
259 | for(; table->name; ++table ){ |
---|
260 | if( (table->bitfields & v) |
---|
261 | && ( ((table->bitfields & v) ^ table->bitfields) |
---|
262 | & (table->mask?table->mask:~0) ) == 0 ){ |
---|
263 | printf( " %s %s (%s) try '%s%s'\n", |
---|
264 | set?"set":"clear", |
---|
265 | table->name, table->comment, |
---|
266 | set? "":"-", table->try ); |
---|
267 | } |
---|
268 | } |
---|
269 | } |
---|
270 | } |
---|