67 unsigned char compress[4];
79 if (
fcb->cellhd.compressed < 0) {
80 if (
read(
fcb->data_fd, compress, 3) != 3 || compress[0] != 251 ||
81 compress[1] != 255 || compress[2] != 251)
82 fcb->cellhd.compressed = 0;
85 if (!
fcb->cellhd.compressed)
95static int read_row_ptrs(
int nrows,
int old,
off_t *
row_ptr,
int fd)
98 unsigned char *buf, *
b;
110 n = ((
unsigned int)nrows + 1) *
sizeof(
off_t);
130 if (
read(fd, buf, n) != n)
133 for (row = 0,
b = buf; row <= (
unsigned int)nrows; row++) {
136 for (n = 0; n <
nbytes; n++) {
137 unsigned char c = *
b++;
161 int nrows =
fcb->cellhd.rows;
162 int old =
fcb->cellhd.compressed < 0;
164 if (read_row_ptrs(nrows, old,
fcb->row_ptr,
fcb->data_fd) < 0) {
165 G_warning(
_(
"Fail of initial read of compressed file [%s in %s]"),
176 int nrows =
fcb->cellhd.rows;
178 if (read_row_ptrs(nrows, 0,
fcb->null_row_ptr,
null_fd) < 0) {
179 G_warning(
_(
"Fail of initial read of compressed null file [%s in %s]"),
187static int write_row_ptrs(
int nrows,
off_t *
row_ptr,
int fd)
190 unsigned char *buf, *
b;
191 int len, row, result;
199 len = (nrows + 1) *
nbytes + 1;
203 for (row = 0; row <= nrows; row++) {
207 for (i =
nbytes - 1; i >= 0; i--) {
215 result = (
write(fd, buf, len) == len);
224 int nrows =
fcb->cellhd.rows;
226 return write_row_ptrs(nrows,
fcb->row_ptr,
fcb->data_fd);
232 int nrows =
fcb->cellhd.rows;
234 return write_row_ptrs(nrows,
fcb->null_row_ptr,
null_fd);
AMI_err name(char **stream_name)
void G_free(void *)
Free allocated memory.
void void void void G_fatal_error(const char *,...) __attribute__((format(printf
void G_warning(const char *,...) __attribute__((format(printf
#define assert(condition)
struct fileinfo * fileinfo
SYMBOL * err(FILE *fp, SYMBOL *s, char *msg)