12 #include <sys/types.h>
17 #include <grass/gis.h>
19 static char **mapset_name;
20 static char **mapset_name2;
21 static int nmapset = 0;
22 static int nmapset2 = 0;
23 static int new_mapset(
const char *);
24 static int get_list_of_mapsets(
void);
43 get_list_of_mapsets();
47 if (n < 0 || n >= nmapset)
48 return ((
char *)
NULL);
50 return mapset_name[n];
53 static int get_list_of_mapsets(
void)
63 while (fscanf(fd,
"%s", name) == 1)
87 static int new_mapset(
const char *name)
95 (
char **)G_realloc((
char *)mapset_name, nmapset *
sizeof(
char *));
96 mapset_name[nmapset - 1] =
G_store(name);
109 mapset_name2 = mapset_name;
127 names = mapset_name2;
130 mapset_name2 = mapset_name;
160 static int alloc = 0;
167 G_debug(3,
"G_available_mapsets");
171 mapsets = (
char **)G_calloc(alloc,
sizeof(
char *));
188 if (stat(buf, &st) == 0) {
189 G_debug(4,
"%s is mapset", ent->d_name);
191 if (n + 2 >= alloc) {
193 mapsets = (
char **)G_realloc(mapsets, alloc *
sizeof(
char *));
194 for (i = n; i < alloc; i++)
198 mapsets[n] =
G_store(ent->d_name);
203 G_debug(4,
"%s is not mapset", ent->d_name);
238 for (i = 0; i < nmapset; i++) {
239 if (strcmp(mapset_name[i], mapset) == 0)