* Copyright (c) 1980 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
* direct formatted external i/o - common read/write routines
c_dfe(a
,flg
,str
) cilist
*a
; char *str
;
cursor
=scale
=recpos
=reclen
=0;
if(not_legal(lunit
)) err(errflag
,F_ERUNIT
,str
);
if(!curunit
->ufd
&& (n
=fk_open(flg
,DIR,FMT
,(ftnint
)lunit
)))
if(!curunit
->ufmt
) err(errflag
,F_ERNOFIO
,str
)
if(!curunit
->useek
|| !curunit
->url
) err(errflag
,F_ERNODIO
,str
)
fseek(cf
, (long)curunit
->url
* recnum
, 0);
if(cursor
< 0 && -cursor
> ftell(cf
)) rewind(cf
);
else fseek(cf
,(long)cursor
,1);
{ if(reclen
< recpos
) reclen
= recpos
;
if((recpos
+ cursor
) < 0) cursor
= -recpos
; /* BOR */
n
= reclen
- recpos
; /* n >= 0 */
if(!reading
&& (cursor
-n
) > 0)
while(cursor
--) if(n
=(*putn
)(' ')) return(n
);
if(recpos
>= curunit
->url
) err(errflag
,F_EREREC
,"dfe")
fseek(cf
,(long)cursor
,1);