16 #include <grass/gis.h>
17 #include <grass/glocale.h>
18 #include "local_proto.h"
44 int Segment_open(SEGMENT *SEG,
char *fname, off_t nrows, off_t ncols,
int srows,
45 int scols,
int len,
int nseg)
50 nseg_total = ((nrows + srows - 1) / srows) * ((ncols + scols - 1) / scols);
52 if (nseg >= nseg_total) {
59 SEG->cache = G_calloc(
sizeof(
char) * SEG->nrows * SEG->ncols, SEG->len);
69 G_warning(_(
"Segment file name is NULL"));
73 if (access(fname, F_OK) == 0) {
74 G_warning(_(
"Segment file exists already"));
81 if (-1 == (SEG->fd = creat(SEG->fname, 0666))) {
82 G_warning(_(
"Unable to create segment file"));
90 G_warning(_(
"Could not write segment file"));
94 G_warning(_(
"Illegal segment configuration parameter(s)"));
101 if (-1 == (SEG->fd = open(SEG->fname, 2))) {
103 G_warning(_(
"Unable to re-open segment file"));
110 G_warning(_(
"Could not read segment file"));
void G_verbose_message(const char *msg,...)
Print a message to stderr but only if module is in verbose mode.
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 Segment_open(SEGMENT *SEG, char *fname, off_t nrows, off_t ncols, int srows, int scols, int len, int nseg)
Initialize segment structure and open segment file.
char * G_store(const char *s)
Copy string to allocated memory.