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:  *	@(#)douio.c	5.1	6/7/85
   7:  */
   8: 
   9: /*
  10:  * unformatted external i/o
  11:  */
  12: 
  13: #include "fio.h"
  14: 
  15: LOCAL char *eor = "eor/uio";
  16: LOCAL char *uio = "uio";
  17: 
  18: LOCAL
  19: do_us(number,ptr,len) ftnint *number; ftnlen len; char *ptr;  /* sequential */
  20: {
  21:     if(reading)
  22:     {
  23:         recpos += *number * len;
  24:         if (recpos > reclen) {
  25:             recpos -= *number * len;
  26:             e_rsue(); /* in case tries another read */
  27:             err(errflag,F_EREREC,eor);
  28:         }
  29: 
  30:         if (fread(ptr,(int)len,(int)(*number),cf) != *number)
  31:             return(due_err(uio));
  32:     }
  33:     else
  34:     {
  35:         reclen += *number * len;
  36:         fwrite(ptr,(int)len,(int)(*number),cf);
  37:     }
  38:     return(OK);
  39: }
  40: 
  41: do_uio(number,ptr,len) ftnint *number; ftnlen len; char *ptr;
  42: {
  43:     if(sequential)
  44:         return(do_us(number,ptr,len));
  45:     else
  46:         return(do_ud(number,ptr,len));
  47: }
  48: 
  49: LOCAL
  50: do_ud(number,ptr,len) ftnint *number; ftnlen len; char *ptr;  /* direct */
  51: {
  52:     recpos += *number * len;
  53:     if(recpos > curunit->url && curunit->url!=1)
  54:         err(errflag,F_EREREC,eor);
  55:     if(reading)
  56:     {
  57:         if (fread(ptr, (int)len, (int)(*number), cf) != *number)
  58:             return(due_err(uio));
  59:     }
  60:     else
  61:         fwrite(ptr,(int)len,(int)(*number),cf);
  62:     return(OK);
  63: }
  64: 
  65: due_err(s) char *s;
  66: {
  67:     if(feof(cf))
  68:         err(endflag,EOF,s)
  69:     else
  70:     {   clearerr(cf);
  71:         err(errflag,errno,s)
  72:     }
  73: }

Defined functions

do_ud defined in line 49; used 1 times
  • in line 46
do_uio defined in line 41; never used
do_us defined in line 18; used 1 times
  • in line 44
due_err defined in line 65; used 4 times

Defined variables

eor defined in line 15; used 2 times
uio defined in line 16; used 2 times
Last modified: 1985-06-08
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1279
Valid CSS Valid XHTML 1.0 Strict