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

Defined functions

bs defined in line 146; used 2 times
clear defined in line 106; used 4 times
dasi300 defined in line 171; used 2 times
dasi450 defined in line 160; used 1 times
  • in line 84
delay defined in line 113; used 1 times
escape defined in line 141; used 6 times
hp2645 defined in line 181; used 1 times
  • in line 90
main defined in line 61; never used
margin defined in line 132; used 2 times
misc defined in line 189; used 1 times
  • in line 97
nl defined in line 151; used 8 times
syslook defined in line 50; used 2 times
tabs defined in line 118; used 6 times
tn300 defined in line 176; used 1 times
  • in line 86
tty37 defined in line 166; used 2 times

Defined variables

margset defined in line 48; used 3 times
sccsid defined in line 2; never used
tty defined in line 33; used 1 times
  • in line 55

Defined struct's

sysnod defined in line 22; used 4 times
  • in line 33(2), 53(2)

Defined macros

BS defined in line 20; used 1 times
CLR defined in line 17; used 1 times
CR defined in line 19; used 2 times
DASI300 defined in line 27; used 2 times
DASI300S defined in line 28; used 2 times
DASI450 defined in line 29; used 2 times
DEL defined in line 15; used 1 times
ESC defined in line 12; used 1 times
HP defined in line 32; used 1 times
  • in line 45
MGN defined in line 18; used 1 times
NL defined in line 10; used 1 times
RHM defined in line 13; used 1 times
SET defined in line 16; used 2 times
SI defined in line 14; used 1 times
SP defined in line 8; used 2 times
TB defined in line 9; never used
TN300 defined in line 30; used 3 times
TTY37 defined in line 31; used 2 times
Last modified: 1997-03-29
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 3417
Valid CSS Valid XHTML 1.0 Strict