7
#include <grass/vask.h>
8
#include "local_proto.h"
10
int ask_target(char *group, char *location, char *mapset)
13
char t1[80], t2[80], t3[80];
14
char cur_location[30], cur_mapset[30];
16
strcpy(cur_location, location);
17
strcpy(cur_mapset, mapset);
19
sprintf(t1, "Please select the target LOCATION and MAPSET for group<%s>",
21
sprintf(t2, "CURRENT LOCATION: %s", G_location());
22
sprintf(t3, "CURRENT MAPSET: %s", G_mapset());
28
V_line(9, "TARGET LOCATION:");
29
V_line(10, "TARGET MAPSET:");
31
"(enter list for a list of locations or mapsets within a location)");
32
V_ques(location, 's', 9, 18, 20);
33
V_ques(mapset, 's', 10, 18, 20);
36
if (strcmp(location, "list") == 0)
37
strcpy(location, cur_location);
38
if (strcmp(mapset, "list") == 0)
39
strcpy(mapset, cur_mapset);
44
if (*location == 0 && *mapset == 0)
47
if (*location == 0 || strcmp(location, "list") == 0)
49
else if (no_location(location)) {
50
fprintf(stderr, "\n** <%s> - unknown location\n", location);
54
G__setenv("LOCATION_NAME", location);
55
if (*mapset == 0 || strcmp(mapset, "list") == 0)
57
else if (mapset_ok(mapset))
62
fprintf(stderr, "Hit RETURN -->");
69
int list_locations(void)
73
sprintf(buf, "ls -C %s\n", G_gisdbase());
74
fprintf(stderr, "\nKnown locations:\n");
80
int no_location(char *location)
84
sprintf(buf, "%s/%s", G_gisdbase(), location);
85
return access(buf, 0) != 0;
88
int list_mapsets(void)
95
sprintf(buf, "ls %s/%s", G_gisdbase(), G_location());
96
fprintf(stderr, "LOCATION %s\n", G_location());
97
fprintf(stderr, "\nAvailable mapsets:\n");
103
while (fscanf(fd, "%s", buf) == 1) {
105
len = strlen(buf) + 1;
107
len = (len + 1) * 20;
110
fprintf(stderr, "\n");
113
if ((ok = (G__mapset_permissions(buf)) == 1))
115
fprintf(stderr, "%s%-*s", ok ? "(+)" : " ", len, buf);
119
fprintf(stderr, "\n");
122
"\nnote: you only have access to mapsets marked with (+)\n");
125
"\nnote: you do not have access to any of these mapsets\n");
131
int mapset_ok(char *mapset)
133
switch (G__mapset_permissions(mapset)) {
137
fprintf(stderr, "\n** <%s> - permission to mapset denied **\n",
141
fprintf(stderr, "\n** <%s> - mapset not found **\n", mapset);