66 unsigned char compress[4];
79 if (read(fcb->
data_fd, compress, 3) != 3
80 || compress[0] != 251 || compress[1] != 255 || compress[2] != 251)
94 static int read_row_ptrs(
int nrows,
int old, off_t *
row_ptr,
int fd)
97 unsigned char *buf, *
b;
107 n = (nrows + 1) *
sizeof(off_t);
120 if (read(fd, &nbytes, 1) != 1)
125 n = (nrows + 1) * nbytes;
127 if (read(fd, buf, n) != n)
130 for (row = 0, b = buf; row <= nrows; row++) {
133 for (n = 0; n < (int)nbytes; n++) {
134 unsigned char c = *b++;
136 if (nbytes >
sizeof(off_t) && n < nbytes -
sizeof(off_t) &&
162 G_warning(
_(
"Fail of initial read of compressed file [%s in %s]"),
175 if (read_row_ptrs(nrows, 0, fcb->
null_row_ptr, null_fd) < 0) {
176 G_warning(
_(
"Fail of initial read of compressed null file [%s in %s]"),
184 static int write_row_ptrs(
int nrows, off_t *
row_ptr,
int fd)
186 int nbytes =
sizeof(off_t);
187 unsigned char *buf, *
b;
188 int len, row, result;
190 lseek(fd, 0L, SEEK_SET);
192 len = (nrows + 1) * nbytes + 1;
196 for (row = 0; row <= nrows; row++) {
200 for (i = nbytes - 1; i >= 0; i--) {
208 result = (write(fd, buf, len) == len);
227 return write_row_ptrs(nrows, fcb->
null_row_ptr, null_fd);
void G_free(void *)
Free allocated memory.
int compressed
Compression mode (raster header only)
struct fileinfo * fileinfo
void G_warning(const char *,...) __attribute__((format(printf
int rows
Number of rows for 2D data.