|
|
1.1 ! root 1: /* ce is the parameter for "clear to end of line" */ ! 2: # include "stdio.h" ! 3: # include "ctype.h" ! 4: char *tgetent(), *tgoto(), *tputs(), *tgetstr(), *getenv(); ! 5: static char tname[25]="", tcapbuf[1024], *Movcur, strarea[1204], *p_area=strarea; ! 6: static char *Home=NULL, *Clr2nd=NULL, *Clear=NULL, *ClrLine=NULL; ! 7: static int tset=0; ! 8: tgate() ! 9: { ! 10: static gate=0; char *envp; ! 11: if (gate==0) ! 12: { ! 13: gate=1; ! 14: if (!isatty(1)) return; /* don't ask pointless questions */ ! 15: if (tset==0) ! 16: { ! 17: envp = getenv("TERM"); ! 18: if (tname[0]==0 && envp != NULL) ! 19: strncpy (tname, envp, 25); ! 20: if (! *tname) { ! 21: fputs ("Terminal type? ", stdout); ! 22: fflush(stdout); ! 23: gets(tname); ! 24: } ! 25: } ! 26: if (*tname==0) return; ! 27: switch ( tgetent(tcapbuf, tname)) ! 28: { ! 29: case -1: fprintf(stderr, "No termcap file\n"); ! 30: exit(1); ! 31: case 0: /* unknown terminal */ ! 32: return; ! 33: default: break; ! 34: } ! 35: if (strcmp(tname, "adm3a")==0) ! 36: { ! 37: extern char *UP; ! 38: UP = "xxx"; ! 39: } ! 40: Movcur = tgetstr("cm", &p_area); ! 41: Home = tgetstr("ho", &p_area); ! 42: Clr2nd = tgetstr("cd", &p_area); ! 43: Clear = tgetstr("cl", &p_area); ! 44: ClrLine = tgetstr("ce", &p_area); ! 45: } ! 46: } ! 47: tpos (line, col) ! 48: { ! 49: tgate(); ! 50: if (Movcur!=NULL) ! 51: { ! 52: char tmpstr[100]; ! 53: strncpy(tmpstr, tgoto(Movcur, col, line), 100); ! 54: if (strcmp(tmpstr, "OOPS")==0) return; ! 55: termwr(tmpstr); ! 56: } ! 57: else ! 58: if (Home!=NULL) ! 59: { ! 60: termwr(Home); ! 61: while (line-- > 0) ! 62: termwr("\n"); ! 63: while (col-- > 0) ! 64: termwr(" "); ! 65: } ! 66: return; ! 67: } ! 68: startsc() ! 69: { ! 70: tgate(); ! 71: if (Home != NULL) ! 72: termwr(Home); ! 73: else ! 74: if (Movcur != NULL) ! 75: tpos(0,0); ! 76: if (Clr2nd != NULL) ! 77: termwr(Clr2nd); ! 78: else if (Clear !=NULL) ! 79: termwr(Clear); ! 80: } ! 81: clr2end () ! 82: { ! 83: tgate(); ! 84: if (Clr2nd !=NULL) ! 85: termwr(Clr2nd); ! 86: } ! 87: clrline() ! 88: { ! 89: tgate(); ! 90: if (ClrLine !=NULL) ! 91: termwr(ClrLine); ! 92: } ! 93: ifclear() ! 94: { ! 95: return (Clr2nd!=NULL); ! 96: } ! 97: ifclrline() ! 98: { ! 99: return(ClrLine!=NULL); ! 100: } ! 101: stterm(t) ! 102: char *t; ! 103: { ! 104: strcpy(tname, t); ! 105: tset=1; ! 106: } ! 107: char * ! 108: gtterm() ! 109: { ! 110: return(tname); ! 111: } ! 112: termwr(s) ! 113: char *s; ! 114: { ! 115: int delay; char *sr; ! 116: for(sr=s; isdigit(*sr); sr++) ! 117: ; ! 118: fputs(sr, stdout); ! 119: if (sr<=s) return; ! 120: for (delay=atoi(s)/10; delay>0; delay--) ! 121: putc(000, stdout); ! 122: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.