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 >
Text File  |  2000-06-30  |  1KB  |  39 lines

  1.  
  2. #define NOCCARGC
  3. #include stdio.h
  4. #include clib.def
  5. extern int _fcbptr[], _chrpos[], _nextc[];
  6. /*
  7. ** Position fd to 128-byte record indicated by 
  8. ** "offset" relative to the point indicated by "base."
  9. **
  10. **    BASE      OFFSET-RELATIVE-TO
  11. **      0       first record
  12. **      1       current record
  13. **      2       end of file (last record + 1)
  14. **
  15. ** Returns NULL on success, else EOF.
  16. */
  17. cseek(fd, offset, base) int fd, offset, base; {
  18.   int oldrrn, *rrn;
  19.   if(!_mode(fd) || isatty(fd) || fflush(fd)) return EOF;
  20.   rrn = _fcbptr[fd] + RRNOFF;
  21.   oldrrn = *rrn;
  22.   switch (base) {
  23.     case 2: _bdos(POSEND, _fcbptr[fd]);
  24.     case 1: *rrn += offset;
  25.             break;
  26.     case 0: *rrn = offset;
  27.             break;
  28.     default: return (EOF);
  29.     }
  30.   if(_sector(fd, RDRND)) {
  31.     *rrn = oldrrn;
  32.     return EOF;
  33.     }
  34.   _chrpos[fd] = 0;
  35.   _nextc[fd] = EOF;
  36.   _clreof(fd);
  37.   return (NULL);
  38.   }
  39.