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