Annotation of 41BSD/lib/libI77uc/sue.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * sequential unformatted external read/write routines
                      3:  */
                      4: 
                      5: #include "fio.h"
                      6: 
                      7: extern int reclen;
                      8: long recloc;
                      9: char *rsue = "read sue";
                     10: char *sue = "sue";
                     11: 
                     12: s_rsue(a) cilist *a;
                     13: {
                     14:        int n;
                     15:        reading = YES;
                     16:        if(n=c_sue(a,READ)) return(n);
                     17:        if(curunit->uwrt) nowreading(curunit);
                     18:        recpos = 0;
                     19:        if(fread(&reclen,sizeof(int),1,cf) == 1) return(OK);
                     20:        if(feof(cf))
                     21:        {       curunit->uend = YES;
                     22:                err(endflag, EOF, rsue)
                     23:        }
                     24:        clearerr(cf);
                     25:        err(errflag, errno, rsue)
                     26: }
                     27: 
                     28: s_wsue(a) cilist *a;
                     29: {
                     30:        int n;
                     31:        reading = NO;
                     32:        if(n=c_sue(a,WRITE)) return(n);
                     33:        if(!curunit->uwrt) nowwriting(curunit);
                     34:        reclen = 0;
                     35:        recloc=ftell(cf);
                     36:        fseek(cf,(long)sizeof(int),1);
                     37:        curunit->uend = NO;
                     38:        return(OK);
                     39: }
                     40: 
                     41: c_sue(a,flag) cilist *a;
                     42: {      int n;
                     43:        external = sequential = YES;
                     44:        formatted = NO;
                     45:        lfname = NULL;
                     46:        elist = NO;
                     47:        errflag = a->cierr;
                     48:        endflag = a->ciend;
                     49:        lunit = a->ciunit;
                     50:        if(not_legal(lunit)) err(errflag,101,sue)
                     51:        curunit = &units[lunit];
                     52:        if(!curunit->ufd && (n=fk_open(flag,SEQ,UNF,(ftnint)lunit)))
                     53:                err(errflag,n,sue)
                     54:        cf = curunit->ufd;
                     55:        elist = YES;
                     56:        lfname = curunit->ufnm;
                     57:        if(curunit->ufmt) err(errflag,103,sue)
                     58:        if(curunit->url) err(errflag,105,sue)
                     59:        if(!curunit->useek) err(errflag,120,sue)
                     60:        return(OK);
                     61: }
                     62: 
                     63: e_wsue()
                     64: {      long loc;
                     65:        fwrite(&reclen,sizeof(int),1,cf);
                     66:        loc=ftell(cf);
                     67:        fseek(cf,recloc,0);
                     68:        fwrite(&reclen,sizeof(int),1,cf);
                     69:        fseek(cf,loc,0);
                     70:        return(OK);
                     71: }
                     72: 
                     73: e_rsue()
                     74: {
                     75:        fseek(cf,(long)(reclen-recpos+sizeof(int)),1);
                     76:        return(OK);
                     77: }

unix.superglobalmegacorp.com

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