Annotation of researchv10dc/libI77/old/wsfe.c, revision 1.1

1.1     ! root        1: /*     @(#)wsfe.c      1.2     */
        !             2: /*     3.0 SID #       1.2     */
        !             3: /*write sequential formatted external*/
        !             4: #include "fio.h"
        !             5: #include "fmt.h"
        !             6: extern int x_putc(),w_ed(),w_ned();
        !             7: extern int xw_end(),xw_rev(),x_wSL();
        !             8: extern int hiwater;
        !             9: s_wsfe(a) cilist *a;   /*start*/
        !            10: {      int n;
        !            11:        if(!init) f_init();
        !            12:        if(n=c_sfe(a)) return(n);
        !            13:        reading=0;
        !            14:        sequential=1;
        !            15:        formatted=1;
        !            16:        external=1;
        !            17:        elist=a;
        !            18:        hiwater = cursor=recpos=0;
        !            19:        nonl = 0;
        !            20:        scale=0;
        !            21:        fmtbuf=a->cifmt;
        !            22:        curunit = &units[a->ciunit];
        !            23:        cf=curunit->ufd;
        !            24:        if(pars_f(fmtbuf)<0) err(a->cierr,100,"startio");
        !            25:        putn= x_putc;
        !            26:        doed= w_ed;
        !            27:        doned= w_ned;
        !            28:        doend=xw_end;
        !            29:        dorevert=xw_rev;
        !            30:        donewrec=x_wSL;
        !            31:        fmt_bg();
        !            32:        cplus=0;
        !            33:        cblank=curunit->ublnk;
        !            34:        if(!curunit->uwrt) (void) nowwriting(curunit);
        !            35:        return(0);
        !            36: }
        !            37: x_putc(c)
        !            38: {
        !            39:        /* this uses \n as an indicator of record-end */
        !            40:        if(c == '\n' && recpos < hiwater) {     /* fseek calls fflush, a loss */
        !            41:                if(cf->_ptr + hiwater - recpos < _bufend(cf))
        !            42:                        cf->_ptr += hiwater - recpos;
        !            43:                else
        !            44:                        (void) fseek(cf, hiwater - recpos, 1);
        !            45:        }
        !            46:        putc(c,cf);
        !            47:        recpos++;
        !            48: }
        !            49: pr_put(c)
        !            50: {      static flag new = 1;
        !            51:        recpos++;
        !            52:        if(c=='\n')
        !            53:        {       new=1;
        !            54:                putc(c,cf);
        !            55:        }
        !            56:        else if(new==1)
        !            57:        {       new=0;
        !            58:                if(c=='0') putc('\n',cf);
        !            59:                else if(c=='1') putc('\f',cf);
        !            60:        }
        !            61:        else putc(c,cf);
        !            62: }
        !            63: x_wSL()
        !            64: {
        !            65:        (*putn)('\n');
        !            66:        recpos=0;
        !            67:        cursor = 0;
        !            68:        hiwater = 0;
        !            69:        return(1);
        !            70: }
        !            71: xw_end()
        !            72: {
        !            73:        if(nonl == 0)
        !            74:                (*putn)('\n');
        !            75:        hiwater = recpos = cursor = 0;
        !            76:        return(0);
        !            77: }
        !            78: xw_rev()
        !            79: {
        !            80:        if(workdone) (*putn)('\n');
        !            81:        hiwater = recpos = cursor = 0;
        !            82:        return(workdone=0);
        !            83: }

unix.superglobalmegacorp.com

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