33 static int get_ref(
const char *,
const char *,
const char *,
struct Ref *);
34 static int set_color(
const char *,
const char *,
const char *,
struct Ref *);
35 static int put_ref(
const char *,
const char *,
const struct Ref *);
49 stat = (fscanf(fd,
"%s", group) == 1);
62 fprintf(fd,
"%s\n", group);
81 stat = (fscanf(fd,
"%s", subgroup) == 1);
96 fprintf(fd,
"%s\n", subgroup);
116 return get_ref(group,
"",
NULL, ref);
135 return get_ref(group,
"", mapset, ref);
154 const char *subgroup,
struct Ref *ref)
156 return get_ref(group, subgroup,
NULL, ref);
175 const char *subgroup,
const char *mapset,
178 return get_ref(group, subgroup, mapset, ref);
182 static int get_ref(
const char *group,
const char *subgroup,
const char *gmapset,
struct Ref *ref)
197 if (gmapset ==
NULL || *gmapset == 0)
209 while (
G_getl2(buf,
sizeof buf, fd)) {
210 n = sscanf(buf,
"%255s %255s %15s", name, mapset, color);
211 if (n == 2 || n == 3) {
214 set_color(name, mapset, color, ref);
224 static int set_color(
const char *
name,
const char *mapset,
const char *color,
229 for (n = 0; n < ref->
nfiles; n++) {
262 ref->red.table =
NULL;
263 ref->grn.table =
NULL;
266 ref->red.index =
NULL;
267 ref->grn.index =
NULL;
270 if (ref->
nfiles <= 0 || ref->red.n >= 0 || ref->
blu.
n >= 0 ||
320 return put_ref(group,
"", ref);
341 const struct Ref *ref)
343 return put_ref(group, subgroup, ref);
346 static int put_ref(
const char *group,
const char *subgroup,
347 const struct Ref *ref)
359 for (n = 0; n < ref->
nfiles; n++) {
361 if (n == ref->red.n || n == ref->grn.n || n == ref->
blu.
n) {
401 for (n = 0; n < ref->
nfiles; n++) {
402 if (strcmp(ref->
file[n].
name, name) == 0
457 if (n == ref2->red.n)
459 if (n == ref2->grn.n)
461 if (n == ref2->
blu.
n)
486 ref->red.n = ref->grn.n = ref->
blu.
n = -1;
487 ref->red.table = ref->grn.table = ref->
blu.
table =
NULL;
int G_getl2(char *, int, FILE *)
Gets a line of text from a file of any pedigree.
int I_find_group(const char *)
does group exist?
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)
FILE * I_fopen_group_ref_old2(const char *, const char *)
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_subgroup_ref2(const char *group, const char *subgroup, const char *mapset, struct Ref *ref)
read subgroup REF file
int I_get_subgroup(const char *group, char *subgroup)
int I_init_ref_color_nums(struct Ref *ref)
int G_unqualified_name(const char *, const char *, char *, char *)
Returns unqualified map name (without @ mapset)
FILE * I_fopen_group_file_old(const char *, const char *)
Open group file for reading.
FILE * I_fopen_group_ref_new(const char *)
FILE * I_fopen_subgroup_ref_old2(const char *, const char *, const char *)
int I_get_group_ref2(const char *group, const char *mapset, struct Ref *ref)
read group REF file
int I_get_group(char *group)
FILE * G_fopen_new(const char *, const char *)
Open a new database file.
int I_put_subgroup_ref(const char *group, const char *subgroup, const struct Ref *ref)
write subgroup REF file
void int G_suppress_warnings(int)
Suppress printing a warning message to stderr.
FILE * G_fopen_old(const char *, const char *, const char *)
Open a database file for reading.
int I_transfer_group_ref_file(const struct Ref *ref2, int n, struct Ref *ref1)
copy Ref lists
struct Ref_Color red grn blu
FILE * I_fopen_group_file_new(const char *, const char *)
const char * G_mapset(void)
Get current mapset name.
int I_put_group(const char *group)
int I_get_group_ref(const char *group, struct Ref *ref)
read group REF file
int I_free_group_ref(struct Ref *ref)
free Ref structure
FILE * I_fopen_subgroup_ref_new(const char *, const char *)
int I_get_subgroup_ref(const char *group, const char *subgroup, struct Ref *ref)
read subgroup REF file