|
|
1.1 root 1: static char *sccsid = "@(#)sh.print.c 4.4 6/11/83";
2:
3: #include "sh.h"
4:
5: /*
6: * C Shell
7: */
8:
9: psecs(l)
10: long l;
11: {
12: register int i;
13:
14: i = l / 3600;
15: if (i) {
16: printf("%d:", i);
17: i = l % 3600;
18: p2dig(i / 60);
19: goto minsec;
20: }
21: i = l;
22: printf("%d", i / 60);
23: minsec:
24: i %= 60;
25: printf(":");
26: p2dig(i);
27: }
28:
29: p2dig(i)
30: register int i;
31: {
32:
33: printf("%d%d", i / 10, i % 10);
34: }
35:
36: char linbuf[128];
37: char *linp = linbuf;
38:
39: putchar(c)
40: register int c;
41: {
42:
43: if ((c & QUOTE) == 0 && (c == 0177 || c < ' ' && c != '\t' && c != '\n')) {
44: putchar('^');
45: if (c == 0177)
46: c = '?';
47: else
48: c |= 'A' - 1;
49: }
50: c &= TRIM;
51: *linp++ = c;
52: if (c == '\n' || linp >= &linbuf[sizeof linbuf - 2])
53: flush();
54: }
55:
56: draino()
57: {
58:
59: linp = linbuf;
60: }
61:
62: flush()
63: {
64: register int unit;
65: int lmode = 0;
66:
67: #include <sys/ioctl.h>
68:
69: if (linp == linbuf)
70: return;
71: if (haderr)
72: unit = didfds ? 2 : SHDIAG;
73: else
74: unit = didfds ? 1 : SHOUT;
75: #ifdef TIOCLGET
76: if (didfds==0 && ioctl(unit, TIOCLGET, &lmode)==0 &&
77: lmode & LFLUSHO) {
78: lmode = LFLUSHO;
79: ioctl(unit, TIOCLBIC, &lmode);
80: write(unit, "\n", 1);
81: }
82: #endif
83: write(unit, linbuf, linp - linbuf);
84: linp = linbuf;
85: }
86:
87: plist(vp)
88: register struct varent *vp;
89: {
90:
91: if (setintr)
92: sigrelse(SIGINT);
93: for (vp = vp->link; vp != 0; vp = vp->link) {
94: int len = blklen(vp->vec);
95:
96: printf(vp->name);
97: printf("\t");
98: if (len != 1)
99: putchar('(');
100: blkpr(vp->vec);
101: if (len != 1)
102: putchar(')');
103: printf("\n");
104: }
105: if (setintr)
106: sigrelse(SIGINT);
107: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.