• Main Page
  • Related Pages
  • Data Structures
  • Files
  • File List
  • Globals

mapset.c

Go to the documentation of this file.
00001 
00002 /**********************************************************************
00003  *
00004  *   char *
00005  *   G_mapset()
00006  *
00007  *   returns:    pointer to string containing the one word mapset
00008  *               name.
00009  *               NULL if user does not have access to mapset.
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            case 0:
00053            G_fatal_error ("MAPSET %s - permission denied", mapset);
00054            break;
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 }

Generated on Wed Oct 13 2010 12:09:29 for GRASS Programmer's Manual by  doxygen 1.7.1