1: static char *sccsid = "@(#)tabs.c 4.1 (Berkeley) 10/1/80";
2: #include <stdio.h>
3: #include <sgtty.h>
4:
5: #define SP ' '
6: #define TB '\t'
7: #define NL '\n'
8:
9: # define ESC 033
10: # define RHM 060
11: # define SI 017
12: # define DEL 0177
13: # define SET '1'
14: # define CLR '2'
15: # define MGN '9'
16: # define CR '\r'
17: # define BS '\b'
18:
19: struct sysnod {
20: char *sysnam;
21: int sysval;
22: };
23:
24: #define DASI300 1
25: #define DASI300S 2
26: #define DASI450 3
27: #define TN300 4
28: #define TTY37 5
29: #define HP 6
30: struct sysnod tty[] = {
31: {"dasi300", DASI300},
32: {"300", DASI300},
33: {"dasi300s", DASI300S},
34: {"300s", DASI300S},
35: {"dasi450", DASI450},
36: {"450", DASI450},
37: {"37", TTY37},
38: {"tty37", TTY37},
39: {"tn300", TN300},
40: {"terminet", TN300},
41: {"tn", TN300},
42: {"hp", HP},
43: {0, 0},
44: };
45: int margset = 1;
46:
47: syslook(w)
48: char *w;
49: {
50: register struct sysnod *sp;
51:
52: for (sp = tty; sp->sysnam!=NULL; sp++)
53: if (strcmp(sp->sysnam, w)==0)
54: return(sp->sysval);
55: return(0);
56: }
57:
58: main(argc,argv)
59: int argc; char **argv;
60: {
61: struct sgttyb tb;
62: int type;
63: char *getenv();
64:
65: type=0;
66: if (argc>=2 && strcmp(argv[1],"-n")==0) {
67: margset--; argc--; argv++;
68: }
69: if (argc>=2) {
70: type=syslook(argv[1]);
71: } else {
72: type=syslook(getenv("TERM"));
73: }
74:
75: switch(type) {
76:
77: case DASI300: dasi300(); break;
78:
79: case DASI300S: dasi300(); break;
80:
81: case DASI450: dasi450(); break;
82:
83: case TN300: tn300(); break;
84:
85: case TTY37: tty37(); break;
86:
87: case HP: hp2645(); break;
88:
89: default:
90: gtty (0, &tb);
91: if ( (tb.sg_flags & (LCASE|CRMOD)) == CRMOD) {
92: /* test for CR map on, upper case off, i.e. terminet but not 33 */
93: if ((tb.sg_ispeed) == B300) /* test for 300 baud */
94: misc();
95: }
96: else if ((tb.sg_flags & (CRMOD|LCASE)) == 0 && (tb.sg_ispeed ) == B150) {
97: /* apparent model 37 */
98: tty37();
99: }
100: }
101: }
102:
103: clear(n)
104: {
105: escape(CLR);
106: delay(n);
107: putchar(CR); nl();
108: }
109:
110: delay(n)
111: {
112: while (n--) putchar(DEL);
113: }
114:
115: tabs(n)
116: {
117: int i,j;
118:
119: if(margset) n--;
120:
121: for( i=0; i<n; ++i ){
122: for( j=0; j<8; ++j ) {
123: putchar(SP);
124: }
125: escape(SET);
126: }
127: }
128:
129: margin(n)
130: {
131: int i;
132:
133: if(margset) {
134: for( i=0; i<n; ++i) putchar(SP);
135: }
136: }
137:
138: escape(c)
139: {
140: putchar(ESC); putchar(c);
141: }
142:
143: bs(n)
144: {
145: while (n--) putchar(BS);
146: }
147:
148: nl()
149: {
150: putchar(NL);
151: }
152:
153:
154:
155: /* ======== terminal types ======== */
156:
157: dasi450()
158: {
159: struct sgttyb t;
160: gtty(0,&t);
161: t.sg_flags &= ~ALLDELAY;
162: stty(0,&t);
163: clear(8); bs(16); margin(8); escape(MGN); nl(); tabs(16);
164: escape(RHM); nl();
165: }
166:
167: tty37()
168: {
169: putchar(SI); clear(40); bs(8); tabs(9); nl();
170: }
171:
172: dasi300()
173: {
174: clear(8); tabs(15); nl();
175: }
176:
177: tn300()
178: {
179: struct sgttyb t;
180: gtty(0,&t);
181: t.sg_flags &= ~ALLDELAY;
182: t.sg_flags |= CR1|BS1;
183: stty(0,&t);
184: clear(8); margin(8); escape(SET); tabs(14); nl();
185: }
186:
187: hp2645()
188: {
189: escape('3'); /*clr*/
190: putchar(CR);
191: tabs(10);
192: nl();
193: }
194:
195: misc()
196: {
197: tabs(14); nl();
198: }
Defined functions
bs
defined in line
143; used 2 times
main
defined in line
58;
never used
misc
defined in line
195; used 1 times
nl
defined in line
148; used 8 times
tabs
defined in line
115; used 6 times
Defined variables
sccsid
defined in line
1;
never used
tty
defined in line
30; used 1 times
Defined struct's
Defined macros
BS
defined in line
17; used 1 times
CLR
defined in line
14; used 1 times
CR
defined in line
16; used 2 times
DEL
defined in line
12; used 1 times
ESC
defined in line
9; used 1 times
HP
defined in line
29; used 1 times
MGN
defined in line
15; used 1 times
NL
defined in line
7; used 1 times
RHM
defined in line
10; used 1 times
SET
defined in line
13; used 2 times
SI
defined in line
11; used 1 times
SP
defined in line
5; used 2 times
TB
defined in line
6;
never used
TN300
defined in line
27; used 3 times
TTY37
defined in line
28; used 2 times