19static const char NULL_STRING[] =
"null";
20static int reclass_type(
FILE *,
char **,
char **,
char **);
21static FILE *fopen_cellhd_old(
const char *,
const char *);
22static FILE *fopen_cellhd_new(
const char *);
23static int get_reclass_table(
FILE *,
struct Reclass *,
char **);
48 fd = fopen_cellhd_old(
name, mapset);
95 for (
j = 0, k = 0;
j <
l;
j++) {
108 (*rmaps)[i - 1] = (
char *)
G_malloc(k + 1);
110 (*rmaps)[i - 1][k] = 0;
121 (*rmaps)[i - 1] =
NULL;
146 fd = fopen_cellhd_old(
name, mapset);
153 if (reclass->
type == 0) {
156 return reclass->
type;
158 if (reclass->
type < 0) {
161 G_warning(
_(
"Error reading beginning of header file for <%s@%s>: %s"),
165 return reclass->
type;
168 switch (reclass->
type) {
183 _(
"Illegal reclass format in header file for <%s@%s>: %s"),
199 switch (reclass->
type) {
201 if (reclass->
num > 0)
248 for (i = 0; i < 2; i++) {
249 if (
fgets(buf,
sizeof buf, fd) ==
NULL) {
256 if (buf[
strlen(buf) - 1] !=
'\n') {
262 if (
sscanf(buf,
"%[^:]:%s", label,
arg) != 2) {
288 _(
"Mapset not read, only raster name: %s"), *
rname);
292 _(
"Raster name not read, only mapset: %s"), *
rmapset);
301static FILE *fopen_cellhd_old(
const char *
name,
const char *mapset)
323 switch (reclass->
type) {
325 if (reclass->
min > reclass->
max || reclass->
num <= 0) {
335 fd = fopen_cellhd_new(
name);
367 fprintf(fd,
"%s\n", NULL_STRING);
385 G_warning(
_(
"Unable to create dependency file in <%s@%s>"),
398 if (!
G_getl2(buf,
sizeof(buf), fd))
415static FILE *fopen_cellhd_new(
const char *
name)
434static int get_reclass_table(
FILE *fd,
struct Reclass *reclass,
454 while (
fgets(buf,
sizeof buf, fd)) {
457 if (
sscanf(buf,
"#%d", &cat) == 1) {
466 if (
sscanf(buf,
"%d", &cat) != 1) {
472 _(
"Reading integer failed on line: %s "
473 "(after reading min: %d)"),
477 _(
"First entry (min) not read yet and "
478 "reading integer failed on line: %s"),
487 if (len != (
int)len) {
493 reclass->
table[n - 1] = cat;
495 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.