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