00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include <string.h>
00014 #include <stdlib.h>
00015 #include <grass/gis.h>
00016 #include <grass/glocale.h>
00017
00018
00031 char *G_mapset(void)
00032 {
00033 static char mapset[GMAPSET_MAX];
00034 static int first = 1;
00035 char *m;
00036
00037 m = G__mapset();
00038 if (m == NULL)
00039 G_fatal_error(_("MAPSET is not set"));
00040
00041 if (first)
00042 first = 0;
00043 else if (strcmp(mapset, m) == 0)
00044 return mapset;
00045 strcpy(mapset, m);
00046
00047 switch (G__mapset_permissions(mapset)) {
00048 case 0:
00049 case 1:
00050 return mapset;
00051
00052
00053
00054
00055
00056 default:
00057 G_fatal_error(_("MAPSET %s not found"), mapset);
00058 break;
00059 }
00060 exit(EXIT_FAILURE);
00061 }
00062
00063 char *G__mapset(void)
00064 {
00065 return G__getenv("MAPSET");
00066 }