|
|
1.1 ! root 1: /* ! 2: * Copyright (c) 1980 Regents of the University of California. ! 3: * All rights reserved. The Berkeley Software License Agreement ! 4: * specifies the terms and conditions for redistribution. ! 5: */ ! 6: ! 7: #ifndef lint ! 8: static char *sccsid = "@(#)sh.print.c 5.2 (Berkeley) 6/6/85"; ! 9: #endif ! 10: ! 11: #include "sh.h" ! 12: #include <sys/ioctl.h> ! 13: ! 14: /* ! 15: * C Shell ! 16: */ ! 17: ! 18: psecs(l) ! 19: long l; ! 20: { ! 21: register int i; ! 22: ! 23: i = l / 3600; ! 24: if (i) { ! 25: printf("%d:", i); ! 26: i = l % 3600; ! 27: p2dig(i / 60); ! 28: goto minsec; ! 29: } ! 30: i = l; ! 31: printf("%d", i / 60); ! 32: minsec: ! 33: i %= 60; ! 34: printf(":"); ! 35: p2dig(i); ! 36: } ! 37: ! 38: p2dig(i) ! 39: register int i; ! 40: { ! 41: ! 42: printf("%d%d", i / 10, i % 10); ! 43: } ! 44: ! 45: char linbuf[128]; ! 46: char *linp = linbuf; ! 47: ! 48: putchar(c) ! 49: register int c; ! 50: { ! 51: ! 52: if ((c & QUOTE) == 0 && (c == 0177 || c < ' ' && c != '\t' && c != '\n')) { ! 53: putchar('^'); ! 54: if (c == 0177) ! 55: c = '?'; ! 56: else ! 57: c |= 'A' - 1; ! 58: } ! 59: c &= TRIM; ! 60: *linp++ = c; ! 61: if (c == '\n' || linp >= &linbuf[sizeof linbuf - 2]) ! 62: flush(); ! 63: } ! 64: ! 65: draino() ! 66: { ! 67: ! 68: linp = linbuf; ! 69: } ! 70: ! 71: flush() ! 72: { ! 73: register int unit; ! 74: int lmode; ! 75: ! 76: if (linp == linbuf) ! 77: return; ! 78: if (haderr) ! 79: unit = didfds ? 2 : SHDIAG; ! 80: else ! 81: unit = didfds ? 1 : SHOUT; ! 82: #ifdef TIOCLGET ! 83: if (didfds == 0 && ioctl(unit, TIOCLGET, (char *)&lmode) == 0 && ! 84: lmode&LFLUSHO) { ! 85: lmode = LFLUSHO; ! 86: (void) ioctl(unit, TIOCLBIC, (char *)&lmode); ! 87: (void) write(unit, "\n", 1); ! 88: } ! 89: #endif ! 90: (void) write(unit, linbuf, linp - linbuf); ! 91: linp = linbuf; ! 92: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.