Annotation of 41BSD/lib/libI77uc/backspace.c, revision 1.1

1.1     ! root        1: /*
        !             2:  * Backspace records
        !             3:  */
        !             4: 
        !             5: #include "fio.h"
        !             6: 
        !             7: char *bksp = "backspace";
        !             8: char last_char();
        !             9: 
        !            10: f_back(a) alist *a;
        !            11: {      unit *b;
        !            12:        int n,i;
        !            13:        long x,y;
        !            14:        lfname = NULL;
        !            15:        elist = NO;
        !            16:        external = YES;
        !            17:        errflag = a->aerr;
        !            18:        lunit = a->aunit;
        !            19:        if (not_legal(lunit)) err(errflag,101,bksp)
        !            20:        b= &units[lunit];
        !            21:        if(!b->ufd && (n=fk_open(READ,SEQ,FMT,(ftnint)lunit)) )
        !            22:                err(errflag,n,bksp)
        !            23:        lfname = b->ufnm;
        !            24:        if(b->uend)
        !            25:        {       b->uend = NO;
        !            26:                return(OK);
        !            27:        }
        !            28:        if((x=ftell(b->ufd))==0) return(OK);
        !            29:        if(!b->useek) err(errflag,106,bksp)
        !            30:        if(b->uwrt) t_runc(b,errflag);
        !            31:        if(b->url)              /* direct access, purely academic */
        !            32:        {       y = x%(long)b->url;
        !            33:                x -= y?y:b->url;
        !            34:                fseek(b->ufd,x,0);
        !            35:                return(OK);
        !            36:        }
        !            37:        if(!b->ufmt)            /* unformatted sequential */
        !            38:        {       fseek(b->ufd,-(long)sizeof(int),1);
        !            39:                fread((char *)&n,sizeof(int),1,b->ufd);
        !            40:                fseek(b->ufd,-(long)n-2*sizeof(int),1);
        !            41:                return(OK);
        !            42:        }
        !            43:        if(x==1)                        /* formatted sequential */
        !            44:        {       rewind(b->ufd);
        !            45:                return(OK);
        !            46:        }
        !            47:        while(last_char(b->ufd)!='\n'); /* slow but simple */
        !            48:        return(OK);
        !            49: }

unix.superglobalmegacorp.com

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