mapset.c 1009 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*!
  2. \file gis/mapset.c
  3. \brief GIS library - environment routines (mapset)
  4. (C) 2001-2009 by the GRASS Development Team
  5. This program is free software under the
  6. GNU General Public License (>=v2).
  7. Read the file COPYING that comes with GRASS
  8. for details.
  9. \author Original author CERL
  10. */
  11. #include <string.h>
  12. #include <stdlib.h>
  13. #include <grass/gis.h>
  14. #include <grass/glocale.h>
  15. /*!
  16. * \brief Get current mapset name
  17. *
  18. * Returns the name of the current mapset in the current
  19. * location. This routine is often used when accessing files in the
  20. * current mapset. See Mapsets for an explanation of mapsets.
  21. *
  22. * G_fatal_error() is called on error.
  23. *
  24. * \return pointer mapset name
  25. */
  26. const char *G_mapset(void)
  27. {
  28. const char *m = G__mapset();
  29. if (!m)
  30. G_fatal_error(_("MAPSET is not set"));
  31. return m;
  32. }
  33. /*!
  34. * \brief Get current mapset name
  35. *
  36. * \return pointer mapset name
  37. * \return NULL on error
  38. */
  39. const char *G__mapset(void)
  40. {
  41. return G__getenv("MAPSET");
  42. }