21static const char NULL_STRING[] =
"null";
22static int reclass_type(
FILE *,
char **,
char **,
char **);
23static FILE *fopen_cellhd_old(
const char *,
const char *);
24static FILE *fopen_cellhd_new(
const char *);
25static int get_reclass_table(
FILE *,
struct Reclass *,
char **);
50 fd = fopen_cellhd_old(
name, mapset);
97 for (
j = 0, k = 0;
j <
l;
j++) {
110 (*rmaps)[i - 1] = (
char *)
G_malloc(k + 1);
112 (*rmaps)[i - 1][k] = 0;
123 (*rmaps)[i - 1] =
NULL;
148 fd = fopen_cellhd_old(
name, mapset);
155 if (reclass->
type == 0) {
158 return reclass->
type;
160 if (reclass->
type < 0) {
163 G_warning(
_(
"Error reading beginning of header file for <%s@%s>: %s"),
167 return reclass->
type;
170 switch (reclass->
type) {
185 _(
"Illegal reclass format in header file for <%s@%s>: %s"),
201 switch (reclass->
type) {
203 if (reclass->
num > 0)
250 for (i = 0; i < 2; i++) {
251 if (
fgets(buf,
sizeof buf, fd) ==
NULL) {
258 if (buf[
strlen(buf) - 1] !=
'\n') {
264 if (
sscanf(buf,
"%[^:]:%s", label,
arg) != 2) {
290 _(
"Mapset not read, only raster name: %s"), *
rname);
294 _(
"Raster name not read, only mapset: %s"), *
rmapset);
303static FILE *fopen_cellhd_old(
const char *
name,
const char *mapset)
325 switch (reclass->
type) {
327 if (reclass->
min > reclass->
max || reclass->
num <= 0) {
337 fd = fopen_cellhd_new(
name);
369 fprintf(fd,
"%s\n", NULL_STRING);
387 G_warning(
_(
"Unable to create dependency file in <%s@%s>"),
400 if (!
G_getl2(buf,
sizeof(buf), fd))
417static FILE *fopen_cellhd_new(
const char *
name)
436static int get_reclass_table(
FILE *fd,
struct Reclass *reclass,
456 while (
fgets(buf,
sizeof buf, fd)) {
459 if (
sscanf(buf,
"#%d", &cat) == 1) {
468 if (
sscanf(buf,
"%d", &cat) != 1) {
474 _(
"Reading integer failed on line: %s "
475 "(after reading min: %d)"),
479 _(
"First entry (min) not read yet and "
480 "reading integer failed on line: %s"),
489 if (len != (
int)len) {
495 reclass->
table[n - 1] = cat;
497 reclass->
max = reclass->
min + n - 1;
int G_getl2(char *, int, FILE *)
Gets a line of text from a file of any pedigree.
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
FILE * G_fopen_new(const char *, const char *)
Open a new database file.
char * G_file_name_misc(char *, const char *, const char *, const char *, const char *)
Builds full path names to GIS misc data files.
void G_fseek(FILE *, off_t, int)
Change the file position of the stream.
FILE * G_fopen_old(const char *, const char *, const char *)
Open a database file for reading.
char * G_fully_qualified_name(const char *, const char *)
Get fully qualified element name.
int G_asprintf(char **, const char *,...) __attribute__((format(printf
FILE * G_fopen_old_misc(const char *, const char *, const char *, const char *)
open a database misc file for reading
char * G_store(const char *)
Copy string to allocated memory.
const char * G_mapset(void)
Get current mapset name.
size_t G_strlcpy(char *, const char *, size_t)
Safe string copy function.
void Rast_set_c_null_value(CELL *, int)
To set a number of CELL raster values to NULL.
#define Rast_is_c_null_value(cellVal)
int Rast_get_reclass(const char *name, const char *mapset, struct Reclass *reclass)
Get reclass.
int Rast_put_reclass(const char *name, const struct Reclass *reclass)
Put reclass.
int Rast_is_reclassed_to(const char *name, const char *mapset, int *nrmaps, char ***rmaps)
Get child reclass maps list.
void Rast_free_reclass(struct Reclass *reclass)
Free Reclass structure.
int Rast_is_reclass(const char *name, const char *mapset, char rname[256], char rmapset[256])
Check if raster map is reclassified.