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++)
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)
char * G_mapset(void)
current mapset name
sprintf(buf2,"%s", G3D_CATS_ELEMENT)
int G__mapset_permissions(const char *mapset)
Check for user mapset permission.
void G_free(void *buf)
Free allocated memory.
char * G_store(const char *s)
Copy string to allocated memory.
void G_add_mapset_to_search_path(const char *mapset)
Add mapset to the list of mapsets in search path.
int G__create_alt_search_path(void)
Define alternative mapset search path.
int G__switch_search_path(void)
Switch mapset search path.
char ** G_available_mapsets(void)
Get list of available mapsets for current location.
char * G_location_path(void)
Get current location directory.
char * G__mapset_name(int n)
Get name of the n'th mapset from the mapset_name[] list.
int G_is_mapset_in_search_path(const char *mapset)
Check if given mapset is in search path.
int G_reset_mapsets(void)
Reset number of mapsets.
def mapsets
List available mapsets.
char buf[GNAME_MAX+sizeof(G3D_DIRECTORY)+2]
int G_debug(int level, const char *msg,...)
Print debugging message.
FILE * G_fopen_old(const char *element, const char *name, const char *mapset)
Open a database file for reading.