23 #include <grass/gis.h>
24 #include "local_proto.h"
26 static int read_int(
int,
int *);
27 static int read_off_t(
int, off_t *);
61 if (lseek(fd, 0L, SEEK_SET) < 0) {
69 if (!read_off_t(fd, &SEG->nrows) || !read_off_t(fd, &SEG->ncols) ||
70 !read_int(fd, &SEG->srows) || !read_int(fd, &SEG->scols) ||
71 !read_int(fd, &SEG->len))
77 static int read_int(
int fd,
int *n)
81 if ((bytes_read = read(fd, n,
sizeof(
int))) == -1)
82 G_warning(
"read_int: %s", strerror(errno));
84 bytes_read = (bytes_read ==
sizeof(int));
89 static int read_off_t(
int fd, off_t *n)
93 if ((bytes_read = read(fd, n,
sizeof(off_t))) == -1)
94 G_warning(
"read_off_t: %s", strerror(errno));
96 bytes_read = (bytes_read ==
sizeof(off_t));
void G_warning(const char *msg,...)
Print a warning message to stderr.
int Segment_init(SEGMENT *SEG, int fd, int nseg)
Initialize segment structure.
int seg_setup(SEGMENT *SEG)
Internal use only.
SYMBOL * err(FILE *fp, SYMBOL *s, char *msg)