home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.barnyard.co.uk
/
2015.02.ftp.barnyard.co.uk.tar
/
ftp.barnyard.co.uk
/
cpm
/
walnut-creek-CDROM
/
ENTERPRS
/
CPM
/
UTILS
/
S
/
SMC21LIB.LZH
/
CSEEK.C
< prev
next >
Wrap
Text File
|
2000-06-30
|
1KB
|
39 lines
#define NOCCARGC
#include stdio.h
#include clib.def
extern int _fcbptr[], _chrpos[], _nextc[];
/*
** Position fd to 128-byte record indicated by
** "offset" relative to the point indicated by "base."
**
** BASE OFFSET-RELATIVE-TO
** 0 first record
** 1 current record
** 2 end of file (last record + 1)
**
** Returns NULL on success, else EOF.
*/
cseek(fd, offset, base) int fd, offset, base; {
int oldrrn, *rrn;
if(!_mode(fd) || isatty(fd) || fflush(fd)) return EOF;
rrn = _fcbptr[fd] + RRNOFF;
oldrrn = *rrn;
switch (base) {
case 2: _bdos(POSEND, _fcbptr[fd]);
case 1: *rrn += offset;
break;
case 0: *rrn = offset;
break;
default: return (EOF);
}
if(_sector(fd, RDRND)) {
*rrn = oldrrn;
return EOF;
}
_chrpos[fd] = 0;
_nextc[fd] = EOF;
_clreof(fd);
return (NULL);
}