mapset.c

Go to the documentation of this file.
00001 /**********************************************************************
00002  *
00003  *   char *
00004  *   G_mapset()
00005  *
00006  *   returns:    pointer to string containing the one word mapset
00007  *               name.
00008  *               NULL if user does not have access to mapset.
00009  *
00010  **********************************************************************/
00011 
00012 #include <string.h>
00013 #include <stdlib.h>
00014 #include "gis.h"
00015 #include "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     case 0:
00056             sprintf(msg,"MAPSET %s - permission denied", mapset);
00057             break;
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 

Generated on Mon Jan 1 19:49:25 2007 for GRASS by  doxygen 1.5.1