#if !defined(lint) && defined(DOSCCS) static char *sccsid = "@(#)tabs.c 4.1.2 (2.11BSD) 1997/3/28"; #endif #include #include #define SP ' ' #define TB '\t' #define NL '\n' # define ESC 033 # define RHM 060 # define SI 017 # define DEL 0177 # define SET '1' # define CLR '2' # define MGN '9' # define CR '\r' # define BS '\b' struct sysnod { char *sysnam; int sysval; }; #define DASI300 1 #define DASI300S 2 #define DASI450 3 #define TN300 4 #define TTY37 5 #define HP 6 struct sysnod tty[] = { {"dasi300", DASI300}, {"300", DASI300}, {"dasi300s", DASI300S}, {"300s", DASI300S}, {"dasi450", DASI450}, {"450", DASI450}, {"37", TTY37}, {"tty37", TTY37}, {"tn300", TN300}, {"terminet", TN300}, {"tn", TN300}, {"hp", HP}, {0, 0}, }; int margset = 1; syslook(w) char *w; { register struct sysnod *sp; for (sp = tty; sp->sysnam!=NULL; sp++) if (strcmp(sp->sysnam, w)==0) return(sp->sysval); return(0); } main(argc,argv) int argc; char **argv; { struct sgttyb tb; int type; char *getenv(); type=0; if (argc>=2 && strcmp(argv[1],"-n")==0) { margset--; argc--; argv++; } if (argc>=2) { type=syslook(argv[1]); } else { type=syslook(getenv("TERM")); } switch(type) { case DASI300: dasi300(); break; case DASI300S: dasi300(); break; case DASI450: dasi450(); break; case TN300: tn300(); break; case TTY37: tty37(); break; case HP: hp2645(); break; default: gtty (0, &tb); if (tb.sg_flags & CRMOD) { /* test for CR map on, i.e. terminet but not 33 */ if ((tb.sg_ispeed) == B300) /* test for 300 baud */ misc(); } else if ((tb.sg_flags & CRMOD) == 0 && (tb.sg_ispeed ) == B150) { /* apparent model 37 */ tty37(); } } } clear(n) { escape(CLR); delay(n); putchar(CR); nl(); } delay(n) { while (n--) putchar(DEL); } tabs(n) { int i,j; if(margset) n--; for( i=0; i