13 #include <sys/types.h> 20 #include "gis_local_proto.h" 32 static void new_mapset(
const char *);
48 if (n < 0 || n >= st->path.count)
51 return st->path.names[n];
62 if (st->path.count > 0)
67 st->path.names =
NULL;
75 while (fscanf(fp,
"%s", name) == 1) {
76 if (strcmp(name, cur) == 0)
84 static const char perm[] =
"PERMANENT";
90 void new_mapset(
const char *
name)
92 if (st->path.count >= st->path.size) {
94 st->path.names =
G_realloc(st->path.names, st->path.size *
sizeof(
char *));
97 st->path.names[st->path.count++] =
G_store(name);
105 st->path2.count = st->path.count;
106 st->path2.names = st->path.names;
119 count = st->path2.count;
120 names = st->path2.names;
122 st->path2.count = st->path.count;
123 st->path2.names = st->path.names;
125 st->path.count =
count;
126 st->path.names = names;
147 char **mapsets =
NULL;
153 G_debug(3,
"G_get_available_mapsets");
155 mapsets =
G_calloc(alloc,
sizeof(
char *));
168 sprintf(buf,
"%s/%s/WIND", location, ent->d_name);
170 if (
G_stat(buf, &st) != 0) {
171 G_debug(4,
"%s is not mapset", ent->d_name);
175 G_debug(4,
"%s is mapset", ent->d_name);
177 if (n + 2 >= alloc) {
179 mapsets =
G_realloc(mapsets, alloc *
sizeof(
char *));
182 mapsets[n++] =
G_store(ent->d_name);
218 for (i = 0; i < st->path.count; i++) {
219 if (strcmp(st->path.names[i], mapset) == 0)
void G_create_alt_search_path(void)
Define alternative mapset search path.
char ** G_get_available_mapsets(void)
Get list of available mapsets for current location.
void G_reset_mapsets(void)
Reset number of mapsets.
int G_mapset_permissions(const char *)
Check for user mapset permission.
void G_free(void *)
Free allocated memory.
char * G_location_path(void)
Get current location UNIX-like path.
void G_add_mapset_to_search_path(const char *mapset)
Add mapset to the list of mapsets in search path.
void G__get_list_of_mapsets(void)
Fill list of mapsets from search path (internal use only)
int G_is_mapset_in_search_path(const char *mapset)
Check if given mapset is in search path.
FILE * G_fopen_old(const char *, const char *, const char *)
Open a database file for reading.
const char * G_get_mapset_name(int n)
Get name of the n'th mapset from the current mapset search path.
int G_stat(const char *, struct stat *)
Get file status.
void G_switch_search_path(void)
Switch mapset search path.
const char * G_mapset(void)
Get current mapset name.
char * G_store(const char *)
Copy string to allocated memory.
int G_debug(int, const char *,...) __attribute__((format(printf