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:  *	@(#)c_sfe.c	5.2	7/30/85
   7:  */
   8: 
   9: /*
  10:  * sequential formatted external I/O - common read & write routines
  11:  */
  12: 
  13: #include "fio.h"
  14: 
  15: c_sfe(a,flag,mode,str) cilist *a; char *str; /* check */
  16: {   unit *p;
  17:     int n;
  18: 
  19:     external=YES;
  20:     formatted=FORMATTED;
  21:     fmtbuf=a->cifmt;
  22:     lfname = NULL;
  23:     elist = NO;
  24:     errflag = a->cierr;
  25:     endflag = a->ciend;
  26:     lunit = a->ciunit;
  27:     if(not_legal(lunit)) err(errflag,F_ERUNIT,str);
  28:     curunit = p = &units[lunit];
  29:     if(!p->ufd && (n=fk_open(flag,mode,FMT,(ftnint)lunit)) )
  30:         err(errflag,n,str)
  31:     cf = curunit->ufd;
  32:     elist = YES;
  33:     lfname = curunit->ufnm;
  34:     if(!p->ufmt) err(errflag,F_ERNOFIO,str)
  35:     cursor=recpos=scale=reclen=0;
  36:     radix = 10;
  37:     signit = YES;
  38:     cblank = curunit->ublnk;
  39:     cplus = NO;
  40:     return(OK);
  41: }
  42: 
  43: x_tab()
  44: {   int n;
  45:     if(reclen < recpos) reclen = recpos;
  46:     if(curunit->useek)
  47:     {   if((recpos+cursor) < 0) cursor = -recpos;   /* to BOR */
  48:         n = reclen - recpos;    /* distance to eor, n>=0 */
  49:         if((cursor-n) > 0)
  50:         {   fseek(cf,(long)n,1);  /* find current eor */
  51:             recpos = reclen;
  52:             cursor -= n;
  53:         }
  54:         else
  55:         {   fseek(cf,(long)cursor,1);  /* do not pass go */
  56:             recpos += cursor;
  57:             return(cursor=0);
  58:         }
  59:     }
  60:     else
  61:         if(cursor < 0) return(F_ERSEEK);   /* can't go back */
  62:     while(cursor--)
  63:     {   if(reading)
  64:         {   n = (*getn)();
  65:             if(n=='\n') return(cursor=0);   /* be tolerant */
  66:             if(n==EOF) return(EOF);
  67:         }
  68:         else    (*putn)(' ');   /* fill in the empty record */
  69:     }
  70:     return(cursor=0);
  71: }

Defined functions

c_sfe defined in line 15; used 2 times
x_tab defined in line 43; used 4 times
Last modified: 1985-07-31
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1070
Valid CSS Valid XHTML 1.0 Strict