# 2.11BSD#431 - /usr/src/usr.bin/tabs.c

##### Functions

    bs                X
    clear             X
    dasi300           X
    dasi450           X
    delay             X
    escape            X
    hp2645            X
    main              X
    margin            X
    misc              X
    nl                X
    syslook           X
    tabs              X
    tn300             X
    tty37             X

##### Variables

    margset           X
    tty               X

##### Macros

    BS                X
    CLR               X
    CR                X
    DASI300           X
    DASI300S          X
    DASI450           X
    DEL               X
    ESC               X
    HP                X
    MGN               X
    NL                X
    RHM               X
    SET               X
    SI                X
    SP                X
    TB                X
    TN300             X
    TTY37             X

##### struct's

    sysnod            X

       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

- in line 162, 168

clear defined in line 106; used 4 times

- in line 162, 168-178(3)

dasi300 defined in line 171; used 2 times

- in line 80-82(2)

dasi450 defined in line 160; used 1 times

- in line 84

delay defined in line 113; used 1 times

- in line 109

escape defined in line 141; used 6 times

- in line 108, 128, 162-163(2), 178-183(2)

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

- in line 162, 178

misc defined in line 189; used 1 times

- in line 97

nl defined in line 151; used 8 times

- in line 110, 162-178(5), 186-191(2)

syslook defined in line 50; used 2 times

- in line 73-75(2)

tabs defined in line 118; used 6 times

- in line 162, 168-178(3), 185, 191

tn300 defined in line 176; used 1 times

- in line 86

tty37 defined in line 166; used 2 times

- in line 88, 101

#### Defined variables

margset defined in line 48; used 3 times

- in line 70, 122, 136

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

- in line 148

CLR defined in line 17; used 1 times

- in line 108

CR defined in line 19; used 2 times

- in line 110, 184

DASI300 defined in line 27; used 2 times

- in line 34-35(2)

DASI300S defined in line 28; used 2 times

- in line 36-37(2)

DASI450 defined in line 29; used 2 times

- in line 38-39(2)

DEL defined in line 15; used 1 times

- in line 115

ESC defined in line 12; used 1 times

- in line 143

HP defined in line 32; used 1 times

- in line 45

MGN defined in line 18; used 1 times

- in line 162

NL defined in line 10; used 1 times

- in line 153

RHM defined in line 13; used 1 times

- in line 163

SET defined in line 16; used 2 times

- in line 128, 178

SI defined in line 14; used 1 times

- in line 168

SP defined in line 8; used 2 times

- in line 126, 137

TB defined in line 9; never used
TN300 defined in line 30; used 3 times

- in line 42-44(3)

TTY37 defined in line 31; used 2 times

- in line 40-41(2)

Last modified: 1997-03-29 Generated: 2016-12-26 | Generated by src2html V0.67 page hit count: 1501 |