32 static int get_ref(
const char *,
const char *,
const char *,
struct Ref *);
33 static int set_color(
const char *,
const char *,
const char *,
struct Ref *);
34 static int put_ref(
const char *,
const char *,
const struct Ref *);
48 stat = (fscanf(fd,
"%255s", group) == 1);
61 fprintf(fd,
"%s\n", group);
80 stat = (fscanf(fd,
"%255s", subgroup) == 1);
95 fprintf(fd,
"%s\n", subgroup);
114 return get_ref(group,
"",
NULL, ref);
132 return get_ref(group,
"", mapset, ref);
151 return get_ref(group, subgroup,
NULL, ref);
169 const char *mapset,
struct Ref *ref)
171 return get_ref(group, subgroup, mapset, ref);
174 static int get_ref(
const char *group,
const char *subgroup,
const char *gmapset,
189 if (gmapset ==
NULL || *gmapset == 0)
201 while (
G_getl2(buf,
sizeof buf, fd)) {
202 int n = sscanf(buf,
"%255s %255s %15s",
name, mapset,
204 if (n == 2 || n == 3) {
207 set_color(
name, mapset, color, ref);
217 static int set_color(
const char *
name,
const char *mapset,
const char *color,
222 for (n = 0; n < ref->
nfiles; n++) {
255 ref->red.table =
NULL;
256 ref->grn.table =
NULL;
259 ref->red.index =
NULL;
260 ref->grn.index =
NULL;
263 if (ref->
nfiles <= 0 || ref->red.n >= 0 || ref->
blu.
n >= 0 ||
312 return put_ref(group,
"", ref);
332 const struct Ref *ref)
334 return put_ref(group, subgroup, ref);
337 static int put_ref(
const char *group,
const char *subgroup,
338 const struct Ref *ref)
350 for (n = 0; n < ref->
nfiles; n++) {
352 if (n == ref->red.n || n == ref->grn.n || n == ref->
blu.
n) {
391 for (n = 0; n < ref->
nfiles; n++) {
442 if (n == ref2->red.n)
444 if (n == ref2->grn.n)
446 if (n == ref2->
blu.
n)
469 ref->red.n = ref->grn.n = ref->
blu.
n = -1;
470 ref->red.table = ref->grn.table = ref->
blu.
table =
NULL;
FILE * G_fopen_old(const char *, const char *, const char *)
Open a database file for reading.
int G_getl2(char *, int, FILE *)
Gets a line of text from a file of any pedigree.
int G_unqualified_name(const char *, const char *, char *, char *)
Returns unqualified map name (without @ mapset)
const char * G_mapset(void)
Get current mapset name.
FILE * G_fopen_new(const char *, const char *)
Open a new database file.
void int G_suppress_warnings(int)
Suppress printing a warning message to stderr.
FILE * I_fopen_subgroup_ref_old2(const char *, const char *, const char *)
FILE * I_fopen_group_file_new(const char *, const char *)
FILE * I_fopen_subgroup_ref_new(const char *, const char *)
FILE * I_fopen_group_file_old(const char *, const char *)
Open group file for reading.
FILE * I_fopen_group_ref_new(const char *)
int I_find_group(const char *)
does group exist?
FILE * I_fopen_group_ref_old2(const char *, const char *)
int I_get_subgroup(const char *group, char *subgroup)
int I_put_subgroup_ref(const char *group, const char *subgroup, const struct Ref *ref)
write subgroup REF file
int I_add_file_to_group_ref(const char *name, const char *mapset, struct Ref *ref)
add file name to Ref structure
int I_put_subgroup(const char *group, const char *subgroup)
int I_get_subgroup_ref2(const char *group, const char *subgroup, const char *mapset, struct Ref *ref)
read subgroup REF file
int I_get_group_ref(const char *group, struct Ref *ref)
read group REF file
int I_transfer_group_ref_file(const struct Ref *ref2, int n, struct Ref *ref1)
copy Ref lists
int I_init_ref_color_nums(struct Ref *ref)
int I_free_group_ref(struct Ref *ref)
free Ref structure
int I_get_subgroup_ref(const char *group, const char *subgroup, struct Ref *ref)
read subgroup REF file
int I_get_group_ref2(const char *group, const char *mapset, struct Ref *ref)
read group REF file
int I_put_group_ref(const char *group, const struct Ref *ref)
write group REF file
int I_init_group_ref(struct Ref *ref)
initialize Ref structure
int I_get_group(char *group)
int I_put_group(const char *group)
struct Ref_Color red grn blu