ftell_.c 900 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, const char *who)
  11. #endif
  12. {
  13. if (Unit >= MXUNIT || Unit < 0)
  14. f__fatal(101, who);
  15. return f__units[Unit].ufd;
  16. }
  17. integer
  18. #ifdef KR_headers
  19. ftell_(Unit) integer *Unit;
  20. #else
  21. ftell_(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. fseek_(Unit, offset, whence) integer *Unit, *offset, *whence;
  30. #else
  31. fseek_(integer *Unit, integer *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, *offset, w) ? 1 : 0;
  46. }
  47. #ifdef __cplusplus
  48. }
  49. #endif