25 #include "local_proto.h" 28 static int read_int(
int,
int *);
29 static int read_off_t(
int, off_t *);
65 if (lseek(fd, 0L, SEEK_SET) < 0) {
68 G_warning(
"Segment_init: %s", strerror(err));
73 if (!read_off_t(fd, &SEG->
nrows)
74 || !read_off_t(fd, &SEG->
ncols)
75 || !read_int(fd, &SEG->
srows)
76 || !read_int(fd, &SEG->
scols)
77 || !read_int(fd, &SEG->
len))
84 static int read_int(
int fd,
int *n)
88 if ((bytes_read = read(fd, n,
sizeof(
int))) == -1)
89 G_warning(
"read_int: %s", strerror(errno));
91 bytes_read = (bytes_read ==
sizeof(int));
96 static int read_off_t(
int fd, off_t *n)
100 if ((bytes_read = read(fd, n,
sizeof(off_t))) == -1)
101 G_warning(
"read_off_t: %s", strerror(errno));
103 bytes_read = (bytes_read ==
sizeof(off_t));
SYMBOL * err(FILE *fp, SYMBOL *s, char *msg)
int Segment_init(SEGMENT *SEG, int fd, int nseg)
Initialize segment structure.
void G_warning(const char *,...) __attribute__((format(printf
int seg_setup(SEGMENT *SEG)
Internal use only.