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