seek.c 567 B

123456789101112131415161718192021222324252627282930
  1. #include <stdio.h>
  2. #include <sys/types.h>
  3. #include <grass/gis.h>
  4. #include <grass/glocale.h>
  5. off_t G_ftell(FILE *fp)
  6. {
  7. #ifdef HAVE_FSEEKO
  8. return ftello(fp);
  9. #else
  10. return (off_t) ftell(fp);
  11. #endif
  12. }
  13. void G_fseek(FILE *fp, off_t offset, int whence)
  14. {
  15. #ifdef HAVE_FSEEKO
  16. if (fseeko(fp, offset, whence) != 0)
  17. G_fatal_error(_("unable to seek"));
  18. #else
  19. long loff = (long) offset;
  20. if ((off_t) loff != offset)
  21. G_fatal_error(_("seek offset out of range"));
  22. if (fseek(fp, loff, whence) != 0)
  23. G_fatal_error(_("unable to seek"));
  24. #endif
  25. }