GRASS Programmer's Manual  6.4.2(2012)
segment/seek.c
Go to the documentation of this file.
00001 
00015 #include <stdio.h>
00016 #include <sys/types.h>
00017 #include <unistd.h>
00018 #include <string.h>
00019 #include <errno.h>
00020 #include <grass/config.h>
00021 #include <grass/gis.h>
00022 #include <grass/segment.h>
00023 
00024 
00037 int segment_seek(const SEGMENT * SEG, int n, int index)
00038 {
00039     off_t offset;
00040 
00041     offset = (off_t) n *SEG->size + index + SEG->offset;
00042 
00043     if (lseek(SEG->fd, offset, SEEK_SET) == (off_t) - 1) {
00044         G_warning("segment_seek: %s", strerror(errno));
00045         return -1;
00046     }
00047 
00048     return 0;
00049 }
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines