getrow.c 573 B

1234567891011121314151617181920212223242526
  1. #include <stdlib.h>
  2. #include <unistd.h>
  3. #include <sys/types.h>
  4. #include <grass/gis.h>
  5. #include <grass/raster.h>
  6. #include <grass/glocale.h>
  7. #include "glob.h"
  8. #include "local_proto.h"
  9. int getmaprow(int fd, void *buf, int row, int len)
  10. {
  11. Rast_get_d_row(fd, (DCELL *) buf, row);
  12. return 1;
  13. }
  14. int getrow(int fd, void *buf, int row, int len)
  15. {
  16. if (direction > 0)
  17. lseek(fd, (off_t) row * len, 0);
  18. else
  19. lseek(fd, (off_t) (nrows - row - 1) * len, 0);
  20. if (read(fd, (DCELL *) buf, len) != len)
  21. G_fatal_error(_("Error reading temporary file"));
  22. return 1;
  23. }