Annotation of 43BSDTahoe/bin/csh/sh.print.c, revision 1.1.1.1

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.4 (Berkeley) 6/6/88";
                      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[LINELEN];
                     46: char *linp = linbuf;
                     47: 
                     48: cshputchar(ch)
                     49:        register int ch;
                     50: {
                     51:        CSHPUTCHAR;
                     52: }
                     53: 
                     54: draino()
                     55: {
                     56:        linp = linbuf;
                     57: }
                     58: 
                     59: flush()
                     60: {
                     61:        register int unit;
                     62:        int lmode;
                     63: 
                     64:        if (linp == linbuf)
                     65:                return;
                     66:        if (haderr)
                     67:                unit = didfds ? 2 : SHDIAG;
                     68:        else
                     69:                unit = didfds ? 1 : SHOUT;
                     70: #ifdef TIOCLGET
                     71:        if (didfds == 0 && ioctl(unit, TIOCLGET, (char *)&lmode) == 0 &&
                     72:            lmode&LFLUSHO) {
                     73:                lmode = LFLUSHO;
                     74:                (void) ioctl(unit, TIOCLBIC, (char *)&lmode);
                     75:                (void) write(unit, "\n", 1);
                     76:        }
                     77: #endif
                     78:        (void) write(unit, linbuf, linp - linbuf);
                     79:        linp = linbuf;
                     80: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.