home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 2 / ctrom_ii_b.zip / ctrom_ii_b / PROGRAM / C / SMALL_C / CSEEK.C < prev    next >
Text File  |  1987-10-04  |  1KB  |  33 lines

  1.  
  2. #define NOCCARGC  /* no argument count passing */
  3. #include stdio.h
  4. #include clib.def
  5. /*
  6. ** Position fd to the byte indicated by
  7. ** "offset" relative to the point indicated by "base."
  8. ** 
  9. ** offset is given by offstlo which defines bits 
  10. ** 0-15 of the true offset and offsthi, which defines
  11. ** bits 16-31 of the true offset.  I.e., true offset is
  12. ** offstlo + offsthi>>16.  Note that this will require
  13. ** some creative programming, since this version of
  14. ** Small C uses 16-bit signed integers.
  15. **
  16. **     BASE     OFFSET-RELATIVE-TO
  17. **       0      first record
  18. **       1      current record
  19. **       2      end of file (last record + 1)
  20. **
  21. ** Returns NULL on success, else EOF.
  22. */
  23. extern int Ufd[];
  24. seek(fd, offstlo, offsthi, base) int fd, offstlo, offsthi, base; {
  25.   if(!Umode(fd) || isatty(fd)) return (EOF);
  26.  
  27.   /* Gotta set up offstlo and offsthi up to move */
  28.   /* into the registers.                         */
  29.   if(Umsdos(offstlo,offsthi,Ufd[fd],base+POSFIL)==ERR) return(ERR);
  30.   return (NULL);
  31.   }
  32.  
  33.