* Copyright (c) 1980 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
* sequential formatted external I/O - common read & write routines
c_sfe(a
,flag
,mode
,str
) cilist
*a
; char *str
; /* check */
external
=formatted
=FORMATTED
;
if(not_legal(lunit
)) err(errflag
,F_ERUNIT
,str
);
curunit
= p
= &units
[lunit
];
if(!p
->ufd
&& (n
=fk_open(flag
,mode
,FMT
,(ftnint
)lunit
)) )
if(!p
->ufmt
) err(errflag
,F_ERNOFIO
,str
)
cursor
=recpos
=scale
=reclen
=0;
if(reclen
< recpos
) reclen
= recpos
;
{ if((recpos
+cursor
) < 0) cursor
= -recpos
; /* to BOR */
n
= reclen
- recpos
; /* distance to eor, n>=0 */
{ fseek(cf
,(long)n
,1); /* find current eor */
{ fseek(cf
,(long)cursor
,1); /* do not pass go */
if(cursor
< 0) return(F_ERSEEK
); /* can't go back */
if(n
=='\n') return(cursor
=0); /* be tolerant */
else (*putn
)(' '); /* fill in the empty record */