|
|
1.1 ! root 1: /* Copyright (c) 1979 Regents of the University of California */ ! 2: #include <sgtty.h> ! 3: #include <ctype.h> ! 4: ! 5: /* ! 6: * The following array gives the number of tens of milliseconds per ! 7: * character for each speed as returned by gtty. Thus since 300 ! 8: * baud returns a 7, there are 33.3 milliseconds per char at 300 baud. ! 9: */ ! 10: static ! 11: short tmspc10[] = { ! 12: 0, 2000, 1333, 909, 743, 666, 500, 333, 166, 83, 55, 41, 20, 10 ! 13: }; ! 14: ! 15: short ospeed; ! 16: char PC; ! 17: ! 18: /* ! 19: * Put the character string cp out, with padding. ! 20: * The number of affected lines is affcnt, and the routine ! 21: * used to output one character is outc. ! 22: */ ! 23: tputs(cp, affcnt, outc) ! 24: register char *cp; ! 25: int affcnt; ! 26: int (*outc)(); ! 27: { ! 28: register int i = 0; ! 29: register int mspc10; ! 30: ! 31: if (cp == 0) ! 32: return; ! 33: ! 34: /* ! 35: * Convert the number representing the delay. ! 36: */ ! 37: if (isdigit(*cp)) { ! 38: do ! 39: i = i * 10 + *cp++ - '0'; ! 40: while (isdigit(*cp)); ! 41: } ! 42: i *= 10; ! 43: if (*cp == '.') { ! 44: cp++; ! 45: if (isdigit(*cp)) ! 46: i += *cp - '0'; ! 47: /* ! 48: * Only one digit to the right of the decimal point. ! 49: */ ! 50: while (isdigit(*cp)) ! 51: cp++; ! 52: } ! 53: ! 54: /* ! 55: * If the delay is followed by a `*', then ! 56: * multiply by the affected lines count. ! 57: */ ! 58: if (*cp == '*') ! 59: cp++, i *= affcnt; ! 60: ! 61: /* ! 62: * The guts of the string. ! 63: */ ! 64: while (*cp) ! 65: (*outc)(*cp++); ! 66: ! 67: /* ! 68: * If no delay needed, or output speed is ! 69: * not comprehensible, then don't try to delay. ! 70: */ ! 71: if (i == 0) ! 72: return; ! 73: if (ospeed <= 0 || ospeed >= (sizeof tmspc10 / sizeof tmspc10[0])) ! 74: return; ! 75: ! 76: /* ! 77: * Round up by a half a character frame, ! 78: * and then do the delay. ! 79: * Too bad there are no user program accessible programmed delays. ! 80: * Transmitting pad characters slows many ! 81: * terminals down and also loads the system. ! 82: */ ! 83: mspc10 = tmspc10[ospeed]; ! 84: i += mspc10 / 2; ! 85: for (i /= mspc10; i > 0; i--) ! 86: (*outc)(PC); ! 87: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.