ftell64_.c 917 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #include "f2c.h"
  2. #include "fio.h"
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. static FILE *
  7. #ifdef KR_headers
  8. unit_chk(Unit, who) integer Unit; char *who;
  9. #else
  10. unit_chk(integer Unit, char *who)
  11. #endif
  12. {
  13. if (Unit >= MXUNIT || Unit < 0)
  14. f__fatal(101, who);
  15. return f__units[Unit].ufd;
  16. }
  17. longint
  18. #ifdef KR_headers
  19. ftell64_(Unit) integer *Unit;
  20. #else
  21. ftell64_(integer *Unit)
  22. #endif
  23. {
  24. FILE *f;
  25. return (f = unit_chk(*Unit, "ftell")) ? FTELL(f) : -1L;
  26. }
  27. int
  28. #ifdef KR_headers
  29. fseek64_(Unit, offset, whence) integer *Unit, *whence; longint *offset;
  30. #else
  31. fseek64_(integer *Unit, longint *offset, integer *whence)
  32. #endif
  33. {
  34. FILE *f;
  35. int w = (int)*whence;
  36. #ifdef SEEK_SET
  37. static int wohin[3] = { SEEK_SET, SEEK_CUR, SEEK_END };
  38. #endif
  39. if (w < 0 || w > 2)
  40. w = 0;
  41. #ifdef SEEK_SET
  42. w = wohin[w];
  43. #endif
  44. return !(f = unit_chk(*Unit, "fseek"))
  45. || FSEEK(f, (OFF_T)*offset, w) ? 1 : 0;
  46. }
  47. #ifdef __cplusplus
  48. }
  49. #endif