18 #include "local_proto.h"
37 int seg_exp, n_total_segs;
44 G_warning(
"Segment setup: illegal segment file parameters");
50 SEG->
offset = (int)lseek(SEG->
fd, 0L, SEEK_CUR);
61 while (SEG->
scols - (1 << seg_exp) > 0)
64 if (SEG->
scols - (1 << seg_exp) == 0) {
67 while (SEG->
srows - (1 << seg_exp) > 0)
69 if (SEG->
srows - (1 << seg_exp) == 0) {
73 G_debug(1,
"Segment setup: fast address activated");
85 while (SEG->
len - (1 << seg_exp) > 0)
87 if (SEG->
len - (1 << seg_exp) == 0) {
91 G_debug(1,
"Segment setup: fast seek activated");
101 if (SEG->
nseg > n_total_segs) {
103 "Segment setup: reducing number of open segments from %d to %d",
104 SEG->
nseg, n_total_segs);
105 SEG->
nseg = n_total_segs;
108 if ((SEG->
scb = (
struct scb *)
G_malloc(SEG->
nseg *
sizeof(
struct scb))) ==
116 sizeof(
struct aq))) ==
NULL)
122 for (i = 0; i < SEG->
nseg; i++) {
158 for (i = 0; i < n_total_segs; i++)
int seg_address_slow(const SEGMENT *SEG, off_t row, off_t col, int *n, int *index)
int seg_address_fast(const SEGMENT *SEG, off_t row, off_t col, int *n, int *index)
void G_warning(const char *,...) __attribute__((format(printf
int G_debug(int, const char *,...) __attribute__((format(printf
int seg_seek_fast(const SEGMENT *SEG, int n, int index)
int seg_seek_slow(const SEGMENT *SEG, int n, int index)
int seg_setup(SEGMENT *SEG)
Internal use only.
int(* address)(const struct SEGMENT *, off_t, off_t, int *, int *)
struct SEGMENT::scb * scb
int(* seek)(const struct SEGMENT *S, int, int)